[Bioperl-guts-l] [14994] bioperl-live/trunk/Bio/SearchIO/fasta.pm: perltidy

Christopher John Fields cjfields at dev.open-bio.org
Sun Nov 16 01:18:02 EST 2008


Revision: 14994
Author:   cjfields
Date:     2008-11-16 01:18:02 -0500 (Sun, 16 Nov 2008)

Log Message:
-----------
perltidy

Modified Paths:
--------------
    bioperl-live/trunk/Bio/SearchIO/fasta.pm

Modified: bioperl-live/trunk/Bio/SearchIO/fasta.pm
===================================================================
--- bioperl-live/trunk/Bio/SearchIO/fasta.pm	2008-11-16 06:14:41 UTC (rev 14993)
+++ bioperl-live/trunk/Bio/SearchIO/fasta.pm	2008-11-16 06:18:02 UTC (rev 14994)
@@ -19,9 +19,9 @@
   # Do not use this object directly, use it through the SearchIO system
    use Bio::SearchIO;
    my $searchio = Bio::SearchIO->new(-format => 'fasta',
-				    -file   => 'report.FASTA');
+                    -file   => 'report.FASTA');
    while( my $result = $searchio->next_result ) {
-	# ... do what you would normally doi with Bio::SearchIO.
+    # ... do what you would normally doi with Bio::SearchIO.
    }
 
 =head1 DESCRIPTION
@@ -66,10 +66,8 @@
 
 =cut
 
-
 # Let the code begin...
 
-
 package Bio::SearchIO::fasta;
 use vars qw(%MODEMAP %MAPPING $IDLENGTH);
 use strict;
@@ -78,7 +76,8 @@
 
 use Bio::Factory::ObjectFactory;
 
