SequenceReader/SequenceReaderFastq.cpp

Go to the documentation of this file.
00001 
00002 // #######################################################################
00003 
00004 // SSAHA : Sequence Search and Alignment by Hashing Algorithm
00005 // Version 3.2, released 1st March 2004
00006 // Copyright (c) Genome Research 2002
00007 
00008 // SSAHA is free software; you can redistribute it and/or modify 
00009 // it under the terms of version 2 of the GNU General Public Licence
00010 // as published by the Free Software Foundation.
00011  
00012 // This program is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 // GNU General Public Licence for more details.
00016  
00017 // You should have received a copy of the GNU General Public Licence
00018 // along with this program; if not, write to the Free Software
00019 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00020 // or see the on-line version at http://www.gnu.org/copyleft/gpl.txt
00021 
00022 // #######################################################################
00023 
00024 // Module Name  : SequenceReaderFastq
00025 // File Name    : SequenceReaderFastq.cpp
00026 // Language     : C++
00027 // Module Author: Anthony J. Cox (ac2@sanger.ac.uk)
00028 
00029 // Description:
00030 
00031 // Includes:
00032 
00033 #include "SequenceReader.h"
00034 #include "SequenceReaderFastq.h"
00035 #include "SequenceEncoder.h"
00036 #include <strstream>
00037 #include <fstream>
00038 
00039 // ### Function Definitions ###
00040 
00041 // Name:
00042 // Arguments:
00043 // TYPE  NAME  IN/OUT COMMENT
00044 // Returns: TYPE COMMENT
00045 
00046 SequenceReaderFastq::SequenceReaderFastq
00047 ( const char* fileName, 
00048   SequenceEncoder* pEncoder,
00049   ostream& monitoringStream  ) : 
00050 SequenceReaderFile
00051 ( fileName, '@', '+', pEncoder->clone(), monitoringStream )
00052 {
00053   monitoringStream_ << "constructing SequenceReaderFastq" << endl;
00054 } // ~constructor
00055 
00056 SequenceReaderFastq::SequenceReaderFastq
00057 ( const char* fileName, ostream& monitoringStream ) : 
00058 SequenceReaderFile
00059 ( fileName, '@', '+', new SequenceEncoderDNA(12), monitoringStream )
00060 {
00061   monitoringStream_ << "constructing SequenceReaderFastq" << endl;
00062 } // ~constructor
00063 
00064 SequenceReaderFastq::SequenceReaderFastq( const SequenceReaderFastq& rhs):
00065 SequenceReaderFile((SequenceReaderFile)rhs)
00066 {
00067   monitoringStream_ << "copy constructing SequenceReaderFastq" << endl;
00068 }
00069 
00070 
00071 
00072 
00073 SequenceReaderFastq::~SequenceReaderFastq()
00074 {
00075   monitoringStream_ << "destructing SequenceReaderFastq" << endl;
00076 } // ~destructor
00077 
00078 SequenceReaderFastqProtein::SequenceReaderFastqProtein
00079 ( const char* fileName, ostream& monitoringStream ) :
00080 SequenceReaderFastq
00081 ( fileName, new SequenceEncoderProtein(5), monitoringStream )
00082 {
00083   monitoringStream_ << "constructing SequenceReaderFastqProtein" << endl;
00084 } // ~constructor
00085 
00086 
00087 
00088   // Function Name: getNextSequence
00089   // Arguments: WordSequence& (out), int (in)
00090   // Returns:   bool
00091   // Read the next set of sequence information from the file and parse it
00092   // into WordSequence format
00093   int SequenceReaderFastq::getNextSequence
00094   ( WordSequence& nextSeq, int wordLength )
00095   {
00096     DEBUG_L2( "SequenceReaderFastq::getNextSequence" );
00097     if (SequenceReaderFile::getNextSequence( nextSeq, wordLength ) == -1 )
00098     {
00099       return -1;
00100     } // ~if
00101 
00102     // Now spool past the quality info 
00103     
00104     //    char firstOfLine;
00105     // `Interesting' standard library quirk: even though we are exclusively
00106     // reading chars firstOfLine must be an int (cos EOF is an int not a char)
00107     int firstOfLine;
00108     while (1==1)
00109     {
00110       firstOfLine = pInputFileStream_->peek();
00111       if (    ( firstOfLine == EOF ) 
00112            || ( (char)firstOfLine == seqStartChar_)) 
00113       {      
00114         return nextSeq.getNumBasesInLast();
00115       } // ~if 
00116       pInputFileStream_->getline( inputBuffer_, inputBufferSize_, '\n' );
00117 
00118     } // ~while
00119     return nextSeq.getNumBasesInLast(); 
00120 
00121   } // ~SequenceReaderFastq::getNextSequence
00122 
00123 
00124 
00125 
00126 // End of file SequenceReaderFastq.cpp
00127 
00128 
00129 
00130 

Generated on Fri Dec 21 13:12:16 2007 for ssaha by  doxygen 1.5.2