Last active
September 8, 2016 22:04
-
-
Save cjfields/50c7611d8f2ab78821780e7397a08bd5 to your computer and use it in GitHub Desktop.
Parsing a FASTA file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use 5.010; | |
use strict; | |
use warnings; | |
use Bio::SeqIO; | |
my $file = shift; | |
my $in = Bio::SeqIO->new(-format => 'fasta', -file => $file); | |
my $ct = 0; | |
while (my $record = $in->next_seq) { | |
$ct++; | |
} | |
say "Count: $ct"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use v6; | |
use Bio::SeqIO; | |
my $file = @*ARGS.shift; | |
my $in = Bio::SeqIO.new(:format<fasta>, :file($file)); | |
my $ct = 0; | |
while $in.next-Seq -> $record { | |
$ct++; | |
} | |
say "Count: $ct"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use v6; | |
use Bio::Grammar::Fasta; | |
my $file = @*ARGS.shift; | |
my $data = Bio::Grammar::Fasta.parsefile($file); | |
my $ct = 0; | |
for $data<record> -> $record { | |
$ct++; | |
} | |
say $ct; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[cjfields@Chriss-MacBook-Air bioperl6]$ time perl fasta.pl sequence.fasta | |
Count: 12097 | |
real 0m0.434s | |
user 0m0.416s | |
sys 0m0.014s | |
[cjfields@Chriss-MacBook-Air bioperl6]$ time perl6 fasta.pl6 sequence.fasta | |
Count: 12097 | |
real 0m4.406s | |
user 0m4.284s | |
sys 0m0.102s | |
[cjfields@Chriss-MacBook-Air bioperl6]$ time perl6 grammar.pl6 sequence.fasta | |
12097 | |
real 0m2.571s | |
user 0m2.491s | |
sys 0m0.074s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment