Our Sponsors



Download BioinformaticsOnline(BOL) Apps in your chrome browser.




Question: Question: Quick way to calculate length of multiple fasta file!!

Anjana
3071 days ago

Question: Quick way to calculate length of multiple fasta file!!
I am using this perl code right nowadays.

#!/usr/bin/perl use warnings; use strict;
open(FASTA, "<", seq.fa) or die("Can't open\n"); my %singleLineSequences; my $sequence_id; while(){ my $line = $_; chomp($line); if ($line =~ m/^>(\S+)/){ $sequence_id = $1;
$singleLineSequences{$sequence_id} = ""; } else { $singleLineSequences{$sequence_id} = $singleLineSequences{$sequence_id} . $line; } }

foreach my $sequence_entry (keys %singleLineSequences){ my $currentSequence = $singleLineSequences{$sequence_entry}; my $lengthSequence = length($currentSequence); print $sequence_entry . "," . $lengthSequence . "\n"; }
Best Answer
2

I prefer samtools command

samtools faidx sample.fa