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. ...
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 ...
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:
...
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:
...
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 ...
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 ...
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. ...
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 ...
7
votes
Remove/delete sequences by ID from multifasta
Suppose you keep sequence names in ids.txt and sequences in seq.fa:
...
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 ...
6
votes
Accepted
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 ...
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 ...
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 ...
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 ...
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:
...
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 ...
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:
...
4
votes
Accepted
Pattern mining from a genomic sequence
echo ">ATGCTTATTGCCCATTTCGTGCATGCATATGCGCATTCGCGATCGATTAGGGATAT" | grep -oP 'TTCG[CGT][ATGC]{1,15}TTCG[CGT]'
[CGT] looks ...
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 ...
3
votes
Replace lowercase characters with -
You could try it with sed.
Replace all lower-case chars with - in lines not starting with ...
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 ...
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 ...
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 ...
3
votes
Remove/delete sequences by ID from multifasta
Using the FastaToTbl and TblToFasta scripts I have posted before, you can do:
...
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 ...
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.
<...
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
...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
shell × 43fasta × 8
bash × 8
linux × 8
awk × 8
fastq × 7
r × 5
perl × 4
python × 3
vcf × 2
multiple-sequence-alignment × 2
sratoolkit × 2
cutadapt × 2
subset × 2
benchmarking × 2
samtools × 1
blast × 1
ngs × 1
ncbi × 1
file-formats × 1
read-mapping × 1
quality-control × 1
pymol × 1
taxonomy × 1
atac-seq × 1