BioPerl
view release on metacpan or search on metacpan
Bio/SeqIO/gbdriver.pm view on Meta::CPAN
$seqdata->{FEATURE_KEY} = $ann;
}
# throw back to top if seq is found to avoid regex
next PARSER if $ann eq 'ORIGIN';
} else {
($data = $line) =~ s{^\s+}{};
chomp $data;
}
my $delim = ($seqdata && $seqdata->{NAME} eq 'FEATURES') ? "\n" : ' ';
$seqdata->{$annkey} .= ($seqdata->{$annkey}) ? $delim.$data : $data;
}
}
=head2 write_seq
Title : write_seq
Usage : $stream->write_seq($seq)
Function: writes the $seq object (must be seq) to the stream
Returns : 1 for success and 0 for error
Args : array of 1 to n Bio::SeqI objects
=cut
sub write_seq {
shift->throw("Use Bio::SeqIO::genbank for output");
# maybe make a Writer class as well????
}
=head2 seqhandler
Title : seqhandler
Usage : $stream->seqhandler($handler)
Function: Get/Set the Bio::Seq::HandlerBaseI object
Returns : Bio::Seq::HandlerBaseI
Args : Bio::Seq::HandlerBaseI
=cut
sub seqhandler {
my ($self, $handler) = @_;
if ($handler) {
$self->throw("Not a Bio::HandlerBaseI") unless
ref($handler) && $handler->isa("Bio::HandlerBaseI");
$self->{'_seqhandler'} = $handler;
}
return $self->{'_seqhandler'};
}
#=head2 _process_features
#
# Title : _process_features
# Usage : $self->_process_features($seqdata)
# Function: Process feature data chunk into usable bits
# Returns :
# Args : data chunk
#
#=cut
sub _process_features {
my ($self, $seqdata) = @_;
my @ftlines = split m{\n}, $seqdata->{DATA};
delete $seqdata->{DATA};
# don't deal with balancing quotes for now; just get rid of them...
# Should we worry about checking whether these are balanced
# for round-tripping tests?
map { s{"}{}g } @ftlines;
# all sfs start with the location...
my $qual = 'LOCATION';
my $ct = 0;
for my $qualdata (@ftlines) {
if ($qualdata =~ m{^/([^=]+)=?(.+)?}) {
($qual, $qualdata) = ($1, $2);
$qualdata ||= ''; # for those qualifiers that have no data, like 'pseudo'
$ct = (exists $seqdata->{$qual}) ?
((ref($seqdata->{$qual})) ? scalar(@{ $seqdata->{$qual} }) : 1)
: 0 ;
}
my $delim = ($qual eq 'translation' || exists $FTQUAL_NO_QUOTE{$qual}) ?
'' : ' ';
# if more than one, turn into an array ref and append
if ($ct == 0) {
(exists $seqdata->{$qual}) ? ($seqdata->{$qual}.= $delim.$qualdata || '') :
($seqdata->{$qual} .= $qualdata || '');
} else {
if (!ref($seqdata->{$qual})) {
$seqdata->{$qual} = [$seqdata->{$qual}];
}
(exists $seqdata->{$qual}->[$ct]) ? (($seqdata->{$qual}->[$ct]) .= $delim.$qualdata) :
(($seqdata->{$qual}->[$ct]) .= $qualdata);
}
}
}
1;
__END__
( run in 0.583 second using v1.01-cache-2.11-cpan-d7a12ab2c7f )