File Coverage

Bio/Tools/RepeatMasker.pm
Criterion Covered Total %
statement 33 35 94.2
branch 7 10 70.0
condition n/a
subroutine 5 5 100.0
pod 2 2 100.0
total 47 52 90.3


line stmt bran cond sub pod time code
1             #
2             # BioPerl module for Bio::Tools::RepeatMasker
3             #
4             # Please direct questions and support issues to
5             #
6             # Cared for by Shawn Hoon
7             #
8             # Copyright Shawn Hoon
9             #
10             # You may distribute this module under the same terms as perl itself
11              
12             # POD documentation - main docs before the code
13              
14             =head1 NAME
15              
16             Bio::Tools::RepeatMasker - a parser for RepeatMasker output
17              
18             =head1 SYNOPSIS
19              
20             use Bio::Tools::RepeatMasker;
21             my $parser = Bio::Tools::RepeatMasker->new(-file => 'seq.fa.out');
22             while( my $result = $parser->next_result ) {
23             # get some value
24             }
25              
26             =head1 DESCRIPTION
27              
28             A parser for RepeatMasker output
29              
30             =head1 FEEDBACK
31              
32             =head2 Mailing Lists
33              
34             User feedback is an integral part of the evolution of this and other
35             Bioperl modules. Send your comments and suggestions preferably to
36             the Bioperl mailing list. Your participation is much appreciated.
37              
38             bioperl-l@bioperl.org - General discussion
39             http://bioperl.org/wiki/Mailing_lists - About the mailing lists
40              
41             =head2 Support
42              
43             Please direct usage questions or support issues to the mailing list:
44              
45             I
46              
47             rather than to the module maintainer directly. Many experienced and
48             reponsive experts will be able look at the problem and quickly
49             address it. Please include a thorough description of the problem
50             with code and data examples if at all possible.
51              
52             =head2 Reporting Bugs
53              
54             Report bugs to the Bioperl bug tracking system to help us keep track
55             of the bugs and their resolution. Bug reports can be submitted via
56             the web:
57              
58             https://github.com/bioperl/bioperl-live/issues
59              
60             =head1 AUTHOR - Shawn Hoon
61              
62             Email shawnh@fugu-sg.org
63              
64             =head1 APPENDIX
65              
66             The rest of the documentation details each of the object methods.
67             Internal methods are usually preceded with a _
68              
69             =cut
70              
71              
72             # Let the code begin...
73              
74              
75             package Bio::Tools::RepeatMasker;
76 1     1   437 use strict;
  1         1  
  1         26  
77              
78 1     1   235 use Bio::SeqFeature::FeaturePair;
  1         2  
  1         35  
79              
80 1     1   8 use base qw(Bio::Root::Root Bio::Root::IO);
  1         4  
  1         379  
81              
82             =head2 new
83              
84             Title : new
85             Usage : my $obj = Bio::Tools::RepeatMasker->new();
86             Function: Builds a new Bio::Tools::RepeatMasker object
87             Returns : Bio::Tools::RepeatMasker
88             Args : -fh/-file => $val, for initing input, see Bio::Root::IO
89              
90             =cut
91              
92             sub new {
93 1     1 1 11 my($class,@args) = @_;
94              
95 1         9 my $self = $class->SUPER::new(@args);
96 1         6 $self->_initialize_io(@args);
97              
98 1         3 return $self;
99             }
100              
101             =head2 next_result
102              
103             Title : next_result
104             Usage : my $r = $rpt_masker->next_result
105             Function: Get the next result set from parser data
106             Returns : Bio::SeqFeature::FeaturePair
107             Feature1 is the Query coordinates and Feature2 is the Hit
108             Args : none
109              
110             =cut
111              
112             sub next_result {
113 5     5 1 18 my ($self) = @_;
114 5         6 local $_;
115 5         17 while (defined($_=$self->_readline()) ) {
116 8 50       19 if (/no repetitive sequences detected/) {
117 0         0 $self->warn( "RepeatMasker didn't find any repetitive sequences\n");
118 0         0 return ;
119             }
120             #ignore introductory lines
121 8 100       27 if (/\d+/) {
122 5         39 my @element = split;
123             # ignore features with negatives
124 5 50       13 next if ($element[11-13] =~ /-/);
125 5         8 my (%feat1, %feat2);
126 5         17 my @line = split;
127 5         13 my ($score, $query_name, $query_start, $query_end, $strand,
128             $repeat_name, $repeat_class ) = @line[0, 4, 5, 6, 8, 9, 10];
129              
130 5         9 my ($hit_start,$hit_end);
131              
132 5 100       13 if ($strand eq '+') {
    50          
133 3         6 ($hit_start, $hit_end) = @line[11, 12];
134 3         4 $strand = 1;
135             } elsif ($strand eq 'C') {
136 2         3 ($hit_end, $hit_start) = @line[12, 13];
137 2         4 $strand = -1;
138             }
139 5         33 my $rf = Bio::SeqFeature::Generic->new
140             (-seq_id => $query_name,
141             -score => $score,
142             -start => $query_start,
143             -end => $query_end,
144             -strand => $strand,
145             -source_tag => 'RepeatMasker',
146             -primary_tag => $repeat_class,
147             -tag => { 'Target'=> [$repeat_name, $hit_start, $hit_end]},
148             );
149              
150 5         32 my $rf2 = Bio::SeqFeature::Generic->new
151             (-seq_id => $repeat_name,
152             -score => $score,
153             -start => $hit_start,
154             -end => $hit_end,
155             -strand => $strand,
156             -source_tag => "RepeatMasker",
157             -primary_tag => $repeat_class,
158             -tag => { 'Target'=> [$query_name,$query_start,$query_end] },
159             );
160              
161 5         25 my $fp = Bio::SeqFeature::FeaturePair->new(-feature1 => $rf,
162             -feature2 => $rf2);
163 5         15 return $fp;
164             }
165             }
166             }
167              
168             1;