Mercurial > repos > mahtabm > ensembl
comparison variant_effect_predictor/Bio/Tools/Hmmpfam.pm @ 0:1f6dce3d34e0
Uploaded
author | mahtabm |
---|---|
date | Thu, 11 Apr 2013 02:01:53 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:1f6dce3d34e0 |
---|---|
1 #BioPerl module for Bio::Tools::Hmmpfam | |
2 # | |
3 # Cared for by Balamurugan Kumarasamy | |
4 # | |
5 # You may distribute this module under the same terms as perl itself | |
6 # POD documentation - main docs before the code | |
7 # | |
8 | |
9 =head1 NAME | |
10 | |
11 Bio::Tools::Hmmpfam | |
12 | |
13 =head1 SYNOPSIS | |
14 | |
15 use Bio::Tools::Hmmpfam; | |
16 my $hmmpfam_parser = new Bio::Tools::Hmmpfam(-fh =>$filehandle ); | |
17 while( my $hmmpfam_feat = $hmmpfam_parser->next_result ) { | |
18 push @hmmpfam_feat, $hmmpfam_feat; | |
19 } | |
20 | |
21 =head1 DESCRIPTION | |
22 | |
23 Parser for Hmmpfam program | |
24 | |
25 =head1 FEEDBACK | |
26 | |
27 =head2 Mailing Lists | |
28 | |
29 User feedback is an integral part of the evolution of this and other | |
30 Bioperl modules. Send your comments and suggestions preferably to | |
31 the Bioperl mailing list. Your participation is much appreciated. | |
32 | |
33 bioperl-l@bioperl.org - General discussion | |
34 http://bioperl.org/MailList.shtml - About the mailing lists | |
35 | |
36 =head2 Reporting Bugs | |
37 | |
38 Report bugs to the Bioperl bug tracking system to help us keep track | |
39 of the bugs and their resolution. Bug reports can be submitted via | |
40 email or the web: | |
41 | |
42 bioperl-bugs@bioperl.org | |
43 http://bugzilla.bioperl.org/ | |
44 | |
45 =head1 AUTHOR - Balamurugan Kumarasamy | |
46 | |
47 Email: fugui@worf.fugu-sg.org | |
48 | |
49 =head1 APPENDIX | |
50 | |
51 The rest of the documentation details each of the object methods. | |
52 Internal methods are usually preceded with a _ | |
53 | |
54 | |
55 =cut | |
56 | |
57 package Bio::Tools::Hmmpfam; | |
58 use vars qw(@ISA); | |
59 use strict; | |
60 | |
61 use Bio::Root::Root; | |
62 use Bio::SeqFeature::FeaturePair; | |
63 use Bio::Root::IO; | |
64 use Bio::SeqFeature::Generic; | |
65 @ISA = qw(Bio::Root::Root Bio::Root::IO ); | |
66 | |
67 | |
68 | |
69 =head2 new | |
70 | |
71 Title : new | |
72 Usage : my $obj = new Bio::Tools::Hmmpfam(-fh=>$filehandle); | |
73 Function: Builds a new Bio::Tools::Hmmpfam object | |
74 Returns : Bio::Tools::Hmmpfam | |
75 Args : -filename | |
76 -fh (filehandle) | |
77 | |
78 =cut | |
79 | |
80 sub new { | |
81 my($class,@args) = @_; | |
82 | |
83 my $self = $class->SUPER::new(@args); | |
84 $self->_initialize_io(@args); | |
85 | |
86 return $self; | |
87 } | |
88 | |
89 | |
90 =head2 next_result | |
91 | |
92 Title : next_result | |
93 Usage : my $feat = $hmmpfam_parser->next_result | |
94 Function: Get the next result set from parser data | |
95 Returns : L<Bio::SeqFeature::Generic> | |
96 Args : none | |
97 | |
98 =cut | |
99 | |
100 sub next_result { | |
101 my ($self) = @_; | |
102 my $filehandle; | |
103 | |
104 my $line; | |
105 | |
106 my $id; | |
107 while ($_=$self->_readline()) { | |
108 $line = $_; | |
109 chomp $line; | |
110 | |
111 | |
112 last if $line=~m/^Alignments of top-scoring domains/; | |
113 next if ($line=~m/^Model/ || /^\-/ || /^$/); | |
114 | |
115 if ($line=~m/^Query sequence:\s+(\S+)/) { | |
116 $id = $1; | |
117 $self->seqname($id); | |
118 } | |
119 | |
120 if (my ($hid, $start, $end, $hstart, $hend, $score, $evalue) = $line=~m/^(\S+)\s+\S+\s+(\d+)\s+(\d+)\s+\S+\s+(\d+)\s+(\d+)\s+\S+\s+(\S+)\s+(\S+)/) { | |
121 my %feature; | |
122 | |
123 ($feature{name}) = $self->seqname; | |
124 $feature{score} = $score; | |
125 $feature{p_value} = sprintf ("%.3e", $evalue); | |
126 $feature{start} = $start; | |
127 $feature{end} = $end; | |
128 $feature{hname} = $hid; | |
129 $feature{hstart} = $hstart; | |
130 $feature{hend} = $hend; | |
131 ($feature{source}) = 'pfam'; | |
132 $feature{primary} = $hid; | |
133 ($feature{program}) = 'pfam'; | |
134 ($feature{db}) = 'db1'; | |
135 ($feature{logic_name}) = 'hmmpfam'; | |
136 my $new_feat = $self->create_feature (\%feature); | |
137 return $new_feat | |
138 | |
139 } | |
140 next; | |
141 | |
142 } | |
143 return; | |
144 } | |
145 | |
146 =head2 create_feature | |
147 | |
148 Title : create_feature | |
149 Usage : my $feat=$hmmpfam_parser->create_feature($feature,$seqname) | |
150 Function: creates a SeqFeature Generic object | |
151 Returns : L<Bio::SeqFeature::Generic> | |
152 Args : | |
153 | |
154 | |
155 =cut | |
156 | |
157 sub create_feature { | |
158 my ($self, $feat) = @_; | |
159 | |
160 | |
161 | |
162 my $feature1= Bio::SeqFeature::Generic->new( -seqname =>$feat->{name}, | |
163 -start =>$feat->{start}, | |
164 -end =>$feat->{end}, | |
165 -score =>$feat->{score}, | |
166 -source =>$feat->{source}, | |
167 -primary =>$feat->{primary}, | |
168 ); | |
169 | |
170 | |
171 | |
172 my $feature2= Bio::SeqFeature::Generic->new( | |
173 -start =>$feat->{hstart}, | |
174 -end =>$feat->{hend}, | |
175 ); | |
176 | |
177 | |
178 | |
179 | |
180 my $featurepair = Bio::SeqFeature::FeaturePair->new; | |
181 $featurepair->feature1 ($feature1); | |
182 $featurepair->feature2 ($feature2); | |
183 | |
184 $featurepair->add_tag_value('evalue',$feat->{p_value}); | |
185 $featurepair->add_tag_value('percent_id','NULL'); | |
186 $featurepair->add_tag_value("hid",$feat->{primary}); | |
187 return $featurepair; | |
188 | |
189 } | |
190 | |
191 =head2 seqname | |
192 | |
193 Title : seqname | |
194 Usage : obj->seqname($seqname) | |
195 Function: Internal(not to be used directly) | |
196 Returns : | |
197 Args : seqname | |
198 | |
199 =cut | |
200 | |
201 sub seqname{ | |
202 my($self,$seqname)=@_; | |
203 | |
204 if(defined($seqname)) | |
205 { | |
206 $self->{'seqname'}=$seqname; | |
207 } | |
208 | |
209 return $self->{'seqname'}; | |
210 | |
211 } | |
212 | |
213 1; | |
214 | |
215 |