Bio/SearchIO/Writer/GbrowseGFF.pm

filter: Statementstmt 62.6% 99 / 158 Branchbran 40.2% 37 / 92 Conditioncond 29.0% 9 / 31 MC/DCmcdc 0.0% 0 / 19 Subroutinesub 80.0% 8 / 10 Podpod 80.0% 4 / 5 totaltotal 49.8% 157 / 315 CC 60 SCAR 56.1
CC
60
Cov
52%
to_string
355.1
significance_filter
56.0
new
3.1
CRAP 273.5
« Bio/TreeIO/pag.pm ↑ Summary Bio/SeqIO/gbdriver.pm »
1 #-----------------------------------------------------------------
2 #
3 # BioPerl module Bio::SearchIO::Writer::GbrowseGFF.pm
4 #
5 # Please direct questions and support issues to <bioperl-l@bioperl.org>
6 #
7 # Cared for by Mark Wilkinson <markw@illuminae.com>
8 #
9 # You may distribute this module under the same terms as perl itself
10 #-----------------------------------------------------------------
11  
12 =head1 NAME
13  
14 Bio::SearchIO::Writer::GbrowseGFF - Interface for outputting parsed search results in Gbrowse GFF format
15  
16 =head1 SYNOPSIS
17  
18 use Bio::SearchIO;
19 my $in = Bio::SearchIO->new(-file => 'result.blast',
20 -format => 'blast');
21 my $out = Bio::SearchIO->new(-output_format => 'GbrowseGFF',
22 -output_cigar => 1,
23 -output_signif => 1,
24 -file => ">result.gff");
25 while( my $r = $in->next_result ) {
26 $out->write_result($r);
27 }
28  
29 =head1 DESCRIPTION
30  
31 This writer produces Gbrowse flavour GFF from a Search::Result object.
32  
33 =head1 AUTHOR Mark Wilkinson
34  
35 Email markw-at-illuminae-dot-com
36  
37 =head1 CONTRIBUTORS
38  
39 Susan Miller sjmiller at email-DOT-arizon-DOT-edu
40 Jason Stajich jason at bioperl-dot-org
41  
42 =head1 FEEDBACK
43  
44 =head2 Mailing Lists
45  
46 User feedback is an integral part of the evolution of this and other
47 Bioperl modules. Send your comments and suggestions preferably to
48 the Bioperl mailing list. Your participation is much appreciated.
49  
50 bioperl-l@bioperl.org - General discussion
51 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
52  
53 =head2 Support
54  
55 Please direct usage questions or support issues to the mailing list:
56  
57 I<bioperl-l@bioperl.org>
58  
59 rather than to the module maintainer directly. Many experienced and
60 reponsive experts will be able look at the problem and quickly
61 address it. Please include a thorough description of the problem
62 with code and data examples if at all possible.
63  
64 =head2 Reporting Bugs
65  
66 Report bugs to the Bioperl bug tracking system to help us keep track
67 of the bugs and their resolution. Bug reports can be submitted via
68 the web:
69  
70 https://github.com/bioperl/bioperl-live/issues
71  
72 =head1 APPENDIX
73  
74 The rest of the documentation details each of the object methods.
75 Internal methods are usually preceded with a _
76  
77 =cut
78  
79  
80 package Bio::SearchIO::Writer::GbrowseGFF;
81 2 $Bio::SearchIO::Writer::GbrowseGFF::VERSION = '1.7.8';
82 2 ▶use vars qw(%Defaults);
Subroutine BEGIN: called CC=1 SCAR=0.0
83 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
84  
85 2 $Defaults{'Prefix'} = 'EST';
86 2 $Defaults{'HSPTag'} = 'HSP';
87 2 $Defaults{'MatchTag'} = 'match';
88  
89 2 ▶use base qw(Bio::Root::Root Bio::SearchIO::SearchWriterI);
Subroutine BEGIN: called CC=1 SCAR=0.0
90  
91  
92 =head2 new
93  
94 Title : new
95 Usage : my $obj = Bio::SearchIO::Writer::GbrowseGFF->new(@args);
96 Function: Builds a new Bio::SearchIO::Writer::GbrowseGFF object
97 Returns : an instance of Bio::SearchIO::Writer::GbrowseGFF
98 Args : -e_value => 10 : set e_value parsing cutoff (default undef)
99 (note the -e_value flag is deprecated.)
100  
101 =cut
102  
103 1 ▶sub new {
Subroutine new: called CC=3 SCAR=11.3
Pod documented
104 1 my($class,@args) = @_;
105  
106 1 my $self = $class->SUPER::new(@args);
107 ($self->{'_evalue'},
108 $self->{'_cigar'},
109 $self->{'_prefix'},
110 1 $self->{'_signif'} ) = $self->_rearrange([qw(E_VALUE OUTPUT_CIGAR PREFIX
111 OUTPUT_SIGNIF)], @args);
112 1 ▶ $self->{'_evalue'} && warn( "Use of the -e_value argument is deprecated.\nIn future, use \$writer->filter(\"type\", \&code) instead.\n\tparsing will proceed correctly with this e_value\n");
Branch: 1 branch
BranchTrueFalseTotal
$self->{"_evalue"} and warn "Use of the -e_value argument is deprecated.\nIn future, use \$writer->filter(\"type\", &code) instead.\n\tparsing will proceed correctly with this e_value\n" 0 1 1
113 1 $self->{Gbrowse_HSPID} = 0;
114 1 $self->{Gbrowse_HITID} = 0;
115 1 ▶ $self->{'_prefix'} ||= $Defaults{'Prefix'};
Condition33%1/3
$self->{"_prefix"} ||= $Bio::SearchIO::Writer::GbrowseGFF::Defaults{"Prefix"}
l!l&&r!l&&!r
100
MC/DC0%0/2
$self->{"_prefix"} ||= $Bio::SearchIO::Writer::GbrowseGFF::Defaults{"Prefix"}
$self->{"_prefix"} $Bio::SearchIO::Writer::GbrowseGFF::Defaults{"Prefix"}
Truth table33%1/3
A ||= B
A= $self->{"_prefix"}B= $Bio::SearchIO::Writer::GbrowseGFF::Defaults{"Prefix"}
ABresult
1X1
011
000
116 1 return $self;
117 }
118  
119 5 ▶sub _incrementHSP {
Subroutine _incrementHSP: called CC=1 SCAR=0.0
120 5 my ($self) = @_;
121 5 return ++$self->{Gbrowse_HSPID};
122 }
123  
124 2 ▶sub _incrementHIT {
Subroutine _incrementHIT: called CC=1 SCAR=0.0
125 2 my ($self) = @_;
126 return ++$self->{Gbrowse_HITID}
127 2 }
128 # according to the GFF3 spec:
129 #"match". In addition to the generic "match"
130 #type, there are the subclasses "cDNA_match," "EST_match,"
131 #"translated_nucleotide_match," "nucleotide_to_protein_match," and
132 #"nucleotide_motif."
133  
134 =head2 to_string
135  
136 Purpose : Produce the Gbrowse format GFF lines for a Result
137 Usage : print $writer->to_string( $result_obj, @args);
138 Argument : $result_obj = A Bio::Search::Result::ResultI object
139 -version => 1|2|2.5|3 ; the GFF format you want to output (default 3)
140 -match_tag => match|cDNA_match|EST_match|translated_nucleotide_match
141 nucleotide_to_protein_match|nucleotide_motif
142 This is the SO term to be placed in GFF column 3.
143 -prefix => String to prefix the group by, default is EST
144 (see %Defaults class variable) A default can also
145 be set on object init
146 Returns : String containing data for each search Result or any of its
147 : sub-objects (Hits and HSPs).
148 Throws : n/a
149  
150 =cut
151  
152 #-reference => 'hit'|'query' ; whether the hit sequence name or the
153 # query sequence name is used as the
154 # 'reference' sequence (GFF column 1)
155  
156 1 ▶sub to_string {
Subroutine to_string: called CC=52 SCAR=58.7
Pod documented
157 1 my ($self, $result, @args) = @_;
158 1 my ($format, $reference,
159 $match_tag,$hsp_tag,
160 $prefix) = $self->_rearrange([qw
161 (VERSION
162 REFERENCE
163 MATCH_TAG HSP_TAG
164 PREFIX)], @args);
165 1 ▶ $self->warn($reference) if $reference;
Branch: 1 branch
BranchTrueFalseTotal
if $reference 0 1 1
166 1 ▶ $reference ||='hit'; # default is that the hit sequence (db sequence) becomes the reference sequence. I think this is fairly typical...
Condition50%1/2
$reference ||= "hit"
l!l
01
MC/DC0%0/1
$reference ||= "hit"
$reference
Truth table50%1/2
A
A= $reference
Aresult
11
00
167 1 ▶ $match_tag ||= $Defaults{'MatchTag'}; # default is the generic 'match' tag.
Condition33%1/3
$match_tag ||= $Bio::SearchIO::Writer::GbrowseGFF::Defaults{"MatchTag"}
l!l&&r!l&&!r
010
MC/DC0%0/2
$match_tag ||= $Bio::SearchIO::Writer::GbrowseGFF::Defaults{"MatchTag"}
$match_tag $Bio::SearchIO::Writer::GbrowseGFF::Defaults{"MatchTag"}
Truth table33%1/3
A ||= B
A= $match_tagB= $Bio::SearchIO::Writer::GbrowseGFF::Defaults{"MatchTag"}
ABresult
1X1
011
000
168 1 ▶ $hsp_tag ||= $Defaults{'HSPTag'}; # default is the generic 'hsp' tag.
Condition33%1/3
$hsp_tag ||= $Bio::SearchIO::Writer::GbrowseGFF::Defaults{"HSPTag"}
l!l&&r!l&&!r
010
MC/DC0%0/2
$hsp_tag ||= $Bio::SearchIO::Writer::GbrowseGFF::Defaults{"HSPTag"}
$hsp_tag $Bio::SearchIO::Writer::GbrowseGFF::Defaults{"HSPTag"}
Truth table33%1/3
A ||= B
A= $hsp_tagB= $Bio::SearchIO::Writer::GbrowseGFF::Defaults{"HSPTag"}
ABresult
1X1
011
000
169 1 ▶ $prefix ||= $self->{'_prefix'};
Condition33%1/3
$prefix ||= $self->{"_prefix"}
l!l&&r!l&&!r
010
MC/DC0%0/2
$prefix ||= $self->{"_prefix"}
$prefix $self->{"_prefix"}
Truth table33%1/3
A ||= B
A= $prefixB= $self->{"_prefix"}
ABresult
1X1
011
000
170 1 ▶ $self->throw("$reference must be one of 'query', or 'hit'\n") unless $reference;
Branch: 1 branch
BranchTrueFalseTotal
unless $reference 0 1 1
171  
172 #************* THIS IS WHERE I STOPPED ****************
173 # *****************************************************
174 #*************************************************
175  
176 1 ▶ $format ||='3';
Condition50%1/2
$format ||= 3
l!l
01
MC/DC0%0/1
$format ||= 3
$format
Truth table50%1/2
A
A= $format
Aresult
11
00
177 1 my $gffio = Bio::Tools::GFF->new(-gff_version => $format); # try to set it
178  
179 # just in case that behaviour changes (at the moment, an invalid format throws an exception, but it might return undef in the future
180 1 ▶ return "" unless defined $gffio; # be kind and don't return undef in case the person is putting the output directly into a print statement without testing it
Branch: 1 branch
BranchTrueFalseTotal
unless defined $gffio 0 1 1
181 # now $gffio is either false, or a valid GFF formatter
182  
183 1 my ($GFF,$cigar,$score);
184 1 my ($resultfilter,$hitfilter,$hspfilter) = (
185 $self->filter('RESULT'),
186 $self->filter('HIT'),
187 $self->filter('HSP'));
188 1 ▶ $result->can('rewind') && $result->rewind(); # ensure we're at the beginning
Branch: 1 branch
BranchTrueFalseTotal
$result->can("rewind") and $result->rewind 1 0 1
189 0 ▶ next if (defined $resultfilter && ! (&{$resultfilter}($result)) );
Branch: 1 branch
BranchTrueFalseTotal
if defined $resultfilter and not &{$resultfilter;}($result) 0 1 1
Condition33%1/3
defined $resultfilter and not &{$resultfilter;}($result)
!ll&&!rl&&r
100
MC/DC0%0/2
defined $resultfilter and not &{$resultfilter;}($result)
defined $resultfilter not &{$resultfilter;}($result)
Truth table33%1/3
A and not(B)
A= defined $resultfilterB= not &{$resultfilter;}($result)
ABresult
0X0
100
111
190  
191 1 ▶ while( my $hit = $result->next_hit ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $hit = $result->next_hit) 2 1 3
192  
193 2 ▶ if (defined $self->{_evalue}){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"_evalue"}) 0 2 2
194 0 ▶ next unless ($hit->significance < $self->{_evalue});
Branch: 1 branch
BranchTrueFalseTotal
unless $hit->significance < $self->{"_evalue"} 0 0 0
195 }
196 0 ▶ next if( defined $hitfilter && ! &{$hitfilter}($hit) ); # test against filter code
Branch: 1 branch
BranchTrueFalseTotal
if defined $hitfilter and not &{$hitfilter;}($hit) 0 2 2
Condition33%1/3
defined $hitfilter and not &{$hitfilter;}($hit)
!ll&&!rl&&r
200
MC/DC0%0/2
defined $hitfilter and not &{$hitfilter;}($hit)
defined $hitfilter not &{$hitfilter;}($hit)
Truth table33%1/3
A and not(B)
A= defined $hitfilterB= not &{$hitfilter;}($hit)
ABresult
0X0
100
111
197  
198 2 ▶ my $refseq = $reference eq 'hit' ? $hit->name : $result->query_name;
Branch: 1 branch
BranchTrueFalseTotal
$reference eq 'hit' ? : 2 0 2
199 2 ▶ my $seqname = $reference eq 'hit' ? $result->query_name : $hit->name; # hopefully this will be a simple identifier without a full description line!!
Branch: 1 branch
BranchTrueFalseTotal
$reference eq 'hit' ? : 2 0 2
200 2 ▶ if ($self->{_signif}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'_signif'}) { } 2 0 2
201 2 $score = $hit->significance;
202 } else {
203 0 $score = $hit->raw_score;
204 }
205 2 ▶ $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;
Branch: 1 branch
BranchTrueFalseTotal
unless $refseq 0 2 2
206 2 my $source = $hit->algorithm;
207 2 ▶ $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;
Branch: 1 branch
BranchTrueFalseTotal
unless $refseq 0 2 2
208 2 ▶ $self->throw("This module only works on (T)BLASTN reports at this time. Sorry.\n") unless $source =~ /BLASTN/;
Branch: 1 branch
BranchTrueFalseTotal
unless $source =~ /BLASTN/ 0 2 2
209  
210 2 my @plus_hsps;
211 my @minus_hsps;
212  
213 # pre-process the HSP's because we later need to know
214 # the extents of the plus and munus strand
215 # on both the subject and query strands individually
216 2 my ($qpmin, $qpmax, $qmmin, $qmmax, $spmin, $spmax, $smmin, $smmax); # variables for the plus/minus strand min start and max end to know the full extents of the hit
217 2 ▶ while( my $hsp = $hit->next_hsp ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $hsp = $hit->next_hsp) 5 2 7
218 5 ▶ if ( defined $self->{_evalue} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"_evalue"}) 0 5 5
219 # for backward compatibility only
220 0 ▶ next unless ($hsp->significance < $self->{_evalue});
Branch: 1 branch
BranchTrueFalseTotal
unless $hsp->significance < $self->{"_evalue"} 0 0 0
221 }
222 0 ▶ next if( defined $hspfilter && ! &{$hspfilter}($hsp) ); # test against HSP filter
Branch: 1 branch
BranchTrueFalseTotal
if defined $hspfilter and not &{$hspfilter;}($hsp) 0 5 5
Condition33%1/3
defined $hspfilter and not &{$hspfilter;}($hsp)
!ll&&!rl&&r
500
MC/DC0%0/2
defined $hspfilter and not &{$hspfilter;}($hsp)
defined $hspfilter not &{$hspfilter;}($hsp)
Truth table33%1/3
A and not(B)
A= defined $hspfilterB= not &{$hspfilter;}($hsp)
ABresult
0X0
100
111
223 5 ▶ if ($hsp->hit->strand >= 0 ){
Branch: 1 branch
BranchTrueFalseTotal
if ($hsp->hit->strand >= 0) 5 0 5
224 5 push @plus_hsps, $hsp;
225 5 ▶ if (defined $qpmin){ # set or reset the minimum and maximum extent of the plus-strand hit
Branch: 1 branch
BranchTrueFalseTotal
if (defined $qpmin) { } 3 2 5
226 3 ▶ $qpmin = $hsp->query->start if $hsp->query->start < $qpmin;
Branch: 1 branch
BranchTrueFalseTotal
if $hsp->query->start < $qpmin 0 3 3
227 3 ▶ $qpmax = $hsp->query->end if $hsp->query->end > $qpmax;
Branch: 1 branch
BranchTrueFalseTotal
if $hsp->query->end > $qpmax 2 1 3
228 3 ▶ $spmin = $hsp->hit->start if $hsp->hit->start < $spmin;
Branch: 1 branch
BranchTrueFalseTotal
if $hsp->hit->start < $spmin 0 3 3
229 3 ▶ $spmax = $hsp->hit->end if $hsp->hit->end > $spmax;
Branch: 1 branch
BranchTrueFalseTotal
if $hsp->hit->end > $spmax 2 1 3
230 } else {
231 2 $qpmin = $hsp->query->start;
232 2 $qpmax = $hsp->query->end;
233 2 $spmin = $hsp->hit->start;
234 2 $spmax = $hsp->hit->end;
235 }
236 }
237 5 ▶ if ($hsp->hit->strand < 0 ){
Branch: 1 branch
BranchTrueFalseTotal
if ($hsp->hit->strand < 0) 0 5 5
238 0 push @minus_hsps, $hsp;
239 0 ▶ if (defined $qmmin){ # set or reset the minimum and maximum extent of the minus-strand hit
Branch: 1 branch
BranchTrueFalseTotal
if (defined $qmmin) { } 0 0 0
240 0 ▶ $qmmin = $hsp->query->start if $hsp->query->start < $qmmin;
Branch: 1 branch
BranchTrueFalseTotal
if $hsp->query->start < $qmmin 0 0 0
241 0 ▶ $qmmax = $hsp->query->end if $hsp->query->end > $qmmax;
Branch: 1 branch
BranchTrueFalseTotal
if $hsp->query->end > $qmmax 0 0 0
242 0 ▶ $smmin = $hsp->hit->start if $hsp->hit->start < $smmin;
Branch: 1 branch
BranchTrueFalseTotal
if $hsp->hit->start < $smmin 0 0 0
243 0 ▶ $smmax = $hsp->hit->end if $hsp->hit->end > $smmax;
Branch: 1 branch
BranchTrueFalseTotal
if $hsp->hit->end > $smmax 0 0 0
244 } else {
245 0 $qmmin = $hsp->query->start;
246 0 $qmmax = $hsp->query->end;
247 0 $smmin = $hsp->hit->start;
248 0 $smmax = $hsp->hit->end;
249 }
250 }
251 #else next if there is no strand, but that makes no sense..??
252 }
253 2 ▶ next unless (scalar(@plus_hsps) + scalar(@minus_hsps)); # next if no hsps (??)
Branch: 1 branch
BranchTrueFalseTotal
unless scalar(@plus_hsps) + scalar(@minus_hsps) 0 2 2
254 2 my $ID = $self->_incrementHIT();
255 # okay, write out the index line for the entire hit before
256 # processing HSP's
257 # unfortunately (or not??), HitI objects do not implement
258 # SeqFeatureI, so we can't just call ->gff_string
259 # as a result, this module is quite brittle to changes
260 # in the GFF format since we are hard-coding the GFF output here :-(
261  
262 2 ▶ if (scalar(@plus_hsps)){
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @plus_hsps) 2 0 2
263 2 my %tags = ( 'ID' => "match_sequence$ID");
264  
265 2 ▶ if ($format==2.5) {
Branch: 1 branch
BranchTrueFalseTotal
if ($format == 2.5) { } 0 2 2
266 0 $tags{'Target'} = "$prefix:$seqname";
267 0 $tags{'tstart'} = $qmmin;
268 0 $tags{'tend'} = $qmmax;
269 } else {
270 2 $tags{'Target'} = "$prefix:$seqname $qpmin $qpmax";
271 }
272 2 ▶ if ( $self->{'_cigar'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_cigar"}) 2 0 2
273 2 $tags{'Gap'} = $cigar;
274 }
275 2 my $feat = Bio::SeqFeature::Generic->new(
276 -seq_id => $refseq,
277 -source_tag => $source,
278 -primary_tag => $match_tag,
279 -start => $spmin,
280 -end => $spmax,
281 -score => $score,
282 -strand => '+',
283 -frame => '.',
284 -tag => \%tags
285 );
286  
287  
288 2 my $formatter = Bio::Tools::GFF->new(-gff_version => $format);
289 2 $GFF .= $feat->gff_string($formatter)."\n";
290 }
291 2 ▶ if (scalar(@minus_hsps)){
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @minus_hsps) 0 2 2
292 0 my %tags = ( 'ID' => "match_sequence$ID");
293  
294 0 ▶ if ($format==2.5) {
Branch: 1 branch
BranchTrueFalseTotal
if ($format == 2.5) { } 0 0 0
295 0 $tags{'Target'} = "$prefix:$seqname";
296 0 $tags{'tstart'} = $qpmax;
297 0 $tags{'tend'} = $qpmin;
298 }
299 else {
300 0 $tags{'Target'} = "$prefix:$seqname $qpmax $qpmin";
301 }
302 0 my $feat = Bio::SeqFeature::Generic->new(
303 -seq_id => $refseq,
304 -source_tag => $source,
305 -primary_tag => $match_tag,
306 -start => $smmin,
307 -end => $smmax,
308 -score => $score,
309 -strand => '-',
310 -frame => '.',
311 -tag => \%tags
312 );
313  
314 0 my $formatter = Bio::Tools::GFF->new(-gff_version => $format);
315 0 $GFF .= $feat->gff_string($formatter)."\n";
316 }
317  
318 # process + strand hsps
319 2 foreach my $hsp (@plus_hsps){
320 5 my $hspID = $self->_incrementHSP();
321 5 my $qstart = $hsp->query->start;
322 5 my $qend = $hsp->query->end;
323 5 my $sstart = $hsp->hit->start;
324 5 my $send = $hsp->hit->end;
325 5 my $score = $hsp->score;
326  
327 5 my %tags = ( 'ID' => "match_hsp$hspID",
328 'Parent' => "match_sequence$ID" );
329  
330 5 ▶ if ($format==2.5) {
Branch: 1 branch
BranchTrueFalseTotal
if ($format == 2.5) { } 0 5 5
331 0 $tags{'Target'} = "$prefix:$seqname";
332 0 $tags{'tstart'} = $qstart;
333 0 $tags{'tend'} = $qend;
334 }
335 else {
336 5 $tags{'Target'} = "$prefix:$seqname $qstart $qend";
337 }
338 5 ▶ if ( $self->{'_cigar'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_cigar"}) 5 0 5
339 5 $tags{'Gap'} = $hsp->cigar_string;
340 }
341  
342 5 my $feat = Bio::SeqFeature::Generic->new(
343 -seq_id => $refseq,
344 -source_tag => $source,
345 -primary_tag => $hsp_tag,
346 -start => $sstart,
347 -end => $send,
348 -score => $score,
349 -strand => '+',
350 -frame => '.',
351 -tag => \%tags
352 );
353  
354 5 my $formatter = Bio::Tools::GFF->new(-gff_version => $format);
355 5 $GFF .= $feat->gff_string($formatter)."\n";
356 }
357  
358 2 foreach my $hsp (@minus_hsps) {
359 0 my $hspID = $self->_incrementHSP();
360 0 my $qstart = $hsp->query->start;
361 0 my $qend = $hsp->query->end;
362 0 my $sstart = $hsp->hit->start;
363 0 my $send = $hsp->hit->end;
364 0 my $score = $hsp->score;
365  
366 0 my %tags = ( 'ID' => "match_hsp$hspID",
367 'Parent' => "match_sequence$ID" );
368  
369 0 ▶ if ($format==2.5) {
Branch: 1 branch
BranchTrueFalseTotal
if ($format == 2.5) { } 0 0 0
370 0 $tags{'Target'} = "$prefix:$seqname";
371 0 $tags{'tstart'} = $qend;
372 0 $tags{'tend'} = $qstart;
373 }
374 else {
375 0 $tags{'Target'} = "$prefix:$seqname $qend $qstart";
376 }
377 0 ▶ if ( $self->{'_cigar'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_cigar"}) 0 0 0
378 0 $tags{'Gap'} = $hsp->cigar_string;
379 }
380  
381 0 my $feat = Bio::SeqFeature::Generic->new(
382 -seq_id => $refseq,
383 -source_tag => $source,
384 -primary_tag => $hsp_tag,
385 -start => $sstart,
386 -end => $send,
387 -score => $score,
388 -strand => '-',
389 -frame => '.',
390 -tag => \%tags
391 );
392  
393 0 my $formatter = Bio::Tools::GFF->new(-gff_version => $format);
394 0 $GFF .= $feat->gff_string($formatter) ."\n";
395 }
396 }
397 1 return $GFF;
398 }
399  
400 0 ▶sub significance_filter {
Subroutine significance_filter: not called CC=7 SCAR=40.3
Pod undocumented
401 0 my ($self,$method,$code) = @_;
402 0 ▶ return unless $method;
Branch: 1 branch
BranchTrueFalseTotal
unless $method 0 0 0
403 0 $method = uc($method);
404 0 ▶ if( $method ne 'HSP' &&
Branch: 1 branch
BranchTrueFalseTotal
if ($method ne "HSP" and $method ne "HIT" and $method ne "RESULT") 0 0 0
Condition0%0/6
$method ne "HSP" and $method ne "HIT" and $method ne "RESULT"
!ll&&!rl&&r
000
$method ne "HSP" and $method ne "HIT"
!ll&&!rl&&r
000
MC/DC0%0/3
$method ne "HSP" and $method ne "HIT" and $method ne "RESULT"
$method ne "HSP" $method ne "HIT" $method ne "RESULT"
Truth table0%0/4
A and B and C
A= $method ne "HSP"B= $method ne "HIT"C= $method ne "RESULT"
ABCresult
0XX0
10X0
1100
1111
405 $method ne 'HIT' &&
406 $method ne 'RESULT' ) {
407 0 $self->warn("Unknown method $method");
408 0 return;
409 }
410 0 ▶ if( $code ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($code) 0 0 0
411 0 ▶ $self->throw("Must provide a valid code reference") unless ref($code) =~ /CODE/;
Branch: 1 branch
BranchTrueFalseTotal
unless ref($code) =~ /CODE/ 0 0 0
412 0 $self->{$method} = $code;
413 }
414 0 return $self->{$method};
415 }
416  
417 =head2 start_report
418  
419 Title : start_report
420 Usage : $self->start_report()
421 Function: has no function, returns nothing
422 Returns : empty string
423 Args : none
424  
425 =cut
426  
427 0 ▶sub start_report { return '' }
Subroutine start_report: not called CC=1 SCAR=6.9
Pod documented
428  
429 =head2 end_report
430  
431 Title : end_report
432 Usage : $self->end_report()
433 Function: has no function, returns nothing
434 Returns : empty string
435 Args : none
436  
437  
438 =cut
439  
440 1 ▶sub end_report { return '' }
Subroutine end_report: called CC=1 SCAR=0.0
Pod documented
441  
442 =head2 filter
443  
444 Title : filter
445 Usage : $writer->filter('hsp', \&hsp_filter);
446 Function: Filter out either at HSP,Hit,or Result level
447 Returns : none
448 Args : string => data type,
449 CODE reference
450 Note : GbrowseGFF.pm makes no changes to the default filter code
451  
452  
453 =cut
454  
455 2 1;
« Bio/TreeIO/pag.pm ↑ Summary Bio/SeqIO/gbdriver.pm »