0
|
1 # $Id: Seg.pm,v 1.6 2002/10/22 07:45:22 lapp Exp $
|
|
2 #
|
|
3 # BioPerl module for Bio::Tools::Seg
|
|
4 #
|
|
5 # Copyright Balamurugan Kumarasamy
|
|
6 #
|
|
7 # You may distribute this module under the same terms as perl itself
|
|
8 #
|
|
9 # POD documentation - main docs before the code
|
|
10 #
|
|
11 # Copyright
|
|
12 #
|
|
13 # You may distribute this module under the same terms as perl itself
|
|
14 # POD documentation - main docs before the code
|
|
15
|
|
16 =head1 NAME
|
|
17
|
|
18 Bio::Tools::Seg - parse Seg output (filter low complexity protein sequence)
|
|
19
|
|
20 =head1 SYNOPSIS
|
|
21
|
|
22 use Bio::Tools::Seg;
|
|
23 my $parser = new Bio::Tools::Seg(-fh =>$filehandle );
|
|
24 while( my $seg_feat = $parser->next_result ) {
|
|
25 #do something
|
|
26 #eg
|
|
27 push @seg_feat, $seg_feat;
|
|
28 }
|
|
29
|
|
30 =head1 DESCRIPTION
|
|
31
|
|
32 Parser for Seg output
|
|
33
|
|
34 =head1 FEEDBACK
|
|
35
|
|
36 =head2 Mailing Lists
|
|
37
|
|
38 User feedback is an integral part of the evolution of this and other
|
|
39 Bioperl modules. Send your comments and suggestions preferably to
|
|
40 the Bioperl mailing list. Your participation is much appreciated.
|
|
41
|
|
42 bioperl-l@bioperl.org - General discussion
|
|
43 http://bioperl.org/MailList.shtml - About the mailing lists
|
|
44
|
|
45 =head2 Reporting Bugs
|
|
46
|
|
47 Report bugs to the Bioperl bug tracking system to help us keep track
|
|
48 of the bugs and their resolution. Bug reports can be submitted via
|
|
49 email or the web:
|
|
50
|
|
51 bioperl-bugs@bioperl.org
|
|
52 http://bugzilla.bioperl.org/
|
|
53
|
|
54 =head1 AUTHOR - Bala
|
|
55
|
|
56 Email savikalpa@fugu-sg.org
|
|
57
|
|
58
|
|
59 =head1 CONTRIBUTORS
|
|
60
|
|
61 Additional contributors names and emails here
|
|
62
|
|
63 =head1 APPENDIX
|
|
64
|
|
65 The rest of the documentation details each of the object methods.
|
|
66 Internal methods are usually preceded with a _
|
|
67
|
|
68 =cut
|
|
69
|
|
70 package Bio::Tools::Seg;
|
|
71 use vars qw(@ISA);
|
|
72 use strict;
|
|
73
|
|
74 use Bio::Root::Root;
|
|
75 use Bio::SeqFeature::FeaturePair;
|
|
76 use Bio::Root::IO;
|
|
77 use Bio::SeqFeature::Generic;
|
|
78 @ISA = qw(Bio::Root::Root Bio::Root::IO);
|
|
79
|
|
80
|
|
81
|
|
82
|
|
83
|
|
84 =head2 new
|
|
85
|
|
86 Title : new
|
|
87 Usage : my $obj = new Bio::Tools::Seg();
|
|
88 Function: Builds a new Bio::Tools::Seg object
|
|
89 Returns : Bio::Tools::Seg
|
|
90 Args : -fh/-file => $val, # for initing input, see Bio::Root::IO
|
|
91
|
|
92
|
|
93 =cut
|
|
94
|
|
95
|
|
96 sub new {
|
|
97 my($class,@args) = @_;
|
|
98
|
|
99 my $self = $class->SUPER::new(@args);
|
|
100 $self->_initialize_io(@args);
|
|
101
|
|
102 return $self;
|
|
103 }
|
|
104
|
|
105 =head2 next_result
|
|
106
|
|
107 Title : next_result
|
|
108 Usage : my $feat = $seg->next_result
|
|
109 Function: Get the next result set from parser data
|
|
110 Returns : Bio::SeqFeature::Generic
|
|
111 Args : none
|
|
112
|
|
113
|
|
114 =cut
|
|
115
|
|
116 sub next_result {
|
|
117 my ($self) = @_;
|
|
118
|
|
119 my $line;
|
|
120 # parse
|
|
121 my $id;
|
|
122 while ($_=$self->_readline()) {
|
|
123 $line = $_;
|
|
124 chomp $line;
|
|
125
|
|
126 next if /^$/;
|
|
127 if ($line=~/^\>/) { #if it is a line starting with a ">"
|
|
128 $line=~/^\>\s*(\S+)\s*\((\d+)\-(\d+)\)\s*complexity=(\S+)/;
|
|
129 my $id = $1;
|
|
130 my $start = $2;
|
|
131 my $end = $3;
|
|
132 my $score = $4;
|
|
133
|
|
134 #for example in this line test_prot(214-226) complexity=2.26 (12/2.20/2.50)
|
|
135 #$1 is test_prot $2 is 214 $3 is 226 and $4 is 2.26
|
|
136
|
|
137 my (%feature);
|
|
138 $feature{name} = $id;
|
|
139 $feature{score} = $score;
|
|
140 $feature{start} = $start;
|
|
141 $feature{end} = $end;
|
|
142 $feature{source} = "Seg";
|
|
143 $feature{primary} = 'low_complexity';
|
|
144 $feature{program} = "Seg";
|
|
145 $feature{logic_name} = 'low_complexity';
|
|
146 my $new_feat = $self->create_feature (\%feature);
|
|
147 return $new_feat;
|
|
148 }
|
|
149 next;
|
|
150 }
|
|
151
|
|
152 }
|
|
153
|
|
154
|
|
155 =head2 create_feature
|
|
156
|
|
157 Title : create_feature
|
|
158 Usage : obj->create_feature(\%feature)
|
|
159 Function: Internal(not to be used directly)
|
|
160 Returns :
|
|
161 Args :
|
|
162
|
|
163
|
|
164 =cut
|
|
165
|
|
166 sub create_feature {
|
|
167 my ($self, $feat) = @_;
|
|
168
|
|
169
|
|
170 # create feature object
|
|
171 my $feature = Bio::SeqFeature::Generic->new(-seq_id => $feat->{name},
|
|
172 -start => $feat->{start},
|
|
173 -end => $feat->{end},
|
|
174 -score => $feat->{score},
|
|
175 -source => $feat->{source},
|
|
176 -primary => $feat->{primary},
|
|
177 -logic_name => $feat->{logic_name},
|
|
178 );
|
|
179
|
|
180 return $feature;
|
|
181
|
|
182 }
|
|
183
|
|
184 1;
|
|
185
|
|
186
|