Bio::SeqIO
strider
Summary
Bio::SeqIO::strider - DNA strider sequence input/output stream
Package variables
Privates (from "my" definitions)
%type2alphabet = reverse %alphabet2type
$size_F_HEADER = 112
%alphabet2type = ( dna => 1, rna => 3, protein => 4, )
$c = new Convert::Binary::C ( ByteOrder => 'BigEndian', Alignment => 2 )
$headerdef;
Included modules
Inherit
Synopsis
Do not use this module directly. Use it via the Bio::SeqIO class.
Description
This object can transform Bio::Seq objects to and from strider
'binary' format, as documented in the strider manual, in which the
first 112 bytes are a header, following by the sequence, followed by a
sequence description.
Note: it does NOT assign any sequence identifier, since they are not
contained in the byte stream of the file; the Strider application
simply displays the name of the file on disk as the name of the
sequence. The caller should set the id, probably based on the name of
the file (after possibly cleaning up whitespace, which ought not to be
used as the id in most applications).
Note: the strider 'comment' is mapped to the BioPerl 'description'
(since there is no other text field, and description maps to defline
text).
Methods
Methods description
Title : next_seq Usage : $seq = $stream->next_seq() Function: returns the next sequence in the stream Returns : Bio::Seq object Args : NONE |
Title : write_seq Usage : $stream->write_seq(@seq) Function: writes the $seq object into the stream Returns : 1 for success and 0 for error Args : array of 1 to n Bio::PrimarySeqI objects |
Methods code
sub _initialize
{ my($self,@args) = @_;
$self->SUPER::_initialize(@args);
unless ( defined $self->sequence_factory ) {
$self->sequence_factory(Bio::Seq::SeqFactory->new(-verbose => $self->verbose(),
-type => 'Bio::Seq::RichSeq'));
}} |
sub next_seq
{ my( $self ) = @_;
my $fh = $self->_fh;
my ($header,$sequence,$fulldesc);
read $fh,$header,$size_F_HEADER or return ; $self->throw("required $size_F_HEADER bytes while reading strider header in " . $self->{'_file'} . " but found: " . length($header))
unless $size_F_HEADER == length($header);
my $headerdata = $c->unpack('F_HEADER',$header) or return;
read $fh,$sequence,$headerdata->{nLength};
read $fh,$fulldesc,$headerdata->{com_length};
$fulldesc =~ s/\cM/ /g; my $seq = $self->sequence_factory->create(
-seq => $sequence,
-desc => $fulldesc,
-alphabet => $type2alphabet{$headerdata->{type}} || 'dna',
);
return $seq; } |
sub write_seq
{ my ($self,@seq) = @_;
my $fh = $self->_fh() || *STDOUT; foreach my $seq (@seq) {
$self->throw("Did not provide a valid Bio::PrimarySeqI object")
unless defined $seq && ref($seq) && $seq->isa('Bio::PrimarySeqI');
my $headerdata = $c->pack('F_HEADER',{
versionNb => 0,
type => $alphabet2type{$seq->alphabet} || $alphabet2type{dna},
topology => $seq->is_circular ? 1 : 0,
nLength => $seq->length,
nMinus => 0,
com_length => length($seq->desc || ""),
});
print $fh $headerdata, $seq->seq() || "" , $seq->desc || "";
} } |
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://bioperl.org/wiki/Mailing_lists - 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 the
web:
http://bugzilla.open-bio.org/
| AUTHORS - Malcolm Cook | Top |
Modelled after Bio::SeqIO::fasta by Ewan Birney <birney@ebi.ac.uk> and
Lincoln Stein <lstein@cshl.org>
The rest of the documentation details each of the object
methods. Internal methods are usually preceded with a _