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

Linux ‘sed’ command in Perl programming

Dr. Muniba Faiza
Last updated: July 18, 2020 1:02 pm
Dr. Muniba Faiza
Share
3 Min Read
SHARE

When it comes to handling large data files to process, it becomes very difficult to write programs for the beginners, especially when you have to execute another script within one. For this purpose, the Linux operating system offers several advantages for bioinformatics programming such as ‘awk’ and ‘sed’ one-liners, they prove to be of great help!

The sed command is a stream editor that parses and performs basic text transformations on a file or an input stream from a pipeline. sed allows restricting the command to certain lines or characters. It reads text line-by-line, removes trailing newline, and stores them into an empty data buffer known as pattern space, on which the specified commands are executed. It is an amazing utility but the documentation is a bit difficult.

Syntax:
sed OPTIONS... [SCRIPT] [INPUTFILE]

In bioinformatics, sometimes we need to edit large fasta files, which is quite difficult and tedious when done manually. The replacement and deletion commands of sed are most widely used, which can edit more than five thousands of sequences in a few seconds.

sed substitution command:
sed 's/regexp/replacement/g' input > output

or to modify the input file without getting output in another file, -i option is used:

sed -i input 's/regexp/replacement/g'

It has a vast range of applications in bioinformatics programming such as:

  • one can easily edit or modify the fasta headers in a file consisting of a large number of sequences,
  • can search for a particular expression present within the sequences,
  • can delete text in between the lines, or in terms of bioinformatics, it can easily delete a specific number of residues from specific lines,
  • can handle large data files, and so on.

In Perl, sed command can be easily executed using exec(), system(), qx//, or backticks (``) depending on the need of the program. The similarity between the sed and Perl is that they use similar identifiers and/ characters. For example,

[table id=2 /]

If you want to insert five blank spaces at the beginning of each line, then the following can be used:

$ sed 's/^/     /'

Again, here ‘^’ is used for recognizing the first character in a line in Perl and sed.

Further reading:

https://www.computerhope.com/unix/used.htm

http://www.grymoire.com/Unix/Sed.html#uh-47

Share This Article
Facebook Copy Link Print
ByDr. Muniba Faiza
Follow:
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
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

Clustering using MCL
Bioinformatics ProgrammingSoftwareTools

How to perform graph-based clustering of peptide/protein sequences using MCL?

June 22, 2020
How to preprocess data for clustering in MATLAB?
Bioinformatics ProgrammingMatlab

How to preprocess data for clustering in MATLAB?

September 9, 2022
Extracting first and last residue from helix file in DSSP format.
Bioinformatics ProgrammingPythonSecondary structure

Extracting first and last residue from helix file in DSSP format.

May 12, 2022
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