Bio/Matrix/PSM/InstanceSite.pm

filter: Statementstmt 53.5% 38 / 71 Branchbran 32.1% 9 / 28 Conditioncond 60.0% 3 / 5 MC/DCmcdc 33.3% 1 / 3 Subroutinesub 45.4% 5 / 11 Podpod 100% 9 / 9 totaltotal 51.1% 65 / 127 CC 17 SCAR 19.6
CC
17
Cov
48%
annotation
20.0
new
6.1
mid
6.0
CRAP 7.1
« Bio/SeqIO/ace.pm ↑ Summary Bio/SeqFeature/Gene/GeneStructure.pm »
1  
2 =head1 NAME
3  
4 Bio::Matrix::PSM::InstanceSite - A PSM site occurrence
5  
6 =head1 SYNOPSIS
7  
8 use Bio::Matrix::PSM::InstanceSite;
9  
10 #You can get an InstanceSite object either from a file:
11  
12 my ($instances,$matrix)=$SomePSMFile->parse_next;
13  
14 #or from memory
15  
16 my %params=(seq=>'TATAAT',
17 id=>"TATAbox1", accession=>'ENSG00000122304', mid=>'TB1',
18 desc=>'TATA box, experimentally verified in PRM1 gene',
19 -relpos=>-35, -anchor=>'CHR7', -start=>35000921, -end=>35000926);
20  
21 #Last 2 arguments are passed to create a Bio::LocatableSeq object
22 #Anchor shows the coordinates system for the Bio::LocatableSeq object
23  
24 =head1 DESCRIPTION
25  
26 Abstract interface to PSM site occurrence (PSM sequence
27 match). InstanceSite objects may be used to describe a PSM (See
28 L<Bio::Matrix::PSM::SiteMatrix>) sequence matches. The usual
29 characteristic of such a match is sequence coordinates, score,
30 sequence and sequence (gene) identifier- accession number or other id.
31  
32 This object inherits from Bio::LocatableSeq (which defines the real
33 sequence) and might hold a SiteMatrix object, used to detect the CRE
34 (cis-regulatory element), or created from this CRE.
35  
36 While the documentation states that the motif id and gene id
37 (accession) combination should be unique, this is not entirely true-
38 there might be more than one occurrence of the same cis-regulatory
39 element in the upstream region of the same gene. Therefore relpos
40 would be the third element to create a really unique combination.
41  
42 =head1 FEEDBACK
43  
44 =head2 Mailing Lists
45  
46 User feedback is an integral part of the evolution of this and other
47 Bioperl modules. Send your comments and suggestions preferably to one
48 of the Bioperl mailing lists. Your participation is much appreciated.
49  
50 bioperl-l@bioperl.org - General discussion
51 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
52  
53 =head2 Support
54  
55 Please direct usage questions or support issues to the mailing list:
56  
57 I<bioperl-l@bioperl.org>
58  
59 rather than to the module maintainer directly. Many experienced and
60 reponsive experts will be able look at the problem and quickly
61 address it. Please include a thorough description of the problem
62 with code and data examples if at all possible.
63  
64 =head2 Reporting Bugs
65  
66 Report bugs to the Bioperl bug tracking system to help us keep track
67 the bugs and their resolution. Bug reports can be submitted via the
68 web:
69  
70 https://github.com/bioperl/bioperl-live/issues
71  
72 =head2 Description
73  
74 Bio::Matrix::PSM::InstanceSiteI implementation
75  
76 =head1 AUTHOR - Stefan Kirov
77  
78 Email skirov@utk.edu
79  
80  
81 =head1 APPENDIX
82  
83 =cut
84  
85  
86 # Let the code begin...
87 package Bio::Matrix::PSM::InstanceSite;
88 13 $Bio::Matrix::PSM::InstanceSite::VERSION = '1.7.8';
89 13 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
90  
91 13 ▶use base qw(Bio::LocatableSeq Bio::Matrix::PSM::InstanceSiteI);
Subroutine BEGIN: called CC=1 SCAR=0.0
92  
93 =head2 new
94  
95 Title : new
96 Usage : my $isntance=Bio::Matrix::PSM::InstanceSite->new
97 (-seq=>'TATAAT', -id=>"TATAbox1",
98 -accession_number='ENSG00000122304', -mid=>'TB1',
99 -desc=>'TATA box, experimentally verified in PRM1 gene',
100 -relpos=>-35, -anchor=>'CHR7', -start=>35000921, -end=>35000926, strand=>1)
101 Function: Creates an InstanceSite object from memory.
102 Throws :
103 Example :
104 Returns : Bio::Matrix::PSM::InstanceSite object
105 Args : hash
106  
107  
108 =cut
109  
110 202 ▶sub new {
Subroutine new: called CC=6 SCAR=18.1
Pod documented
111 202 my ($class, @args) = @_;
112 202 my %args = @args; #Too many things to rearrange, and I am creating >1K such objects routinely, so this is a performance issue
113 202 ▶ $args{'-start'} ||= 1;
Condition100%2/2
$args{"-start"} ||= 1
l!l
96106
MC/DC100%1/1
$args{"-start"} ||= 1
$args{"-start"}
Truth table100%2/2
A
A= $args{"-start"}
Aresult
11
00
114 202 my $end = $args{'-start'} + length($args{-seq}) -1;
115 202 ▶ if (!defined($args{-strand})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $args{"-strand"}) 107 95 202
116 107 $args{-strand}=1;
117 107 @args=%args;
118 }
119 202 my $self = $class->SUPER::new(@args,'-end',$end);
120
121 202 ▶ while( @args ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args) 1601 202 1803
122 1601 (my $key = shift @args) =~ s/-//gi; #deletes all dashes (only dashes)!
123 1601 $args{$key} = shift @args;
124 }
125 #should throw exception if seq is null, for now just warn
126 202 ▶ if (($args{seq} eq '') || (!defined($args{seq}))) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"seq"} eq "" or not defined $args{"seq"}) 0 202 202
Condition33%1/3
$args{"seq"} eq "" or not defined $args{"seq"}
l!l&&r!l&&!r
00202
MC/DC0%0/2
$args{"seq"} eq "" or not defined $args{"seq"}
$args{"seq"} eq "" not defined $args{"seq"}
Truth table33%1/3
A or not(B)
A= $args{"seq"} eq ""B= not defined $args{"seq"}
ABresult
1X1
011
000
127 0 $args{seq}="AGCT";
128 0 warn "No sequence?!\n";
129 }
130 202 $self->{mid}=$args{mid};
131 202 $self->seq($args{seq});
132 202 $self->desc($args{desc});
133 202 $self->{score}=$args{score};
134 202 $self->{relpos}=$args{relpos};
135 202 $self->{frame}=$args{frame};
136 202 $self->{anchor}=$args{anchor};
137 202 return $self;
138 }
139  
140  
141 =head2 mid
142  
143 Title : mid
144 Usage : my $mid=$instance->mid;
145 Function: Get/Set the motif id
146 Throws :
147 Example :
148 Returns : scalar
149 Args : scalar
150  
151  
152 =cut
153  
154 0 ▶sub mid {
Subroutine mid: not called CC=2 SCAR=17.9
Pod documented
155 0 my $self = shift;
156 0 my $prev = $self->{mid};
157 0 ▶ if (@_) { $self->{mid} = shift; }
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
158 0 return $prev;
159 }
160  
161 =head2 score
162  
163 Title : score
164 Usage : my $score=$instance->score;
165 Function: Get/Set the score (mismatches) between the instance and the attached (or
166 initial) PSM
167 Throws :
168 Example :
169 Returns : real number
170 Args : real number
171  
172 =cut
173  
174 17 ▶sub score {
Subroutine score: called CC=2 SCAR=7.4
Pod documented
175 17 my $self = shift;
176 17 my $prev = $self->{score};
177 0 ▶ if (@_) { $self->{score} = shift; }
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 17 17
178 17 return $prev;
179 }
180  
181 =head2 anchor
182  
183 Title : anchor
184 Usage : my $anchor=$instance->anchor;
185 Function: Get/Set the anchor which shows what coordinate system start/end use
186 Throws :
187 Example :
188 Returns : string
189 Args : string
190  
191 =cut
192  
193 0 ▶sub anchor {
Subroutine anchor: not called CC=2 SCAR=17.9
Pod documented
194 0 my $self = shift;
195 0 my $prev = $self->{anchor};
196 0 ▶ if (@_) { $self->{anchor} = shift; }
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
197 0 return $prev;
198 }
199  
200 =head2 start
201  
202 Title : start
203 Usage : my $start=$instance->start;
204 Function: Get/Set the position of the instance on the sequence used
205 Throws :
206 Example :
207 Returns : integer
208 Args : integer
209  
210 =cut
211  
212  
213 #Provided by LocatableSeq
214  
215 =head2 minstance
216  
217 Title : minstance
218 Usage : my $minstance=$misntance->score;
219 Function: Get/Set the unique identifier- sequence id/motif id, for example PRM1_TATAbox.
220 Not necessarily human readable.
221 Throws :
222 Example :
223 Returns : string
224 Args : string
225  
226 =cut
227  
228 0 ▶sub minstance {
Subroutine minstance: not called CC=2 SCAR=17.9
Pod documented
229 0 my $self = shift;
230 0 my $prev = $self->{minstance};
231 0 ▶ if (@_) { $self->{minstance} = shift; }
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
232 0 return $prev;
233 }
234  
235 =head2 relpos
236  
237 Title : relpos
238 Usage : my $seqpos=$instance->relpos;
239 Function: Get/Set the relative position of the instance with respect to the transcription start
240 site (if known). Can and usually is negative.
241 Throws :
242 Example :
243 Returns : integer
244 Args : integer
245  
246 =cut
247  
248 0 ▶sub relpos {
Subroutine relpos: not called CC=2 SCAR=17.9
Pod documented
249 0 my $self = shift;
250 0 my $prev = $self->{relpos};
251 0 ▶ if (@_) { $self->{relpos} = shift; }
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
252 0 return $prev;
253 }
254  
255 =head2 annotation
256  
257 Title : annotation
258 Usage : $ann = $seq->annotation or $seq->annotation($annotation)
259 Function: Gets or sets the annotation
260 Returns : L<Bio::AnnotationCollectionI> object
261 Args : None or L<Bio::AnnotationCollectionI> object
262  
263 See L<Bio::AnnotationCollectionI> and L<Bio::Annotation::Collection>
264 for more information
265  
266 =cut
267  
268 0 ▶sub annotation {
Subroutine annotation: not called CC=4 SCAR=30.0
Pod documented
269 0 my ($obj,$value) = @_;
270 0 ▶ if( defined $value ) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $value) { } 0 0 0
elsif (not defined $obj->{'_annotation'}) { } 0 0 0
271 0 ▶ $obj->throw("object of class ".ref($value)." does not implement ".
Branch: 1 branch
BranchTrueFalseTotal
unless $value->isa("Bio::AnnotationCollectionI") 0 0 0
272 "Bio::AnnotationCollectionI. Too bad.")
273 unless $value->isa("Bio::AnnotationCollectionI");
274 0 $obj->{'_annotation'} = $value;
275 } elsif( ! defined $obj->{'_annotation'}) {
276 0 $obj->{'_annotation'} = Bio::Annotation::Collection->new();
277 }
278 0 return $obj->{'_annotation'};
279 }
280  
281 =head2 species
282  
283 Title : species
284 Usage : $species = $seq->species() or $seq->species($species)
285 Function: Gets or sets the species
286 Returns : L<Bio::Species> object
287 Args : None or L<Bio::Species> object
288  
289 See L<Bio::Species> for more information
290  
291 =cut
292  
293 0 ▶sub species {
Subroutine species: not called CC=2 SCAR=17.9
Pod documented
294 0 my ($self, $species) = @_;
295 0 ▶ if ($species) {
Branch: 1 branch
BranchTrueFalseTotal
if ($species) { } 0 0 0
296 0 $self->{'species'} = $species;
297 } else {
298 0 return $self->{'species'};
299 }
300 }
301  
302  
303 =head2 frame
304  
305 Title : frame
306 Usage : my $frane=$instance->frame;
307 Function: Get/Set the frame of a DNA instance with respect to a protein motif used.
308 Returns undef if the motif was not protein or the DB is protein.
309 Throws :
310 Example :
311 Returns : integer
312 Args : integer (0, 1, 2)
313  
314 =cut
315  
316 104 ▶sub frame {
Subroutine frame: called CC=3 SCAR=11.0
Pod documented
317 104 my $self = shift;
318 104 my $prev = $self->{frame};
319 104 ▶ if (@_) { $self->{frame} = shift; $self->throw("This is not a legitimate frame") unless (grep(/$self->{frame}/,qw[0 1 2])); }
Branch: 2 branches
BranchTrueFalseTotal
if (@_) 87 17 104
unless grep /$self->{"frame"}/, (0, 1, 2) 0 87 87
320 104 return $prev;
321 }
322  
323 13 1;
« Bio/SeqIO/ace.pm ↑ Summary Bio/SeqFeature/Gene/GeneStructure.pm »