Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

gnGBKSource Class Reference

gnGBKSource is a GenBank sequence file reader. More...

#include <gnGBKSource.h>

Inheritance diagram for gnGBKSource:

gnFileSource gnBaseSource gnClone List of all members.

Public Member Functions

 gnGBKSource ()
 Empty Constructor, does nothing.

 gnGBKSource (const gnGBKSource &s)
 Clone Constructor copies the specified gnGBKSource.

 ~gnGBKSource ()
 Destructor, frees memory.

gnGBKSource * Clone () const
 Returns an exact copy of this class.

uint32 GetContigListLength () const
 Get the number of sequence contigs in this source.

boolean HasContig (const string &name) const
 Looks for a contig by name.

uint32 GetContigID (const string &name) const
 Get a contig index by name.

string GetContigName (const uint32 i) const
 Get the name of the specified contig.

gnSeqI GetContigSeqLength (const uint32 i) const
 Get the total number of base pairs in the specified contig.

boolean SeqRead (const gnSeqI start, char *buf, uint32 &bufLen, const uint32 contigI=ALL_CONTIGS)
 Gets sequence data from this source.

gnGenomeSpecGetSpec () const
 Get the annotated sequence data as a gnGenomeSpec.

gnFileContigGetFileContig (const uint32 contigI) const
 Returns a pointer to the file contig corresponding to contigI or null if none exists.

virtual void Open (string openString)
 Opens the source given in "openString" for reading.

virtual void Open ()
 Opens this source for reading.

virtual void Close ()
 Closes the file or connection this source is reading from.

virtual string GetOpenString () const
 Get the location of the source that is being used.

virtual const gnFilterGetFilter () const
 Get the filter currently being used to filter unwanted characters out of read sequences.

virtual void SetFilter (gnFilter *filter)
 Set the filter that will be used to filter unwanted characters out of the sequence data.

virtual boolean Read (const uint64 pos, char *buf, uint32 &bufLen)
 Gets raw input from this source.


Static Public Member Functions

boolean Write (gnSequence &seq, const string &filename)
 Writes the specified gnSequence to a .GBK file named "filename".

boolean Write (gnBaseSource *source, const string &filename)
 Writes the specified source to a .GBK file named "filename".


Protected Member Functions

void DetermineNewlineType ()

Protected Attributes

string m_openString
ifstream m_ifstream
const gnFilterm_pFilter
gnNewlineType m_newlineType
uint32 m_newlineSize

Private Member Functions

boolean SeqSeek (const gnSeqI start, const uint32 &contigI, uint64 &startPos, uint64 &readableBytes)
boolean SeqStartPos (const gnSeqI start, gnFileContig &contig, uint64 &startPos, uint64 &readableBytes)
boolean ParseStream (istream &fin)

Static Private Member Functions

string & Filler (uint32 length)
void FormatString (string &data, uint32 offset, uint32 width)
void WriteHeader (gnMultiSpec *spec, const string &hdr, ofstream &m_ofstream)

Private Attributes

gnGenomeSpecm_spec
vector< gnFileContig * > m_contigList

Detailed Description

gnGBKSource is a GenBank sequence file reader.

This class reads and writes the GenBank file format. gnGBKSource is used by gnSourceFactory to read files and should only be used directly when writing out files in GBK file format by calling gnGBKSource::Write( mySpec, "C:\mySeqFile.gbk");

Definition at line 50 of file gnGBKSource.h.


Constructor & Destructor Documentation

gnGBKSource::gnGBKSource  
 

Empty Constructor, does nothing.

Definition at line 23 of file gnGBKSource.cpp.

References DebugMsg(), gnFilter::fullDNASeqFilter(), gnFileSource::m_openString, and gnFileSource::m_pFilter.

Referenced by Clone().

gnGBKSource::gnGBKSource const gnGBKSource &    s
 

Clone Constructor copies the specified gnGBKSource.

Parameters:
s The gnGBKSource to copy.

Definition at line 31 of file gnGBKSource.cpp.

References m_contigList.

gnGBKSource::~gnGBKSource  
 

Destructor, frees memory.

