157
my ($self,@args) = @_;
158
my $builder = $self->sequence_builder();
163
my (@acc, @features);
164
my ($display_id, $annotation);
167
# initialize; we may come here because of starting over
172
%params = (-verbose => $self->verbose); # reset hash
175
$buffer = $self->_readline();
177
return undef if( !defined $buffer ); # end of file
178
$buffer =~ /^ENTRY/ ||
179
$self->throw("KEGG stream with bad ENTRY line. Not KEGG in my book. Got '$buffer'");
182
my @chunks = split /\n(?=\S)/, $buffer;
184
foreach my $chunk (@chunks){
185
my($key) = $chunk =~ /^(\S+)/;
186
$FIELDS{$key} = $chunk;
189
my($entry_id,$entry_seqtype,$entry_species) = $FIELDS{ENTRY} =~ /^ENTRY\s+(\d+)\s+(\S+)\s+(\S+)\s*$/;
191
my($name) = $FIELDS{NAME} =~ /^NAME\s+(.+)$/;
193
my($definition) = $FIELDS{DEFINITION} =~ /^DEFINITION\s+(.+)$/s;
194
$definition =~ s/\s+/ /gs;
196
my($aa_length,$aa_seq) = $FIELDS{AASEQ} =~ /^AASEQ\s+(\d+)\n(.+)$/s;
198
my($nt_length,$nt_seq) = $FIELDS{NTSEQ} =~ /^NTSEQ\s+(\d+)\n(.+)$/s;
201
$annotation = Bio::Annotation::Collection->new();
202
$annotation->add_Annotation('description',Bio::Annotation::Comment->new(-text => $definition));
204
my($ortholog_db,$ortholog_id,$ortholog_desc) = $FIELDS{ORTHOLOG} =~ /^ORTHOLOG\s+(\S+):\s+(\S+)\s+(\S*)\s*$/;
205
$annotation->add_Annotation('dblink',Bio::Annotation::DBLink->new(-database => $ortholog_db,
206
-primary_id => $ortholog_id,
207
-comment => $ortholog_desc
211
$FIELDS{CLASS} =~ s/^CLASS\s+//;
212
while($FIELDS{CLASS} =~ /.+?\[(\S+):(\S+)\]/gs){
213
$annotation->add_Annotation('dblink',Bio::Annotation::DBLink->new(-database => $1, -primary_id => $2));
216
$FIELDS{DBLINKS} =~ s/^DBLINKS/ /;
217
while($FIELDS{DBLINKS} =~ /\s+(\S+):\s+(\S+)\n/gs){
218
$annotation->add_Annotation('dblink',Bio::Annotation::DBLink->new(-database => $1, -primary_id => $2));
161
my ($self,@args) = @_;
162
my $builder = $self->sequence_builder();
167
my (@acc, @features);
168
my ($display_id, $annotation);
171
# initialize; we may come here because of starting over
176
%params = (-verbose => $self->verbose); # reset hash
179
$buffer = $self->_readline();
181
return if( !defined $buffer ); # end of file
182
$buffer =~ /^ENTRY/ ||
183
$self->throw("KEGG stream with bad ENTRY line. Not KEGG in my book. Got $buffer'");
186
my @chunks = split /\n(?=\S)/, $buffer;
188
foreach my $chunk (@chunks){
189
my($key) = $chunk =~ /^(\S+)/;
190
$FIELDS{$key} = $chunk;
193
# changing to split method to get entry_ids that include
194
# sequence version like Whatever.1
195
my(undef,$entry_id,$entry_seqtype,$entry_species) =
196
split(' ',$FIELDS{ENTRY});
200
($name) = $FIELDS{NAME} =~ /^NAME\s+(.+)$/;
203
my( $definition, $aa_length, $aa_seq, $nt_length, $nt_seq );
205
if(( exists $FIELDS{DEFINITION} ) and ( $FIELDS{DEFINITION} =~ /^DEFINITION/ )) {
206
($definition) = $FIELDS{DEFINITION} =~ /^DEFINITION\s+(.+)$/s;
207
$definition =~ s/\s+/ /gs;
209
if(( exists $FIELDS{AASEQ} ) and ( $FIELDS{AASEQ} =~ /^AASEQ/ )) {
210
($aa_length,$aa_seq) = $FIELDS{AASEQ} =~ /^AASEQ\s+(\d+)\n(.+)$/s;
213
if(( exists $FIELDS{NTSEQ} ) and ( $FIELDS{NTSEQ} =~ /^NTSEQ/ )) {
214
($nt_length,$nt_seq) = $FIELDS{NTSEQ} =~ /^NTSEQ\s+(\d+)\n(.+)$/s;
218
$annotation = Bio::Annotation::Collection->new();
220
$annotation->add_Annotation('description',
221
Bio::Annotation::Comment->new(-text => $definition));
223
$annotation->add_Annotation('aa_seq',
224
Bio::Annotation::Comment->new(-text => $aa_seq));
226
my($ortholog_db,$ortholog_id,$ortholog_desc);
227
if ($FIELDS{ORTHOLOG}) {
228
($ortholog_db,$ortholog_id,$ortholog_desc) = $FIELDS{ORTHOLOG}
229
=~ /^ORTHOLOG\s+(\S+):\s+(\S+)\s+(.*?)$/;
231
$annotation->add_Annotation('dblink',Bio::Annotation::DBLink->new(
232
-database => $ortholog_db,
233
-primary_id => $ortholog_id,
234
-comment => $ortholog_desc) );
238
$FIELDS{MOTIF} =~ s/^MOTIF\s+//;
239
while($FIELDS{MOTIF} =~/\s*?(\S+):\s+(.+?)$/mg){
242
foreach my $id (split(/\s+/, $ids)){
244
$annotation->add_Annotation('dblink',Bio::Annotation::DBLink->new(
252
if($FIELDS{PATHWAY}) {
253
$FIELDS{PATHWAY} =~ s/^PATHWAY\s+//;
254
while($FIELDS{PATHWAY} =~ /\s*PATH:\s+(.+)$/mg){
255
$annotation->add_Annotation('pathway',
256
Bio::Annotation::Comment->new(-text => "$1"));
260
if ($FIELDS{CLASS}) {
261
$FIELDS{CLASS} =~ s/^CLASS\s+//;
262
$FIELDS{'CLASS'} =~ s/\n//g;
263
while($FIELDS{CLASS} =~ /(.*?)\[(\S+):(\S+)\]/g){
264
my ($pathway,$db,$id) = ($1,$2,$3);
265
$pathway =~ s/\s+/ /g;
266
$pathway =~ s/\s$//g;
267
$pathway =~ s/^\s+//;
268
$annotation->add_Annotation('pathway',
269
Bio::Annotation::Comment->new(-text => $pathway));
271
$annotation->add_Annotation('dblink',Bio::Annotation::DBLink->new(
272
-database => $db, -primary_id => $id));
276
if($FIELDS{DBLINKS}) {
277
$FIELDS{DBLINKS} =~ s/^DBLINKS/ /;
278
while($FIELDS{DBLINKS} =~ /\s+(\S+):\s+(\S+)\n?/gs){ ### modified
279
$annotation->add_Annotation('dblink',Bio::Annotation::DBLink->new(
280
-database => $1, -primary_id => $2)) if $1;
221
284
$params{'-alphabet'} = 'dna';
222
285
$params{'-seq'} = $nt_seq;
223
286
$params{'-display_id'} = $name;
224
287
$params{'-accession_number'} = $entry_id;
225
$params{'-species'} = Bio::Species->new(-common_name => $entry_species);
288
$params{'-species'} = Bio::Species->new(
289
-common_name => $entry_species);
226
290
$params{'-annotation'} = $annotation;
228
292
$builder->add_slot_value(%params);