Bio::SeqIO phd
SummaryIncluded librariesPackage variablesSynopsisDescriptionGeneral documentationMethods
Toolbar
WebCvs
Summary
Bio::SeqIO::phd - phd file input/output stream
Package variables
Privates (from "my" definitions)
$dumper = new Dumpvalue()
Included modules
Bio::Annotation::Collection
Bio::Annotation::Comment
Bio::Seq::RichSeq
Bio::Seq::SeqFactory
Dumpvalue
Inherit
Bio::SeqIO
Synopsis
Do not use this module directly. Use it via the Bio::SeqIO class.
Description
This object can transform .phd files (from Phil Green's phred basecaller)
to and from Bio::Seq::Quality objects. The phd format is described in section 10
at this url: http://www.phrap.org/phredphrap/phred.html
Methods
_initialize
No description
Code
next_seqDescriptionCode
write_headerDescriptionCode
write_seqDescriptionCode
Bio::Seq::Quality::attribute
No description
Code
Bio::Seq::Quality::chromat_file
No description
Code
Bio::Seq::Quality::abi_thumbprint
No description
Code
Bio::Seq::Quality::phred_version
No description
Code
Bio::Seq::Quality::call_method
No description
Code
Bio::Seq::Quality::quality_levels
No description
Code
Bio::Seq::Quality::trace_array_min_index
No description
Code
Bio::Seq::Quality::trace_array_max_index
No description
Code
Bio::Seq::Quality::chem
No description
Code
Bio::Seq::Quality::dye
No description
Code
Bio::Seq::Quality::time
No description
Code
Bio::Seq::Quality::touch
No description
Code
Methods description
next_seqcode    nextTop
 Title   : next_seq()
Usage : $swq = $stream->next_seq()
Function: returns the next phred sequence in the stream
Returns : Bio::Seq::Quality object
Args : NONE
write_headercodeprevnextTop
 Title   : write_header()
Usage : $seqio->write_header()
Function: Write out the header (BEGIN_COMMENTS .. END_COMMENT) part of a phd file
Returns : nothing
Args : a Bio::Seq::Quality object
Notes : These are the comments that reside in the header of a phd file
at the present time. If not provided by the Bio::Seq::Quality object,
the following default values will be used:
CHROMAT_FILE : $swq->id() ABI_THUMBPRINT : 0 PHRED_VERSION : 0.980904.e CALL_METHOD : phred QUALITY_LEVELS : 99 TIME : TRACE_ARRAY_MIN_INDEX : 0 TRACE_ARRAY_MAX_INDEX : unknown CHEM : unknown DYE : unknown
write_seqcodeprevnextTop
 Title   : write_seq()
Usage : $seqio->write_seq($swq);
Function: Write out a phd file.
Returns : Nothing.
Args : a Bio::Seq::Quality object
Methods code
_initializedescriptionprevnextTop
sub _initialize {
  my($self,@args) = @_;
  $self->SUPER::_initialize(@args);
  if( ! defined $self->sequence_factory ) {
      $self->sequence_factory(Bio::Seq::SeqFactory->new
                  (-verbose => $self->verbose(),
                   -type => 'Bio::Seq::Quality'));
  }
}
next_seqdescriptionprevnextTop
sub next_seq {
    my ($self,@args) = @_;
    my $seq;
    while (my $entry = $self->_readline) {
        chomp $entry;
        if ($entry =~ /^BEGIN_SEQUENCE\s+(\S+)/) {
            if (defined $seq) {
                # done with current sequence
$self->_pushback($entry); last; } else { # start new sequence
my $id = $1; $seq = $self->sequence_factory->create( -id => $id, -primary_id => $id, -display_id => $id, ); } } elsif ($entry =~ /^BEGIN_COMMENT/) { my $collection = Bio::Annotation::Collection->new; while ($entry = $self->_readline) { chomp $entry; if ($entry =~ /^(\w+):\s+(.+)$/) { my ($name, $content) = ($1, $2); my $comment = Bio::Annotation::Comment->new( -text => $content, -tagname => $name ); $collection->add_Annotation('header',$comment); } elsif ($entry =~ /^END_COMMENT/) { $seq->Bio::Seq::RichSeq::annotation($collection); last; } } } elsif ($entry =~ /^BEGIN_DNA/) { my $dna = ''; my @qualities = (); my @trace_indices = (); while ($entry = $self->_readline) { chomp $entry; if ( $entry =~ /(\S+)\s+(\S+)\s+(\S+)/ ) { # add nucleotide and quality scores to sequence
$dna .= $1; push @qualities,$2; push(@trace_indices,$3) if defined $3; # required for phd file
} elsif ($entry =~ /^END_DNA/) { # end of sequence, save it
$seq->seq($dna); $seq->qual(\@qualities); $seq->trace(\@trace_indices); last; } } } elsif ($entry =~ /^END_SEQUENCE/) { # the sequence may be over, but some other info can come after
next; } elsif ($entry =~ /^WR{/) { # Whole-Read items
# Programs like Consed or Autofinish add it to phd file. See doc:
# http://www.phrap.org/consed/distributions/README.16.0.txt
#my ($type, $nane, $date, $time) = split(' ',$self->_readline);
#my $extra_info = '';
#while ($entry = $self->_readline) {
# chomp $entry;
# last if ($entry =~ /\}/);
# $extra_info .= $entry;
#}
### fea: save WR somewhere? but where?
} } return $seq;
}
write_headerdescriptionprevnextTop
sub write_header {
    my ($self, $swq) = @_;
    $self->_print("\nBEGIN_COMMENT\n\n");
    #defaults
my $time = localtime(); for ([CHROMAT_FILE =>$swq->attribute('CHROMAT_FILE')], [ABI_THUMBPRINT => 0], [PHRED_VERSION => '0.980904.e'], [CALL_METHOD => 'phred'], [QUALITY_LEVELS => '99'], [TIME => $time], [TRACE_ARRAY_MIN_INDEX => 0], [TRACE_ARRAY_MAX_INDEX => 'unknown'], [CHEM => 'unknown'], [DYE => 'unknown']) { $swq->attribute($_->[0],$_->[1]) unless $swq->attribute($_->[0]); } my @annot = $swq->annotation->get_Annotations('header'); for (@annot) { $self->_print($_->tagname,": ",$_->text,"\n"); } $self->_print("\nEND_COMMENT\n\n"); $self->flush if $self->_flush_on_write && defined $self->_fh; return 1;
}
write_seqdescriptionprevnextTop
sub write_seq {
    my ($self,$swq) = @_;

    $self->throw("You must pass a Bio::Seq::Quality object to write_seq")
        unless (ref($swq) eq "Bio::Seq::Quality");

    $self->throw("Can't create the phd because the sequence and the quality in the Quality object are of different lengths.")
        unless $swq->length() ne 'DIFFERENT';

    $self->_print("BEGIN_SEQUENCE ".$swq->id()."\n");
    $self->write_header($swq);
    $self->_print("BEGIN_DNA\n");
    for my $curr(1 ..  $swq->length()) {
    $self->_print (sprintf("%s %s %s\n",
                   uc($swq->baseat($curr)),
                   $swq->qualat($curr),
                   $swq->trace_index_at($curr)));
    }
    $self->_print ("END_DNA\n\nEND_SEQUENCE\n");

    $self->flush if $self->_flush_on_write && defined $self->_fh;
    return 1;
}
Bio::Seq::Quality::attributedescriptionprevnextTop
sub Bio::Seq::Quality::attribute {
    my ($self, $name, $value) = @_;
    my $collection = $self->annotation;
    my @annot = $collection->get_Annotations('header');
    my %attribute;
    my $annot;
    for (@annot) {
        $attribute{$_->tagname} = $_->display_text;
        $annot = $_ if $_->tagname eq $name;
    }


    unless (defined $attribute{$name}) { #new comment
my $comment = Bio::Annotation::Comment->new(-text => $value || 'unknown'); $comment->tagname($name); $collection->add_Annotation('header',$comment); return; } return $attribute{$name} unless (defined $value);#get
#print "ATTRIBUTE ",$annot," $name $attribute{$name}\n";
$annot->text($value); #set
return;
}
Bio::Seq::Quality::chromat_filedescriptionprevnextTop
sub Bio::Seq::Quality::chromat_file {
    my ($self,$arg) =  @_;
    return $self->attribute('CHROMAT_FILE',$arg);
}
Bio::Seq::Quality::abi_thumbprintdescriptionprevnextTop
sub Bio::Seq::Quality::abi_thumbprint {
    my ($self,$arg) =  @_;
    return $self->attribute('ABI_THUMBPRINT',$arg);
}
Bio::Seq::Quality::phred_versiondescriptionprevnextTop
sub Bio::Seq::Quality::phred_version {
    my ($self,$arg) =  @_;
    return $self->attribute('PHRED_VERSION', $arg);
}
Bio::Seq::Quality::call_methoddescriptionprevnextTop
sub Bio::Seq::Quality::call_method {
    my ($self,$arg) =  @_;
    return $self->attribute('CALL_METHOD', $arg);
}
Bio::Seq::Quality::quality_levelsdescriptionprevnextTop
sub Bio::Seq::Quality::quality_levels {
    my ($self,$arg) =  @_;
    return $self->attribute('QUALITY_LEVELS', $arg);
}
Bio::Seq::Quality::trace_array_min_indexdescriptionprevnextTop
sub Bio::Seq::Quality::trace_array_min_index {
    my ($self,$arg) =  @_;
    return $self->attribute('TRACE_ARRAY_MIN_INDEX', $arg);
}
Bio::Seq::Quality::trace_array_max_indexdescriptionprevnextTop
sub Bio::Seq::Quality::trace_array_max_index {
    my ($self,$arg) =  @_;
    return $self->attribute('TRACE_ARRAY_MAX_INDEX', $arg);
}
Bio::Seq::Quality::chemdescriptionprevnextTop
sub Bio::Seq::Quality::chem {
    my ($self,$arg) =  @_;
    return $self->attribute('CHEM', $arg);
}
Bio::Seq::Quality::dyedescriptionprevnextTop
sub Bio::Seq::Quality::dye {
    my ($self,$arg) =  @_;
    return $self->attribute('DYE', $arg);
}
Bio::Seq::Quality::timedescriptionprevnextTop
sub Bio::Seq::Quality::time {
    my ($self,$arg) =  @_;
    return $self->attribute('TIME', $arg);
}
Bio::Seq::Quality::touchdescriptionprevnextTop
sub Bio::Seq::Quality::touch {
    my $time = localtime();
    shift->attribute('TIME',$time);
    return;
}

1;
}
General documentation
FEEDBACKTop
Mailing ListsTop
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
Support Top
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.
Reporting BugsTop
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/
AUTHOR Chad MatsallaTop
Chad Matsalla bioinformatics@dieselwurks.com
CONTRIBUTORSTop
Jason Stajich, jason@bioperl.org
Jean-Marc Frigerio, Frigerio@pierroton.inra.fr
APPENDIXTop
The rest of the documentation details each of the object
methods. Internal methods are usually preceded with a _
attributeTop
 Title   : attribute()
Usage : swq->attribute(name[,value]);
Function: Get/Set the name attribute.
Returns : a string if 1 param, nothing else.
Args : a name or a pair name, value
chromat_fileTop
 Title   : chromat_file
Usage : swq->chromat_file([filename]);
Function: Get/Set the CHROMAT_FILE attribute.
Returns : a string if 1 param, nothing else.
Args : none or a filename
abi_thumbprintTop
 Title   : abi_thumbprint
Usage : swq->abi_thumbprint([value]);
Function: Get/Set the ABI_THUMBPRINT attribute.
Returns : a string if 1 param, nothing else.
Args : none or a value
phred_versionTop
 Title   : phred_version
Usage : swq->phred_version([value]);
Function: Get/Set the PHRED_VERSION attribute.
Returns : a string if 1 param, nothing else.
Args : none or a value
call_methodTop
 Title   : call_method
Usage : swq->call_method([value]);
Function: Get/Set the CALL_METHOD attribute.
Returns : a string if 1 param, nothing else.
Args : none or a value
quality_levelsTop
 Title   : quality_levels
Usage : swq->quality_levels([value]);
Function: Get/Set the quality_levels attribute.
Returns : a string if 1 param, nothing else.
Args : none or a value
trace_array_min_indexTop
 Title   : trace_array_min_index
Usage : swq->trace_array_min_index([value]);
Function: Get/Set the trace_array_min_index attribute.
Returns : a string if 1 param, nothing else.
Args : none or a value
trace_array_max_indexTop
 Title   : trace_array_max_index
Usage : swq->trace_array_max_index([value]);
Function: Get/Set the trace_array_max_index attribute.
Returns : a string if 1 param, nothing else.
Args : none or a value
chemTop
 Title   : chem
Usage : swq->chem([value]);
Function: Get/Set the chem attribute.
Returns : a string if 1 param, nothing else.
Args : none or a value
dyeTop
 Title   : dye
Usage : swq->dye([value]);
Function: Get/Set the dye attribute.
Returns : a string if 1 param, nothing else.
Args : none or a value
timeTop
 Title   : time
Usage : swq->time([value]);
Function: Get/Set the time attribute.
Returns : a string if 1 param, nothing else.
Args : none or a value
touchTop
 Title   : touch
Usage : swq->touch();
Function: Set the time attribute to current time.
Returns : nothing
Args : none