Anjana3071 days ago
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"; }
I prefer samtools command
samtools faidx sample.fa
I prefer samtools command
samtools faidx sample.fa