Hot answers tagged

18 votes
Accepted

Using shells other than bash

Bioinformatics tools written in shell and other shell scripts generally specify the shell they want to use (via #!/bin/sh or e.g. ...
John Marshall's user avatar
11 votes

Using shells other than bash

TL;DR SH adheres to an official industry standard, but it is not suitable for scientific computing. Bash is considered an informal standard (e.g., by Google). Bash 3 is preferable in most of ...
Karel Břinda's user avatar
9 votes
Accepted

Splitting fasta file into smaller files based on header pattern

Here's a simple awk approach: awk '{if(/^>/){split($1,a,"[|.]")}print >> a[2]".fa"}' Protein_FASTA.txt Or, more concisely, just: ...
terdon's user avatar
  • 9,352
9 votes
Accepted

How to merge .fastq.qz files into a single .fastq.gz with their same id without losing any content in parallel

All you need is cat. You won't find any better tool for a simple job like this. Just run: ...
terdon's user avatar
  • 9,352
9 votes

How I can change the name of multiple files at once in R or terminal?

Use perl-rename. This is usually called rename on Debian-based systems like Ubuntu or Mint, and ...
terdon's user avatar
  • 9,352
7 votes

How do I efficiently subset a very large line-based file?

Turns out, simply keeping track of the next candidate line (after sorting the sample line numbers) fixes the performance issue, and most of the remaining slowness seems to be due to the overhead of ...
Konrad Rudolph's user avatar
7 votes

Using shells other than bash

The Open Group Base Specifications Issue 7 IEEE Std 1003.1™-2008, 2016 Edition, or "The POSIX Standard" for short, is the standard that defines the interfaces and utilities provided by a Unix system. ...
Kusalananda's user avatar
7 votes

Remove/delete sequences by ID from multifasta

Just today I wrote a script to do exactly this using Biopython. I also add a warning If any the headers I wanted to filter was not present in the original fasta. So ...
Kamil S Jaron's user avatar
6 votes

Remove/delete sequences by ID from multifasta

Suppose you keep sequence names in ids.txt and sequences in seq.fa: ...
user172818's user avatar
  • 6,285
6 votes

Remove/delete sequences by ID from multifasta

If you want to learn how to do things with command-line tools, you can linearize the FASTA with awk, pipe to grep to filter for ...
Alex Reynolds's user avatar
6 votes
Accepted

Regular expression struggle

You have an extra done, instead you want: ...
Devon Ryan's user avatar
  • 19.5k
5 votes
Accepted

Bash script error at paste command

Your problem is that you have written a script in bash but are then running it using sh. Bash, the Bourne-again shell, is not ...
terdon's user avatar
  • 9,352
5 votes

Using shells other than bash

The generic command sh is quite literally an industry standard, a POSIX standard, to be precise (IEEE 1003.2 and 1003.2a, available for purchase for hundreds of ...
gringer's user avatar
  • 13k
5 votes

Using shells other than bash

I would not say bash as a "standard", but it is indeed likely to be the most widely used unix shell and available by default on most modern unix/linux distros. There are a few other more convenient ...
user172818's user avatar
  • 6,285
5 votes

How do I efficiently subset a very large line-based file?

Perl should be fairly fast with this when using a hash set to store the list of lines. A structure like this also works for subsetting based on a field value, where the comparison would be with the ...
gringer's user avatar
  • 13k
5 votes
Accepted

How I can change the name of multiple files at once in R or terminal?

just to complete your question, you can do it in R in one line. After setting the directory as your working directory, just type the following: ...
dc37's user avatar
  • 1,021
4 votes
Accepted

Replace lowercase characters with -

The following sed command will do the trick. sed -e '/^[^>]/ s/[a-z]/\-/g' in.fna > out.fna Lines starting with ...
arup's user avatar
  • 594
4 votes

How do I efficiently subset a very large line-based file?

Some related questions appear in other sites, with potentially interesting solutions, which I report here: To sample approximately 1% of the non-empty lines: ...
bli's user avatar
  • 3,070
4 votes
Accepted

Pattern mining from a genomic sequence

echo ">ATGCTTATTGCCCATTTCGTGCATGCATATGCGCATTCGCGATCGATTAGGGATAT" | grep -oP 'TTCG[CGT][ATGC]{1,15}TTCG[CGT]' [CGT] looks ...
haci's user avatar
  • 3,672
4 votes

How I can run this code on my files?

$f in your command is not pointing anywhere since your for loop was defined as for file in *.vcf;. You should use ...
haci's user avatar
  • 3,672
3 votes

Replace lowercase characters with -

You could try it with sed. Replace all lower-case chars with - in lines not starting with ...
Peter Menzel's user avatar
3 votes

How to merge .fastq.qz files into a single .fastq.gz with their same id without losing any content in parallel

We sequence DNA on daily basis. Like terdon said, you can use cat to group all the FastQ of all your sample whether they are ...
user324810's user avatar
  • 1,045
3 votes
Accepted

Batch alignment of inconsistently named Fastq files

A very simple approach, but one which will work with the names you show, is to remove any occurrence of 00N (where N is any ...
terdon's user avatar
  • 9,352
3 votes
Accepted

Using a Bash Script to search TaxIDs against NCBI's Taxonomy yields "400 Bad Request" error?

If I understand correctly, your question boils down to: parsing a bunch of numbers in a row from a .csv file gives a different result from parsing a bunch of numbers as rows of a text file. I that ...
mdperry's user avatar
  • 258
3 votes

Remove/delete sequences by ID from multifasta

Using the FastaToTbl and TblToFasta scripts I have posted before, you can do: ...
terdon's user avatar
  • 9,352
3 votes

How I can change the name of multiple files at once in R or terminal?

If your filenames do not contain blank spaces, you can do it with a for-loop in bash: Make a test run with echo so that the ...
Soren's user avatar
  • 1,273
3 votes

How I can change the name of multiple files at once in R or terminal?

EDIT: (Based on the comments by @terdon, with minor changes) Try this Perl one-liner. It is recommended for general use, even if your file names contain "unexpected" characters such as newlines. <...
Timur Shtatland's user avatar
3 votes
Accepted

How to loop multiple function in shell script?

You don't need a loop. You can do the whole thing with a simple awk one-liner: awk -vRS='>' 'FNR>1{ printf ">%s",$0 > "gene"FNR-1".fasta"}' org*fasta ...
terdon's user avatar
  • 9,352
3 votes

How do I cut a genome into one specific region?

If you know the coordinates, you could just use samtools faidx to extract the corresponding subsequence from the FASTA file(s). Regions can be specified on the ...
Steve's user avatar
  • 2,706

Only top scored, non community-wiki answers of a minimum length are eligible