1 # $Id: Match.pm,v 1.2 2007/06/14 18:01:52 nathan Exp $
3 # BioPerl module for Bio::Tools::Match
5 # Please direct questions and support issues to <bioperl-l@bioperl.org>
7 # Cared for by Sendu Bala <bix@sendu.me.uk>
11 # You may distribute this module under the same terms as perl itself
13 # POD documentation - main docs before the code
17 Bio::Tools::Match - Parses output from Transfac's match(TM)
23 use Bio::Tools::Match;
25 my $parser = Bio::Tools::Match->new(-file => "match.out");
27 while (my $feat = $parser->next_result) {
28 my $start = $feat->start;
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;
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.
40 Each result is a Bio::SeqFeature::Annotated representing a single matrix match.
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.
50 bioperl-l@bioperl.org - General discussion
51 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
55 Please direct usage questions or support issues to the mailing list:
57 I<bioperl-l@bioperl.org>
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.
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
70 https://github.com/bioperl/bioperl-live/issues
72 =head1 AUTHOR - Sendu Bala
78 The rest of the documentation details each of the object methods.
79 Internal methods are usually preceded with a _
83 # Let the code begin...
85 package Bio
::Tools
::Match
;
88 use Bio
::SeqFeature
::Generic
;
89 use Bio
::Annotation
::SimpleValue
;
91 use base
qw(Bio::Root::Root Bio::Root::IO);
97 Usage : my $obj = Bio::Tools::Match->new();
98 Function: Builds a new Bio::Tools::Match object
99 Returns : Bio::Tools::Match
100 Args : -file (or -fh) should contain the contents of a standard match output
105 my ($class, @args) = @_;
106 my $self = $class->SUPER::new
(@args);
108 $self->_initialize_io(@args);
116 Usage : $result = $obj->next_result();
117 Function: Returns the next result available from the input, or undef if there
119 Returns : Bio::SeqFeature::Annotated object. Features are annotated with tags
120 for 'matrix_score', 'matrix_id' and a 'predicted' tag.
128 my $line = $self->_readline || return;
130 if (! $self->{found_seq_id
} && $line =~ /^Inspecting sequence ID\s+(.+)/) {
131 $self->{found_seq_id
} = $1;
134 while ($line !~ /^\s\S+\s+\|\s+\d+/) {
135 $line = $self->_readline || return;
139 # The first column gives the TRANSFAC(r) identifier of the matching matrix,
140 # then comes the position and the strand where the respective match has been
141 # found. The core similarity score is given in column three, the matrix
142 # similarity score in column four. The last column gives the matching
146 #Search for sites by WeightMatrix library: /home/sendu/files/programs/transfac/cgi-bin/data/matrix.dat
147 #Sequence file: sequence.fa
148 #Site selection profile: mxprf Profile generated from /home/sendu/files/programs/transfac/cgi-bin/data/matrix.dat with default values.
151 #Inspecting sequence ID Homo_sapiens
153 # V$MYOD_01 | 5 (+) | 0.751 | 0.784 | ttaGAGGTggcg
154 # V$MYOD_01 | 5 (-) | 0.778 | 0.580 | ttagAGGTGgcg
155 # V$MYOD_01 | 30 (+) | 0.751 | 0.581 | gctCAGGCaccc
157 # V$RORA_Q4 | 53610 (+) | 0.775 | 0.668 | tgtgggGGCCA
158 # V$RORA_Q4 | 53639 (+) | 0.775 | 0.636 | gtcgggGGACA
160 # Total sequences length=53654
162 # Total number of found sites=1735559
164 # Frequency of sites per nucleotide=32.347243
166 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+)/;
167 my $feat = Bio
::SeqFeature
::Generic
->new(
168 -seq_id
=> $self->{found_seq_id
},
170 -end
=> $start + length($seq) - 1,
172 -score
=> $core_score,
173 -source
=> 'transfac_match');
175 my $sv = Bio
::Annotation
::SimpleValue
->new(-tagname
=> 'predicted', -value
=> 1);
176 $feat->annotation->add_Annotation($sv);
177 $sv = Bio
::Annotation
::SimpleValue
->new(-tagname
=> 'matrix_score', -value
=> $matrix_score);
178 $feat->annotation->add_Annotation($sv);
179 $sv = Bio
::Annotation
::SimpleValue
->new(-tagname
=> 'matrix_id', -value
=> $matrix_id);
180 $feat->annotation->add_Annotation($sv);