Connect with us

Bioinformatics Programming

Some common awk bash commands to modify multi-FASTA files

Published

on

awk commands for multi-FASTA files

Some basic operations on multi-FASTA sequence files is a tedious task without using bioinformatics programming. It helps in modifying FASTA sequences or their headers such as removal, addition, or substitution of certain characters in the header, or manipulating the sequence format, and so on. In such cases, shell bash commands provide an easy way to perform such tasks on FASTA sequences.

Here are some simple ‘awk’ commands to manipulate FASTA headers in multi-fasta files.

1. Convert all lowercase residues to uppercase in a FASTA sequence file

$ awk 'BEGIN{FS=" "}{if(!/>/){print toupper($0)}else{print $1}}' input.fasta > output.fasta

2. Rearrange FASTA sequences according to their length

$ awk '/^>/ {printf("%s%s\t",(N>0?"\n":""), $0);N++;next;} {printf("%s",$0);} END {printf("\n");}' input.fasta |\
>awk -F '\t' '{printf("%d\t%s\n",length($2),$0;)}' |\
>sort -k1,1n | cut -f 2- |tr "\t" "\n" > output.fasta

3. Add ‘>’ at the beginning of headers in a FASTA file

$ awk '{if ($0 ~/_/) {printf ">";} print $0; }' input.fasta > output.fasta

4. Match FASTA headers in two different multi-FASTA files

$ awk 'NR=FNR{a[$0];next}$0 in a{print $0}' input1.fasta input2.fasta

5. Merge all FASTA files in a directory into a single FASTA file

$ awk '1' *.fasta > all .fasta

OR

$ awk'1' *.fa > all.fa

These are some common operations that are performed on multi-FASTA files using awk. Visit the following articles for other operations on multi-FASTA files using bash commands:

Dr. Muniba is a Bioinformatician based in New Delhi, India. She has completed her PhD in Bioinformatics from South China University of Technology, Guangzhou, China. She has cutting edge knowledge of bioinformatics tools, algorithms, and drug designing. When she is not reading she is found enjoying with the family. Know more about Muniba

Bioinformatics Programming

How to obtain SMILES of ligands using PDB ligand IDs?

Published

on

How to obtain SMILES of ligands using PDB ligand IDs?

Fetching SMILE strings for a given number of SDF files of chemical compounds is not such a trivial task. We can quickly obtain them using RDKit or OpenBabel. But what if you don’t have SDF files of ligands in the first place? All you have is Ligand IDs from PDB. If they are a few then you can think of downloading SDF files manually but still, it seems time-consuming, especially when you have multiple compounds to work with. Therefore, we provide a Python script that will read all Ligand IDs and fetch their SDF files, and will finally convert them into SMILE strings. (more…)

Continue Reading

Bioinformatics Programming

How to get secondary structure of multiple PDB files using DSSP in Python?

Published

on

How to get secondary structure of multiple PDB files using DSSP in Python?

In this article, we will obtain the secondary structure of multiple PDB files present in a directory using DSSP [1]. You need to have DSSP installed on your system. (more…)

Continue Reading

Bioinformatics Programming

vs_analysis_compound.py: Python script to search for binding affinities based on compound names.

Published

on

vs_analysis_compound.py: Python script to search for binding affinities based on compound names.

Previously, we have provided the vs_analysis.py script to analyze virtual screening (VS) results obtained from Autodock Vina. In this article, we have provided another script to search for binding affinity associated with a compound. (more…)

Continue Reading

LATEST ISSUE

ADVERT