line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id: Seq.pm,v 1.4 2005/01/25 06:17:28 cmungall Exp $ |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# This GO module is maintained by Chris Mungall |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# see also - http://www.geneontology.org |
6
|
|
|
|
|
|
|
# - http://www.godatabase.org/dev |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# You may distribute this module under the same terms as perl itself |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
package GO::Model::Seq; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 NAME |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
GO::Model::Seq; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 SYNOPSIS |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
print $gene_product->seq->seq; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 DESCRIPTION |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
represents a biological sequence; uses the bioperl Bio::PrimarySeq class |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
any call that you can do on a bioperl sequence object, you can do |
25
|
|
|
|
|
|
|
here, with the addition of the calls below |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
to get bioperl, see http://www.bioperl.org |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=cut |
30
|
|
|
|
|
|
|
|
31
|
14
|
|
|
14
|
|
73
|
use Carp; |
|
14
|
|
|
|
|
26
|
|
|
14
|
|
|
|
|
814
|
|
32
|
14
|
|
|
14
|
|
76
|
use Exporter; |
|
14
|
|
|
|
|
25
|
|
|
14
|
|
|
|
|
569
|
|
33
|
14
|
|
|
14
|
|
74
|
use GO::Utils qw(rearrange); |
|
14
|
|
|
|
|
57
|
|
|
14
|
|
|
|
|
698
|
|
34
|
14
|
|
|
14
|
|
1118
|
use GO::Model::Root; |
|
14
|
|
|
|
|
35
|
|
|
14
|
|
|
|
|
1002
|
|
35
|
14
|
|
|
14
|
|
69
|
use strict; |
|
14
|
|
|
|
|
30
|
|
|
14
|
|
|
|
|
487
|
|
36
|
14
|
|
|
14
|
|
69
|
use vars qw(@ISA $AUTOLOAD); |
|
14
|
|
|
|
|
35
|
|
|
14
|
|
|
|
|
17210
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
@ISA = qw(GO::Model::Root Exporter); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub _valid_params { |
41
|
0
|
|
|
0
|
|
|
return qw(id xref_list pseq description); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub _initialize |
45
|
|
|
|
|
|
|
{ |
46
|
0
|
|
|
0
|
|
|
my $self = shift; |
47
|
0
|
|
|
|
|
|
my ($paramh) = @_; |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
my @bpargs = @_; |
50
|
0
|
|
|
|
|
|
my %h = (); |
51
|
0
|
0
|
|
|
|
|
if (ref($paramh) eq "HASH") { |
52
|
0
|
|
|
|
|
|
@bpargs = (); |
53
|
0
|
|
|
|
|
|
foreach my $k (keys %$paramh) { |
54
|
0
|
0
|
|
|
|
|
if (grep {$k eq $_} $self->_valid_params) { |
|
0
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
$h{$k} = $paramh->{$k}; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
else { |
58
|
0
|
|
|
|
|
|
push(@bpargs, "-".$k, $paramh->{$k}); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
} |
62
|
0
|
|
|
|
|
|
require "Bio/PrimarySeq.pm"; |
63
|
0
|
|
|
|
|
|
my $pseq = Bio::PrimarySeq->new(@bpargs); |
64
|
0
|
|
|
|
|
|
$self->pseq($pseq); |
65
|
0
|
|
|
|
|
|
$self->SUPER::_initialize(\%h); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head2 pseq |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Usage - |
72
|
|
|
|
|
|
|
Returns - Bio::PrimarySeq |
73
|
|
|
|
|
|
|
Args - |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=cut |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub pseq { |
78
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
79
|
0
|
0
|
|
|
|
|
if (@_) { |
80
|
0
|
|
|
|
|
|
$self->{pseq} = shift; |
81
|
0
|
0
|
|
|
|
|
if ($self->{pseq}->isa("Bio::Seq::RichSeqI")) { |
82
|
0
|
|
|
|
|
|
my $annot = $self->{pseq}->annotation; |
83
|
|
|
|
|
|
|
# foreach my $link ( $annot->each_DBLink ) { |
84
|
0
|
|
|
|
|
|
foreach my $link ( $annot->get_Annotations('dblink') ) { |
85
|
0
|
|
|
|
|
|
my $xref = |
86
|
|
|
|
|
|
|
GO::Model::Xref->new; |
87
|
0
|
|
|
|
|
|
$xref->xref_key($link->primary_id); |
88
|
0
|
|
|
|
|
|
$xref->xref_dbname($link->database); |
89
|
0
|
|
|
|
|
|
$self->add_xref($xref); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
} |
93
|
0
|
|
|
|
|
|
return $self->{pseq}; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub id { |
97
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
98
|
0
|
0
|
|
|
|
|
$self->{id} = shift if @_; |
99
|
0
|
|
|
|
|
|
return $self->{id}; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
0
|
|
|
0
|
0
|
|
sub residues {shift->pseq->seq(@_)} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head2 md5checksum |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Usage - my $md5 = $seq->md5checksum() OR $seq->md5checksum($md5) |
107
|
|
|
|
|
|
|
Returns - 32 char hex string |
108
|
|
|
|
|
|
|
Args - 32 char hex string [optional] |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
checksum for seq - easy way to check if it has been changed etc |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
(requires Digest::MD5 module from CPAN) |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=cut |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub md5checksum { |
117
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
# we want to be able to manipulte the checksum |
120
|
|
|
|
|
|
|
# even if the actual residues are not in memory at this time |
121
|
0
|
0
|
|
|
|
|
if (@_) { |
122
|
0
|
|
|
|
|
|
$self->{md5checksum} = shift; |
123
|
|
|
|
|
|
|
} |
124
|
0
|
|
|
|
|
|
my $res = $self->pseq->seq(); |
125
|
0
|
0
|
|
|
|
|
if (!$res) { |
126
|
0
|
|
|
|
|
|
return $self->{md5checksum}; |
127
|
|
|
|
|
|
|
} |
128
|
0
|
|
|
|
|
|
require "Digest/MD5.pm"; |
129
|
0
|
|
|
|
|
|
my $md5 = Digest::MD5->new; |
130
|
0
|
|
|
|
|
|
$md5->add($self->residues); |
131
|
0
|
|
|
|
|
|
my $hex = $md5->hexdigest; |
132
|
|
|
|
|
|
|
|
133
|
0
|
|
|
|
|
|
$self->{md5checksum} = $hex; |
134
|
|
|
|
|
|
|
|
135
|
0
|
|
|
|
|
|
return $self->{md5checksum}; |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head2 to_fasta |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Usage - |
141
|
|
|
|
|
|
|
Returns - |
142
|
|
|
|
|
|
|
Args - |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=cut |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
sub to_fasta { |
147
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
148
|
|
|
|
|
|
|
|
149
|
0
|
|
|
|
|
|
my $res = $self->seq; |
150
|
0
|
|
|
|
|
|
$res =~ s/(.{50})/$1\n/g; |
151
|
0
|
|
0
|
|
|
|
my $hdr = $self->description || $self->display_id; |
152
|
|
|
|
|
|
|
# my $hdr = $self->display_id; |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
return |
155
|
0
|
|
|
|
|
|
sprintf(">%s\n%s\n", |
156
|
|
|
|
|
|
|
$hdr, |
157
|
|
|
|
|
|
|
$res); |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head2 add_xref |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
- Usage : $term->add_xref($xref); |
163
|
|
|
|
|
|
|
- Args : GO::Term::Xref |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=cut |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
sub add_xref { |
169
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
170
|
|
|
|
|
|
|
|
171
|
0
|
0
|
|
|
|
|
if (@_) { |
172
|
0
|
|
|
|
|
|
my $xref = shift; |
173
|
0
|
0
|
|
|
|
|
$self->xref_list([]) unless $self->xref_list; |
174
|
0
|
0
|
|
|
|
|
$xref->isa("GO::Model::Xref") || confess("Not an Xref"); |
175
|
0
|
|
|
|
|
|
push(@{$self->xref_list}, $xref); |
|
0
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
# delegate calls to Bio::Seq object |
180
|
|
|
|
|
|
|
sub AUTOLOAD { |
181
|
|
|
|
|
|
|
|
182
|
0
|
|
0
|
0
|
|
|
my $self = shift || confess; |
183
|
|
|
|
|
|
|
|
184
|
0
|
|
|
|
|
|
my $name = $AUTOLOAD; |
185
|
0
|
|
|
|
|
|
$name =~ s/.*://; # strip fully-qualified portion |
186
|
|
|
|
|
|
|
|
187
|
0
|
0
|
|
|
|
|
if ($name eq "DESTROY") { |
188
|
|
|
|
|
|
|
# we dont want to propagate this!! |
189
|
0
|
|
|
|
|
|
return; |
190
|
|
|
|
|
|
|
} |
191
|
|
|
|
|
|
|
|
192
|
0
|
0
|
|
|
|
|
if (!$self->pseq) { confess("assertion error") } |
|
0
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
|
194
|
0
|
0
|
|
|
|
|
if ($self->pseq->can($name)) { |
195
|
0
|
|
|
|
|
|
return $self->pseq->$name(@_); |
196
|
|
|
|
|
|
|
} |
197
|
0
|
0
|
|
|
|
|
if ($self->is_valid_param($name)) { |
198
|
|
|
|
|
|
|
|
199
|
0
|
0
|
|
|
|
|
$self->{$name} = shift if @_; |
200
|
0
|
|
|
|
|
|
return $self->{$name}; |
201
|
|
|
|
|
|
|
} |
202
|
|
|
|
|
|
|
else { |
203
|
0
|
|
|
|
|
|
confess("can't do $name on $self"); |
204
|
|
|
|
|
|
|
} |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
} |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
1; |