Mercurial > repos > mahtabm > ensembl
comparison variant_effect_predictor/Bio/Seq/TraceI.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::Seq::TraceI | |
2 # | |
3 # Cared for by Chad Matsalla <bioinformatics@dieselwurks.com | |
4 # | |
5 # Copyright Chad Matsalla | |
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 =head1 NAME | |
12 | |
13 Bio::Seq::TraceI - Interface definition for a Bio::Seq::Trace | |
14 | |
15 =head1 SYNOPSIS | |
16 | |
17 # get a Bio::Seq::Qual compliant object somehow | |
18 $st = &get_object_somehow(); | |
19 | |
20 # to test this is a seq object | |
21 $st->isa("Bio::Seq::TraceI") | |
22 || $obj->throw("$obj does not implement the Bio::Seq::TraceI interface"); | |
23 | |
24 # set the trace for T to be @trace_points | |
25 my $arrayref = $st->trace("T",\@trace_points); | |
26 # get the trace points for "C" | |
27 my $arrayref = $st->trace("C"); | |
28 # get a subtrace for "G" from 10 to 100 | |
29 $arrayref = $st->subtrace("G",10,100); | |
30 # what is the trace value for "A" at position 355? | |
31 my $trace_calue = $st->traceat("A",355); | |
32 # create a false trace for "A" with $accuracy | |
33 $arrayref = $st->false_trace("A",Bio::Seq::SeqWithQuality, $accuracy); | |
34 # does this trace have entries for each base? | |
35 $bool = $st->is_complete(); | |
36 # how many entries are there in this trace? | |
37 $length = $st->length(); | |
38 | |
39 | |
40 | |
41 =head1 DESCRIPTION | |
42 | |
43 This object defines an abstract interface to basic trace information. This | |
44 information may have come from an ABI- or scf- formatted file or may have been | |
45 made up. | |
46 | |
47 =head1 FEEDBACK | |
48 | |
49 =head2 Mailing Lists | |
50 | |
51 User feedback is an integral part of the evolution of this and other | |
52 Bioperl modules. Send your comments and suggestions preferably to one | |
53 of the Bioperl mailing lists. Your participation is much appreciated. | |
54 | |
55 bioperl-l@bioperl.org - General discussion | |
56 http://bio.perl.org/MailList.html - About the mailing lists | |
57 | |
58 =head2 Reporting Bugs | |
59 | |
60 Report bugs to the Bioperl bug tracking system to help us keep track | |
61 the bugs and their resolution. Bug reports can be submitted via email | |
62 or the web: | |
63 | |
64 bioperl-bugs@bio.perl.org | |
65 http://bugzilla.bioperl.org/ | |
66 | |
67 =head1 AUTHOR - Chad Matsalla | |
68 | |
69 Email bioinformatics@dieselwurks.com | |
70 | |
71 =head1 APPENDIX | |
72 | |
73 The rest of the documentation details each of the object methods. | |
74 Internal methods are usually preceded with a _ | |
75 | |
76 =cut | |
77 | |
78 | |
79 # Let the code begin... | |
80 | |
81 | |
82 package Bio::Seq::TraceI; | |
83 use vars qw(@ISA); | |
84 use strict; | |
85 use Carp; | |
86 use Dumpvalue; | |
87 | |
88 =head1 Implementation Specific Functions | |
89 | |
90 These functions are the ones that a specific implementation must | |
91 define. | |
92 | |
93 =head2 trace($base,\@new_values) | |
94 | |
95 Title : trace($base,\@new_values) | |
96 Usage : @trace_Values = @{$obj->trace($base,\@new_values)}; | |
97 Function: Returns the trace values as a reference to an array containing the | |
98 trace values. The individual elements of the trace array are not validated | |
99 and can be any numeric value. | |
100 Returns : A reference to an array. | |
101 Status : | |
102 Arguments: $base : which color channel would you like the trace values for? | |
103 - $base must be one of "A","T","G","C" | |
104 \@new_values : a reference to an array of values containing trace | |
105 data for this base | |
106 | |
107 =cut | |
108 | |
109 sub trace { | |
110 my ($self) = @_; | |
111 if( $self->can('throw') ) { | |
112 $self->throw("Bio::Seq::TraceI definition of trace - implementing class did not provide this method"); | |
113 } else { | |
114 confess("Bio::Seq::TraceI definition of trace - implementing class did not provide this method"); | |
115 } | |
116 } | |
117 | |
118 =head2 subtrace($base,$start,$end) | |
119 | |
120 Title : subtrace($base,$start,$end) | |
121 Usage : @subset_of_traces = @{$obj->subtrace("A",10,40)}; | |
122 Function: returns the trace values from $start to $end, where the | |
123 first value is 1 and the number is inclusive, ie 1-2 are the first | |
124 two trace values of this base. Start cannot be larger than end but can | |
125 be equal. | |
126 Returns : A reference to an array. | |
127 Args : $base: "A","T","G" or "C" | |
128 $start: a start position | |
129 $end : an end position | |
130 | |
131 =cut | |
132 | |
133 sub subtrace { | |
134 my ($self) = @_; | |
135 | |
136 if( $self->can('throw') ) { | |
137 $self->throw("Bio::Seq::TraceI definition of subtrace - implementing class did not provide this method"); | |
138 } else { | |
139 confess("Bio::Seq::TraceI definition of subtrace - implementing class did not provide this method"); | |
140 } | |
141 | |
142 } | |
143 | |
144 =head2 can_call_new() | |
145 | |
146 Title : can_call_new() | |
147 Usage : if( $obj->can_call_new ) { | |
148 $newobj = $obj->new( %param ); | |
149 } | |
150 Function: can_call_new returns 1 or 0 depending on whether an | |
151 implementation allows new constructor to be called. If a new | |
152 constructor is allowed, then it should take the followed hashed | |
153 constructor list. | |
154 $myobject->new( -qual => $quality_as_string, | |
155 -display_id => $id, | |
156 -accession_number => $accession, | |
157 ); | |
158 Example : | |
159 Returns : 1 or 0 | |
160 Args : | |
161 | |
162 | |
163 =cut | |
164 | |
165 sub can_call_new{ | |
166 my ($self,@args) = @_; | |
167 # we default to 0 here | |
168 return 0; | |
169 } | |
170 | |
171 =head2 traceat($channel,$position) | |
172 | |
173 Title : qualat($channel,$position) | |
174 Usage : $trace = $obj->traceat(500); | |
175 Function: Return the trace value at the given location, where the | |
176 first value is 1 and the number is inclusive, ie 1-2 are the first | |
177 two bases of the sequence. Start cannot be larger than end but can | |
178 be equal. | |
179 Returns : A scalar. | |
180 Args : A base and a position. | |
181 | |
182 =cut | |
183 | |
184 sub traceat { | |
185 my ($self,$value) = @_; | |
186 if( $self->can('warn') ) { | |
187 $self->warn("Bio::Seq::TraceI definition of traceat - implementing class did not provide this method"); | |
188 } else { | |
189 warn("Bio::Seq::TraceI definition of traceat - implementing class did not provide this method"); | |
190 } | |
191 return ''; | |
192 } | |
193 | |
194 =head2 length() | |
195 | |
196 Title : length() | |
197 Usage : $length = $obj->length("A"); | |
198 Function: Return the length of the array holding the trace values for the "A" | |
199 channel. A check should be done to make sure that this Trace object | |
200 is_complete() before doing this to prevent hazardous results. | |
201 Returns : A scalar (the number of elements in the quality array). | |
202 Args : If used, get the traces from that channel. Default to "A" | |
203 | |
204 =cut | |
205 | |
206 sub length { | |
207 my ($self)= @_; | |
208 if( $self->can('throw') ) { | |
209 $self->throw("Bio::Seq::TraceI definition of length - implementing class did not provide this method"); | |
210 } else { | |
211 confess("Bio::Seq::TraceI definition of length - implementing class did not provide this method"); | |
212 } | |
213 } | |
214 | |
215 =head2 trace_indices($new_indices) | |
216 | |
217 Title : trace_indices($new_indices) | |
218 Usage : $indices = $obj->trace_indices($new_indices); | |
219 Function: Return the trace iindex points for this object. | |
220 Returns : A scalar | |
221 Args : If used, the trace indices will be set to the provided value. | |
222 | |
223 =cut | |
224 | |
225 sub trace_indices { | |
226 my ($self)= @_; | |
227 if( $self->can('throw') ) { | |
228 $self->throw("Bio::Seq::TraceI definition of trace_indices - implementing class did not provide this method"); | |
229 } else { | |
230 confess("Bio::Seq::TraceI definition of trace_indices - implementing class did not provide this method"); | |
231 } | |
232 } | |
233 | |
234 | |
235 | |
236 | |
237 1; |