[Bio] / SeedViewer / MetagenomeAnalysis.pm Repository:
ViewVC logotype

Diff of /SeedViewer/MetagenomeAnalysis.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.14, Thu Jun 12 15:18:36 2008 UTC revision 1.15, Thu Jun 12 19:19:19 2008 UTC
# Line 393  Line 393 
393    
394  }  }
395    
396    =pod
397    
398    =item * B<get_sequences_fasta> (I<sequence_ids>)
399    
400    Retrieve the sequences for a given list of I<sequence_ids> from the metagenome job directory in fasta format.
401    
402    =cut
403    
404    sub get_sequences_fasta {
405      my ($self, $ids) = @_;
406    
407      # get the path to the sequence file
408      my $sequence_file = $self->job->org_dir.'/contigs';
409    
410      # hash the ids
411      my %idh = map { $_ => 1 } @$ids;
412    
413      # store the result
414      my $sequence = '';
415    
416      # iterate over the sequence file
417      open(FASTA, "<$sequence_file") or die "Unable to read metagenome sequences: $!";
418      while(<FASTA>) {
419    
420        # look only at id lines
421        next unless /^\>/;
422    
423        # get the id
424        my ($id) = /^\>(.+)/;
425        chomp($id);
426    
427        # find the id in the requested id hash
428        next unless exists ($idh{$id});
429    
430        # id was found, delete it from the hash
431        delete $idh{$id};
432    
433        # print the header line
434        $sequence .= $_;
435    
436        # print all the following lines to the result
437        while(<FASTA>) {
438          last if /^>/;
439          $sequence .= $_;
440        }
441    
442        last unless (scalar(keys(%idh)));
443      }
444    
445      return $sequence;
446    
447    }
448    
449  =pod  =pod
450    
# Line 531  Line 583 
583    my $where = $self->get_where_clause();    my $where = $self->get_where_clause();
584    $where = ($where) ? "and $where" : '';    $where = ($where) ? "and $where" : '';
585    
586      $filter =~ s/'/''/g;
587    
588    my $sth = $self->dbh->prepare("select id1, ali_ln, id2, tax_str from $table where dbid=$dbid $where and tax_str like '$filter%'");    my $sth = $self->dbh->prepare("select id1, ali_ln, id2, tax_str from $table where dbid=$dbid $where and tax_str like '$filter%'");
589    $sth->execute;    $sth->execute;
590    my $result = $sth->fetchall_arrayref();    my $result = $sth->fetchall_arrayref();

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.15

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3