Bio::SearchIO::Writer BSMLResultWriter
SummaryIncluded librariesPackage variablesSynopsisDescriptionGeneral documentationMethods
Summary
Bio::SearchIO::Writer::BSMLResultWriter - DESCRIPTION of Object
Package variables
No package variables defined.
Included modules
Bio::Root::Root
Bio::SearchIO::SearchWriterI
IO::String
XML::Writer
Inherit
Bio::Root::Root Bio::SearchIO::SearchWriterI
Synopsis
  use Bio::SearchIO;
  my $in = new Bio::SearchIO(-file   => 'result.blast',
                             -format => 'blast');
  my $out = new Bio::SearchIO(-output_format  => 'BSMLResultWriter',
                              -file           => ">result.bsml");
  while( my $r = $in->next_result ) {
    $out->write_result($r);
  }
Description
This is a writer to produce BSML for a search result.
Methods
newDescriptionCode
to_stringDescriptionCode
Methods description
newcode    nextTop
 Title   : new
 Usage   : my $obj = new Bio::SearchIO::Writer::BSMLResultWriter();
 Function: Builds a new Bio::SearchIO::Writer::BSMLResultWriter object 
 Returns : an instance of Bio::SearchIO::Writer::BSMLResultWriter
 Args    :
to_stringcodeprevnextTop
 Purpose   : Produces data for each Search::Result::ResultI in a string.
           : This is an abstract method. For some useful implementations,
           : see ResultTableWriter.pm, HitTableWriter.pm, 
           : and HSPTableWriter.pm.
 Usage     : print $writer->to_string( $result_obj, @args );
 Argument  : $result_obj = A Bio::Search::Result::ResultI object
           : @args = any additional arguments used by your implementation.
 Returns   : String containing data for each search Result or any of its
           : sub-objects (Hits and HSPs).
 Throws    : n/a