Definition at line 39 of file gnGBKSource.cpp.

References m_contigList, and gnFileSource::m_ifstream.


Member Function Documentation

gnGBKSource * gnGBKSource::Clone   const [inline, virtual]
 

Returns an exact copy of this class.

Implements gnFileSource.

Definition at line 110 of file gnGBKSource.h.

References gnGBKSource().

void gnFileSource::Close   [virtual, inherited]
 

Closes the file or connection this source is reading from.

Exceptions:
IOStreamError if an error occurs closing the file.

Implements gnBaseSource.

Definition at line 56 of file gnFileSource.cpp.

References IOStreamFailed(), gnFileSource::m_ifstream, and Throw_gnEx.

void gnFileSource::DetermineNewlineType   [protected, inherited]
 

Definition at line 74 of file gnFileSource.cpp.

References gnNewlineMac, gnNewlineUnix, gnNewlineWindows, gnFileSource::m_ifstream, gnFileSource::m_newlineSize, and gnFileSource::m_newlineType.

Referenced by ParseStream(), and gnFASSource::ParseStream().

string& gnGBKSource::Filler uint32    length [static, private]
 

void gnGBKSource::FormatString string &    data,
uint32    offset,
uint32    width
[static, private]
 

Definition at line 252 of file gnGBKSource.cpp.

References uint32.

uint32 gnGBKSource::GetContigID const string &    name const [virtual]
 

Get a contig index by name.

If the source does not contain a contig by the specified name GetContigID returns UINT32_MAX.

Parameters:
name The name of the contig to look for.
Returns:
The index of the named contig or UINT32_MAX.

Implements gnBaseSource.

Definition at line 59 of file gnGBKSource.cpp.

References m_contigList, and uint32.

uint32 gnGBKSource::GetContigListLength   const [inline, virtual]
 

Get the number of sequence contigs in this source.

Returns:
The number of contigs in this source.

Implements gnBaseSource.

Definition at line 116 of file gnGBKSource.h.

References m_contigList, and uint32.

string gnGBKSource::GetContigName const uint32    i const [virtual]
 

Get the name of the specified contig.

Returns an empty string if the specified contig is out of range.

Parameters:
i The index of the contig or ALL_CONTIGS.
Returns:
The name of the contig or an empty string.

Implements gnBaseSource.

Definition at line 68 of file gnGBKSource.cpp.

References m_contigList.

gnSeqI gnGBKSource::GetContigSeqLength const uint32    i const [virtual]
 

Get the total number of base pairs in the specified contig.

Parameters:
i The index of the contig or ALL_CONTIGS.
Returns:
The length in base pairs of the specified contig.

Implements gnBaseSource.

Definition at line 76 of file gnGBKSource.cpp.

References gnMultiSpec::GetLength(), gnSeqI, GNSEQI_ERROR, m_contigList, and m_spec.

gnFileContig * gnGBKSource::GetFileContig const uint32    contigI const [virtual]
 

Returns a pointer to the file contig corresponding to contigI or null if none exists.

Implements gnFileSource.

Definition at line 545 of file gnGBKSource.cpp.

References m_contigList.

const gnFilter * gnFileSource::GetFilter   const [inline, virtual, inherited]
 

Get the filter currently being used to filter unwanted characters out of read sequences.

Returns:
A pointer to the gnFilter currently in use.

Implements gnBaseSource.

Definition at line 68 of file gnFileSource.h.

References gnFileSource::m_pFilter.

string gnFileSource::GetOpenString   const [inline, virtual, inherited]
 

Get the location of the source that is being used.

Returns:
The location string describing this source, usually a file name.

Implements gnBaseSource.

Definition at line 62 of file gnFileSource.h.

References gnFileSource::m_openString.

gnGenomeSpec * gnGBKSource::GetSpec   const [inline, virtual]
 

Get the annotated sequence data as a gnGenomeSpec.

GetSpec returns a gnGenomeSpec which contains the sequence, header, and feature data contained by this source.

Returns:
The annotated sequence data.

Implements gnBaseSource.

Definition at line 126 of file gnGBKSource.h.

References gnGenomeSpec::Clone(), and m_spec.

