BioPerl

 view release on metacpan or  search on metacpan

Bio/SearchIO/fasta.pm  view on Meta::CPAN


    # Hsp_score Hsp_evalue Hsp_bit-score
    # Hsp_sw-score Hsp_gaps Hsp_identity Hsp_positive
    # Hsp_align-len Hsp_query-from Hsp_query-to
    # Hsp_hit-from Hsp_hit-to Hsp_qseq Hsp_midline

    $self->start_element( { 'Name' => 'Hit' } );
    $self->element(
		   {
		    'Name' => 'Hit_len',
		    'Data' => $hit->{hit_len}
		   }
		  ) if exists $hit->{hit_len};
    $self->element(
		   {
		    'Name' => 'Hit_id',
		    'Data' => $hit->{id}
		   }
		  ) if exists $hit->{id};
    $self->element(
		   {
		    'Name' => 'Hit_accession',
		    'Data' => $hit->{acc}
		   }
		  ) if exists $hit->{acc};
    $self->element(
		   {
		    'Name' => 'Hit_def',
		    'Data' => $hit->{desc}
		   }
		  ) if exists $hit->{desc};
    $self->element(
		   {
		    'Name' => 'Hit_signif',
		    'Data' => $hit->{evalue}
		   }
		  ) if exists $hit->{evalue};
    $self->element(
		   {
		    'Name' => 'Hit_score',
		    'Data' => $hit->{bits}
		   }
		  ) if exists $hit->{bits};

    for my $hsp (@{$hit->{HSPs}}) {

      $self->start_element( { 'Name' => 'Hsp' } );
      $self->element({'Name' => 'Hsp_score', 'Data' => $hsp->{'z-sc'}})
	if exists $hsp->{'z-sc'};
      $self->element({'Name' => 'Hsp_evalue', 'Data' => $hsp->{evalue} } )
	if exists $hsp->{evalue};
      $self->element({'Name' => 'Hsp_evalue2', 'Data' => $hsp->{evalue2} } )
	if exists $hsp->{evalue2};

      $self->element({'Name' => 'Hsp_bit-score', 'Data' => $hsp->{bits} } )
	if exists $hsp->{bits};
      $self->element({'Name' => 'Hsp_sw-score', 'Data' => $hsp->{'n-w'} } )
	if exists $hsp->{'n-w'};
      $self->element({'Name' => 'Hsp_sw-score', 'Data' => $hsp->{sw} } )
	if exists $hsp->{sw};
      $self->element({'Name' => 'Hsp_gaps', 'Data' => $hsp->{'%_gid'} } )
	if exists $hsp->{'%_gid'};
      $self->element({
		      'Name' => 'Hsp_identity',
		      'Data' =>
		      sprintf( "%.0f", $hsp->{'%_id'} * $hsp->{alen} )
		     }) if ( exists $hsp->{'%_id'} && exists $hsp->{alen} );

      if ( exists $hsp->{'%_gid'} ) {
	$self->element(
		       {
			'Name' => 'Hsp_positive',
			'Data' =>
			sprintf( "%.0f", $hsp->{'%_gid'} * $hsp->{alen} )
		       }
		      ) if exists $hsp->{'%_gid'} && exists $hsp->{alen};
      } else {
	$self->element(
		       {
			'Name' => 'Hsp_positive',
			'Data' =>
			sprintf( "%.0f", $hsp->{'%_id'} * $hsp->{alen} )
		       }
		      ) if ( exists $hsp->{'%_id'} && exists $hsp->{alen} );
      }

      $self->element(
		     {
		      'Name' => 'Hsp_align-len', 'Data' => $hsp->{alen} } )
	if exists $hsp->{alen};
      $self->element(
		     {
		      'Name' => 'Hsp_query-from', 'Data' => $hsp->{an0} } )
	if exists $hsp->{an0};
      $self->element(
		     {
		      'Name' => 'Hsp_query-to', 'Data' => $hsp->{ax0} } )
	if exists $hsp->{ax0};
      $self->element(
		     {
		      'Name' => 'Hsp_hit-from', 'Data' => $hsp->{an1} } )
	if exists $hsp->{an1};
      $self->element(
		     {
		      'Name' => 'Hsp_hit-to', 'Data' => $hsp->{ax1} } )
	if exists $hsp->{ax1};

      $self->element(
		     {
		      'Name' => 'Hsp_querygaps', 'Data' => $hsp->{qgaps} } )
	if exists $hsp->{qgaps};
      $self->element(
		     {
		      'Name' => 'Hsp_hitgaps', 'Data' => $hsp->{lgaps} } )
	if exists $hsp->{lgaps};

      if ( $self->{'_reporttype'} =~ m/^FAST[NXY]$/o ) {
	if ( 8 == scalar grep { exists $hsp->{$_} }
	     qw(an0 ax0 pn0 px0 an1 ax1 pn1 px1) ) {
	  if ( $hsp->{ax0} < $hsp->{an0} ) {
	    $self->element(
			   {
			    'Name' => 'Hsp_query-frame',
			    'Data' =>
			    "-@{[(($hsp->{px0} - $hsp->{ax0}) % 3) + 1]}"
			   }
			  );
	  } else {
	    $self->element(
			   {
			    'Name' => 'Hsp_query-frame',
			    'Data' =>
			    "+@{[(($hsp->{an0} - $hsp->{pn0}) % 3) + 1]}"
			   }
			  );
	  }



( run in 1.325 second using v1.01-cache-2.11-cpan-5735350b133 )