How to concatenate FASTA sequences using Perl?

/

Here is a simple Perl script to concatenate multiline FASTA sequences into a single line. A similar Perl script has been provided in one of the previous articles (A Perl script to convert multiline FASTA sequences into a single line). That script is useful for the FASTA files consisting of sequences split into a particular number of residues per line. The script provided in this article can also be used for large files consisting of multiple FASTA sequences split into the indefinite number of residues per line.

Let’s name the multiline FASTA input file as “input.fa”.

#!/usr/bin/perl -w
use strict;

my $input_fasta="input.fa";
open(FILE,"<$input_fasta") || die ("Error opening $input_fasta $!"); 
my $line = ; 
print $line; 
while ($line = ) 
{ chomp $line; 
  if ($line=~m/^>;(.*)/) 
       { print "\n",$line,"\n"; }
  else { print $line; }
}

print "\n";
exit;

 

Muniba is a Bioinformatician based in the South China University of Technology. 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 Reply

HOW TO CITE THIS ARTICLE Muniba Faiza (2020). How to concatenate FASTA sequences using Perl?. Bioinformatics Review, 6 (01)
Previous Story

Editorial: New perspectives for BiR with a new year

Next Story

How to install DeepView-Swiss PDB Viewer on Linux?

Latest from Bioinformatics Programming

Willing to stay updated?

By investing less than 30 seconds you can start recieving all our new articles in your mailbox. Stay updated with latest Bioinformatics Research, trends and tools of trade.

 

Lost your password? Please enter your email address. You will receive mail with link to set new password.

0 $0.00