-BEGIN { 
+BEGIN {
+
     # Set IDLENGTH to a new value if you have
     # compile FASTA with a different ID length
     # (actually newest FASTA allows the setting of this
@@ -86,73 +85,72 @@
     $IDLENGTH = 6;
 
     # mapping of NCBI Blast terms to Bioperl hash keys
-    %MODEMAP = ('FastaOutput' => 'result',
-		'Hit'         => 'hit',
-		'Hsp'         => 'hsp'
-		);
+    %MODEMAP = (
+        'FastaOutput' => 'result',
+        'Hit'         => 'hit',
+        'Hsp'         => 'hsp'
+    );
 
     # This should really be done more intelligently, like with
     # XSLT
 
-    %MAPPING = 
-	( 
-	  'Hsp_bit-score' => 'HSP-bits',
-	  'Hsp_score'     => 'HSP-score',
-	  'Hsp_sw-score'  => 'HSP-swscore',
-	  'Hsp_evalue'    => 'HSP-evalue',
-	  'Hsp_query-from'=> 'HSP-query_start',
-	  'Hsp_query-to'  => 'HSP-query_end',
-	  'Hsp_hit-from'  => 'HSP-hit_start',
-	  'Hsp_hit-to'    => 'HSP-hit_end',
-	  'Hsp_positive'  => 'HSP-conserved',
-	  'Hsp_identity'  => 'HSP-identical',
-	  'Hsp_gaps'      => 'HSP-hsp_gaps',
-	  'Hsp_hitgaps'   => 'HSP-hit_gaps',
-	  'Hsp_querygaps' => 'HSP-query_gaps',
-	  'Hsp_qseq'      => 'HSP-query_seq',
-	  'Hsp_hseq'      =>  'HSP-hit_seq',
-	  'Hsp_midline'   =>  'HSP-homology_seq',
-	  'Hsp_align-len' =>  'HSP-hsp_length',
-	  'Hsp_query-frame'=> 'HSP-query_frame',
-	  'Hsp_hit-frame'  => 'HSP-hit_frame',
+    %MAPPING = (
+        'Hsp_bit-score'   => 'HSP-bits',
+        'Hsp_score'       => 'HSP-score',
+        'Hsp_sw-score'    => 'HSP-swscore',
+        'Hsp_evalue'      => 'HSP-evalue',
+        'Hsp_query-from'  => 'HSP-query_start',
+        'Hsp_query-to'    => 'HSP-query_end',
+        'Hsp_hit-from'    => 'HSP-hit_start',
+        'Hsp_hit-to'      => 'HSP-hit_end',
+        'Hsp_positive'    => 'HSP-conserved',
+        'Hsp_identity'    => 'HSP-identical',
+        'Hsp_gaps'        => 'HSP-hsp_gaps',
+        'Hsp_hitgaps'     => 'HSP-hit_gaps',
+        'Hsp_querygaps'   => 'HSP-query_gaps',
+        'Hsp_qseq'        => 'HSP-query_seq',
+        'Hsp_hseq'        => 'HSP-hit_seq',
+        'Hsp_midline'     => 'HSP-homology_seq',
+        'Hsp_align-len'   => 'HSP-hsp_length',
+        'Hsp_query-frame' => 'HSP-query_frame',
+        'Hsp_hit-frame'   => 'HSP-hit_frame',
 
-	  'Hit_id'        => 'HIT-name',
-	  'Hit_len'       => 'HIT-length',
-	  'Hit_accession' => 'HIT-accession',
-	  'Hit_def'       => 'HIT-description',
-	  'Hit_signif'    => 'HIT-significance',
-	  'Hit_score'     => 'HIT-score',
+        'Hit_id'        => 'HIT-name',
+        'Hit_len'       => 'HIT-length',
+        'Hit_accession' => 'HIT-accession',
+        'Hit_def'       => 'HIT-description',
+        'Hit_signif'    => 'HIT-significance',
+        'Hit_score'     => 'HIT-score',
 
-	  'FastaOutput_program'  => 'RESULT-algorithm_name',
-	  'FastaOutput_version'  => 'RESULT-algorithm_version',
-	  'FastaOutput_query-def'=> 'RESULT-query_name',
-	  'FastaOutput_querydesc'=> 'RESULT-query_description',
-	  'FastaOutput_query-len'=> 'RESULT-query_length',
-	  'FastaOutput_db'       => 'RESULT-database_name',
-	  'FastaOutput_db-len'   => 'RESULT-database_entries',
-	  'FastaOutput_db-let'   => 'RESULT-database_letters',
+        'FastaOutput_program'   => 'RESULT-algorithm_name',
+        'FastaOutput_version'   => 'RESULT-algorithm_version',
+        'FastaOutput_query-def' => 'RESULT-query_name',
+        'FastaOutput_querydesc' => 'RESULT-query_description',
+        'FastaOutput_query-len' => 'RESULT-query_length',
+        'FastaOutput_db'        => 'RESULT-database_name',
+        'FastaOutput_db-len'    => 'RESULT-database_entries',
+        'FastaOutput_db-let'    => 'RESULT-database_letters',
 
-	  'Parameters_matrix'    => { 'RESULT-parameters' => 'matrix'},
-	  'Parameters_expect'    => { 'RESULT-parameters' => 'expect'},
-	  'Parameters_include'   => { 'RESULT-parameters' => 'include'},
-	  'Parameters_sc-match'  => { 'RESULT-parameters' => 'match'},
-	  'Parameters_sc-mismatch' => { 'RESULT-parameters' => 'mismatch'},
-	  'Parameters_gap-open'  => { 'RESULT-parameters' => 'gapopen'},
-	  'Parameters_gap-ext'   => { 'RESULT-parameters' => 'gapext'},
-	  'Parameters_word-size' => { 'RESULT-parameters' => 'wordsize'},
-	  'Parameters_ktup'      => { 'RESULT-parameters' => 'ktup'},
-	  'Parameters_filter'    => {'RESULT-parameters' => 'filter'},
-	  'Statistics_db-num'    => { 'RESULT-statistics' => 'dbentries'},
-	  'Statistics_db-len'    => { 'RESULT-statistics' => 'dbletters'},
-	  'Statistics_hsp-len'   => { 'RESULT-statistics' => 'hsplength'},
-	  'Statistics_eff-space' => { 'RESULT-statistics' => 'effectivespace'},
-	  'Statistics_kappa'     => { 'RESULT-statistics' => 'kappa' },
-	  'Statistics_lambda'    => { 'RESULT-statistics' => 'lambda' },
-	  'Statistics_entropy'   => { 'RESULT-statistics' => 'entropy'},
-	  );
+        'Parameters_matrix'      => { 'RESULT-parameters' => 'matrix' },
+        'Parameters_expect'      => { 'RESULT-parameters' => 'expect' },
+        'Parameters_include'     => { 'RESULT-parameters' => 'include' },
+        'Parameters_sc-match'    => { 'RESULT-parameters' => 'match' },
+        'Parameters_sc-mismatch' => { 'RESULT-parameters' => 'mismatch' },
+        'Parameters_gap-open'    => { 'RESULT-parameters' => 'gapopen' },
+        'Parameters_gap-ext'     => { 'RESULT-parameters' => 'gapext' },
+        'Parameters_word-size'   => { 'RESULT-parameters' => 'wordsize' },
+        'Parameters_ktup'        => { 'RESULT-parameters' => 'ktup' },
+        'Parameters_filter'      => { 'RESULT-parameters' => 'filter' },
+        'Statistics_db-num'      => { 'RESULT-statistics' => 'dbentries' },
+        'Statistics_db-len'      => { 'RESULT-statistics' => 'dbletters' },
+        'Statistics_hsp-len'     => { 'RESULT-statistics' => 'hsplength' },
+        'Statistics_eff-space'   => { 'RESULT-statistics' => 'effectivespace' },
+        'Statistics_kappa'       => { 'RESULT-statistics' => 'kappa' },
+        'Statistics_lambda'      => { 'RESULT-statistics' => 'lambda' },
+        'Statistics_entropy'     => { 'RESULT-statistics' => 'entropy' },
+    );
 }
 
-
 use base qw(Bio::SearchIO);
 
 =head2 new
@@ -170,16 +168,19 @@
 =cut
 
 sub _initialize {
-  my($self, at args) = @_;
-  $self->SUPER::_initialize(@args);
-  return unless @args;
-  my ($idlength) = $self->_rearrange([qw(IDLENGTH)], at args);
-  $self->idlength($idlength || $IDLENGTH);
-  $self->_eventHandler->register_factory('hsp', 
-                                         Bio::Factory::ObjectFactory->new(
-                                            -type      => 'Bio::Search::HSP::FastaHSP',
-                                            -interface => 'Bio::Search::HSP::HSPI'));
-  return 1;
+    my ( $self, @args ) = @_;
+    $self->SUPER::_initialize(@args);
+    return unless @args;
+    my ($idlength) = $self->_rearrange( [qw(IDLENGTH)], @args );
+    $self->idlength( $idlength || $IDLENGTH );
+    $self->_eventHandler->register_factory(
+        'hsp',
+        Bio::Factory::ObjectFactory->new(
+            -type      => 'Bio::Search::HSP::FastaHSP',
+            -interface => 'Bio::Search::HSP::HSPI'
+        )
+    );
+    return 1;
 }
 
 =head2 next_result
@@ -192,656 +193,1195 @@
 
 =cut
 
-sub next_result{
-   my ($self) = @_;
-   local $/ = "\n";
-   local $_;
+sub next_result {
+    my ($self) = @_;
+    local $/ = "\n";
+    local $_;
 
-   my $data = '';
-   my $seentop = 0;
-   my $current_hsp;
-   $self->start_document();
-   my @hit_signifs;
-   while( defined ($_ = $self->_readline )) {
-       next if( ! $self->in_element('hsp')  &&
-		/^\s+$/); # skip empty lines
-       if( m/(\S+)\s+searches\s+a\s+(protein\s+or\s+DNA\s+)?sequence/oxi || 
-	   /(\S+)\s+compares\s+a/ ||
-	   ( m/^\#\s+/ && 
-	     ($_ = $self->_readline) &&
-	     /(\S+)\s+searches\s+a\s+(protein\s+or\s+DNA\s+)?sequence/oxi ||
-	     /(\S+)\s+compares\s+a/
-	   )
-	 ) {
-	   if( $seentop ) {
-	       $self->_pushback($_);
-	       $self->end_element({ 'Name' => 'FastaOutput'});
-	       return $self->end_document();
-	   }
-	   $self->{'_reporttype'} = $1;
-	   $self->start_element({ 'Name' => 'FastaOutput' } );
-	   $self->{'_result_count'}++;
-	   $seentop = 1;
-	   $self->debug("reporttype is ".$self->{'_reporttype'}."\n") if $self->verbose > 0;
-	   $self->element({ 'Name' => 'FastaOutput_program',
-			    'Data' => $self->{'_reporttype'}});
-	   $_ = $self->_readline();
-	   my ($version) = (/version\s+(\S+)/);
-	   $version = '' unless defined $version;
-	   $self->{'_version'} = $version;
-	   $self->element({ 'Name' => 'FastaOutput_version',
-			    'Data' => $version});
+    my $data    = '';
+    my $seentop = 0;
+    my $current_hsp;
+    $self->start_document();
+    my @hit_signifs;
+    while ( defined( $_ = $self->_readline ) ) {
+        next if ( !$self->in_element('hsp')
+            && /^\s+$/ );    # skip empty lines
+        if (
+               m/(\S+)\s+searches\s+a\s+(protein\s+or\s+DNA\s+)?sequence/oxi
+            || /(\S+)\s+compares\s+a/
+            || (   m/^\#\s+/
+                && ( $_ = $self->_readline )
+                && /(\S+)\s+searches\s+a\s+(protein\s+or\s+DNA\s+)?sequence/oxi
+                || /(\S+)\s+compares\s+a/ )
+          )
+        {
+            if ($seentop) {

@@ Diff output truncated at 10000 characters. @@



More information about the Bioperl-guts-l mailing list