bpp-seq3  3.0.0
bpp::PhredPhd Class Referenceabstract

The phd sequence file format from phred software. More...

#include <Bpp/Seq/Io/PhredPhd.h>

+ Inheritance diagram for bpp::PhredPhd:
+ Collaboration diagram for bpp::PhredPhd:

Public Member Functions

 PhredPhd ()
 Build a new PhredPhd object. More...
 
virtual ~PhredPhd ()
 
bool nextSequence (std::istream &input, Sequence &seq, std::vector< size_t > &pos) const
 Read a SequenceWithQuality from stream and store chromatographic positions. More...
 
virtual bool nextSequence (std::istream &input, SequenceType &seq) const =0
 Read sequence from stream. More...
 
The ISequenceStream interface.
bool nextSequence (std::istream &input, Sequence &seq) const
 
The IOFormat interface.
const std::string getDataType () const
 
const std::string getFormatName () const
 
const std::string getFormatDescription () const
 

Private Member Functions

bool parseFile_ (std::istream &input, std::string &name, std::string &sequence, std::vector< int > &qual, std::vector< size_t > &pos) const
 Global file parser. More...
 
bool parseDNA_ (std::istream &input, std::string &sequence, std::vector< int > &qual, std::vector< size_t > &pos) const
 Parse the DNA part of the file. More...
 

Detailed Description

The phd sequence file format from phred software.

This class read DNA SequenceWithQuality from phd files produced by the phred program from the University of Washington.

Usage
// Creating a SequenceWithQuality object
DNA alpha;
SequenceWithQuality seq(&alpha);
std::vector<int> pos;
// Create a PhredPhd parser
// Opening the file
std::ifstream in("my_sequence.phd");
// Read the sequence
pp.nextSequence(in, seq, pos);
// Close the file
in.close();
PhredPhd()
Build a new PhredPhd object.
Definition: PhredPhd.h:50
Author
Sylvain Gaillard

Definition at line 44 of file PhredPhd.h.

Constructor & Destructor Documentation

◆ PhredPhd()

bpp::PhredPhd::PhredPhd ( )
inline

Build a new PhredPhd object.

Definition at line 50 of file PhredPhd.h.

◆ ~PhredPhd()

virtual bpp::PhredPhd::~PhredPhd ( )
inlinevirtual

Definition at line 52 of file PhredPhd.h.

Member Function Documentation

◆ getDataType()

const std::string bpp::PhredPhd::getDataType ( ) const
inlinevirtual

Implements bpp::IOFormat.

Definition at line 89 of file PhredPhd.h.

◆ getFormatDescription()

const std::string bpp::PhredPhd::getFormatDescription ( ) const
inlinevirtual

Implements bpp::IOFormat.

Definition at line 91 of file PhredPhd.h.

◆ getFormatName()

const std::string bpp::PhredPhd::getFormatName ( ) const
inlinevirtual

Implements bpp::IOFormat.

Definition at line 90 of file PhredPhd.h.

◆ nextSequence() [1/3]

bool PhredPhd::nextSequence ( std::istream &  input,
Sequence seq 
) const

Definition at line 18 of file PhredPhd.cpp.

◆ nextSequence() [2/3]

bool PhredPhd::nextSequence ( std::istream &  input,
Sequence seq,
std::vector< size_t > &  pos 
) const

Read a SequenceWithQuality from stream and store chromatographic positions.

A more complete parser that read a SequenceWithQuality and store the position of each base call on the chromatogram in a vector of int.

Parameters
inputThe stream to read.
seqThe sequence to fill.
posThe vector of positions to fill.
Exceptions
ExceptionIOException and Sequence related exceptions.

Definition at line 26 of file PhredPhd.cpp.

References parseFile_(), bpp::Sequence::setContent(), bpp::AbstractCoreSequence::setName(), and bpp::SequenceWithQuality::setQualities().

◆ nextSequence() [3/3]

template<class SequenceType >
virtual bool bpp::TemplateISequenceStream< SequenceType >::nextSequence ( std::istream &  input,
SequenceType &  seq 
) const
pure virtualinherited

Read sequence from stream.

Read one sequence from a stream.

Parameters
inputThe stream to read.
seqThe sequence to fill.
Returns
true if a sequence was read or false if not.
Exceptions
ExceptionIOExecption and Sequence related Exceptions.

◆ parseDNA_()

bool PhredPhd::parseDNA_ ( std::istream &  input,
std::string &  sequence,
std::vector< int > &  qual,
std::vector< size_t > &  pos 
) const
private

Parse the DNA part of the file.

Read the DNA part until ‘END_DNA’ or EOF.

Parameters
inputThe stream to read
sequenceThe string to store the sequence
qualThe vector to store qualities
posThe vector to store positions

Definition at line 94 of file PhredPhd.cpp.

References bpp::StringTokenizer::getToken(), bpp::StringTokenizer::hasMoreToken(), bpp::StringTokenizer::numberOfRemainingTokens(), bpp::TextTools::toInt(), and bpp::TextTools::toUpper().

Referenced by parseFile_().

◆ parseFile_()

bool PhredPhd::parseFile_ ( std::istream &  input,
std::string &  name,
std::string &  sequence,
std::vector< int > &  qual,
std::vector< size_t > &  pos 
) const
private

Global file parser.

Parameters
inputThe stream to read
nameThe string to store the sequence name
sequenceThe string to store the sequence
qualThe vector to store qualities
posThe vector to store positions

Definition at line 56 of file PhredPhd.cpp.

References bpp::StringTokenizer::getToken(), bpp::StringTokenizer::hasMoreToken(), and parseDNA_().

Referenced by nextSequence().


The documentation for this class was generated from the following files: