Connect with us

Bioinformatics Programming

Modifying multi-FASTA files using Bash: ‘Sed’ Command

Published

on

Dealing with thousands of FASTA sequences is a tedious task without using bioinformatics programming. It eases multiple minute tasks to be performed on 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 sed commands to manipulate FASTA headers in multi-fasta files.

  1. To remove everything after first ‘/’ or  ‘_’ from FASTA headers.

$ sed 's|\/.*||' input.fasta > output.fasta

$ sed 's|\_.*||' input.fasta > output.fasta

2. To remove everything after last ‘/’ or  ‘_’ from FASTA headers.

$ sed 's|_[^/]*$||' input.fasta > output.fasta

$ sed 's|_[^_]*$||' input.fasta > output.fasta

3. To remove all FASTA headers and output only sequences.

$ sed '|^>|d' input.fasta > output.fasta

4. To remove everything after a dot (.) from FASTA headers.

$ sed '|[.].*$||' input.fasta > output.fasta

5. To replace a dot with an underscore (_) in FASTA header (provided no dot is present in the sequence).

$ sed '|\.|_|g' input.fasta > output.fasta

6. To delete a specific number of characters (n) from the FASTA header.

$ sed '|^>|s|.\{n\}$||' input.fasta > output.fasta

Here, replace with the specific number, for example, 3, 5, 10, etc.

7. To remove all characters after first space in the FASTA header.

$ sed '|^>| s| .*||' input.fasta > output.fasta

These are a few examples of ‘sed’ commands. Besides, there is awk, grep, Perl -e, and so on that are used for similar operations on multi-FASTA files.

Tariq is founder of Bioinformatics Review and CEO at IQL Technologies. His areas of expertise include algorithm design, phylogenetics, MicroArray, Plant Systematics, and genome data analysis. If you have questions, reach out to him via his homepage.

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