boolean gnGBKSource::HasContig const string &    name const [virtual]
 

Looks for a contig by name.

Returns true if it finds the contig, otherwise false.

Parameters:
name The name of the contig to look for.
Returns:
True if the named contig exists, false otherwise.

Implements gnBaseSource.

Definition at line 50 of file gnGBKSource.cpp.

References m_contigList, and uint32.

void gnFileSource::Open   [virtual, inherited]
 

Opens this source for reading.

Exceptions:
Will throw a FileNotOpened exception if the file was not found or was not accessible.

Implements gnBaseSource.

Definition at line 48 of file gnFileSource.cpp.

References FileNotOpened(), gnFileSource::m_ifstream, gnFileSource::m_openString, and Throw_gnEx.

void gnFileSource::Open string    openString [virtual, inherited]
 

Opens the source given in "openString" for reading.

Parameters:
openString The name of the source (file, network URL, or database) to open.
Exceptions:
Will throw a FileNotOpened exception if the file was not found or was not accessible. Will propagate a FileUnreadable exception if the file format was invalid.

Implements gnBaseSource.

Definition at line 29 of file gnFileSource.cpp.

References FileNotOpened(), gnFileSource::m_ifstream, gnFileSource::m_openString, gnFileSource::ParseStream(), and Throw_gnEx.

boolean gnGBKSource::ParseStream istream &    fin [private, virtual]
 

Implements gnFileSource.

Definition at line 552 of file gnGBKSource.cpp.

References gnFragmentSpec::AddFeature(), gnMultiSpec::AddHeader(), gnBaseFeature::AddLocation(), gnBaseFeature::AddQualifier(), gnGenomeSpec::AddSpec(), gnFragmentSpec::AddSpec(), Array< T >::data, gnFileSource::DetermineNewlineType(), ErrorMsg(), gnFragmentSpec::GetFeatureListLength(), gnMultiSpec::GetHeaderListLength(), gnContigSpec::GetLength(), gnBaseFeature::GetLocationListLength(), gnGenomeSpec::GetSpecListLength(), gnLocation::gnLocationType, gnSeqI, int32, gnFilter::IsValid(), gnLocation::LT_BetweenBases, gnLocation::LT_OneOf, gnLocation::LT_Standard, m_contigList, gnFileSource::m_ifstream, gnFileSource::m_newlineSize, gnFileSource::m_pFilter, m_spec, gnGenomeSpec::RemoveSpec(), SEQ_HEADER_NAME_LENGTH, SEQ_LOCUS_NAME_COLUMN, SEQ_LOCUS_NAME_LENGTH, SEQ_SUBTAG_COLUMN, gnBaseSpec::SetCircular(), gnContigSpec::SetLength(), gnBaseFeature::SetLocationType(), gnBaseSpec::SetName(), gnFileContig::SetName(), gnFileContig::SetRepeatSeqGap(), gnFileContig::SetSectEnd(), gnFileContig::SetSectStart(), gnFileContig::SetSeqLength(), gnContigSpec::SetSourceName(), uint32, and uint64.

boolean gnFileSource::Read const uint64    pos,
char *    buf,
uint32   bufLen
[virtual, inherited]
 

Gets raw input from this source.

Read will attempt to read "bufLen" bytes starting at "pos" directly from the source. It stores the data in "buf", and returns the actual number of bytes read in bufLen. Read will return false if a serious error occurs.

Parameters:
pos The position in the file to start reading.
buf The character array to store data into.
bufLen The number of bytes to read.
Returns:
True if the operation was successful.

Implements gnBaseSource.

Definition at line 63 of file gnFileSource.cpp.

References gnFileSource::m_ifstream.

Referenced by gnRAWSource::SeqRead().

boolean gnGBKSource::SeqRead const gnSeqI    start,
char *    buf,
uint32   bufLen,
const uint32    contigI = ALL_CONTIGS
[virtual]
 

Gets sequence data from this source.

