4
Bio::FeatureIO::interpro - read features from InterPro XML
8
my $in = Bio::FeatureIO(-format=>'interpro');
9
while (my $feat = $in->next_feature) {
10
# do something with the Bio::SeqFeatureI object
15
See L<http://www.ebi.ac.uk/interpro/documentation.html>.
21
User feedback is an integral part of the evolution of this and other
22
Bioperl modules. Send your comments and suggestions preferably to
23
the Bioperl mailing list. Your participation is much appreciated.
25
bioperl-l@bioperl.org - General discussion
26
http://bioperl.org/wiki/Mailing_lists - About the mailing lists
30
Please direct usage questions or support issues to the mailing list:
32
I<bioperl-l@bioperl.org>
34
rather than to the module maintainer directly. Many experienced and
35
reponsive experts will be able look at the problem and quickly
36
address it. Please include a thorough description of the problem
37
with code and data examples if at all possible.
41
Report bugs to the Bioperl bug tracking system to help us keep track
42
of the bugs and their resolution. Bug reports can be submitted via
45
https://redmine.open-bio.org/projects/bioperl/
47
=head1 AUTHOR - Allen Day
49
Email allenday@ucla.edu
53
The rest of the documentation details each of the object methods.
54
Internal methods are usually preceded with a _
59
# Let the code begin...
61
package Bio::FeatureIO::interpro;
64
use base qw(Bio::FeatureIO);
65
use Bio::SeqFeature::Annotated;
68
use Bio::Annotation::Comment;
69
use Bio::Annotation::DBLink;
70
use Bio::Annotation::OntologyTerm;
71
use Bio::Annotation::SimpleValue;
72
use Bio::Annotation::Target;
81
$self->SUPER::_initialize(%arg);
82
$self->xml_parser(XML::DOM::Parser->new());
84
while(($buf = $self->_readline()) && $buf !~ /<protein/){
87
$self->_pushback($buf);
93
my $ok = 0; #true if there is another <protein/> record in stream
94
my $record; #holds the record to be parsed and returned.
96
#try to dump buffer from last record before moving on to next record
97
my $f = $self->_shift_feature_buffer();
102
while(my $buf = $self->_readline()){
103
$ok = 1 if $buf =~ m!<protein!;
105
last if $buf =~ m!</protein>!;
109
my $dom = $self->xml_parser->parse($record);
112
my ($pNode) = $dom->findnodes('/protein');
114
my @iNodes = $pNode->findnodes('/protein/interpro');
116
foreach my $iNode (@iNodes){
117
my @cNodes = $iNode->findnodes('classification');
118
my @mNodes = $iNode->findnodes('match');
120
#we don't handle these
121
#my @nNodes = $iNode->findnodes('contains');
122
#my @fNodes = $iNode->findnodes('found_in');
124
foreach my $mNode (@mNodes){
125
my @lNodes = $mNode->findnodes('location');
126
foreach my $lNode (@lNodes){
127
my $feature = Bio::SeqFeature::Annotated->new(
128
-start => $lNode->getAttribute('start'),
129
-end => $lNode->getAttribute('end'),
130
-score => $lNode->getAttribute('score'),
131
# -seq_id => $pNode->getAttribute('id'),
133
$feature->seq_id->value($pNode->getAttribute('id'));
135
#warn $pNode->getAttribute('id');
137
$feature->source( $lNode->getAttribute('evidence') );
139
my $t = Bio::Annotation::OntologyTerm->new(-identifier => 'SO:0000417', -name => 'polypeptide_domain');
140
$feature->add_Annotation('type',$t);
142
my $c = Bio::Annotation::Comment->new(-tagname => 'comment', -text => $iNode->getAttribute('name'));
143
$feature->add_Annotation($c);
145
my $d = Bio::Annotation::DBLink->new();
146
$d->database($mNode->getAttribute('dbname'));
147
$d->primary_id($mNode->getAttribute('id'));
148
$d->optional_id($mNode->getAttribute('name'));
149
$feature->annotation->add_Annotation('dblink',$d);
151
my $s = Bio::Annotation::SimpleValue->new(-tagname => 'status', -value => $lNode->getAttribute('status'));
152
$feature->annotation->add_Annotation($s);
154
foreach my $cNode (@cNodes){
155
my $o = Bio::Annotation::OntologyTerm->new(-identifier => $cNode->getAttribute('id'));
156
$feature->annotation->add_Annotation('ontology_term',$o);
159
$self->_push_feature_buffer($feature);
164
return $self->_shift_feature_buffer;
167
=head2 _push_feature_buffer()
177
sub _push_feature_buffer {
181
push @{ $self->{feature_buffer} }, $f;
185
=head2 _shift_feature_buffer()
195
sub _shift_feature_buffer {
197
return $self->{feature_buffer} ? shift @{ $self->{feature_buffer} } : undef;
202
Usage : $obj->xml_parser($newval)
205
Returns : value of xml_parser (a scalar)
206
Args : on set, new value (a scalar or undef, optional)
213
$self->{'xml_parser'} = $val if defined($val);
214
return $self->{'xml_parser'};