Bio::SearchIO::Writer
GbrowseGFF
Summary
Bio::SearchIO::Writer::GbrowseGFF - Interface for outputting parsed search results in Gbrowse GFF format
Package variables
No package variables defined.
Included modules
Inherit
Synopsis
use Bio::SearchIO;
my $in = new Bio::SearchIO(-file => 'result.blast',
-format => 'blast');
my $out = new Bio::SearchIO(-output_format => 'GbrowseGFF',
-file => ">result.gff");
while( my $r = $in->next_result ) {
$out->write_result($r);
}
Description
This writer produces Gbrowse flavour GFF from a Search::Result object.
Methods
Methods description
Title : new
Usage : my $obj = new Bio::SearchIO::Writer::GbrowseGFF(@args);
Function: Builds a new Bio::SearchIO::Writer::GbrowseGFF object
Returns : an instance of Bio::SearchIO::Writer::GbrowseGFF
Args : -e_value => 10 : set e_value parsing cutoff (default 10) |
Purpose : Produce the Gbrowse format GFF lines for a Result
Usage : print $writer->to_string( $result_obj, @args);
Argument : $result_obj = A Bio::Search::Result::ResultI object
: @args = none at present...
Returns : String containing data for each search Result or any of its
: sub-objects (Hits and HSPs).
Throws : n/a |
Title : start_report
Usage : $self->start_report()
Function: has no function, returns nothing
Returns : empty string
Args : none |
Title : end_report
Usage : $self->end_report()
Function: has no function, returns nothing
Returns : empty string
Args : none |
Methods code
sub new
{ my($class,@args) = @_;
my $self = $class->SUPER::new(@args);
my ($evalue) = $self->_rearrange(["E_VALUE"], @args);
$self->{_evalue} = $evalue > 0?$evalue:10;
return $self;} |
sub to_string
{ my ($self, $result, @args) = @_;
my $GFF;
while( my $hit = $result->next_hit ) {
my $significance = $hit->significance;
next unless (($significance < $self->{_evalue}) && ($self->{_evalue} > 0));
my $refseq = $hit->name;
my $seqname = $result->query_name; my $score = $hit->raw_score;
$self->throw("No reference sequence name found in hit; required for GFF (this may not be your fault if your report type does not include reference sequence names)\n") unless $refseq;
my $source = $hit->algorithm;
$self->throw("No algorithm name found in hit; required for GFF (this may not be your fault if your report type does not include algorithm names)\n") unless $refseq;
$self->throw("This module only works on BLASTN reports at this time. Sorry.\n") unless $source eq "BLASTN";
my @plus_hsps;
my @minus_hsps;
my ($qpmin, $qpmax, $qmmin, $qmmax, $spmin, $spmax, $smmin, $smmax); while( my $hsp = $hit->next_hsp ) {
next unless (($hsp->significance < $self->{_evalue}) && ($self->{_evalue} > 0));
if ($hsp->strand('subject') eq "1"){
push @plus_hsps, $hsp;
if (defined $qpmin){ $qpmin = $hsp->start('query') if $hsp->start('query') < $qpmin;
$qpmax = $hsp->end('query') if $hsp->end('query') > $qpmax;
$spmin = $hsp->start('subject') if $hsp->start('subject') < $spmin;
$spmax = $hsp->end('subject') if $hsp->end('subject') > $spmax;
} else {
$qpmin = $hsp->start('query');
$qpmax = $hsp->end('query');
$spmin = $hsp->start('subject');
$spmax = $hsp->end('subject');
}
}
if ($hsp->strand('subject') eq "-1"){
push @minus_hsps, $hsp;
if (defined $qmmin){ $qmmin = $hsp->start('query') if $hsp->start('query') < $qmmin;
$qmmax = $hsp->end('query') if $hsp->end('query') > $qmmax;
$smmin = $hsp->start('subject') if $hsp->start('subject') < $smmin;
$smmax = $hsp->end('subject') if $hsp->end('subject') > $smmax;
} else {
$qmmin = $hsp->start('query');
$qmmax = $hsp->end('query');
$smmin = $hsp->start('subject');
$smmax = $hsp->end('subject');
}
}
}
next unless (scalar(@plus_hsps) + scalar(@minus_hsps)); if (scalar(@plus_hsps)){
$GFF .= "$refseq\t$source\tmatch\t$spmin\t$spmax\t$score\t+\t.\tTarget EST:$seqname ; tstart $qpmin ; tend $qpmax\n";
}
if (scalar(@minus_hsps)){
$GFF .= "$refseq\t$source\tmatch\t$smmin\t$smmax\t$score\t-\t.\tTarget EST:$seqname ; tstart $qmmax ; tend $qmmin\n"; }
my $strand = "+";
foreach my $hsp(@plus_hsps){
my $qstart = $hsp->start('query');
my $qend = $hsp->end('query');
my $sstart = $hsp->start('subject');
my $send = $hsp->end('subject');
my $score = $hsp->score;
$GFF .= "$refseq\t$source\tHSP\t$sstart\t$send\t$score\t+\t.\tTarget EST:$seqname ; tstart $qstart ; tend $qend\n";
}
foreach my $hsp(@minus_hsps){
my $qstart = $hsp->start('query');
my $qend = $hsp->end('query');
my $sstart = $hsp->start('subject');
my $send = $hsp->end('subject');
my $score = $hsp->score;
$GFF .= "$refseq\t$source\tHSP\t$sstart\t$send\t$score\t-\t.\tTarget EST:$seqname ; tstart $qend ; tend $qstart\n"; }
}
return $GFF;} |
sub start_report
{ return '' } |
sub end_report
{ return '' } |
General documentation
Email markw-at-illuminae-dot-com
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
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/
The rest of the documentation details each of the object methods.
Internal methods are usually preceded with a _
Title : filter
Usage : $writer->filter('hsp', \&hsp_filter);
Function: Filter out either at HSP,Hit,or Result level
Returns : none
Args : string => data type,
CODE reference
Note : GbrowseGFF.pm makes no changes to the default filter code