SeqRead will attempt to read "bufLen" base pairs starting at "start", an offset into the sequence. Reading inside a specific contig can be accomplished by supplying the "contigI" parameter with a valid contig index. SeqRead stores the sequence data in "buf" and returns the actual number of bases read in "bufLen". SeqRead will return false if a serious error occurs.

Parameters:
start The base pair to start reading at.
buf The character array to store base pairs into.
bufLen The number of base pairs to read.
contigI The index of the contig to read or ALL_CONTIGS by default.
Returns:
True if the operation was successful.

Implements gnBaseSource.

Definition at line 87 of file gnGBKSource.cpp.

References Array< T >::data, gnSeqC, gnSeqI, gnFilter::IsValid(), m_contigList, gnFileSource::m_ifstream, gnFileSource::m_pFilter, SeqSeek(), uint32, and uint64.

boolean gnGBKSource::SeqSeek const gnSeqI    start,
const uint32   contigI,
uint64   startPos,
uint64   readableBytes
[private]
 

Definition at line 170 of file gnGBKSource.cpp.

References gnSeqI, m_contigList, SeqStartPos(), and uint64.

Referenced by SeqRead().

boolean gnGBKSource::SeqStartPos const gnSeqI    start,
gnFileContig   contig,
uint64   startPos,
uint64   readableBytes
[private]
 

Definition at line 197 of file gnGBKSource.cpp.

References Array< T >::data, ErrorMsg(), gnFileContig::GetSectStartEnd(), gnFileContig::HasRepeatSeqGap(), gnFilter::IsValid(), gnFileSource::m_ifstream, gnFileSource::m_newlineSize, gnFileSource::m_pFilter, uint32, and uint64.

Referenced by SeqSeek().

void gnFileSource::SetFilter gnFilter   filter [inline, virtual, inherited]
 

Set the filter that will be used to filter unwanted characters out of the sequence data.

Parameters:
filter The filter to remove unwanted characters from the sequence.
Exceptions:
NullPointer is thrown if the specified filter pointer is null.

Implements gnBaseSource.

Definition at line 74 of file gnFileSource.h.

References gnFileSource::m_pFilter, NullPointer(), and Throw_gnEx.

boolean gnGBKSource::Write gnBaseSource   source,
const string &    filename
[inline, static]
 

Writes the specified source to a .GBK file named "filename".

Parameters:
source The source to write out.
filename The name of the file to write.
Returns:
True if successful, false otherwise.

Definition at line 121 of file gnGBKSource.h.

References gnBaseSource::GetSpec(), and Write().

boolean gnGBKSource::Write gnSequence   seq,
const string &    filename
[static]
 

Writes the specified gnSequence to a .GBK file named "filename".

Parameters:
seq The gnSequence to write out.
filename The name of the file to write.
Returns:
True if successful, false otherwise.

Definition at line 304 of file gnGBKSource.cpp.

References BaseCount(), gnSequence::contigLength(), gnSequence::contigStart(), Array< T >::data, gnLocation::GetEnd(), gnFragmentSpec::GetFeature(), gnFragmentSpec::GetFeatureListLength(), gnBaseHeader::GetHeader(), gnMultiSpec::GetHeader(), gnMultiSpec::GetHeaderListLength(), gnBaseHeader::GetHeaderName(), gnMultiSpec::GetLength(), gnBaseFeature::GetLocation(), gnBaseFeature::GetLocationListLength(), gnBaseFeature::GetLocationType(), gnBaseQualifier::GetName(), gnBaseFeature::GetName(), gnBaseSpec::GetName(), gnBaseFeature::GetQualifier(), gnBaseFeature::GetQualifierListLength(), gnGenomeSpec::GetSpec(), gnSequence::GetSpec(), gnGenomeSpec::GetSpecListLength(), gnLocation::GetStart(), gnLocation::GetType(), gnBaseQualifier::GetValue(), gnLocation::gnLocationType, gnSeqC, gnSeqI, int64, gnBaseSpec::IsCircular(), gnLocation::IsEndBoundLonger(), gnLocation::IsEndBoundShorter(), gnLocation::IsStartBoundLonger(), gnLocation::IsStartBoundShorter(), gnLocation::LT_BetweenBases, gnLocation::LT_Complement, gnLocation::LT_Group, gnLocation::LT_OneOf, gnLocation::LT_Order, gnLocation::LT_Standard, SEQ_COLUMN_WIDTH, SEQ_FEATURE_LOC_OFFSET, SEQ_LOCUS_NAME_LENGTH, SEQ_LOCUS_SIZE_LENGTH, SEQ_SUBTAG_COLUMN, gnSequence::ToArray(), uint32, uintToString(), and WriteHeader().

