Bio/Tools/TandemRepeatsFinder.pm

filter: Statementstmt 100% 59 / 59 Branchbran 90.0% 18 / 20 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 11 / 11 Podpod 100% 3 / 3 totaltotal 97.8% 91 / 93 CC 11 SCAR 12.2
CC
11
Cov
97%
next_result
7.0
version
2.0
_current_seq_id
2.0
CRAP 3.4
« Bio/Tools/EPCR.pm ↑ Summary Bio/Tools/Profile.pm »
1  
2 =head1 NAME
3  
4 Bio::Tools::TandemRepeatsFinder - a parser for Tandem Repeats Finder output
5  
6 =head1 SYNOPSIS
7  
8 use Bio::Tools::TandemRepeatsFinder;
9  
10 # create parser
11 my $parser = Bio::Tools::Bio::Tools::TandemRepeatsFinder->new(-file => 'tandem_repeats.out');
12  
13 # loop through results
14 while( my $feature = $parser->next_result ) {
15  
16 # print the source sequence id, start, end, percent matches, and the consensus sequence
17 my ($percent_matches) = $feat->get_tag_values('percent_matches');
18 my ($consensus_sequence) = $feat->get_tag_values('consensus_sequence');
19 print $feat->seq_id()."\t".$feat->start()."\t".$feat->end()."\t$percent_matches\t$consensus_sequence\n";
20  
21 }
22  
23 =head1 DESCRIPTION
24  
25 A parser for Tandem Repeats Finder output.
26 Written and tested for version 4.00
27  
28 Location, seq_id, and score are stored in Bio::SeqFeature::Generic feature.
29 All other data is stored in tags. The available tags are
30  
31 period_size
32 copy_number
33 consensus_size
34 percent_matches
35 percent_indels
36 percent_a
37 percent_c
38 percent_g
39 percent_t
40 entropy
41 consensus_sequence
42 repeat_sequence
43 run_parameters
44 sequence_description
45  
46 The run_parameters are stored in a hashref with the following key:
47  
48 match_weight
49 mismatch_weight
50 indel_weight
51 match_prob
52 indel_prob
53 min_score
54 max_period_size
55  
56 =head1 FEEDBACK
57  
58 =head2 Mailing Lists
59  
60 User feedback is an integral part of the evolution of this and other
61 Bioperl modules. Send your comments and suggestions preferably to
62 the Bioperl mailing list. Your participation is much appreciated.
63  
64 bioperl-l@bioperl.org - General discussion
65 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
66  
67 =head2 Support
68  
69 Please direct usage questions or support issues to the mailing list:
70  
71 I<bioperl-l@bioperl.org>
72  
73 rather than to the module maintainer directly. Many experienced and
74 reponsive experts will be able look at the problem and quickly
75 address it. Please include a thorough description of the problem
76 with code and data examples if at all possible.
77  
78 =head2 Reporting Bugs
79  
80 Report bugs to the Bioperl bug tracking system to help us keep track
81 of the bugs and their resolution. Bug reports can be submitted via
82 the web:
83  
84 https://github.com/bioperl/bioperl-live/issues
85  
86 =head1 AUTHOR - Eric Just
87  
88 Email e-just@northwestern.edu
89  
90 =head1 APPENDIX
91  
92 The rest of the documentation details each of the object methods.
93 Internal methods are usually preceded with a _
94  
95 =cut
96  
97 package Bio::Tools::TandemRepeatsFinder;
98 2 $Bio::Tools::TandemRepeatsFinder::VERSION = '1.7.8';
99 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
100 2 ▶use constant DEBUG => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
101 2 ▶use Bio::SeqFeature::Generic;
Subroutine BEGIN: called CC=1 SCAR=0.0
102  
103 2 ▶use base qw(Bio::Root::Root Bio::Root::IO);
Subroutine BEGIN: called CC=1 SCAR=0.0
104  
105 =head2 new
106  
107 Title : new
108 Usage : my $obj = Bio::Tools::TandemRepeatsFinder->new();
109 Function: Builds a new Bio::Tools::TandemRepeatsFinder object
110 Returns : Bio::Tools::TandemRepeatsFinder
111 Args : -fh/-file => $val, for initing input, see Bio::Root::IO
112  
113 =cut
114  
115 3 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
116 3 my ( $class, @args ) = @_;
117  
118 3 my $self = $class->SUPER::new(@args);
119 3 $self->_initialize_io(@args);
120  
121 3 return $self;
122 }
123  
124 =head2 version
125  
126 Title : version
127 Usage : $self->version( $version )
128 Function: get/set the version of Tandem Repeats finder that was used in analysis
129 Returns : value of version of
130 Args : new value (optional)
131  
132 =cut
133  
134 3 ▶sub version {
Subroutine version: called CC=2 SCAR=7.0
Pod documented
135 3 my ( $self, $value ) = @_;
136 3 ▶ if ( defined $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 3 0 3
137 3 $self->{'version'} = $value;
138 }
139 3 return $self->{'version'};
140 }
141  
142 =head2 _current_seq_id
143  
144 Title : _current_seq_id
145 Usage : $self->_current_seq_id( $current_seq_id )
146 Function: get/set the _current_seq_id
147 Returns : value of _current_seq_id
148 Args : new value (optional)
149  
150 =cut
151  
152 8 ▶sub _current_seq_id {
Subroutine _current_seq_id: called CC=2 SCAR=6.9
153 8 my ( $self, $value ) = @_;
154 8 ▶ if ( defined $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 4 4 8
155 4 $self->{'_current_seq_id'} = $value;
156 }
157 8 return $self->{'_current_seq_id'};
158 }
159  
160 =head2 _current_seq_description
161  
162 Title : _current_seq_description
163 Usage : $self->_current_seq_description( $current_seq_id )
164 Function: get/set the _current_seq_description
165 Returns : value of _current_seq_description
166 Args : new value (optional)
167  
168 =cut
169  
170 8 ▶sub _current_seq_description {
Subroutine _current_seq_description: called CC=2 SCAR=6.9
171 8 my ( $self, $value ) = @_;
172 8 ▶ if ( defined $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 2 6 8
173 2 $self->{'_current_seq_description'} = $value;
174 }
175 8 return $self->{'_current_seq_description'};
176 }
177  
178 =head2 _current_parameters
179  
180 Title : _current_parameters
181 Usage : $self->_current_parameters( $parameters_hashref )
182 Function: get/set the _current_parameters
183 Returns : hashref representing current parameters parsed from results file
184 : keys are
185 match_weight
186 mismatch_weight
187 indel_weight
188 match_prob
189 indel_prob
190 min_score
191 max_period_size
192 Args : parameters hashref (optional)
193  
194 =cut
195  
196 8 ▶sub _current_parameters {
Subroutine _current_parameters: called CC=2 SCAR=6.9
197 8 my ( $self, $value ) = @_;
198 8 ▶ if ( defined $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 4 4 8
199 4 $self->{'_current_parameters'} = $value;
200 }
201 8 return $self->{'_current_parameters'};
202 }
203  
204 =head2 next_result
205  
206 Title : next_result
207 Usage : my $r = $trf->next_result()
208 Function: Get the next result set from parser data
209 Returns : Bio::SeqFeature::Generic
210 Args : none
211  
212 =cut
213  
214 6 ▶sub next_result {
Subroutine next_result: called CC=7 SCAR=19.5
Pod documented
215 6 my ($self) = @_;
216 6 ▶ while ( defined( $_ = $self->_readline() ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = $self->_readline)) 117 2 119
217  
218 # Parse Version line
219 117 ▶ if (/^Version (.+)/) {
Branch: 4 branches
BranchTrueFalseTotal
if (/^Version (.+)/) { } 3 114 117
elsif (/^Sequence: ([^\s]+)\s(.+)?/) { } 4 110 114
elsif (/^Parameters: (.+)/) { } 4 106 110
elsif (/^\d+\s\d+\s\d+/) { } 4 102 106
220 3 my $version = $1;
221 3 $self->warn("parsed version: $version\n") if DEBUG;
222 3 ▶ $self->warn( qq{ Bio::Tools::TandemRepeatsFinder was written and tested for Tandem Repeats Masker Version 4.00 output
Branch: 1 branch
BranchTrueFalseTotal
if $version != 4 0 3 3
223 You appear to be using Verion $version. Use at your own risk.}) if ($version != 4);
224 3 $self->version($version);
225 }
226  
227 # Parse Sequence identifier
228 # i.e. Sequence: DDB0215018 |Masked Chromosomal Sequence| Chr 2f
229 elsif ( /^Sequence: ([^\s]+)\s(.+)?/ ) {
230 4 my $seq_id = $1;
231 4 my $seq_description = $2;
232 4 $self->warn("parsed sequence_id: $seq_id\n") if DEBUG;
233 4 $self->_current_seq_id($seq_id);
234 4 $self->_current_seq_description($seq_description);
235 }
236  
237 # Parse Parameters
238 # i.e. Parameters: 2 7 7 80 10 50 12
239 elsif (/^Parameters: (.+)/) {
240 4 my $params = $1;
241 4 $self->warn("parsed parameters: $params\n") if DEBUG;
242  
243 4 my @param_array = split /\s/, $params;
244  
245 4 my $param_hash = {
246 match_weight => $param_array[0],
247 mismatch_weight => $param_array[1],
248 indel_weight => $param_array[2],
249 match_prob => $param_array[3],
250 indel_prob => $param_array[4],
251 min_score => $param_array[5],
252 max_period_size => $param_array[6]
253 };
254 4 $self->_current_parameters($param_hash);
255 }
256  
257 # Parse Data
258 # i.e. 13936 13960 12 2.1 12 100 0 50 16 8 52 24 1.70 T TTTTTTTTTT
259 elsif (/^\d+\s\d+\s\d+/) {
260  
261 # call internal method to create Bio::SeqFeature::Generic
262 # to represent tandem repeat
263 4 return $self->_create_feature($_);
264 }
265  
266 elsif (DEBUG) {
267 $self->warn( "UNPARSED LINE:\n" . $_ );
268 }
269 }
270 2 return;
271 }
272  
273 =head2 _create_feature
274  
275 Title : _create_feature
276 Usage : internal method used by 'next_feature'
277 Function: Takes a line from the results file and creates a bioperl object
278 Returns : Bio::SeqFeature::Generic
279 Args : none
280  
281 =cut
282  
283 4 ▶sub _create_feature {
Subroutine _create_feature: called CC=1 SCAR=0.0
284 4 my ( $self, $line ) = @_;
285  
286 # split the line and store into named variables
287 4 my @element = split /\s/, $line;
288 my (
289 4 $start, $end, $period_size,
290 $copy_number, $consensus_size, $percent_matches,
291 $percent_indels, $score, $percent_a,
292 $percent_c, $percent_g, $percent_t,
293 $entropy, $consensus_sequence, $repeat_sequence
294 ) = @element;
295  
296 # create tag hash from data in line
297 4 my $tags = {
298 period_size => $period_size,
299 copy_number => $copy_number,
300 consensus_size => $consensus_size,
301 percent_matches => $percent_matches,
302 percent_indels => $percent_indels,
303 percent_a => $percent_a,
304 percent_c => $percent_c,
305 percent_g => $percent_g,
306 percent_t => $percent_t,
307 entropy => $entropy,
308 consensus_sequence => $consensus_sequence,
309 repeat_sequence => $repeat_sequence,
310 run_parameters => $self->_current_parameters(),
311 sequence_description => $self->_current_seq_description()
312 };
313  
314 # create feature from start/end etc
315 4 my $feat = Bio::SeqFeature::Generic->new(
316 -seq_id => $self->_current_seq_id(),
317 -score => $score,
318 -start => $start,
319 -end => $end,
320 -source_tag => 'Tandem Repeats Finder',
321 -primary_tag => 'tandem repeat',
322 -tag => $tags
323 );
324  
325 4 return $feat;
326  
327 }
328  
329 2 1;
330  
« Bio/Tools/EPCR.pm ↑ Summary Bio/Tools/Profile.pm »