| 1 | # | ||||||||||||||
| 2 | # BioPerl module for Bio::Tools::RepeatMasker | ||||||||||||||
| 3 | # | ||||||||||||||
| 4 | # Please direct questions and support issues to <bioperl-l@bioperl.org> | ||||||||||||||
| 5 | # | ||||||||||||||
| 6 | # Cared for by Shawn Hoon <shawnh@fugu-sg.org> | ||||||||||||||
| 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<bioperl-l@bioperl.org> | ||||||||||||||
| 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 | 2 | $Bio::Tools::RepeatMasker::VERSION = '1.7.8'; | |||||||||||||
| 77 | 2 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 78 | |||||||||||||||
| 79 | 2 | ▶ | use Bio::SeqFeature::FeaturePair; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 80 | |||||||||||||||
| 81 | 2 | ▶ | use base qw(Bio::Root::Root Bio::Root::IO); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 82 | |||||||||||||||
| 83 | =head2 new | ||||||||||||||
| 84 | |||||||||||||||
| 85 | Title : new | ||||||||||||||
| 86 | Usage : my $obj = Bio::Tools::RepeatMasker->new(); | ||||||||||||||
| 87 | Function: Builds a new Bio::Tools::RepeatMasker object | ||||||||||||||
| 88 | Returns : Bio::Tools::RepeatMasker | ||||||||||||||
| 89 | Args : -fh/-file => $val, for initing input, see Bio::Root::IO | ||||||||||||||
| 90 | |||||||||||||||
| 91 | =cut | ||||||||||||||
| 92 | |||||||||||||||
| 93 | 1 | ▶ | sub new { | ||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 94 | 1 | my($class,@args) = @_; | |||||||||||||
| 95 | |||||||||||||||
| 96 | 1 | my $self = $class->SUPER::new(@args); | |||||||||||||
| 97 | 1 | $self->_initialize_io(@args); | |||||||||||||
| 98 | |||||||||||||||
| 99 | 1 | return $self; | |||||||||||||
| 100 | } | ||||||||||||||
| 101 | |||||||||||||||
| 102 | =head2 next_result | ||||||||||||||
| 103 | |||||||||||||||
| 104 | Title : next_result | ||||||||||||||
| 105 | Usage : my $r = $rpt_masker->next_result | ||||||||||||||
| 106 | Function: Get the next result set from parser data | ||||||||||||||
| 107 | Returns : Bio::SeqFeature::FeaturePair | ||||||||||||||
| 108 | Feature1 is the Query coordinates and Feature2 is the Hit | ||||||||||||||
| 109 | Args : none | ||||||||||||||
| 110 | |||||||||||||||
| 111 | =cut | ||||||||||||||
| 112 | |||||||||||||||
| 113 | 5 | ▶ | sub next_result { | ||||||||||||
|
Subroutine
next_result: called CC=7 SCAR=19.8
Pod
documented
| |||||||||||||||
| 114 | 5 | my ($self) = @_; | |||||||||||||
| 115 | 5 | local $_; | |||||||||||||
| 116 | 5 | ▶ | while (defined($_=$self->_readline()) ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 117 | 8 | ▶ | if (/no repetitive sequences detected/) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 118 | 0 | $self->warn( "RepeatMasker didn't find any repetitive sequences\n"); | |||||||||||||
| 119 | 0 | return ; | |||||||||||||
| 120 | } | ||||||||||||||
| 121 | #ignore introductory lines | ||||||||||||||
| 122 | 8 | ▶ | if (/\d+/) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 123 | 5 | my @element = split; | |||||||||||||
| 124 | # ignore features with negatives | ||||||||||||||
| 125 | 5 | ▶ | next if ($element[11-13] =~ /-/); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 126 | 5 | my (%feat1, %feat2); | |||||||||||||
| 127 | 5 | my @line = split; | |||||||||||||
| 128 | 5 | my ($score, $query_name, $query_start, $query_end, $strand, | |||||||||||||
| 129 | $repeat_name, $repeat_class ) = @line[0, 4, 5, 6, 8, 9, 10]; | ||||||||||||||
| 130 | |||||||||||||||
| 131 | 5 | my ($hit_start,$hit_end); | |||||||||||||
| 132 | |||||||||||||||
| 133 | 5 | ▶ | if ($strand eq '+') { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 134 | 3 | ($hit_start, $hit_end) = @line[11, 12]; | |||||||||||||
| 135 | 3 | $strand = 1; | |||||||||||||
| 136 | } elsif ($strand eq 'C') { | ||||||||||||||
| 137 | 2 | ($hit_end, $hit_start) = @line[12, 13]; | |||||||||||||
| 138 | 2 | $strand = -1; | |||||||||||||
| 139 | } | ||||||||||||||
| 140 | 5 | my $rf = Bio::SeqFeature::Generic->new | |||||||||||||
| 141 | (-seq_id => $query_name, | ||||||||||||||
| 142 | -score => $score, | ||||||||||||||
| 143 | -start => $query_start, | ||||||||||||||
| 144 | -end => $query_end, | ||||||||||||||
| 145 | -strand => $strand, | ||||||||||||||
| 146 | -source_tag => 'RepeatMasker', | ||||||||||||||
| 147 | -primary_tag => $repeat_class, | ||||||||||||||
| 148 | -tag => { 'Target'=> [$repeat_name, $hit_start, $hit_end]}, | ||||||||||||||
| 149 | ); | ||||||||||||||
| 150 | |||||||||||||||
| 151 | 5 | my $rf2 = Bio::SeqFeature::Generic->new | |||||||||||||
| 152 | (-seq_id => $repeat_name, | ||||||||||||||
| 153 | -score => $score, | ||||||||||||||
| 154 | -start => $hit_start, | ||||||||||||||
| 155 | -end => $hit_end, | ||||||||||||||
| 156 | -strand => $strand, | ||||||||||||||
| 157 | -source_tag => "RepeatMasker", | ||||||||||||||
| 158 | -primary_tag => $repeat_class, | ||||||||||||||
| 159 | -tag => { 'Target'=> [$query_name,$query_start,$query_end] }, | ||||||||||||||
| 160 | ); | ||||||||||||||
| 161 | |||||||||||||||
| 162 | 5 | my $fp = Bio::SeqFeature::FeaturePair->new(-feature1 => $rf, | |||||||||||||
| 163 | -feature2 => $rf2); | ||||||||||||||
| 164 | 5 | return $fp; | |||||||||||||
| 165 | } | ||||||||||||||
| 166 | } | ||||||||||||||
| 167 | } | ||||||||||||||
| 168 | |||||||||||||||
| 169 | 2 | 1; | |||||||||||||