Bio/Tools/Match.pm

filter: Statementstmt 96.9% 32 / 33 Branchbran 75.0% 3 / 4 Conditioncond 42.8% 3 / 7 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 82.1% 46 / 56 CC 6 SCAR 13.8
CC
6
Cov
86%
next_result
6.4
BEGIN
1.0
BEGIN
1.0
CRAP 4.0
« Bio/Das/SegmentI.pm ↑ Summary Bio/Search/HSP/PSLHSP.pm »
1 # $Id: Match.pm,v 1.2 2007/06/14 18:01:52 nathan Exp $
2 #
3 # BioPerl module for Bio::Tools::Match
4 #
5 # Please direct questions and support issues to <bioperl-l@bioperl.org>
6 #
7 # Cared for by Sendu Bala <bix@sendu.me.uk>
8 #
9 # Copyright Sendu Bala
10 #
11 # You may distribute this module under the same terms as perl itself
12  
13 # POD documentation - main docs before the code
14  
15 =head1 NAME
16  
17 Bio::Tools::Match - Parses output from Transfac's match(TM)
18  
19 =head1 SYNOPSIS
20  
21 use strict;
22  
23 use Bio::Tools::Match;
24  
25 my $parser = Bio::Tools::Match->new(-file => "match.out");
26
27 while (my $feat = $parser->next_result) {
28 my $start = $feat->start;
29 my $end = $feat->end;
30 my $core_score = $feat->score;
31 my $matrix_score = ($feat->annotation->get_Annotations('matrix_score'))[0]->value;
32 my $matrix_id = ($feat->annotation->get_Annotations('matrix_id'))[0]->value;
33 }
34  
35 =head1 DESCRIPTION
36  
37 This module is used to parse the output from Transfac's match(TM) program. It
38 doesn't support the histogram output of match.
39  
40 Each result is a Bio::SeqFeature::Annotated representing a single matrix match.
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 the
68 web:
69  
70 https://github.com/bioperl/bioperl-live/issues
71  
72 =head1 AUTHOR - Sendu Bala
73  
74 Email bix@sendu.me.uk
75  
76 =head1 APPENDIX
77  
78 The rest of the documentation details each of the object methods.
79 Internal methods are usually preceded with a _
80  
81 =cut
82  
83 # Let the code begin...
84  
85 package Bio::Tools::Match;
86 2 $Bio::Tools::Match::VERSION = '1.7.8';
87 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
88  
89 2 ▶use Bio::SeqFeature::Generic;
Subroutine BEGIN: called CC=1 SCAR=0.0
90 2 ▶use Bio::Annotation::SimpleValue;
Subroutine BEGIN: called CC=1 SCAR=0.0
91  
92 2 ▶use base qw(Bio::Root::Root Bio::Root::IO);
Subroutine BEGIN: called CC=1 SCAR=0.0
93  
94  
95 =head2 new
96  
97 Title : new
98 Usage : my $obj = Bio::Tools::Match->new();
99 Function: Builds a new Bio::Tools::Match object
100 Returns : Bio::Tools::Match
101 Args : -file (or -fh) should contain the contents of a standard match output
102  
103 =cut
104  
105 1 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
106 1 my ($class, @args) = @_;
107 1 my $self = $class->SUPER::new(@args);
108
109 1 $self->_initialize_io(@args);
110
111 1 return $self;
112 }
113  
114 =head2 next_result
115  
116 Title : next_result
117 Usage : $result = $obj->next_result();
118 Function: Returns the next result available from the input, or undef if there
119 are no more results.
120 Returns : Bio::SeqFeature::Annotated object. Features are annotated with tags
121 for 'matrix_score', 'matrix_id' and a 'predicted' tag.
122 Args : none
123  
124 =cut
125  
126 5 ▶sub next_result {
Subroutine next_result: called CC=6 SCAR=18.6
Pod documented
127 5 my ($self) = @_;
128
129 5 ▶ my $line = $self->_readline || return;
Condition50%1/2
$self->_readline || (return)
l!l
50
MC/DC0%0/1
$self->_readline || (return)
$self->_readline
Truth table50%1/2
A
A= $self->_readline
Aresult
11
00
130
131 5 ▶ if (! $self->{found_seq_id} && $line =~ /^Inspecting sequence ID\s+(.+)/) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->{"found_seq_id"} and $line =~ /^Inspecting sequence ID\s+(.+)/) 0 5 5
Condition33%1/3
not $self->{"found_seq_id"} and $line =~ /^Inspecting sequence ID\s+(.+)/
!ll&&!rl&&r
050
MC/DC0%0/2
not $self->{"found_seq_id"} and $line =~ /^Inspecting sequence ID\s+(.+)/
not $self->{"found_seq_id"} $line =~ /^Inspecting sequence ID\s+(.+)/
Truth table33%1/3
not(A) and B
A= not $self->{"found_seq_id"}B= $line =~ /^Inspecting sequence ID\s+(.+)/
ABresult
0X0
100
111
132 0 $self->{found_seq_id} = $1;
133 }
134
135 5 ▶ while ($line !~ /^\s\S+\s+\|\s+\d+/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($line =~ /^\s\S+\s+\|\s+\d+/) 7 5 12
136 7 ▶ $line = $self->_readline || return;
Condition50%1/2
$self->_readline || (return)
l!l
70
MC/DC0%0/1
$self->_readline || (return)
$self->_readline
Truth table50%1/2
A
A= $self->_readline
Aresult
11
00
137 }
138
139
140 # The first column gives the TRANSFAC(r) identifier of the matching matrix,
141 # then comes the position and the strand where the respective match has been
142 # found. The core similarity score is given in column three, the matrix
143 # similarity score in column four. The last column gives the matching
144 # sequence.
145 #
146 #
147 #Search for sites by WeightMatrix library: /home/sendu/files/programs/transfac/cgi-bin/data/matrix.dat
148 #Sequence file: sequence.fa
149 #Site selection profile: mxprf Profile generated from /home/sendu/files/programs/transfac/cgi-bin/data/matrix.dat with default values.
150 #
151 #
152 #Inspecting sequence ID Homo_sapiens
153 #
154 # V$MYOD_01 | 5 (+) | 0.751 | 0.784 | ttaGAGGTggcg
155 # V$MYOD_01 | 5 (-) | 0.778 | 0.580 | ttagAGGTGgcg
156 # V$MYOD_01 | 30 (+) | 0.751 | 0.581 | gctCAGGCaccc
157 #[...]
158 # V$RORA_Q4 | 53610 (+) | 0.775 | 0.668 | tgtgggGGCCA
159 # V$RORA_Q4 | 53639 (+) | 0.775 | 0.636 | gtcgggGGACA
160 #
161 # Total sequences length=53654
162 #
163 # Total number of found sites=1735559
164 #
165 # Frequency of sites per nucleotide=32.347243
166
167 5 my ($matrix_id, $start, $strand, $core_score, $matrix_score, $seq) = $line =~ /^\s(\S+)\s+\|\s+(\d+)\s+\(([+-])\)\s+\|\s+(\S+)\s+\|\s+(\S+)\s+\|\s+(\S+)/;
168 my $feat = Bio::SeqFeature::Generic->new(
169 -seq_id => $self->{found_seq_id},
170 5 -start => $start,
171 -end => $start + length($seq) - 1,
172 -strand => 1,
173 -score => $core_score,
174 -source => 'transfac_match');
175
176 5 my $sv = Bio::Annotation::SimpleValue->new(-tagname => 'predicted', -value => 1);
177 5 $feat->annotation->add_Annotation($sv);
178 5 $sv = Bio::Annotation::SimpleValue->new(-tagname => 'matrix_score', -value => $matrix_score);
179 5 $feat->annotation->add_Annotation($sv);
180 5 $sv = Bio::Annotation::SimpleValue->new(-tagname => 'matrix_id', -value => $matrix_id);
181 5 $feat->annotation->add_Annotation($sv);
182
183 5 return $feat;
184 }
185  
186 2 1;
« Bio/Das/SegmentI.pm ↑ Summary Bio/Search/HSP/PSLHSP.pm »