line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Fry::Lib::BioPerl; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1785
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
65
|
|
4
|
|
|
|
|
|
|
#use Benchmark qw/:all/; |
5
|
1
|
|
|
1
|
|
14037
|
use Time::HiRes qw/tv_interval gettimeofday/; |
|
1
|
|
|
|
|
5101
|
|
|
1
|
|
|
|
|
8
|
|
6
|
1
|
|
|
1
|
|
2148
|
use Bio::SeqIO; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use Bio::AlignIO; |
8
|
|
|
|
|
|
|
use Bio::Tools::Run::Alignment::Clustalw; |
9
|
|
|
|
|
|
|
use Bio::Tools::Run::Alignment::TCoffee; |
10
|
|
|
|
|
|
|
use Bio::DB::GenBank; |
11
|
|
|
|
|
|
|
#use Bio::Graphics; |
12
|
|
|
|
|
|
|
#Bio::Seq::RichSeq; |
13
|
|
|
|
|
|
|
#Bio::Graphics::Feature; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $VERSION = 0.15; |
16
|
|
|
|
|
|
|
our $Verbose = 1; |
17
|
|
|
|
|
|
|
$Bio::Root::Root::DEBUG = 0; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
#these are defaults |
20
|
|
|
|
|
|
|
our $seqio_file = "$ENV{HOME}/.cpanplus/5.8.1/build/bioperl-1.4/t/data/test.genbank"; |
21
|
|
|
|
|
|
|
#our $seqio_file = "t/data/test.genbank"; |
22
|
|
|
|
|
|
|
our $seqio_format = "genbank"; |
23
|
|
|
|
|
|
|
our $alnio_format = "clustalw"; |
24
|
|
|
|
|
|
|
our $alnio_file = "$ENV{HOME}/.cpanplus/5.8.1/build/bioperl-1.4/t/data/testaln.aln"; |
25
|
|
|
|
|
|
|
#our $alnio_file = "t/data/testaln.aln"; |
26
|
|
|
|
|
|
|
our $default_seqio = "seqio1"; |
27
|
|
|
|
|
|
|
our $default_alnio = "alnio1"; |
28
|
|
|
|
|
|
|
our %clustal_params = (qw/matrix BLOSUM/); |
29
|
|
|
|
|
|
|
our %tcoffee_params = (); |
30
|
|
|
|
|
|
|
our %db_genbank_params = (); |
31
|
|
|
|
|
|
|
my $seqcount = 0; |
32
|
|
|
|
|
|
|
my $alncount = 0; |
33
|
|
|
|
|
|
|
#hackish variable |
34
|
|
|
|
|
|
|
our %temp; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub _default_data { |
37
|
|
|
|
|
|
|
return { |
38
|
|
|
|
|
|
|
cmds=>{ |
39
|
|
|
|
|
|
|
readSeq=>{qw/a brs/,d=>'Read a sequence from a file', |
40
|
|
|
|
|
|
|
u=>'$format$file$obj'}, |
41
|
|
|
|
|
|
|
readAln=>{qw/a bra/,d=>'Read an alignment from a file', |
42
|
|
|
|
|
|
|
u=>'$format$file$obj'}, |
43
|
|
|
|
|
|
|
startClustalw=>{qw/a bsc/,d=>'Initialize clustalw',u=>'%options'}, |
44
|
|
|
|
|
|
|
startTCoffee=>{qw/a bst/,d=>'Initialize tcoffee',u=>'%options'}, |
45
|
|
|
|
|
|
|
startDB=>{qw/a bsd/,d=>'Initialize database',u=>'%options'}, |
46
|
|
|
|
|
|
|
clustalAlign=>{qw/a bca/,d=>'Align with clustalw',u=>'@seq'}, |
47
|
|
|
|
|
|
|
tcoffeeAlign=>{qw/a bta/,d=>'Align with tcoffee',u=>'@seq'}, |
48
|
|
|
|
|
|
|
compareAlign=>{qw/a bcom/,d=>'Compare two alignment methods', |
49
|
|
|
|
|
|
|
u=>'@seq'}, |
50
|
|
|
|
|
|
|
alnioFormat=>{qw/a baf/,d=>'Change alnioout format',u=>'$format'}, |
51
|
|
|
|
|
|
|
seqioFormat=>{qw/a bsf/,d=>'Change seqioout format',u=>'$format'}, |
52
|
|
|
|
|
|
|
listSeqs=>{qw/a bls/,d=>'Read all sequences from a file', |
53
|
|
|
|
|
|
|
u=>'$seqio'}, |
54
|
|
|
|
|
|
|
#nextSeq=>{qw/a ,/,d=>'Get the next Seq'}, |
55
|
|
|
|
|
|
|
writeAln=>{qw/a bwa/,d=>'Write alignments',u=>'@aln'}, |
56
|
|
|
|
|
|
|
displayAln=>{qw/a bda/,d=>'Display alignment info',u=>'@aln'}, |
57
|
|
|
|
|
|
|
getAlnSeqs=>{qw/a bas/,d=>'Save alignment seqs',u=>'$aln'}, |
58
|
|
|
|
|
|
|
writeSeq=>{qw/a bws/,d=>'Write sequences',u=>'@seq'}, |
59
|
|
|
|
|
|
|
translateSeq=>{qw/a bts/,d=>'Translate sequences',u=>'$seq'}, |
60
|
|
|
|
|
|
|
revcomSeq=>{qw/a bts/,d=>'Reverse complement sequences',u=>'$seq'}, |
61
|
|
|
|
|
|
|
getSeqById=>{qw/a bgsi/,d=>'Get sequence by id',u=>'$id'}, |
62
|
|
|
|
|
|
|
#featureImage=>{qw/a bfi/,d=>''}, |
63
|
|
|
|
|
|
|
libCmdAttr=>{qw/a lca/,d=>"Display a library's cmds' attributes", |
64
|
|
|
|
|
|
|
u=>'$attr$lib'}, |
65
|
|
|
|
|
|
|
}, |
66
|
|
|
|
|
|
|
objs=>{ |
67
|
|
|
|
|
|
|
#seqio1=>{} |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
sub _initLib { |
72
|
|
|
|
|
|
|
my ($cls) = @_; |
73
|
|
|
|
|
|
|
#reads in sequence file |
74
|
|
|
|
|
|
|
$cls->newSeqIoInObj; |
75
|
|
|
|
|
|
|
#sequence output |
76
|
|
|
|
|
|
|
$cls->newSeqIoObj('seqioout',-fh=>\*STDOUT,-format=>$seqio_format); |
77
|
|
|
|
|
|
|
#alignment output |
78
|
|
|
|
|
|
|
$cls->newAlnIoObj('alnioout',-fh=>\*STDOUT,-format=>$alnio_format); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
#new*Obj |
82
|
|
|
|
|
|
|
#these methods create objects and index them as Fry::Obj objects as well |
83
|
|
|
|
|
|
|
sub newSeqIoInObj { |
84
|
|
|
|
|
|
|
my ($cls,%arg) = @_; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
#defaults |
87
|
|
|
|
|
|
|
my $objId = delete $arg{obj} || $default_seqio; |
88
|
|
|
|
|
|
|
$arg{-file} = $arg{-file} || $seqio_file; |
89
|
|
|
|
|
|
|
$arg{-format} = $arg{-format} || $seqio_format; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
$cls->newSeqIoObj($objId,%arg); |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
#index seqs of seqio |
94
|
|
|
|
|
|
|
my ($id,@ids); |
95
|
|
|
|
|
|
|
my @newSeqs = $cls->ripStream($cls->obj->get($objId,'obj')); |
96
|
|
|
|
|
|
|
for (@newSeqs) { |
97
|
|
|
|
|
|
|
$id = $cls->newSeqObj($_); |
98
|
|
|
|
|
|
|
push(@ids,$id); |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
$cls->obj->set($objId,seqs=>\@ids); |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
sub newSeqIoObj { |
103
|
|
|
|
|
|
|
my ($cls,$objId,%arg) = @_; |
104
|
|
|
|
|
|
|
#print Dumper \%arg; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
my $obj = $cls->seqioNew(%arg) ; |
107
|
|
|
|
|
|
|
$cls->obj->setOrMake($objId=>$obj); |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
sub newSeqObj { |
110
|
|
|
|
|
|
|
my ($cls,$obj) = @_; |
111
|
|
|
|
|
|
|
$seqcount++; |
112
|
|
|
|
|
|
|
my $id = "seq$seqcount"; |
113
|
|
|
|
|
|
|
$cls->obj->manyNew($id=>{obj=>$obj}); |
114
|
|
|
|
|
|
|
$cls->view("Created sequence '$id'\n") if ($Verbose); |
115
|
|
|
|
|
|
|
return $id; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
sub newAlnObj { |
118
|
|
|
|
|
|
|
my ($cls,$obj) = @_; |
119
|
|
|
|
|
|
|
$alncount++; |
120
|
|
|
|
|
|
|
my $id = "aln$alncount"; |
121
|
|
|
|
|
|
|
$cls->obj->manyNew($id=>{obj=>$obj}); |
122
|
|
|
|
|
|
|
$cls->view("Created alignment '$id'\n") if ($Verbose); |
123
|
|
|
|
|
|
|
return $id; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
sub newAlnIoObj { |
126
|
|
|
|
|
|
|
my ($cls,$objId,%arg) = @_; |
127
|
|
|
|
|
|
|
my $obj = $cls->alnioNew(%arg) ; |
128
|
|
|
|
|
|
|
$cls->obj->setOrMake($objId=>$obj); |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
sub newAlnIoInObj { |
131
|
|
|
|
|
|
|
my ($cls,%arg) = @_; |
132
|
|
|
|
|
|
|
my $objId = delete $arg{obj} || $default_alnio; |
133
|
|
|
|
|
|
|
$arg{-file} = $arg{-file} || $alnio_file; |
134
|
|
|
|
|
|
|
delete $arg{-format}; |
135
|
|
|
|
|
|
|
#$arg{-format} = $arg{-format} || "clustalw"; |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
$cls->newAlnIoObj($objId,%arg); |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
#index seqs of seqio |
140
|
|
|
|
|
|
|
my ($id,@ids); |
141
|
|
|
|
|
|
|
my @newAlns = $cls->ripStream($cls->obj->get($objId,'obj')); |
142
|
|
|
|
|
|
|
for (@newAlns) { |
143
|
|
|
|
|
|
|
$id = $cls->newAlnObj($_); |
144
|
|
|
|
|
|
|
push(@ids,$id); |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
$cls->obj->set($objId,alns=>\@ids); |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
#wrappers around classes to easily substitute your own subclasses of any of these |
149
|
|
|
|
|
|
|
sub seqioNew { shift; return Bio::SeqIO->new(@_) } |
150
|
|
|
|
|
|
|
sub alnioNew { shift; return Bio::AlignIO->new(@_) } |
151
|
|
|
|
|
|
|
sub biodbNew { shift; return Bio::DB::GenBank->new(@_) } |
152
|
|
|
|
|
|
|
sub clustalwNew { shift; return Bio::Tools::Run::Alignment::Clustalw->new(@_) } |
153
|
|
|
|
|
|
|
sub tcoffeeNew { shift; return Bio::Tools::Run::Alignment::TCoffee->new(@_) } |
154
|
|
|
|
|
|
|
sub objObj { shift->obj->get($_[0],'obj') } |
155
|
|
|
|
|
|
|
#commands |
156
|
|
|
|
|
|
|
#h: will probably break in other releases |
157
|
|
|
|
|
|
|
sub libCmdAttr { |
158
|
|
|
|
|
|
|
my ($cls,$attr) = @_; |
159
|
|
|
|
|
|
|
my $lib = "Fry::Lib::BioPerl"; |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
my @ids = @{$cls->lib->get($lib,'cmds') }; |
162
|
|
|
|
|
|
|
$cls->printGeneralAttr('cmd',$attr,@ids); |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
#constructors |
165
|
|
|
|
|
|
|
sub readSeq { |
166
|
|
|
|
|
|
|
#d: initializes $seqio |
167
|
|
|
|
|
|
|
my ($cls,$format,$file,$objId) = @_; |
168
|
|
|
|
|
|
|
$cls->newSeqIoInObj(-file=>$file,-format=>$format,obj=>$objId); |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
sub readAln { |
171
|
|
|
|
|
|
|
my ($cls,$format,$file,$objId) = @_; |
172
|
|
|
|
|
|
|
$cls->newAlnIoInObj(-file=>$file,-format=>$format,obj=>$objId); |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
sub startClustalw { |
175
|
|
|
|
|
|
|
my ($cls,%arg) = @_; |
176
|
|
|
|
|
|
|
#$cls->verify_params(\%arg); |
177
|
|
|
|
|
|
|
my %params = (%clustal_params,%arg); |
178
|
|
|
|
|
|
|
my $obj = $cls->clustalwNew(%params); |
179
|
|
|
|
|
|
|
$cls->obj->manyNew('cw'=>{obj=>$obj}); |
180
|
|
|
|
|
|
|
} |
181
|
|
|
|
|
|
|
sub startDB { |
182
|
|
|
|
|
|
|
my ($cls,%arg) = @_; |
183
|
|
|
|
|
|
|
my %params = (%db_genbank_params,%arg); |
184
|
|
|
|
|
|
|
my $obj = $cls->biodbNew(%params); |
185
|
|
|
|
|
|
|
$cls->obj->manyNew('db1'=>{obj=>$obj}); |
186
|
|
|
|
|
|
|
} |
187
|
|
|
|
|
|
|
sub startTCoffee { |
188
|
|
|
|
|
|
|
my ($cls,%arg) = @_; |
189
|
|
|
|
|
|
|
my %params = (%tcoffee_params,%arg); |
190
|
|
|
|
|
|
|
my $obj = $cls->tcoffeeNew(%params); |
191
|
|
|
|
|
|
|
$cls->obj->manyNew('tc'=>{obj=>$obj}); |
192
|
|
|
|
|
|
|
} |
193
|
|
|
|
|
|
|
#Alignment |
194
|
|
|
|
|
|
|
##$tcoffee |
195
|
|
|
|
|
|
|
sub tcoffeeAlign { |
196
|
|
|
|
|
|
|
my ($cls,@seqs) = @_; |
197
|
|
|
|
|
|
|
@seqs = $cls->idToObj(@seqs); |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
my $t0= [ gettimeofday()]; |
200
|
|
|
|
|
|
|
my $alnobj = $cls->obj->get('tc','obj')->align(\@seqs); |
201
|
|
|
|
|
|
|
my $elapsed = tv_interval($t0); |
202
|
|
|
|
|
|
|
$cls->newAlnObj($alnobj); |
203
|
|
|
|
|
|
|
$temp{tc} = {time=>$elapsed,alnid=>"aln$alncount"}; |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
$cls->view("This alignment took $elapsed seconds\n") if $Verbose; |
206
|
|
|
|
|
|
|
} |
207
|
|
|
|
|
|
|
##$clustalw |
208
|
|
|
|
|
|
|
sub clustalAlign { |
209
|
|
|
|
|
|
|
my ($cls,@seqs) = @_; |
210
|
|
|
|
|
|
|
@seqs = $cls->idToObj(@seqs); |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
my $t0= [ gettimeofday()]; |
213
|
|
|
|
|
|
|
my $alnobj = $cls->obj->get('cw','obj')->align(\@seqs); |
214
|
|
|
|
|
|
|
my $elapsed = tv_interval($t0); |
215
|
|
|
|
|
|
|
$cls->newAlnObj($alnobj); |
216
|
|
|
|
|
|
|
$temp{cw} = {time=>$elapsed,alnid=>"aln$alncount"}; |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
$cls->view("This alignment took $elapsed seconds\n") if $Verbose; |
219
|
|
|
|
|
|
|
} |
220
|
|
|
|
|
|
|
##macros |
221
|
|
|
|
|
|
|
sub compareAlign { |
222
|
|
|
|
|
|
|
my ($cls,@seqs) = @_; |
223
|
|
|
|
|
|
|
@seqs = $cls->idToObj(@seqs); |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
$cls->clustalAlign(@seqs); |
226
|
|
|
|
|
|
|
$cls->tcoffeeAlign(@seqs); |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
$cls->view("Alignment from Clustalw\n"); |
229
|
|
|
|
|
|
|
$cls->view("------------------------------------\n"); |
230
|
|
|
|
|
|
|
$cls->displayAln($temp{cw}{alnid}); |
231
|
|
|
|
|
|
|
$cls->view("Time: ",$temp{cw}{time},"\n"); |
232
|
|
|
|
|
|
|
$cls->view("\nAlignment from TCoffee\n"); |
233
|
|
|
|
|
|
|
$cls->view("------------------------------------\n"); |
234
|
|
|
|
|
|
|
$cls->displayAln($temp{tc}{alnid}); |
235
|
|
|
|
|
|
|
$cls->view("Time: ",$temp{tc}{time},"\n"); |
236
|
|
|
|
|
|
|
} |
237
|
|
|
|
|
|
|
#IO |
238
|
|
|
|
|
|
|
##$alignio |
239
|
|
|
|
|
|
|
sub alnioFormat { |
240
|
|
|
|
|
|
|
my ($cls,$format) = @_; |
241
|
|
|
|
|
|
|
$format ||= $alnio_format; |
242
|
|
|
|
|
|
|
$cls->newAlnIoObj('alnioout',-fh=>\*STDOUT,-format=>$format); |
243
|
|
|
|
|
|
|
} |
244
|
|
|
|
|
|
|
##$seqio |
245
|
|
|
|
|
|
|
sub seqioFormat { |
246
|
|
|
|
|
|
|
my ($cls,$format) = @_; |
247
|
|
|
|
|
|
|
$format ||= $seqio_format; |
248
|
|
|
|
|
|
|
$cls->newSeqIoObj('seqioout',-fh=>\*STDOUT,-format=>$format); |
249
|
|
|
|
|
|
|
} |
250
|
|
|
|
|
|
|
#Sequences |
251
|
|
|
|
|
|
|
##$biodb |
252
|
|
|
|
|
|
|
sub getSeqById { |
253
|
|
|
|
|
|
|
my ($cls,$id) = @_; |
254
|
|
|
|
|
|
|
my $method = "get_Seq_by_id"; |
255
|
|
|
|
|
|
|
my $seq = $cls->objObj('db1')->$method($id); |
256
|
|
|
|
|
|
|
$cls->newSeqObj($seq); |
257
|
|
|
|
|
|
|
} |
258
|
|
|
|
|
|
|
##$seq |
259
|
|
|
|
|
|
|
sub listSeqs { |
260
|
|
|
|
|
|
|
#d: readSeqs |
261
|
|
|
|
|
|
|
my ($cls,$seqioId) = @_; |
262
|
|
|
|
|
|
|
$seqioId ||= $default_seqio; |
263
|
|
|
|
|
|
|
my @seqs = @{$cls->obj->get($seqioId,'seqs') || []}; |
264
|
|
|
|
|
|
|
my $output = "Sequence ids of $seqioId are:\n"; |
265
|
|
|
|
|
|
|
$output .= $cls->seqIds(map {$cls->obj->get($_,'obj')} @seqs); |
266
|
|
|
|
|
|
|
$cls->view($output); |
267
|
|
|
|
|
|
|
} |
268
|
|
|
|
|
|
|
sub translateSeq { |
269
|
|
|
|
|
|
|
my ($cls,$seqId) = @_; |
270
|
|
|
|
|
|
|
my $seqObj = $cls->obj->get($seqId,'obj')->translate; |
271
|
|
|
|
|
|
|
$cls->newSeqObj($seqObj); |
272
|
|
|
|
|
|
|
} |
273
|
|
|
|
|
|
|
sub revcomSeq { |
274
|
|
|
|
|
|
|
my ($cls,$seqId) = @_; |
275
|
|
|
|
|
|
|
my $seqObj = $cls->obj->get($seqId,'obj')->revcom; |
276
|
|
|
|
|
|
|
$cls->newSeqObj($seqObj); |
277
|
|
|
|
|
|
|
} |
278
|
|
|
|
|
|
|
sub writeSeq { |
279
|
|
|
|
|
|
|
my ($cls,@seqs) = @_; |
280
|
|
|
|
|
|
|
@seqs = $cls->idToObj(@seqs); |
281
|
|
|
|
|
|
|
for my $seq (@seqs) { |
282
|
|
|
|
|
|
|
$cls->obj->get(seqioout=>'obj')->write_seq($seq); |
283
|
|
|
|
|
|
|
} |
284
|
|
|
|
|
|
|
} |
285
|
|
|
|
|
|
|
#Alignments |
286
|
|
|
|
|
|
|
##$aln |
287
|
|
|
|
|
|
|
#add,remove,indexSeq,slice,remove_gaps,map_chars |
288
|
|
|
|
|
|
|
sub displayAln { |
289
|
|
|
|
|
|
|
my ($cls,@alns) = @_; |
290
|
|
|
|
|
|
|
@alns = $cls->idToObj(@alns); |
291
|
|
|
|
|
|
|
my %methods = (score=>'Score',consensus_string=>'Consensus string', |
292
|
|
|
|
|
|
|
length=>'Length',no_residues=>'Number of residues', |
293
|
|
|
|
|
|
|
no_sequences=>'Number of sequences',percentage_identity=>'Percentage identity'); |
294
|
|
|
|
|
|
|
my $output; |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
for my $aln (@alns) { |
297
|
|
|
|
|
|
|
for my $m (sort keys %methods) { |
298
|
|
|
|
|
|
|
$output .= $methods{$m}.": ". $aln->$m |
299
|
|
|
|
|
|
|
."\n"; |
300
|
|
|
|
|
|
|
} |
301
|
|
|
|
|
|
|
} |
302
|
|
|
|
|
|
|
$cls->view($output); |
303
|
|
|
|
|
|
|
} |
304
|
|
|
|
|
|
|
sub getAlnSeqs { |
305
|
|
|
|
|
|
|
my ($cls,$alnId) = @_; |
306
|
|
|
|
|
|
|
my $aln = $cls->objObj($alnId); |
307
|
|
|
|
|
|
|
my @ids; |
308
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
for my $seq ($aln->each_seq) { push(@ids,$cls->newSeqObj($seq)) } |
310
|
|
|
|
|
|
|
#for my $seq ($aln->each_seq) { |
311
|
|
|
|
|
|
|
#my $obj = Bio::Seq->new(-display_id=>$seq->{display_id},-seq=>$seq->{seq}); |
312
|
|
|
|
|
|
|
##print "s: ",$seq->{seq},"\n"; |
313
|
|
|
|
|
|
|
#push(@ids,$cls->newSeqObj($obj)) |
314
|
|
|
|
|
|
|
#} |
315
|
|
|
|
|
|
|
$cls->obj->set($alnId,seqs=>\@ids); |
316
|
|
|
|
|
|
|
} |
317
|
|
|
|
|
|
|
sub writeAln { |
318
|
|
|
|
|
|
|
my ($cls,@alns) = @_; |
319
|
|
|
|
|
|
|
@alns = $cls->idToObj(@alns); |
320
|
|
|
|
|
|
|
for my $aln (@alns) { |
321
|
|
|
|
|
|
|
$cls->obj->get(alnioout=>'obj')->write_aln($aln); |
322
|
|
|
|
|
|
|
} |
323
|
|
|
|
|
|
|
} |
324
|
|
|
|
|
|
|
##misc |
325
|
|
|
|
|
|
|
sub seqIds { |
326
|
|
|
|
|
|
|
my ($cls,@seqs) = @_; |
327
|
|
|
|
|
|
|
my $output; |
328
|
|
|
|
|
|
|
|
329
|
|
|
|
|
|
|
if (@seqs > 0) { |
330
|
|
|
|
|
|
|
for my $seq (@seqs) { |
331
|
|
|
|
|
|
|
$output .= sprintf "%s\n", $seq->display_id; |
332
|
|
|
|
|
|
|
} |
333
|
|
|
|
|
|
|
} |
334
|
|
|
|
|
|
|
else { $output = "No sequences to display." } |
335
|
|
|
|
|
|
|
return $output; |
336
|
|
|
|
|
|
|
} |
337
|
|
|
|
|
|
|
sub idToObj { |
338
|
|
|
|
|
|
|
my ($cls,@idOrObj) = @_; |
339
|
|
|
|
|
|
|
my @return; |
340
|
|
|
|
|
|
|
if (ref $idOrObj[0]) { |
341
|
|
|
|
|
|
|
@return = @idOrObj; |
342
|
|
|
|
|
|
|
} |
343
|
|
|
|
|
|
|
else { @return = map { $cls->obj->get($_,'obj') } @idOrObj } |
344
|
|
|
|
|
|
|
wantarray ? @return : $return[0]; |
345
|
|
|
|
|
|
|
} |
346
|
|
|
|
|
|
|
#d: all Bio::*IO can use this |
347
|
|
|
|
|
|
|
sub ripStream { my $fh = $_[1]->fh; my @seqs = <$fh>; return @seqs } |
348
|
|
|
|
|
|
|
1; |
349
|
|
|
|
|
|
|
__END__ |