Referenced by Write(), and gnDNXSource::Write().

void gnGBKSource::WriteHeader gnMultiSpec   spec,
const string &    hdr,
ofstream &    m_ofstream
[static, private]
 

Definition at line 293 of file gnGBKSource.cpp.

References gnBaseHeader::GetHeader(), gnMultiSpec::GetHeader(), and uint32.

Referenced by Write().


Member Data Documentation

vector< gnFileContig* > gnGBKSource::m_contigList [private]
 

Definition at line 106 of file gnGBKSource.h.

Referenced by GetContigID(), GetContigListLength(), GetContigName(), GetContigSeqLength(), GetFileContig(), gnGBKSource(), HasContig(), ParseStream(), SeqRead(), SeqSeek(), and ~gnGBKSource().

ifstream gnFileSource::m_ifstream [protected, inherited]
 

Definition at line 53 of file gnFileSource.h.

Referenced by gnFileSource::Close(), gnFileSource::DetermineNewlineType(), gnFileSource::gnFileSource(), gnFileSource::Open(), gnSEQSource::ParseStream(), gnRAWSource::ParseStream(), ParseStream(), gnFASSource::ParseStream(), gnFileSource::Read(), gnSEQSource::SeqRead(), SeqRead(), gnFASSource::SeqRead(), gnSEQSource::SeqStartPos(), SeqStartPos(), gnFASSource::SeqStartPos(), gnABISource::~gnABISource(), gnDNXSource::~gnDNXSource(), gnFASSource::~gnFASSource(), ~gnGBKSource(), gnRAWSource::~gnRAWSource(), and gnSEQSource::~gnSEQSource().

uint32 gnFileSource::m_newlineSize [protected, inherited]
 

Definition at line 56 of file gnFileSource.h.

Referenced by gnFileSource::DetermineNewlineType(), gnFileSource::gnFileSource(), ParseStream(), gnFASSource::ParseStream(), and SeqStartPos().

gnNewlineType gnFileSource::m_newlineType [protected, inherited]
 

Definition at line 55 of file gnFileSource.h.

Referenced by gnFileSource::DetermineNewlineType(), and gnFileSource::gnFileSource().

string gnFileSource::m_openString [protected, inherited]
 

Definition at line 52 of file gnFileSource.h.

Referenced by gnFileSource::GetOpenString(), gnABISource::gnABISource(), gnFASSource::gnFASSource(), gnFileSource::gnFileSource(), gnGBKSource(), gnRAWSource::gnRAWSource(), gnSEQSource::gnSEQSource(), and gnFileSource::Open().

const gnFilter* gnFileSource::m_pFilter [protected, inherited]
 

Definition at line 54 of file gnFileSource.h.

Referenced by gnFileSource::GetFilter(), gnABISource::gnABISource(), gnDNXSource::gnDNXSource(), gnFASSource::gnFASSource(), gnFileSource::gnFileSource(), gnGBKSource(), gnSEQSource::gnSEQSource(), gnSEQSource::ParseStream(), gnRAWSource::ParseStream(), ParseStream(), gnFASSource::ParseStream(), gnSEQSource::SeqRead(), SeqRead(), gnFASSource::SeqRead(), gnSEQSource::SeqStartPos(), SeqStartPos(), gnFASSource::SeqStartPos(), and gnFileSource::SetFilter().

gnGenomeSpec* gnGBKSource::m_spec [private]
 

Definition at line 105 of file gnGBKSource.h.

Referenced by GetContigSeqLength(), GetSpec(), and ParseStream().


The documentation for this class was generated from the following files:
Generated on Mon Feb 3 02:34:48 2003 for libGenome by doxygen1.3-rc3