Skip to content

@cjfields /gist:158317
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
pyrimidine1:biomoose cjfields$ cat benchmark_fasta.pl
#!/usr/bin/perl -w
use strict;
use warnings;
use Bio::PrimarySeq;
use Bio::Moose::PrimarySeq;
use Benchmark ':hireswallclock';
use Modern::Perl;
my $file = shift;
timethese (1000, {
'BioPerl' => \&bp,
'BioMoose' => \&bm,
}
);
sub bp {
local $/ = "\n>";
my $c = 'Bio::PrimarySeq';
open (my $fasta, '<', $file) || die "$!";
my @seqs;
while (defined(my $chunk = <$fasta>)) {
my ($header, $seq) = split("\n", $chunk, 2);
$header =~ s{^>}{};
$seq =~ s{[\s>]}{}g;
my $seqobj = $c->new(-seq => $seq, desc => $header);
push @seqs, $seqobj;
}
close $fasta;
}
sub bm {
local $/ = "\n>";
my $c = 'Bio::Moose::PrimarySeq';
open (my $fasta, '<', $file) || die "$!";
my @seqs;
while (defined(my $chunk = <$fasta>)) {
my ($header, $seq) = split("\n", $chunk, 2);
$header =~ s{^>}{};
$seq =~ s{[\s>]}{}g;
my $seqobj = $c->new(-rawseq => $seq, description => $header);
push @seqs, $seqobj;
}
close $fasta;
}
pyrimidine1:biomoose cjfields$ cat testfasta2.faa
>gi|224368035|ref|YP_002602198.1| PyrR [Desulfobacterium autotrophicum HRM2]
MKKRRTILNAEDMERVITRMAYEIIETHRGVKDVALAGIMTRGDFLAHRLQEKILKIEGVKVPVGAMDIN
LYRDDWTQISHYPVVRASKISFSVDNQNIILVDDVLFTGRTIRAAMDAIMDFGRPARIELAVLVDRGHRE
LPLQADYKGTTLATLHSDMVNVCLSEHDGKDTVFIEQEA
>gi|83746228|ref|ZP_00943282.1| PyrR [Ralstonia solanacearum UW551]
MAASRLRGRHAGSPGRRGPADDQAGQTLWQPVAWPLWSAGHLGGRTLLVDRRAGCRRHRRRARCRGRSHH
PPTILRRIPRMTSQQIDAEALYQSLVAQLRTRMAGTHGSNWAVAGIVSGGAWIAARLAQDLGLPDHGVVN
VALHRDDYAKKGLHAQAQPTTLPFEVEERRILLVDDVLATGRTIRAAINELFDYGRPAAVELAVLVDRGE
RQLPIAPDYIGERITLAADESLVLRRDGEGASARFTFTREPKAA
>gi|254383579|ref|ZP_04998929.1| pyrR [Streptomyces sp. Mg1]
MDTQQHSTDDMRPVLEAQDIARVLTRIAHEIVERAKGADDVVLLGIPTRGVYLARRLAAKLEEITGTKIP
VGSLDITMYRDDLRMKPARAIGRTEIPGDDIDGRLVVLIDDVLFSGRTIRAALDALGDLGRPRAVQLAVL
VDRGHRELPIRADYVGKNLPTSLRETVKVQLQEEDGRDAVLLGQRTVQAAGL
>gi|254376970|ref|ZP_04992438.1| pyrR [Streptomyces sp. SPB74]
MDSHTPGHTPGEVPGGPRPVLEGPDIARVLTRIAHEIVERAKGADDVVLLGIPTRGVHLAERLAAKLAAI
TGRPVPTGSLDITMYRDDLRLKPARALGRTEIPAEGLDGRLVVLVDDVLFSGRTIRAALDALGDIGRPRA
VQLAVLVDRGHRELPIRADYVGKNLPTSLRETVKVQLTEEDGRDAVLLGGTAPR
>gi|251782206|ref|YP_002996508.1| PyrR bifunctional protein [Streptococcus dysgalactiae subsp. equisimilis GGS_124]
MKSKEIVDDVTMKRAITRITYEIIERNKQLDNVVLAGIKTRGVFLARRIQERLRQLEGLELPIGELDIKP
FRDDVKVDEDTTLMPVDITGKDVILVDDVLYTGRTIRAAIDNLVSLGRPARVSLAVLVDRGHRELPIRAD
YVGKNIPTSSVEEIIVEVVEVDGRDRVSIVDPT
>gi|153953826|ref|YP_001394591.1| pyrimidine regulatory protein PyrR [Clostridium kluyveri DSM 555]
MKLKALILDEKAMNRTLTRISHEIIEKNKGAEDIVLVGIKRRGYPLAKRISENIYKIEKLKLRVESVDIS
LYRDDLSRLSDQPAIKKSHPIDVEDKKIILVDDVIYTGRTARAAIDAIIHSGRPKLIQLAVLIDRGHREL
PIRADYVGKNIPTSRDEIVSVEISEIDKCNSVKIYEV
>gi|116873275|ref|YP_850056.1| pyrimidine regulatory protein PyrR [Listeria welshimeri serovar 6b str. SLCC5334]
MQKQVVVMDEAAIKRALTRVSYEIIERNKGTKDLALVGIKTRGIYLAERLHTRILEIEGMDVPVGDIDIT
LYRDDLSYKDDDTREPAVHGTNIPFDINGKKVVLVDDVLYTGRTVRAAMDALMDVGRPAQIHLAVLADRG
HRELPIRADYVGKNIPTSANERVEVRLTDVDHAEDAVIINKNE
>gi|126700215|ref|YP_001089112.1| PyrR bifunctional protein [Clostridium difficile 630]
MVEKAQLMDEKAIARAITRISHEIIERNKGVENLVLVGIKTRGVPIANRISKKIEQIEGTKVDTGDIDIT
LYRDDLEKIHVEPVVKGTYLDFNVNDKTVVLVDDVLYTGRTVRASLDAIIDIGRPKSIQLAVLVDRGHRE
LPIRADYVGKNVPTSRHEIISVSLLEIDGEDSVTIKE
>gi|222152893|ref|YP_002562070.1| PyrR bifunctional protein [Streptococcus uberis 0140J]
MKKKEIVDDVTMKRAITRITYEIIERNKSLDNLVLAGIKTRGVYLARRIQERLKQLEGIELPIGELDIKP
FRDDMKVEEDTTDMPFDINGKDVILVDDVLYTGRTIRAAIDNLVSLGRPARVGLAVLVDRGHRELPIRAD
YVGKNIPTSSIEEIVVEVIEVDGKDCVSIVDPS
>gi|221231966|ref|YP_002511118.1| PyrR bifunctional protein [Streptococcus pneumoniae ATCC 700669]
MKTKEVVDELTVKRAITRITYEIIERNKDLNKIVLAGIKTRGVFIAHRIQERLKQLENLSVPVVELDTKP
FRDDVKSGEDTSLVSVDVTDREVILVDDVLYTGRTIRAAIDNIVGHGRPARVSLAVLVDRGHRELPIRPD
YVGKNIPTSRSEEIIVEMTELDDQDRVLITEEA
pyrimidine1:biomoose cjfields$ perl benchmark_fasta.pl testfasta2.faa
Benchmark: timing 1000 iterations of BioMoose, BioPerl...
BioMoose: 0.656269 wallclock secs ( 0.62 usr + 0.02 sys = 0.64 CPU) @ 1562.50/s (n=1000)
BioPerl: 0.924359 wallclock secs ( 0.89 usr + 0.02 sys = 0.91 CPU) @ 1098.90/s (n=1000)
pyrimidine1:biomoose cjfields$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.