Bioinformatics ReviewBioinformatics Review
Notification Show More
Font ResizerAa
  •  Home
  • Docking
  • MD Simulation
  • Tools
  • More Topics
    • Softwares
    • Sequence Analysis
    • Algorithms
    • Bioinformatics Programming
    • Bioinformatics Research Updates
    • Drug Discovery
    • Phylogenetics
    • Structural Bioinformatics
    • Editorials
    • Tips & Tricks
    • Bioinformatics News
    • Featured
    • Genomics
    • Bioinformatics Infographics
  • Community
    • BiR-Research Group
    • Community Q&A
    • Ask a question
    • Join Telegram Channel
    • Join Facebook Group
    • Join Reddit Group
    • Subscription Options
    • Become a Patron
    • Write for us
  • About Us
    • About BiR
    • BiR Scope
    • The Team
    • Guidelines for Research Collaboration
    • Feedback
    • Contact Us
    • Recent @ BiR
  • Subscription
  • Account
    • Visit Dashboard
    • Login
Font ResizerAa
Bioinformatics ReviewBioinformatics Review
Search
Have an existing account? Sign In
Follow US
Bioinformatics Programming

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

Tariq Abdullah
Last updated: July 18, 2020 1:10 pm
Tariq Abdullah
Share
2 Min Read
SHARE

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 n 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.

TAGGED:bashBash commandsFastaheadersmultifastasedsequences
Share This Article
Facebook Copy Link Print
ByTariq Abdullah
Tariq is founder of Bioinformatics Review and Lead Developer 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.
Leave a Comment

Leave a Reply Cancel reply

You must be logged in to post a comment.

Starting in Bioinformatics? Do This First!
Starting in Bioinformatics? Do This First!
Tips & Tricks
[Editorial] Is it ethical to change the order of authors’ names in a manuscript?
Editorial Opinion
Installing bbtools on Ubuntu
[Tutorial] Installing BBTools on Ubuntu (Linux).
Sequence Analysis Software Tools
wes_data_analysis Whole Exome Sequencing (WES) Data visualization Toolkit
wes_data_analysis: Whole Exome Sequencing (WES) Data visualization Toolkit
Bioinformatics Programming GitHub Python

You Might Also Like

Installing pycharm on Ubuntu
Bioinformatics ProgrammingPythonSoftwareTools

Installing Pycharm on Ubuntu (Linux)

May 26, 2021
How to download files from an FTP server using Python?
Bioinformatics ProgrammingPython

How to download files from an FTP server using Python?

September 26, 2022
Bioinformatics Programming

How to execute Unix/shell commands in a Perl script?

July 18, 2020
How to get secondary structure of multiple PDB files using DSSP in Python?
Bioinformatics ProgrammingPython

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

December 5, 2022
Copyright 2024 IQL Technologies
  • Journal
  • Customer Support
  • Contact Us
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Cookie Policy
  • Sitemap
Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?

Not a member? Sign Up