lib/InSilicoSpectro/Databanks/DBEntryUniprot.pm

filter: Statementstmt 79.7% 224 / 281 Branchbran 52.7% 58 / 110 Conditioncond 47.8% 11 / 23 MC/DCmcdc 21.4% 3 / 14 Subroutinesub 81.8% 18 / 22 Podpod 88.8% 8 / 9 totaltotal 70.1% 322 / 459 CC 78 SCAR 35.9
CC
78
Cov
71%
readDat
75.3
updateAnnotPos
15.2
seqExtract
12.5
CRAP 36.2
↑ Summary lib/InSilicoSpectro/Databanks/DBEntry.pm »
1 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2  
3 package InSilicoSpectro::Databanks::DBEntryUniprot;
4 3 require Exporter;
5 3 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 =head1 NAME
8  
9 InSilicoSpectro::Databanks::DBEntryUniprot - Uniprot formated entry
10  
11 =head1 SYNOPSIS
12  
13  
14 =head1 DESCRIPTION
15  
16 Inherit from DBEntry, but can parse a uniprot format
17  
18 =head1 FUNCTIONS
19  
20 =head3 useInSilicoSpectro()
21  
22 determine if InSilicoSpectro lib is used in the current environment. The main difference will be the tracnslation from uniprot MOD_RES nomenclature to InSilciSpectro one
23  
24 =head1 METHODS
25  
26  
27 =head3 my $dbu=InSilicoSpectro::Databanks::DBEntryUniprot;
28  
29 =head2 Accessors/Setters
30  
31 =head3 $dbu->chains()
32  
33 get a ref to an array of arrays for chain delimiter [from, to]
34  
35 =head3 $dbu->add_chain([$from, $to])
36  
37 set chain (through a reference a to an array)
38  
39 =head3 $dbu->clear_chains()
40  
41 Reset the chain arrays
42  
43 =head3 $dbu->signals(); $dbu->add_signal([$from, $to]); $dbu->clear_signals()
44  
45 Idem than for the *chain subs
46  
47 =head2 Derived sequence generation
48  
49 =head3 $dbu->generateIsoforms(shortName)
50  
51 returns an array of InSilicoSpectro::Databanks::DBEntry containing all the isoforms generated by a swissprot entry
52  
53 =head3 $dbu->generateChains(shortName)
54  
55 Retuns an array of InSilicoSpectro::Databanks::DBEntry containing entries from FT CHAIN lines
56  
57 =head3 $dbu->generatePeptides(shortName)
58  
59 Retuns an array of InSilicoSpectro::Databanks::DBEntry containing entries from FT PEPTIDE lines
60  
61 =head3 $dbu->generateDerivedForms([skipIsoforms=>1][, skipChains=>1][, skipPeptides=>1][, shortName=>1])
62  
63 Retuns an array of InSilicoSpectro::Databanks::DBEntry containing entries from the concatenation of the above methods
64  
65 skip* argument will skip the creaion of the mentionned form
66  
67 =head3 $dbu->seqSubstr(from=>int, to=>int [, subseq=>AAstring]);
68  
69 =head3 $dbu->seqSubstr(pos=>int, len=>int [, subseq=>AAstring]);
70  
71 Replace a piece of the sequence by a a subseq (or remove it if sebseq is unfdefined). All annotation will be updated (or remove if they inerfer with the substitued sequence.
72  
73 from=>int notation starts sequence at position 1;
74  
75 pos=>int notation starts sequence at position 0;
76  
77 =head3 $dbu->seqExtract(from=>int, to=>int);
78  
79 =head3 $dbu->seqExtract(pos=>int, len=>int);
80  
81 Keep only the sub sequence described par the given delimiters (see seqSubstr(...) for description)
82  
83 =head2 I/O
84  
85 =head3 $dbe->readDat($fastacontent);
86  
87 read info from fasta contents (fitrs line with '>' and info + remaining is sequence.
88  
89 =head1 EXAMPLES
90  
91 =head1 EXPORT
92  
93 =head3 $VERBOSE
94  
95 verbose level
96  
97 =head1 SEE ALSO
98  
99 =head1 COPYRIGHT
100  
101 Copyright (C) 2004-2005 Geneva Bioinformatics www.genebio.com
102  
103 This library is free software; you can redistribute it and/or
104 modify it under the terms of the GNU Lesser General Public
105 License as published by the Free Software Foundation; either
106 version 2.1 of the License, or (at your option) any later version.
107  
108 This library is distributed in the hope that it will be useful,
109 but WITHOUT ANY WARRANTY; without even the implied warranty of
110 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
111 Lesser General Public License for more details.
112  
113 You should have received a copy of the GNU Lesser General Public
114 License along with this library; if not, write to the Free Software
115 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
116  
117 =head1 AUTHORS
118  
119 Alexandre Masselot, www.genebio.com
120  
121 =cut
122  
123 3 ▶use InSilicoSpectro::Databanks::DBEntry;
Subroutine BEGIN: called CC=1 SCAR=0.0
124 3 ▶use File::Basename;
Subroutine BEGIN: called CC=1 SCAR=0.0
125  
126 {
127 3 ▶ use Object::InsideOut qw(Exporter InSilicoSpectro::Databanks::DBEntry);
Subroutine BEGIN: called CC=1 SCAR=0.0
128 3 our $VERBOSE=0;
129 3 ▶ BEGIN{
Subroutine BEGIN: called CC=1 SCAR=0.0
130 3 our (@EXPORT, @EXPORT_OK);
131 3 @EXPORT = qw(&useInSilicoSpectro $VERBOSE);
132 3 @EXPORT_OK = ();
133 }
134  
135 3 our $isUsingInSilicoSpectro;
136  
137 3 our @attrArrays=qw(chain signal peptide);
138 3 our $attrArraysStr=join '|', @attrArrays;
139 3 our $attrArraysRE=qr/($attrArraysStr)/;
140  
141 3 my @chains :Field(Accessor => 'chains', Type=>'List' );
142 3 my @signals :Field(Accessor => 'signals', Type=>'List' );
143 3 my @peptides :Field(Accessor => 'peptides', Type=>'List' );
144 3 my @__FTLines :Field(Accessor => '__FTLines', Type=>'Hash', Permission=>'Private' );
145 3 my @__VAR_SEQ :Field(Accessor => '__VAR_SEQ', Type=>'Hash', Permission=>'Private' );
146 3 my @__seqSubstr :Field(Accessor => '__seqSubstr', Type=>'List', Permission=>'Private' );
147  
148  
149 3 my %init_args :InitArgs = (
150 );
151 1 ▶ sub _init :Init{
Subroutine _init: called CC=1 SCAR=0.0
152 1 my ($self, $h) = @_;
153 1 $self->chains([]);
154 1 $self->signals([]);
155 1 $self->peptides([]);
156 1 return $self;
157 3 ▶ }
Subroutine BEGIN: called CC=1 SCAR=0.0
158  
159  
160  
161 5 ▶ sub _automethod :Automethod{
Subroutine _automethod: called CC=3 SCAR=13.8
162 5 my ($self, $val) = @_;
163  
164 5 my $set=exists $_[1];
165 5 my $name=$_;
166  
167 5 ▶ if ($name=~/add_($attrArraysStr)/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($name =~ /add_($InSilicoSpectro::Databanks::DBEntryUniprot::attrArraysStr)/) { } 3 2 5
elsif ($name =~ /clear_((?:$InSilicoSpectro::Databanks::DBEntryUniprot::attrArraysStr)(?:s)?)$/) { } 2 0 2
168 3 $name=$1."s";
169 0 ▶ return sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
170 0 ▶ croak "must give a value to add to the array [$name]" unless defined $val;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $val 0 0 0
171 0 push @{$self->$name()}, $val;
172 3 };
173 0 ▶ return sub {return $self->{$name}};
Subroutine __ANON__: not called CC=1 SCAR=6.9
174 } elsif ($name=~/clear_((?:$attrArraysStr)(?:s)?)$/) {
175 2 $name=$1;
176
177 0 ▶ return sub {$self->$name([]);return $self;}
Subroutine __ANON__: not called CC=1 SCAR=6.9
178 2 }
179 3 ▶ }
Subroutine BEGIN: called CC=1 SCAR=0.0
180  
181 ################ Functions
182  
183 0 ▶ sub useInSilicoSpectro{
Subroutine useInSilicoSpectro: not called CC=3 SCAR=24.8
Pod documented
184 0 ▶ return $isUsingInSilicoSpectro if defined $isUsingInSilicoSpectro;
Branch: 1 branch
BranchTrueFalseTotal
if defined $InSilicoSpectro::Databanks::DBEntryUniprot::isUsingInSilicoSpectro 0 0 0
185 0 eval{
186 0 require InSilicoSpectro;
187 0 InSilicoSpectro::init();
188 0 $isUsingInSilicoSpectro=1;
189 };
190 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
191 0 warn "will not use InSilicoSpectro module & definitions";
192 0 warn "$@";
193 0 $isUsingInSilicoSpectro=0;
194 }
195 0 return $isUsingInSilicoSpectro;
196 }
197  
198 # I/O
199 1 ▶ sub readDat{
Subroutine readDat: called CC=42 SCAR=43.2
Pod documented
200 1 my $self=shift;
201 1 my $dat=shift;
202 1 my ($seq, $recSeq, $curFTLine, $recFT);
203  
204 1 $self->clear_chains();
205 1 $self->clear_signals();
206 1 $self->clear_annotatedModRes();
207 1 $self->clear_variants();
208 1 $self->__FTLines({});
209 1 my $acRead;
210 my @descr;
211 1 foreach (split /\n/, $dat) {
212 398 ▶ last if /^\/\//;
Branch: 1 branch
BranchTrueFalseTotal
if m[^//] 1 397 398
213 397 ▶ undef $curFTLine if substr($_, 3, 10)=~/\S/;
Branch: 1 branch
BranchTrueFalseTotal
if substr($_, 3, 10) =~ /\S/ 381 16 397
214  
215 397 ▶ if ($recSeq) {
Branch: 1 branch
BranchTrueFalseTotal
if ($recSeq) 8 389 397
216 8 $seq.=$_;
217 8 next;
218 }
219 389 ▶ if ($curFTLine) {
Branch: 1 branch
BranchTrueFalseTotal
if ($curFTLine) 14 375 389
220 14 ▶ croak "recording FT line is on and line does not match /^FT\\s+/" unless s/^FT\s+//;
Branch: 1 branch
BranchTrueFalseTotal
unless s/^FT\s+// 0 14 14
221 14 ▶ if(($curFTLine->{comment}=~/isoform \S+$/) && ($_!~/^and/) && ($_=~/^\w/)){
Branch: 1 branch
BranchTrueFalseTotal
if ($curFTLine->{'comment'} =~ /isoform \S+$/ and not $_ =~ /^and/ and $_ =~ /^\w/) { } 0 14 14
Condition66%4/6
$curFTLine->{"comment"} =~ /isoform \S+$/ and not $_ =~ /^and/ and $_ =~ /^\w/
!ll&&!rl&&r
1040
$curFTLine->{"comment"} =~ /isoform \S+$/ and not $_ =~ /^and/
!ll&&!rl&&r
1004
MC/DC0%0/3
$curFTLine->{"comment"} =~ /isoform \S+$/ and not $_ =~ /^and/ and $_ =~ /^\w/
$curFTLine->{"comment"} =~ /isoform \S+$/ not $_ =~ /^and/ $_ =~ /^\w/
Truth table50%2/4
A and not(B) and C
A= $curFTLine->{"comment"} =~ /isoform \S+$/B= not $_ =~ /^and/C= $_ =~ /^\w/
ABCresult
0XX0
10X0
1100
1111
222 0 $curFTLine->{comment}.="$_";
223 }else{
224 14 $curFTLine->{comment}.=" $_";
225 }
226 14 next;
227 }
228  
229 375 ▶ if (/^ID\s+(\w+)/) {
Branch: 10 branches
BranchTrueFalseTotal
if (/^ID\s+(\w+)/) { } 1 374 375
elsif (/^AC\s+(\w+)/ and not $acRead) { } 1 373 374
elsif (/^DE\s+(.*)\s*/) { } 2 371 373
elsif (/^OX\s+NCBI_TaxID=(\d+);/) { } 1 370 371
elsif (/^FT\s+CHAIN\s+(\d+)\s+(\d+)/) { } 2 368 370
elsif (/^FT\s+SIGNAL\s+(\d+)\s+(\d+)/) { } 1 367 368
elsif (/^FT\s+PEPTIDE\s+(\d+)\s+(\d+)/) { } 0 367 367
elsif (/^FT\s+MOD_RES\s+(\d+)\s+(\d+)\s+(.*)/) { } 0 367 367
elsif (/^FT\s+(VAR_SEQ|VARIANT)\s+(\d+)\s+(\d+)\s+(.*)/) { } 10 357 367
elsif (/^SQ/) { } 1 356 357
230 1 my $v=$1;
231 1 $self->ID($v);
232 ▶ } elsif (/^AC\s+(\w+)/ && ! $acRead) {
Condition100%3/3
/^AC\s+(\w+)/ and not $acRead
!ll&&!rl&&r
37211
MC/DC100%2/2
/^AC\s+(\w+)/ and not $acRead
/^AC\s+(\w+)/ not $acRead
Truth table100%3/3
A and not(B)
A= /^AC\s+(\w+)/B= not $acRead
ABresult
0X0
100
111
233 1 my $v=$1;
234 1 $self->AC($v);
235 1 $acRead=1;
236 } elsif (/^DE\s+(.*)\s*/) {
237 2 push @descr, $1;
238 } elsif (/^OX\s+NCBI_TaxID=(\d+);/) {
239 1 my $v=$1;
240 1 $self->ncbiTaxid($v);
241 } elsif (/^FT\s+CHAIN\s+(\d+)\s+(\d+)/) {
242 2 my($to, $from)=($1, $2);
243 2 $self->add_chain([$to, $from]);
244 } elsif (/^FT\s+SIGNAL\s+(\d+)\s+(\d+)/) {
245 1 my($to, $from)=($1, $2);
246 1 $self->add_signal([$to, $from]);
247 } elsif (/^FT\s+PEPTIDE\s+(\d+)\s+(\d+)/) {
248 0 my($to, $from)=($1, $2);
249 0 $self->add_peptide([$to, $from]);
250 } elsif (/^FT\s+MOD_RES\s+(\d+)\s+(\d+)\s+(.*)/) {
251 0 ▶ if ($2!=$1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($2 != $1) 0 0 0
252 0 carp "cannot handle multi-position FT MOD_RES: $_";
253 0 next;
254 }
255 0 my ($p, $str)=($1, $3);
256 0 ▶ if (useInSilicoSpectro) {
Branch: 1 branch
BranchTrueFalseTotal
if (useInSilicoSpectro()) { } 0 0 0
257 0 my $mr=InSilicoSpectro::InSilico::ModRes::getModifFromSprotFT($str);
258 0 ▶ unless ($mr){
Branch: 1 branch
BranchTrueFalseTotal
unless ($mr) 0 0 0
259 0 ▶ carp "cannot retrieve mod res from annotation [$str]" if $VERBOSE>=1;
Branch: 1 branch
BranchTrueFalseTotal
if $InSilicoSpectro::Databanks::DBEntryUniprot::VERBOSE >= 1 0 0 0
260 0 next;
261 }
262 0 $self->add_annotatedModRes($p, $mr->get('name'));
263 } else {
264 0 $self->add_annotatedModRes($p, $str);
265 }
266 } elsif (/^FT\s+(VAR_SEQ|VARIANT)\s+(\d+)\s+(\d+)\s+(.*)/) {
267 10 my ($ft, $p1, $p2, $com)=($1, $2, $3, $4);
268 10 $curFTLine={
269 from=>$2,
270 to=>$3,
271 comment=>$4
272 };
273 10 push @{$self->__FTLines->{$1}}, $curFTLine;
274 } elsif (/^SQ/) {
275 1 $recSeq=1;
276 }
277 }
278 1 $self->sequence($seq);
279  
280 #parse description for multine uniprot dat format;
281 1 my $descr;
282 1 foreach(@descr){
283 2 ▶ last if /^Includes:/;
Branch: 1 branch
BranchTrueFalseTotal
if /^Includes:/ 0 2 2
284 2 ▶ $descr=$1 if /RecName: Full=(.*);/;
Branch: 1 branch
BranchTrueFalseTotal
if /RecName: Full=(.*);/ 0 2 2
285 2 ▶ $descr.=" ($1)" if /Short=(.*);/;
Branch: 1 branch
BranchTrueFalseTotal
if /Short=(.*);/ 0 2 2
286 }
287 1 ▶ $descr=join (" ", @descr) unless $descr;
Branch: 1 branch
BranchTrueFalseTotal
unless $descr 1 0 1
288 1 $self->description($descr);
289  
290 #rescan $self->{FTLines}
291 #to put back $self->{seqSubstr} info together with isoform labels
292 1 $self->__VAR_SEQ({});
293 1 $self->__seqSubstr([]);
294 1 ▶ if ($self->__FTLines->{VAR_SEQ}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->__FTLines->{"VAR_SEQ"}) 1 0 1
295 1 foreach my $ftl (@{$self->__FTLines->{VAR_SEQ}}) {
296 4 my @isof= $ftl->{comment}=~/(?<=isoform)\s+([\w\-]+)/gi;
297 4 ▶ carp "cannot parse VAR_SPLIC labels from [$ftl->{comment}] for ".$self->AC unless @isof;
Branch: 1 branch
BranchTrueFalseTotal
unless @isof 0 4 4
298 4 my $substr;
299 4 ▶ if ($ftl->{comment}=~/Missing/i) {
Branch: 2 branches
BranchTrueFalseTotal
if ($ftl->{'comment'} =~ /Missing/i) { } 2 2 4
elsif ($ftl->{'comment'} =~ /\w+\s*\->\s*([A-Z ]+)/) { } 2 0 2
300
301 } elsif ($ftl->{comment}=~/\w+\s*\->\s*([A-Z ]+)/) {
302 2 $substr=$1;
303 2 $substr=~s/\s+//g;
304 } else {
305 0 carp "unparsable for Missing or subst FT VAR_SEQ comment: [$ftl->{comment}] for ".$self->AC;
306 }
307 my $h={
308 from=> $ftl->{from},
309 to=>$ftl->{to},
310 4 substr=>$substr,
311 };
312 4 my $idx=scalar @{$self->__seqSubstr};
313 4 foreach (@isof) {
314 4 push @{$self->__VAR_SEQ->{$_}{seqSubstrIndex}}, $idx;
315 }
316 4 push @{$self->__seqSubstr}, $h;
317 }
318 #reorder sub annotation to be in position decreasing order (to keep coherence)
319 1 foreach (values %{$self->__VAR_SEQ}) {
320 2 my @tmp=@{$_->{seqSubstrIndex}};
321 2 @tmp=sort {$self->__seqSubstr->[$b]{from} <=> $self->__seqSubstr->[$a]{from}} @tmp;
322 2 $_->{seqSubstrIndex}=\@tmp;
323 }
324 #@{$self->{seqSubstr}}=sort {$b->{from} <=> $a->{from}} @{$self->{seqSubstr}};
325 }
326  
327 1 ▶ if ($self->__FTLines->{VARIANT}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->__FTLines->{"VARIANT"}) 1 0 1
328 1 foreach my $ftl (@{$self->__FTLines->{VARIANT}}) {
329 6 ▶ if ($ftl->{comment}=~/([A-Z]+)\s+\->\s+([\*A-Z]+)/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($ftl->{'comment'} =~ /([A-Z]+)\s+\->\s+([\*A-Z]+)/) { } 6 0 6
elsif ($ftl->{'comment'} =~ /Missing/i) { } 0 0 0
330 6 $self->add_variant($ftl->{from}, $1, $2);
331 } elsif ($ftl->{comment}=~/Missing/i) {
332 0 my $tmp='';
333 0 foreach ($ftl->{from}..$ftl->{to}) {
334 0 $tmp.='.';
335 }
336 0 $self->add_variant($ftl->{from}, $tmp, '');
337 } else {
338 0 carp "cannot parse VARIANT info from [$ftl->{comment}] for ".$self->AC;
339 }
340 }
341 }
342  
343 1 $self->__FTLines({});
344 }
345  
346  
347 ################### Derived sequence generation ################3
348  
349 1 ▶ sub generateDerivedForms{
Subroutine generateDerivedForms: called CC=4 SCAR=14.1
Pod documented
350 1 my $self=shift;
351 1 my %hprms=@_;
352  
353 1 my @ret;
354 my @tmp;
355 1 ▶ @tmp=$self->generateChains($hprms{shortName}) unless $hprms{skipChains};
Branch: 1 branch
BranchTrueFalseTotal
unless $hprms{"skipChains"} 1 0 1
356 1 push @ret, @tmp;
357 1 ▶ @tmp=$self->generateIsoforms($hprms{shortName}) unless $hprms{skipIsoforms};
Branch: 1 branch
BranchTrueFalseTotal
unless $hprms{"skipIsoforms"} 1 0 1
358 1 push @ret, @tmp;
359 1 ▶ @tmp=$self->generatePeptides($hprms{shortName}) unless $hprms{skipPeptides};
Branch: 1 branch
BranchTrueFalseTotal
unless $hprms{"skipPeptides"} 1 0 1
360 1 push @ret, @tmp;
361 1 return @ret;
362 }
363  
364 1 ▶ sub generateIsoforms{
Subroutine generateIsoforms: called CC=6 SCAR=17.9
Pod documented
365 1 my $self=shift;
366 1 my $shortName=shift;
367 1 my @isoforms;
368  
369 1 my $counter=0;
370 1 foreach my $isoform (sort {$a <=> $b} keys %{$self->__VAR_SEQ}) {
371 2 my $isoseq=$self->clone(1);
372 2 $isoseq->ACorig($self->AC());
373 2 ▶ $isoseq->AC($shortName ? $self->AC()."_I$counter" : $self->AC()."_ISOFORM_$isoform");
Branch: 1 branch
BranchTrueFalseTotal
$shortName ? : 0 2 2
374 2 $counter++;
375 2 $isoseq->description($self->description()." [ISOFORM $isoform]");
376  
377  
378 2 $isoseq->__VAR_SEQ({});
379 #duplicate seqSubstr not to alter the original sequence
380 2 $isoseq->__seqSubstr([]);
381 2 ▶ if ($self->__seqSubstr) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->__seqSubstr) 2 0 2
382 2 foreach (@{$self->__seqSubstr}) {
383 8 my %h=%$_;
384 8 push @{$isoseq->__seqSubstr}, \%h;
385 }
386 }
387  
388 # #remove seq outside the chain
389 # if($isoseq->chain){
390 # if($isoseq->chain()->[0]>1){
391 # $isoseq->seqSubstr(from=>1, to=>$isoseq->chain()->[0]-1);
392 # }
393 # }
394 2 foreach my $idx (@{$self->__VAR_SEQ->{$isoform}{seqSubstrIndex}}) {
395 4 my %h=%{$isoseq->__seqSubstr->[$idx]};
396 4 $isoseq->seqSubstr(from=> $h{from}, to=>$h{to}, substr=>$h{substr});
397 }
398  
399 #bless up to InSilicoSpectro::Databanks::DBEntry
400 #bless $isoseq, "InSilicoSpectro::Databanks::DBEntry";
401 2 my $dbe=InSilicoSpectro::Databanks::DBEntry->new(COPY=>$isoseq);
402 2 push @isoforms, $dbe;
403 }
404 1 return @isoforms;
405 }
406  
407 1 ▶ sub generatePeptides{
Subroutine generatePeptides: called CC=3 SCAR=15.3
Pod documented
408 1 my $self=shift;
409 1 my $shortName=shift;
410 1 my @peptides;
411 1 my $i=0;
412 1 foreach my $pp (@{$self->peptides()}) {
413 0 my $pseq=$self->clone(1);
414 0 $pseq->description($self->description()." [PEPTIDE $i])");
415 0 $pseq->ACorig($self->AC());
416 0 ▶ $pseq->AC($shortName ? $self->AC()."_P$i" : $self->AC()."_PEPT_$i");
Branch: 1 branch
BranchTrueFalseTotal
$shortName ? : 0 0 0
417 0 $pseq->seqExtract(from=>$pp->[0], to=>$pp->[1]);
418 0 $i++;
419 0 push @peptides, $pseq;
420 }
421 1 return @peptides;
422 }
423  
424  
425 1 ▶ sub generateChains{
Subroutine generateChains: called CC=3 SCAR=11.0
Pod documented
426 1 my $self=shift;
427 1 my $shortName=shift;
428 1 my @chains;
429 1 my $i=0;
430 1 foreach my $c (@{$self->chains()}) {
431 2 my $cseq=$self->clone(1);
432 2 $cseq->ACorig($self->AC());
433 2 ▶ $cseq->AC($shortName ? $self->AC()."_C$i" : $self->AC()."_CHAIN_$i");
Branch: 1 branch
BranchTrueFalseTotal
$shortName ? : 0 2 2
434 2 $cseq->description($self->description()." [CHAIN $i]");
435 2 $cseq->seqExtract(from=>$c->[0], to=>$c->[1]);
436 2 $i++;
437 2 push @chains, $cseq;
438 }
439 1 return @chains;
440 }
441  
442  
443 6 ▶ sub seqSubstr{
Subroutine seqSubstr: called CC=6 SCAR=20.9
Pod documented
444 6 my $self=shift;
445 6 my %hprm=@_;
446 6 my ($pos, $len, $substr);
447 6 ▶ if ($hprm{from} && $hprm{to}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($hprm{'from'} and $hprm{'to'}) { } 6 0 6
elsif (defined $hprm{'pos'} and $hprm{'len'}) { } 0 0 0
Condition33%1/3
$hprm{"from"} and $hprm{"to"}
!ll&&!rl&&r
006
MC/DC0%0/2
$hprm{"from"} and $hprm{"to"}
$hprm{"from"} $hprm{"to"}
Truth table33%1/3
A and B
A= $hprm{"from"}B= $hprm{"to"}
ABresult
0X0
100
111
448 6 $pos=$hprm{from}-1;
449 6 $len=$hprm{to}-$hprm{from}+1;
450 ▶ } elsif ((defined $hprm{pos}) && $hprm{len}) {
Condition0%0/3
defined $hprm{"pos"} and $hprm{"len"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $hprm{"pos"} and $hprm{"len"}
defined $hprm{"pos"} $hprm{"len"}
Truth table0%0/3
A and B
A= defined $hprm{"pos"}B= $hprm{"len"}
ABresult
0X0
100
111
451 0 ($pos, $len)=($hprm{pos}, $hprm{len});
452 } else {
453 0 croak "cannot DBEntryUniprot::seqSubstr with paramer [@_] (either (from=>x, to=>y) or (pos=>x, len=>y) for ".$self->AC;
454 }
455 6 ▶ $substr=$hprm{substr} || '';
Condition100%2/2
$hprm{'substr'} || ''
l!l
24
MC/DC100%1/1
$hprm{'substr'} || ''
$hprm{'substr'}
Truth table100%2/2
A
A= $hprm{'substr'}
Aresult
11
00
456 6 my $seq=$self->sequence;
457 6 $pos|=0;
458 6 $seq=~s/(.{$pos}).{$len}/$1$substr/;
459 6 $self->sequence($seq);
460 #CHANGE 2007/12/19
461 6 $self->updateAnnotPos($pos, $len-length($substr));
462 }
463  
464  
465 2 ▶ sub seqExtract{
Subroutine seqExtract: called CC=7 SCAR=25.2
Pod documented
466 2 my $self=shift;
467 2 my %hprm=@_;
468 2 my ($pos, $len, $substr);
469 2 ▶ if ($hprm{from} && $hprm{to}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($hprm{'from'} and $hprm{'to'}) { } 2 0 2
elsif (defined $hprm{'pos'} and $hprm{'len'}) { } 0 0 0
Condition33%1/3
$hprm{"from"} and $hprm{"to"}
!ll&&!rl&&r
002
MC/DC0%0/2
$hprm{"from"} and $hprm{"to"}
$hprm{"from"} $hprm{"to"}
Truth table33%1/3
A and B
A= $hprm{"from"}B= $hprm{"to"}
ABresult
0X0
100
111
470 2 $pos=$hprm{from}-1;
471 2 $len=$hprm{to}-$hprm{from}+1;
472 ▶ } elsif ((defined $hprm{pos}) && $hprm{len}) {
Condition0%0/3
defined $hprm{"pos"} and $hprm{"len"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $hprm{"pos"} and $hprm{"len"}
defined $hprm{"pos"} $hprm{"len"}
Truth table0%0/3
A and B
A= defined $hprm{"pos"}B= $hprm{"len"}
ABresult
0X0
100
111
473 0 ($pos, $len)=($hprm{pos}, $hprm{len});
474 } else {
475 0 croak "cannot DBEntryUniprot::seqSubstr with paramer [@_] (either (from=>x, to=>y) or (pos=>x, len=>y) for ".$self->AC;
476 }
477 2 my $lseq=length $self->sequence();
478 2 ▶ if ($lseq>($pos+$len)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lseq > $pos + $len) 0 2 2
479 0 $self->seqSubstr(from=>$pos+$len+1, to=>$lseq);
480 }
481 2 ▶ if ($pos>0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pos > 0) 2 0 2
482 2 $self->seqSubstr(from=>1, to =>$pos);
483 }
484 }
485  
486 6 ▶ sub updateAnnotPos{
Subroutine updateAnnotPos: called CC=9 SCAR=27.2
Pod undocumented
487 6 my ($self, $pos, $len)=@_;
488 #shift or remove all annotated PTM
489 6 my @amr=$self->annotatedModRes;
490 6 ▶ if (@amr) {
Branch: 1 branch
BranchTrueFalseTotal
if (@amr) 0 6 6
491 0 $self->clear_annotatedModRes;
492 0 foreach (@amr) {
493 0 my @tmp=@$_;
494 0 my $p=$tmp[0];
495 0 ▶ if ($p>=$pos) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p >= $pos) { } 0 0 0
496 0 $tmp[0]-=$len;
497 0 ▶ $self->add_annotatedModRes(@tmp) if $tmp[0]>$pos;
Branch: 1 branch
BranchTrueFalseTotal
if $tmp[0] > $pos 0 0 0
498 } else {
499 0 $self->add_annotatedModRes(@tmp);
500 }
501 }
502 }
503 6 @amr=$self->variants;
504 6 ▶ if (@amr) {
Branch: 1 branch
BranchTrueFalseTotal
if (@amr) 6 0 6
505 6 $self->clear_variants;
506 6 foreach (@amr) {
507 34 my @tmp=@$_;
508 34 my $p=$tmp[0];
509 34 ▶ if ($p>=$pos) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p >= $pos) { } 22 12 34
510 22 $tmp[0]-=$len;
511 22 ▶ $self->add_variant(@tmp) if $tmp[0]>0;
Branch: 1 branch
BranchTrueFalseTotal
if $tmp[0] > 0 18 4 22
512 } else {
513 12 $self->add_variant(@tmp);
514 }
515 }
516 }
517 }
518  
519 }
520 3 return 1;
↑ Summary lib/InSilicoSpectro/Databanks/DBEntry.pm »