Our Sponsors



Download BioinformaticsOnline(BOL) Apps in your chrome browser.




Parse a Fasta file with Perl

  • Public
By Radha Agarkar 3116 days ago
#!/usr/bin/env perl # Usage: fastaRead.pl data.fa use strict; use warnings; my $filename = $ARGV[0]; my $sequence; open my $fileH, "<", $filename or die "could not open $filename\n"; while (<$fileH>) { chomp; if ($_ =~ /^>/) { print "this line is a header: $_\n"; } else { print "this line contains sequence data: $_\n"; # Concatenate everything from the file into a single var $sequence .= $_; } } close $fileH;