/usr/share/perl5/Bio/SeqIO/kegg.pm is in libbio-perl-perl 1.6.923-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 | #
# BioPerl module for Bio::SeqIO::kegg
#
# Please direct questions and support issues to <bioperl-l@bioperl.org>
#
# Cared for by Allen Day <allenday@ucla.edu>
#
# Copyright Allen Day
#
# You may distribute this module under the same terms as perl itself
# POD documentation - main docs before the code
=head1 NAME
Bio::SeqIO::kegg - KEGG sequence input/output stream
=head1 SYNOPSIS
# It is probably best not to use this object directly, but
# rather go through the SeqIO handler system. Go:
use Bio::SeqIO;
$stream = Bio::SeqIO->new(-file => $filename, -format => 'KEGG');
while ( my $seq = $stream->next_seq() ) {
# do something with $seq
}
=head1 DESCRIPTION
This class transforms KEGG gene records into Bio::Seq objects.
=head2 Mapping of record properties to object properties
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.
=over 4
=item 'ENTRY'
$seq->primary_id
=item 'NAME'
$seq->display_id
=item 'DEFINITION'
$seq->annotation->get_Annotations('description');
=item 'ORTHOLOG'
grep {$_->database eq 'KO'} $seq->annotation->get_Annotations('dblink')
=item 'CLASS'
grep {$_->database eq 'PATH'}
$seq->annotation->get_Annotations('dblink')
=item 'POSITION'
FIXME, NOT IMPLEMENTED
=item 'PATHWAY'
for my $pathway ( $seq->annotation->get_Annotations('pathway') ) {
#
}
=item 'DBLINKS'
$seq->annotation->get_Annotations('dblink')
=item 'CODON_USAGE'
FIXME, NOT IMPLEMENTED
=item 'AASEQ'
$seq->translate->seq
=item 'NTSEQ'
$seq-E<gt>seq
=back
=head1 FEEDBACK
=head2 Mailing Lists
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://bioperl.org/wiki/Mailing_lists - About the mailing lists
=head2 Support
Please direct usage questions or support issues to the mailing list:
I<bioperl-l@bioperl.org>
rather than to the module maintainer directly. Many experienced and
reponsive experts will be able look at the problem and quickly
address it. Please include a thorough description of the problem
with code and data examples if at all possible.
=head2 Reporting Bugs
Report bugs to the Bioperl bug tracking system to help us keep track
the bugs and their resolution. Bug reports can be submitted via the web:
https://redmine.open-bio.org/projects/bioperl/
=head1 AUTHOR - Allen Day
Email allenday@ucla.edu
=head1 APPENDIX
The rest of the documentation details each of the object
methods. Internal methods are usually preceded with a _
=cut
# Let the code begin...
package Bio::SeqIO::kegg;
use strict;
use Bio::SeqFeature::Generic;
use Bio::Species;
use Bio::Seq::SeqFactory;
use Bio::Annotation::Collection;
use Bio::Annotation::Comment;
use Bio::Annotation::DBLink;
use base qw(Bio::SeqIO);
sub _initialize {
my($self,@args) = @_;
$self->SUPER::_initialize(@args);
# hash for functions for decoding keys.
$self->{'_func_ftunit_hash'} = {};
if( ! defined $self->sequence_factory ) {
$self->sequence_factory(Bio::Seq::SeqFactory->new
(-verbose => $self->verbose(),
-type => 'Bio::Seq::RichSeq'));
}
}
=head2 next_seq
Title : next_seq
Usage : $seq = $stream->next_seq()
Function: returns the next sequence in the stream
Returns : Bio::Seq::RichSeq object
Args :
=cut
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;
# initialize; we may come here because of starting over
@features = ();
$annotation = undef;
@acc = ();
$species = undef;
%params = (-verbose => $self->verbose); # reset hash
local($/) = "///\n";
$buffer = $self->_readline();
return if( !defined $buffer ); # end of file
$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;
}
# changing to split method to get entry_ids that include
# sequence version like Whatever.1
my(undef,$entry_id,$entry_seqtype,$entry_species) =
split(' ',$FIELDS{ENTRY});
my($name);
if ($FIELDS{NAME}) {
($name) = $FIELDS{NAME} =~ /^NAME\s+(.+)$/;
}
my( $definition, $aa_length, $aa_seq, $nt_length, $nt_seq );
if(( exists $FIELDS{DEFINITION} ) and ( $FIELDS{DEFINITION} =~ /^DEFINITION/ )) {
($definition) = $FIELDS{DEFINITION} =~ /^DEFINITION\s+(.+)$/s;
$definition =~ s/\s+/ /gs;
}
if(( exists $FIELDS{AASEQ} ) and ( $FIELDS{AASEQ} =~ /^AASEQ/ )) {
($aa_length,$aa_seq) = $FIELDS{AASEQ} =~ /^AASEQ\s+(\d+)\n(.+)$/s;
$aa_seq =~ s/\s+//g;
}
if(( exists $FIELDS{NTSEQ} ) and ( $FIELDS{NTSEQ} =~ /^NTSEQ/ )) {
($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));
$annotation->add_Annotation('aa_seq',
Bio::Annotation::Comment->new(-text => $aa_seq));
my($ortholog_db,$ortholog_id,$ortholog_desc);
if ($FIELDS{ORTHOLOG}) {
($ortholog_db,$ortholog_id,$ortholog_desc) = $FIELDS{ORTHOLOG}
=~ /^ORTHOLOG\s+(\S+):\s+(\S+)\s+(.*?)$/;
$annotation->add_Annotation('dblink',Bio::Annotation::DBLink->new(
-database => $ortholog_db,
-primary_id => $ortholog_id,
-comment => $ortholog_desc) );
}
if($FIELDS{MOTIF}){
$FIELDS{MOTIF} =~ s/^MOTIF\s+//;
while($FIELDS{MOTIF} =~/\s*?(\S+):\s+(.+?)$/mg){
my $db = $1;
my $ids = $2;
foreach my $id (split(/\s+/, $ids)){
$annotation->add_Annotation('dblink',Bio::Annotation::DBLink->new(
-database =>$db,
-primary_id => $id,
-comment => "") );
}
}
}
if($FIELDS{PATHWAY}) {
$FIELDS{PATHWAY} =~ s/^PATHWAY\s+//;
while($FIELDS{PATHWAY} =~ /\s*PATH:\s+(.+)$/mg){
$annotation->add_Annotation('pathway',
Bio::Annotation::Comment->new(-text => "$1"));
}
}
if($FIELDS{POSITION}) {
$FIELDS{POSITION} =~ s/^POSITION\s+//;
$annotation->add_Annotation('position',
Bio::Annotation::Comment->new(-text => $FIELDS{POSITION}));
}
if ($FIELDS{CLASS}) {
$FIELDS{CLASS} =~ s/^CLASS\s+//;
$FIELDS{'CLASS'} =~ s/\n//g;
while($FIELDS{CLASS} =~ /(.*?)\[(\S+):(\S+)\]/g){
my ($pathway,$db,$id) = ($1,$2,$3);
$pathway =~ s/\s+/ /g;
$pathway =~ s/\s$//g;
$pathway =~ s/^\s+//;
$annotation->add_Annotation('pathway',
Bio::Annotation::Comment->new(-text => $pathway));
$annotation->add_Annotation('dblink',Bio::Annotation::DBLink->new(
-database => $db, -primary_id => $id));
}
}
if($FIELDS{DBLINKS}) {
$FIELDS{DBLINKS} =~ s/^DBLINKS/ /;
while($FIELDS{DBLINKS} =~ /\s+(\S+):\s+(\S+)\n?/gs){ ### modified
$annotation->add_Annotation('dblink',Bio::Annotation::DBLink->new(
-database => $1, -primary_id => $2)) if $1;
}
}
$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;
}
=head2 write_seq
Title : write_seq
Note : write_seq() is not implemented for KEGG format output.
=cut
sub write_seq {
shift->throw("write_seq() not implemented for KEGG format output.");
}
1;
|