Bio::SeqIO
kegg
Summary
Bio::SeqIO::kegg - KEGG sequence input/output stream
Package variables
No package variables defined.
Included modules
Inherit
Synopsis
#It is probably best not to use this object directly, but
#rather go through the SeqIO handler system. Go:
$stream = Bio::SeqIO->new(-file => $filename, -format => 'KEGG');
while ( my $seq = $stream->next_seq() ) {
# do something with $seq
}
Description
This class transforms KEGG gene records into Bio::Seq objects.
This section is supposed to document which sections and properties of
a KEGG databank record end up where in the Bioperl object model. It
is far from complete and presently focuses only on those mappings
which may be non-obvious. $seq in the text refers to the
Bio::Seq::RichSeqI implementing object returned by the parser for each
record.
'ENTRY'
$seq->primary_id
'NAME'
$seq->display_id
'DEFINITION'
$seq->annotation->get_Annotations('description');
'ORTHOLOG'
grep {$_->database eq 'KO'} $seq->annotation->get_Annotations('dblink')
'CLASS'
grep {$_->database eq 'PATH'} $seq->annotation->get_Annotations('dblink')
'POSITION'
FIXME, NOT IMPLEMENTED
'DBLINKS'
$seq->annotation->get_Annotations('dblink')
'CODON_USAGE'
FIXME, NOT IMPLEMENTED
'AASEQ'
$seq->translate->seq
'NTSEQ'
$seq->seq
Methods
Methods description
Title : next_seq
Usage : $seq = $stream->next_seq()
Function: returns the next sequence in the stream
Returns : Bio::Seq::RichSeq object
Args : |
Methods code
sub _initialize
{ my($self,@args) = @_;
$self->SUPER::_initialize(@args);
$self->{'_func_ftunit_hash'} = {};
if( ! defined $self->sequence_factory ) {
$self->sequence_factory(new Bio::Seq::SeqFactory
(-verbose => $self->verbose(),
-type => 'Bio::Seq::RichSeq'));
}} |
sub next_seq
{ my ($self,@args) = @_;
my $builder = $self->sequence_builder();
my $seq;
my %params;
my $buffer;
my (@acc, @features);
my ($display_id, $annotation);
my $species;
@features = ();
$annotation = undef;
@acc = ();
$species = undef;
%params = (-verbose => $self->verbose); local($/) = "///\n";
$buffer = $self->_readline();
return undef if( !defined $buffer ); $buffer =~ /^ENTRY/ ||
$self->throw("KEGG stream with bad ENTRY line. Not KEGG in my book. Got '$buffer'");
my %FIELDS;
my @chunks = split /\n(?=\S)/, $buffer;
foreach my $chunk (@chunks){
my($key) = $chunk =~ /^(\S+)/;
$FIELDS{$key} = $chunk;
}
my($entry_id,$entry_seqtype,$entry_species) = $FIELDS{ENTRY} =~ /^ENTRY\s+(\d+)\s+(\S+)\s+(\S+)\s*$/;
my($name) = $FIELDS{NAME} =~ /^NAME\s+(.+)$/;
my($definition) = $FIELDS{DEFINITION} =~ /^DEFINITION\s+(.+)$/s;
$definition =~ s/\s+/ /gs;
my($aa_length,$aa_seq) = $FIELDS{AASEQ} =~ /^AASEQ\s+(\d+)\n(.+)$/s;
$aa_seq =~ s/\s+//g;
my($nt_length,$nt_seq) = $FIELDS{NTSEQ} =~ /^NTSEQ\s+(\d+)\n(.+)$/s;
$nt_seq =~ s/\s+//g;
$annotation = Bio::Annotation::Collection->new();
$annotation->add_Annotation('description',Bio::Annotation::Comment->new(-text => $definition));
my($ortholog_db,$ortholog_id,$ortholog_desc) = $FIELDS{ORTHOLOG} =~ /^ORTHOLOG\s+(\S+):\s+(\S+)\s+(\S*)\s*$/;
$annotation->add_Annotation('dblink',Bio::Annotation::DBLink->new(-database => $ortholog_db,
-primary_id => $ortholog_id,
-comment => $ortholog_desc
)
);
$FIELDS{CLASS} =~ s/^CLASS\s+//;
while($FIELDS{CLASS} =~ /.+?\[(\S+):(\S+)\]/gs){
$annotation->add_Annotation('dblink',Bio::Annotation::DBLink->new(-database => $1, -primary_id => $2));
}
$FIELDS{DBLINKS} =~ s/^DBLINKS/ /;
while($FIELDS{DBLINKS} =~ /\s+(\S+):\s+(\S+)\n/gs){
$annotation->add_Annotation('dblink',Bio::Annotation::DBLink->new(-database => $1, -primary_id => $2));
}
$params{'-alphabet'} = 'dna';
$params{'-seq'} = $nt_seq;
$params{'-display_id'} = $name;
$params{'-accession_number'} = $entry_id;
$params{'-species'} = Bio::Species->new(-common_name => $entry_species);
$params{'-annotation'} = $annotation;
$builder->add_slot_value(%params);
$seq = $builder->make_object();
return $seq; } |
General documentation
User feedback is an integral part of the evolution of this
and other Bioperl modules. Send your comments and suggestions preferably
to one of the Bioperl mailing lists.
Your participation is much appreciated.
bioperl-l@bioperl.org - General discussion
http://www.bioperl.org/MailList.shtml - About the mailing lists
Report bugs to the Bioperl bug tracking system to help us keep track
the bugs and their resolution.
Bug reports can be submitted via email or the web:
bioperl-bugs@bio.perl.org
http://bugzilla.bioperl.org/
The rest of the documentation details each of the object
methods. Internal methods are usually preceded with a _