Bio-FeatureIO
view release on metacpan or search on metacpan
lib/Bio/FeatureIO/ptt.pm view on Meta::CPAN
Returns : Bio::SeqFeatureI object
=cut
sub next_feature {
my $self = shift;
$self->mode eq 'r' || return; # returns if can't read next_feature when we're in write mode
my $line = $self->_readline() or return; # returns if end of file, no more features?
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;
( run in 1.452 second using v1.01-cache-2.11-cpan-62a16548d74 )