Skip to content

Commit

Permalink
speedup searching fastas
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewjpage committed Apr 26, 2013
1 parent a863be5 commit aa9866e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions dist.ini
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ requires = makeblastdb
requires = cd-hit
requires = mcl
requires = mcxdeblast
requires = fasta_grep

[@Basic]
[PruneCruft]
Expand Down
1 change: 0 additions & 1 deletion lib/Bio/PanGenome/AnalyseGroups.pm
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ Take in a groups file and the original FASTA files and create plots and stats
=cut

use Moose;
use Bio::SeqIO;
use Bio::PanGenome::Exceptions;
use Bio::PanGenome::Plot::FreqOfGenes;

Expand Down
3 changes: 2 additions & 1 deletion lib/Bio/PanGenome/Output/GroupMultifasta.pm
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ sub _build__genes {
sub _lookup_sequence {
my ( $self, $gene, $filename ) = @_;

my $fasta_obj = Bio::SeqIO->new( -file => $filename, -format => 'Fasta' );
open(my $fh, '-|', 'fasta_grep -f '.$filename. ' '.$gene);
my $fasta_obj = Bio::SeqIO->new( -fh => $fh, -format => 'Fasta' );
while ( my $seq = $fasta_obj->next_seq() ) {
next unless ( $seq->display_id eq $gene );
return $seq;
Expand Down
7 changes: 5 additions & 2 deletions lib/Bio/PanGenome/Output/OneGenePerGroupFasta.pm
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,17 @@ sub _lookup_sequences {
{
$gene_queue{$gene}++;
}
my $gene_params = join(' ', @{$genes});


my $fasta_obj = Bio::SeqIO->new( -file => $filename, -format => 'Fasta' );
open(my $fh, '-|', 'fasta_grep -f '.$filename. ' '.$gene_params);
my $fasta_obj = Bio::SeqIO->new( -fh => $fh, -format => 'Fasta' );
while ( my $seq = $fasta_obj->next_seq() ) {
last unless(%gene_queue);
for my $gene ( keys %gene_queue)
{
next unless ( $seq->display_id eq $gene );
push(@sequences, $seq);
delete($gene_queue{$gene});
}
}
return \@sequences;
Expand Down

0 comments on commit aa9866e

Please sign in to comment.