Methods code
newdescriptionprevnextTop
sub new {
  my($class,@args) = @_;

  my $self = $class->SUPER::new(@args);
  return $self;
}
to_stringdescriptionprevnextTop
sub to_string {
    my ($self,$result,$num) = @_;
    my $str = new IO::String();
    my $writer = new XML::Writer(OUTPUT     => $str,
				 DATA_INDENT => 1,
				 DATA_MODE   => 1);
    $writer->xmlDecl('UTF-8');
    $writer->doctype('Bsml','-//EBI//Labbook, Inc. BSML DTD//EN',
		     'http://www.labbook.com/dtd/bsml3_1.dtd');
    $writer->startTag('Bsml');
    $writer->startTag('Definitions');
    $writer->startTag('Sequences');
    my $reporttype = $result->algorithm;
    my ($qmoltype,$hmoltype);
    my $hit = $result->next_hit;
    my $hsp = $hit->next_hsp;
    if( $hsp->query->strand == 0 ) { $qmoltype = 'aa' }
    else { $qmoltype = 'nt' }
    
    if( $hsp->hit->strand == 0 ) { $hmoltype = 'aa' }
    else { $hmoltype = 'nt' }
	
    $writer->startTag('Sequence',
		      'length' => $result->query_length,
		      'title'  => $result->query_name . " ". $result->query_description,
		      'molecule' => $qmoltype,
		      'representation' => 'virtual',
		      'id'     => $result->query_name
		      );
    # Here we're annotating the Query sequence with hits
# hence the Feature-table
$writer->startTag('Feature-tables'); $writer->startTag('Feature-table', 'title' => "$reporttype Result", 'class' => $reporttype); my ($hitnum,$hspnum) = (1,1); foreach my $hit ( $result->hits ) { $hspnum = 1; foreach my $hsp ( $hit->hsps ) { $writer->startTag('Feature', 'class' => $reporttype, 'value-type' => 'alignment', 'title' => $hit->name. " ". $hit->description, ); $writer->emptyTag('Interval-loc', 'startpos' => $hsp->query->start, 'endpos' => $hsp->query->end); $writer->emptyTag('Qualifier', 'value-type' => 'score', 'value' => $hsp->score, ); $writer->emptyTag('Qualifier', 'value-type' => 'target-start', 'value' => $hsp->hit->start, ); $writer->emptyTag('Qualifier', 'value-type' => 'target-end', 'value' => $hsp->hit->end, ); $writer->emptyTag('Link', 'title' => 'alignment', 'href' => sprintf("#SPA%d.%d",$hitnum,$hspnum) ); if( $hsp->hit->strand < 0 ) { $writer->emptyTag('Qualifier', 'value-type' => 'target-on-complement', 'value' => 1, ); } $hspnum++; $writer->endTag('Feature'); } $hitnum++; } $writer->endTag('Feature-table'); $writer->endTag('Feature-tables'); $writer->endTag('Sequence'); $writer->endTag('Sequences'); $writer->startTag('Tables'); $writer->startTag('Sequence-search-table', 'search-type' => $reporttype, 'query-length' => $result->query_length); $hitnum = $hspnum = 1; foreach my $hit ( $result->hits ) { $hspnum = 1; foreach my $hsp ( $hit->hsps ) { $writer->startTag('Seq-pair-alignment', 'id' => sprintf("SPA%d.%d",$hitnum,$hspnum), 'method' => join(' ',$result->algorithm), 'compxref' => sprintf("%s:%s", '',$result->query_name), 'refxref' => sprintf("%s:%s", $result->database_name, $hit->name), 'refseq' => $hit->name, 'title' => $result->query_name, 'compseq' => $result->query_name, 'compcaption' => $result->query_name . ' ' . $result->query_description, 'refcaption' => $hit->name . " ". $hit->description, 'totalscore' => $hsp->score, 'refstart' => $hsp->query->start, 'refend' => $hsp->query->end, 'compstart' => $hsp->hit->start, 'compend' => $hsp->hit->end, 'complength' => $hit->length, 'reflength' => $result->query_length); $writer->emptyTag('Attribute', 'name' => 'hit-num', 'content' => $hitnum); $writer->emptyTag('Attribute', 'name' => 'hit-id', 'content' => $hit->name); $writer->emptyTag('Attribute', 'name' => 'hsp-num', 'content' => $hspnum); $writer->emptyTag('Attribute', 'name' => 'hsp-bit-score', 'content' => $hsp->bits); $writer->emptyTag('Attribute', 'name' => 'hsp-evalue', 'content' => $hsp->evalue); $writer->emptyTag('Attribute', 'name' => 'pattern-from', 'content' => 0); $writer->emptyTag('Attribute', 'name' => 'pattern-to', 'content' => 0); $writer->emptyTag('Attribute', 'name' => 'query-frame', 'content' => $hsp->query->frame); $writer->emptyTag('Attribute', 'name' => 'hit-frame', 'content' => $hsp->hit->frame * $hsp->hit->strand); $writer->emptyTag('Attribute', 'name' => 'percent_identity', 'content' => sprintf("%.2f",$hsp->percent_identity)); $writer->emptyTag('Attribute', 'name' => 'percent_similarity', 'content' => sprintf("%.2f",$hsp->frac_conserved('total') * 100)); my $cons = $hsp->frac_conserved('total') * $hsp->length('total'); my $ident = $hsp->frac_identical('total') * $hsp->length('total'); $writer->emptyTag('Attribute', 'name' => 'identity', 'content' => $ident); $writer->emptyTag('Attribute', 'name' => 'positive', 'content' => $cons); $writer->emptyTag('Attribute', 'name' => 'gaps', 'content' => $hsp->gaps('total')); $writer->emptyTag('Attribute', 'name' => 'align-len', 'content' => $hsp->length('total')); $writer->emptyTag('Attribute', 'name' => 'density', 'content' => 0); $writer->emptyTag('Attribute', 'name' => 'hit-len', 'content' => $hit->length); my @extrafields; $writer->emptyTag('Seq-pair-run', 'runlength' => $hsp->hit->length, 'comprunlength' => $hsp->hsp_length, 'complength' => $hsp->hit->length, 'compcomplement'=> $hsp->hit->strand < 0 ? 1 :0, 'refcomplement' => $hsp->query->strand < 0 ? 1 :0, 'refdata' => $hsp->query_string, 'compdata' => $hsp->hit_string, 'alignment' => $hsp->homology_string, ); $hspnum++; $writer->endTag('Seq-pair-alignment'); } $hitnum++; } $writer->endTag('Sequence-search-table'); $writer->endTag('Tables'); $writer->startTag('Research'); $writer->startTag('Analyses'); $writer->startTag('Analysis'); $writer->emptyTag('Attribute', 'name' => 'program', 'content' => $reporttype); $writer->emptyTag('Attribute', 'name' => 'version', 'content' => join(' ',$reporttype, $result->algorithm_version)); $writer->emptyTag('Attribute', 'name' => 'reference', 'content' => $result->algorithm_reference); $writer->emptyTag('Attribute', 'name' => 'db', 'content' => $result->database_name); $writer->emptyTag('Attribute', 'name' => 'db-size', 'content' => $result->database_entries); $writer->emptyTag('Attribute', 'name' => 'db-length', 'content' => $result->database_letters); # $writer->emptyTag('Attribute',
# 'name' => 'iter-num',
# 'content' => $result->iteration_num);
foreach my $attr ( $result->available_parameters ) { $writer->emptyTag('Attribute', 'name' => $attr, 'content' => $result->get_parameter($attr)); } foreach my $attr ( $result->available_statistics ) { $writer->emptyTag('Attribute', 'name' => $attr, 'content' => $result->get_statistic($attr)); } $writer->endTag('Analysis'); $writer->endTag('Analyses'); $writer->endTag('Research'); $writer->endTag('Definitions'); $writer->endTag('Bsml'); $writer->end(); return ${$str->string_ref};
}
General documentation
FEEDBACKTop
Mailing ListsTop
User feedback is an integral part of the evolution of this and other
Bioperl modules. Send your comments and suggestions preferably to
the Bioperl mailing list. Your participation is much appreciated.
  bioperl-l@bioperl.org              - General discussion
  http://bioperl.org/MailList.shtml  - About the mailing lists
Reporting BugsTop
Report bugs to the Bioperl bug tracking system to help us keep track
of the bugs and their resolution. Bug reports can be submitted via
the web:
  http://bugzilla.bioperl.org/
AUTHOR - Jason StajichTop
Email jason-at-bioperl-dot-org
Describe contact details here
CONTRIBUTORSTop
Additional contributors names and emails here
APPENDIXTop
The rest of the documentation details each of the object methods.
Internal methods are usually preceded with a _