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

# gnFileSource Class Reference

gnFileSource is a standard interface to all file based sources of genetic information. More...

`#include <gnFileSource.h>`

Inheritance diagram for gnFileSource:

List of all members.

## Public Member Functions
| gnFileSource ()
| gnFileSource (const gnFileSource &gnfs)
virtual | ~gnFileSource ()
virtual gnFileSource * | Clone () const=0
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 gnFilter * | GetFilter () 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.
virtual gnFileContig * | GetFileContig (const uint32 contigI) const=0
| Returns a pointer to the file contig corresponding to contigI or null if none exists.
virtual uint32 | GetContigListLength () const=0
| Get the number of sequence contigs in this source.
virtual boolean | HasContig (const string &name) const=0
| Looks for a contig by name.
virtual uint32 | GetContigID (const string &name) const=0
| Get a contig index by name.
virtual string | GetContigName (const uint32 i) const=0
| Get the name of the specified contig.
virtual gnSeqI | GetContigSeqLength (const uint32 i) const=0
| Get the total number of base pairs in the specified contig.
virtual boolean | SeqRead (const gnSeqI start, char *buf, uint32 &bufLen, const uint32 contigI=ALL_CONTIGS)=0
| Gets sequence data from this source.
virtual gnGenomeSpec * | GetSpec () const=0
| Get the annotated sequence data as a gnGenomeSpec.
## Protected Member Functions
void | DetermineNewlineType ()
## Protected Attributes
string | m_openString
ifstream | m_ifstream
const gnFilter * | m_pFilter
gnNewlineType | m_newlineType
uint32 | m_newlineSize
## Private Member Functions
virtual boolean | ParseStream (istream &fin)=0

## Detailed Description

gnFileSource is a standard interface to all file based sources of genetic information.

All file source classes are derived from this class.

Definition at line 27 of file gnFileSource.h.

## Constructor & Destructor Documentation

gnFileSource::gnFileSource | ( |  | ) | `[inline]`

| Definition at line 30 of file gnFileSource.h.

gnFileSource::gnFileSource | ( | const gnFileSource & | gnfs | ) |

| Definition at line 18 of file gnFileSource.cpp. References m_ifstream, m_newlineSize, m_newlineType, m_openString, and m_pFilter.

virtual gnFileSource::~gnFileSource | ( |  | ) | `[inline, virtual]`

| Definition at line 32 of file gnFileSource.h.

## Member Function Documentation

virtual gnFileSource* gnFileSource::Clone | ( |  | ) | const`[pure virtual]`

| Implements gnBaseSource. Implemented in gnABISource, gnDNXSource, gnFASSource, gnGBKSource, gnRAWSource, and gnSEQSource.

void gnFileSource::Close | ( |  | ) | `[virtual]`

  | 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(), m_ifstream, and Throw_gnEx.

void gnFileSource::DetermineNewlineType | ( |  | ) | `[protected]`

| Definition at line 74 of file gnFileSource.cpp. References gnNewlineMac, gnNewlineUnix, gnNewlineWindows, m_ifstream, m_newlineSize, and m_newlineType. Referenced by gnGBKSource::ParseStream(), and gnFASSource::ParseStream().

virtual uint32 gnBaseSource::GetContigID | ( | const string & | name | ) | const`[pure virtual, inherited]`

  | 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. Implemented in gnABISource, gnDataBaseSource, gnDNXSource, gnFASSource, gnGBKSource, gnRAWSource, and gnSEQSource. Referenced by gnDNXSource::ParseStream().

virtual uint32 gnBaseSource::GetContigListLength | ( |  | ) | const`[pure virtual, inherited]`

| Get the number of sequence contigs in this source. Returns: The number of contigs in this source. Implemented in gnABISource, gnDataBaseSource, gnDNXSource, gnFASSource, gnGBKSource, gnRAWSource, and gnSEQSource. Referenced by gnFASSource::Write().

virtual string gnBaseSource::GetContigName | ( | const uint32 | i | ) | const`[pure virtual, inherited]`

  | 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. Implemented in gnABISource, gnDataBaseSource, gnDNXSource, gnFASSource, gnGBKSource, gnRAWSource, and gnSEQSource. Referenced by gnFASSource::Write().

virtual gnSeqI gnBaseSource::GetContigSeqLength | ( | const uint32 | i | ) | const`[pure virtual, inherited]`

  | 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. Implemented in gnABISource, gnDataBaseSource, gnDNXSource, gnFASSource, gnGBKSource, gnRAWSource, and gnSEQSource. Referenced by gnSourceSpec::GetSourceLength(), and gnFASSource::Write().

virtual gnFileContig* gnFileSource::GetFileContig | ( | const uint32 | contigI | ) | const`[pure virtual]`

| Returns a pointer to the file contig corresponding to contigI or null if none exists. Implemented in gnABISource, gnDNXSource, gnFASSource, gnGBKSource, gnRAWSource, and gnSEQSource.

