Mercurial > repos > mahtabm > ensembl
comparison variant_effect_predictor/Bio/Tools/Prints.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 # $Id: Prints.pm,v 1.7 2002/10/22 07:45:22 lapp Exp $ | |
2 # | |
3 # BioPerl module for Bio::Tools::Prints | |
4 # | |
5 # Cared for by Balamurugan Kumarasamy | |
6 # | |
7 # You may distribute this module under the same terms as perl itself | |
8 # POD documentation - main docs before the code | |
9 # | |
10 | |
11 =head1 NAME | |
12 | |
13 Bio::Tools::Prints - Parser for FingerPRINTScanII program | |
14 | |
15 =head1 SYNOPSIS | |
16 | |
17 use Bio::Tools::Prints; | |
18 my $prints_parser = new Bio::Tools::Prints(-fh =>$filehandle ); | |
19 while( my $prints_feat = $prints_parser->next_result ) { | |
20 push @prints_feat, $prints_feat; | |
21 } | |
22 | |
23 =head1 DESCRIPTION | |
24 | |
25 PRINTScan II is a PRINTS fingerprint identification algorithm. | |
26 Copyright (C) 1998,1999 Phil Scordis | |
27 | |
28 =head1 FEEDBACK | |
29 | |
30 =head2 Mailing Lists | |
31 | |
32 User feedback is an integral part of the evolution of this and other | |
33 Bioperl modules. Send your comments and suggestions preferably to | |
34 the Bioperl mailing list. Your participation is much appreciated. | |
35 | |
36 bioperl-l@bioperl.org - General discussion | |
37 http://bioperl.org/MailList.shtml - About the mailing lists | |
38 | |
39 =head2 Reporting Bugs | |
40 | |
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 | |
43 email or the web: | |
44 | |
45 bioperl-bugs@bioperl.org | |
46 http://bugzilla.bioperl.org/ | |
47 | |
48 =head1 AUTHOR - Balamurugan Kumarasamy | |
49 | |
50 Email: fugui@worf.fugu-sg.org | |
51 | |
52 =head1 APPENDIX | |
53 | |
54 The rest of the documentation details each of the object methods. | |
55 Internal methods are usually preceded with a _ | |
56 | |
57 | |
58 =cut | |
59 | |
60 package Bio::Tools::Prints; | |
61 use vars qw(@ISA); | |
62 use strict; | |
63 | |
64 use Bio::Root::Root; | |
65 use Bio::SeqFeature::FeaturePair; | |
66 use Bio::Root::IO; | |
67 use Bio::SeqFeature::Generic; | |
68 @ISA = qw(Bio::Root::Root Bio::Root::IO ); | |
69 | |
70 | |
71 | |
72 =head2 new | |
73 | |
74 Title : new | |
75 Usage : my $obj = new Bio::Tools::Prints(-fh=>$filehandle); | |
76 Function: Builds a new Bio::Tools::Prints object | |
77 Returns : Bio::Tools::Prints | |
78 Args : -filename | |
79 -fh (filehandle) | |
80 | |
81 =cut | |
82 | |
83 sub new { | |
84 my($class,@args) = @_; | |
85 | |
86 my $self = $class->SUPER::new(@args); | |
87 $self->_initialize_io(@args); | |
88 | |
89 return $self; | |
90 } | |
91 | |
92 | |
93 =head2 next_result | |
94 | |
95 Title : next_result | |
96 Usage : my $feat = $prints_parser->next_result | |
97 Function: Get the next result set from parser data | |
98 Returns : L<Bio::SeqFeature::Generic> | |
99 Args : none | |
100 | |
101 =cut | |
102 | |
103 sub next_result { | |
104 my ($self) = @_; | |
105 my %printsac; | |
106 my @features; | |
107 my $line; | |
108 my $sequenceId; | |
109 | |
110 while ($_=$self->_readline()) { | |
111 | |
112 | |
113 $line = $_; | |
114 chomp $line; | |
115 | |
116 if ($line =~ s/^Sn;//) { # We have identified a Sn; line so there should be the following: | |
117 | |
118 ($sequenceId) = $line =~ /^\s*(\w+)/; | |
119 $self->seqname($sequenceId); | |
120 next; | |
121 } | |
122 | |
123 | |
124 if ($line =~ s/^1TBH//) { | |
125 my ($id) = $line =~ /^\s*(\w+)/; | |
126 my ($ac) = $line =~ /(PR\w+)\s*$/; | |
127 $printsac{$id} = $ac; | |
128 $self->print_sac(\%printsac); | |
129 next; | |
130 } | |
131 | |
132 | |
133 if ($line =~ s/^3TB//) { | |
134 | |
135 | |
136 | |
137 | |
138 if ($line =~ s/^[HN]//) { | |
139 my($num)=""; | |
140 $line =~ s/^\s+//; | |
141 | |
142 my @elements = split /\s+/, $line; | |
143 | |
144 my ($fingerprintName,$motifNumber,$temp,$tot,$percentageIdentity,$profileScore,$pvalue,$subsequence,$motifLength,$lowestMotifPosition,$matchPosition,$highestMotifPosition) = @elements; | |
145 | |
146 my $start = $matchPosition; | |
147 my $end = $matchPosition + $motifLength - 1; | |
148 my $print_sac = $self->print_sac; | |
149 | |
150 my %printsac = %{$print_sac}; | |
151 my $print = $printsac{$fingerprintName}; | |
152 my $seqname=$self->seqname; | |
153 my $feat = "$print,$start,$end,$percentageIdentity,$profileScore,$pvalue"; | |
154 my $new_feat = $self->create_feature($feat,$seqname); | |
155 return $new_feat; | |
156 } | |
157 if ($line =~ s/^F//) { | |
158 return; | |
159 } | |
160 next; } | |
161 next; | |
162 | |
163 } | |
164 | |
165 | |
166 | |
167 } | |
168 | |
169 =head2 create_feature | |
170 | |
171 Title : create_feature | |
172 Usage : my $feat=$prints_parser->create_feature($feature,$seqname) | |
173 Function: creates a SeqFeature Generic object | |
174 Returns : L<Bio::SeqFeature::Generic> | |
175 Args : | |
176 | |
177 | |
178 =cut | |
179 | |
180 sub create_feature { | |
181 my ($self, $feat,$sequenceId) = @_; | |
182 | |
183 my @f = split (/,/,$feat); | |
184 # create feature object | |
185 my $feature= Bio::SeqFeature::Generic->new(-seq_id =>$sequenceId, | |
186 -start=>$f[1], | |
187 -end => $f[2], | |
188 -score => $f[4], | |
189 -source => "PRINTS", | |
190 -primary =>$f[0], | |
191 -logic_name => "PRINTS", | |
192 ); | |
193 $feature->add_tag_value('evalue',$f[5]); | |
194 $feature->add_tag_value('percent_id',$f[3]); | |
195 | |
196 | |
197 | |
198 return $feature; | |
199 | |
200 } | |
201 | |
202 =head2 print_sac | |
203 | |
204 Title : print_sac | |
205 Usage : $prints_parser->print_sac($print_sac) | |
206 Function: get/set for print_sac | |
207 Returns : | |
208 Args : | |
209 | |
210 | |
211 =cut | |
212 | |
213 sub print_sac{ | |
214 my($self,$printsac)=@_; | |
215 | |
216 if(defined($printsac)) | |
217 { | |
218 $self->{'print_sac'}=$printsac; | |
219 } | |
220 return $self->{'print_sac'}; | |
221 | |
222 } | |
223 | |
224 =head2 seqname | |
225 | |
226 Title : seqname | |
227 Usage : $prints_parser->seqname($seqname) | |
228 Function: get/set for seqname | |
229 Returns : | |
230 Args : | |
231 | |
232 | |
233 =cut | |
234 | |
235 sub seqname{ | |
236 my($self,$seqname)=@_; | |
237 | |
238 if(defined($seqname)) | |
239 { | |
240 $self->{'seqname'}=$seqname; | |
241 } | |
242 | |
243 return $self->{'seqname'}; | |
244 | |
245 } | |
246 | |
247 1; |