Bio::FeatureIO
ptt
Toolbar
Summary
Bio::FeatureIO::ptt - read/write features in PTT format
Package variables
No package variables defined.
Included modules
Inherit
Synopsis
# read features
my $fin = Bio::FeatureIO->new(-file=>'genes.ptt', -format=>'ptt');
my @cds;
while (my $f = $fin->next_feature) {
push @cds, $f if $f->strand > 0;
}
# write features (NOT IMPLEMENTED)
my $fout = Bio::FeatureIO->new(-fh=>\*STDOUT, -format=>'ptt');
for my $f (@cds) {
$fout->write_feature($f);
}
Description
The PTT file format is a table of protein features.
It is used mainly by NCBI who produce PTT files for
all their published genomes found in
ftp://ftp.ncbi.nih.gov/genomes/.
It has the following format:
Line 1
Description of sequence to which the features belong
eg. "Leptospira interrogans chromosome II, complete sequence - 0..358943"
It is usually equivalent to the DEFINITION line of a Genbank file,
with the length of the sequence appended. It is unclear why "0" is
used as a starting range, it should be "1".
Line 2
Number of feature lines in the table
eg. "367 proteins"
Line 3
Column headers, tab separated
eg. "Location Strand Length PID Gene Synonym Code COG Product"
Location : "begin..end" span of feature
Strand : "+" or "-"
Length : number of amino acids excluding the stop codon
PID : analogous to Genbank /db_xref="GI:xxxxxxxxx"
Gene : analogous to Genbank /gene="xxxx"
Synonym : analogous to Genbank /locus_tag="xxxx"
Synonym : analogous to Genbank /locus_tag="xxxx"
COG : CDD COG code with COG letter categories appended
Product : analogous to Genbank /product="xxxx"
Line 4 onwards
Feature lines, nine columns, tab separated, "-" used for empty fields
eg. "2491..3423 + 310 24217063 metF LB002 - COG0685E 5,10-methylenetetrahydrofolate reductase"
Methods
Methods description
Title : _initialize Function: Reading? parses the header of the input Writing? |
Title : next_feature Usage : $io->next_feature() Function: read the next feature from the PTT file Example : Args : Returns : Bio::SeqFeatureI object |
Title : write_feature Usage : $io->write_feature($feature) Function: write a Bio::SeqFeature object in PTT format with no header Example : Args : Bio::SeqFeature object Returns : |
Title : description Usage : $obj->description($newval) Function: set/get the PTT file description for/from line one Example : Returns : value of description (a scalar) Args : on set, new value (a scalar or undef, optional) |
Title : protein_count Usage : $obj->protein_count($newval) Function: set/get the PTT protein count for/from line two Example : Args : on set, new value (a scalar or undef, optional) Returns : value of protein_count (a scalar) |
Methods code
sub _initialize
{ my($self,%arg) = @_;
$self->SUPER::_initialize(%arg);
if ($self->mode eq 'r') {
my $desc = $self->_readline();
chomp $desc;
$self->description($desc);
my $line = $self->_readline();
$line =~ m/^(\d+) proteins/ or $self->throw("Invalid protein count"); $self->protein_count($1);
$self->_readline();
}} |
sub next_feature
{ my $self = shift;
$self->mode eq 'r' || return;
my $line = $self->_readline() or return; chomp $line;
my @col = split m/\t/, $line; @col==$NUM_COL or $self->throw("Too many columns for PTT line");
$col[0] =~ m/(\d+)\.\.(\d+)/ or $self->throw("Invalid location (column 1)"); my $feat = Bio::SeqFeature::Generic->new(-start=>$1, -end=>$2, -primary=>'CDS');
$col[1] =~ m/^([+-])$/ or $self->throw("Invalid strand (column 2)"); $feat->strand($1 eq '+' ? +1 : -1);
for my $i (2 .. $NUM_COL-1) {
$feat->add_tag_value($NAME_OF{$i}, $col[$i]) if $col[$i] ne '-';
}
return $feat; } |
sub write_feature
{ my($self,$feat) = @_;
$self->throw("Only Bio::SeqFeature::Generic or Bio::SeqFeature::Annotated objects are writeable")
unless ( $feat->isa('Bio::SeqFeature::Generic') || $feat->isa('Bio::SeqFeature::Annotated') );
my ($len,$pid,$gene,$synonym,$code,$cog,$product) = qw(- - - - - - -);
my $start = $feat->start;
my $end = $feat->end;
my $loc = "$start..$end";
my $strand = $feat->strand == 1 ? '+' : '-';
$len = int(($end - $start)/3);
$product = join ' ',$feat->get_tag_values("product") if ($feat->has_tag("product"));
$pid = join ' ',$feat->get_tag_values("protein_id") if ($feat->has_tag("protein_id"));
$code = join ' ',$feat->get_tag_values("codon_start") if ($feat->has_tag("codon_start"));
$self->_print(join("\t",($loc,$strand,$len,$pid,$gene,$synonym,$code,$cog,$product)) . "\n");
$self->write_feature($_) foreach $feat->get_SeqFeatures(); } |
sub description
{ my $self = shift;
return $self->{'description'} = shift if @_;
return $self->{'description'};} |
sub protein_count
{ my $self = shift;
return $self->{'protein_count'} = shift if @_;
return $self->{'protein_count'};
}
1;} |
General documentation
User feedback is an integral part of the evolution of this and other
Bioperl modules. Send your comments and suggestions preferably to
the Bioperl mailing list. Your participation is much appreciated.
bioperl-l@bioperl.org - General discussion
http://bioperl.org/wiki/Mailing_lists - About the mailing lists
Please direct usage questions or support issues to the mailing list:
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.
Report bugs to the Bioperl bug tracking system to help us keep track
of the bugs and their resolution. Bug reports can be submitted via
the web:
https://redmine.open-bio.org/projects/bioperl/
| AUTHOR - Torsten Seemann | Top |
Email torsten.seemann AT infotech.monash.edu.au
Based on bed.pm and gff.pm by Allen Day.
The rest of the documentation details each of the object methods.
Internal methods are usually preceded with a _