const gnFilter * gnFileSource::GetFilter | ( |  | ) | const`[inline, virtual]`

| 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 m_pFilter.

string gnFileSource::GetOpenString | ( |  | ) | const`[inline, virtual]`

| 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 m_openString.

virtual gnGenomeSpec* gnBaseSource::GetSpec | ( |  | ) | const`[pure virtual, inherited]`

| 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. Implemented in gnABISource, gnDataBaseSource, gnDNXSource, gnFASSource, gnGBKSource, gnRAWSource, and gnSEQSource. Referenced by gnSequence::LoadSource(), gnSEQSource::Write(), gnRAWSource::Write(), gnGBKSource::Write(), and gnDNXSource::Write().

virtual boolean gnBaseSource::HasContig | ( | const string & | name | ) | const`[pure virtual, inherited]`

  | 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. Implemented in gnABISource, gnDataBaseSource, gnDNXSource, gnFASSource, gnGBKSource, gnRAWSource, and gnSEQSource.

void gnFileSource::Open | ( |  | ) | `[virtual]`

  | 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(), m_ifstream, m_openString, and Throw_gnEx.

void gnFileSource::Open | ( | string | openString | ) | `[virtual]`

  | 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(), m_ifstream, m_openString, ParseStream(), and Throw_gnEx.

virtual boolean gnFileSource::ParseStream | ( | istream & | fin | ) | `[private, pure virtual]`

| Implemented in gnABISource, gnDNXSource, gnFASSource, gnGBKSource, gnRAWSource, and gnSEQSource. Referenced by Open().

boolean gnFileSource::Read | ( | const uint64 | pos,
|  | char * | buf,
|  | uint32 & | bufLen
| ) | `[virtual]`

  | 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 m_ifstream. Referenced by gnRAWSource::SeqRead().

virtual boolean gnBaseSource::SeqRead | ( | const gnSeqI | start,
|  | char * | buf,
|  | uint32 & | bufLen,
|  | const uint32 | contigI = ALL_CONTIGS
| ) | `[pure virtual, inherited]`

  | 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. Implemented in gnABISource, gnDataBaseSource, gnDNXSource, gnFASSource, gnGBKSource, gnRAWSource, and gnSEQSource. Referenced by gnSourceSpec::Read(), and gnFASSource::Write().

void gnFileSource::SetFilter | ( | gnFilter * | filter | ) | `[inline, virtual]`

  | 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 m_pFilter, NullPointer(), and Throw_gnEx.

## Member Data Documentation

ifstream gnFileSource::m_ifstream`[protected]`

| Definition at line 53 of file gnFileSource.h. Referenced by Close(), DetermineNewlineType(), gnFileSource(), Open(), gnSEQSource::ParseStream(), gnRAWSource::ParseStream(), gnGBKSource::ParseStream(), gnFASSource::ParseStream(), Read(), gnSEQSource::SeqRead(), gnGBKSource::SeqRead(), gnFASSource::SeqRead(), gnSEQSource::SeqStartPos(), gnGBKSource::SeqStartPos(), gnFASSource::SeqStartPos(), gnABISource::~gnABISource(), gnDNXSource::~gnDNXSource(), gnFASSource::~gnFASSource(), gnGBKSource::~gnGBKSource(), gnRAWSource::~gnRAWSource(), and gnSEQSource::~gnSEQSource().

uint32 gnFileSource::m_newlineSize`[protected]`

| Definition at line 56 of file gnFileSource.h. Referenced by DetermineNewlineType(), gnFileSource(), gnGBKSource::ParseStream(), gnFASSource::ParseStream(), and gnGBKSource::SeqStartPos().

gnNewlineType gnFileSource::m_newlineType`[protected]`

| Definition at line 55 of file gnFileSource.h. Referenced by DetermineNewlineType(), and gnFileSource().

string gnFileSource::m_openString`[protected]`

| Definition at line 52 of file gnFileSource.h. Referenced by GetOpenString(), gnABISource::gnABISource(), gnFASSource::gnFASSource(), gnFileSource(), gnGBKSource::gnGBKSource(), gnRAWSource::gnRAWSource(), gnSEQSource::gnSEQSource(), and Open().

const gnFilter* gnFileSource::m_pFilter`[protected]`

| Definition at line 54 of file gnFileSource.h. Referenced by GetFilter(), gnABISource::gnABISource(), gnDNXSource::gnDNXSource(), gnFASSource::gnFASSource(), gnFileSource(), gnGBKSource::gnGBKSource(), gnSEQSource::gnSEQSource(), gnSEQSource::ParseStream(), gnRAWSource::ParseStream(), gnGBKSource::ParseStream(), gnFASSource::ParseStream(), gnSEQSource::SeqRead(), gnGBKSource::SeqRead(), gnFASSource::SeqRead(), gnSEQSource::SeqStartPos(), gnGBKSource::SeqStartPos(), gnFASSource::SeqStartPos(), and SetFilter().

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

- gnFileSource.h
- gnFileSource.cpp