SequenceReader/SequenceReaderString.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  : SequenceReaderString
00025 // File Name    : SequenceReaderString.cpp
00026 // Language     : C++
00027 // Module Author: Anthony J. Cox (ac2@sanger.ac.uk)
00028 
00029 // Description:
00030 
00031 // Includes:
00032 
00033 #include "SequenceReaderString.h"
00034 #include "SequenceEncoder.h"
00035 #include <string>
00036 
00037 // ### Function Definitions ###
00038 
00039 // Name:
00040 // Arguments:
00041 // TYPE  NAME  IN/OUT COMMENT
00042 // Returns: TYPE COMMENT
00043 
00044   // Function Name: getNextSequence
00045   // Arguments: WordSequence& (out), int (in)
00046   // Returns:   int
00047   // Read the set of sequence information from the string and parse it
00048   // into WordSequence format. Returns -1 if a problem, else the number of
00049   // valid base pairs in the final word of the sequence
00050 int SequenceReaderStringBase::getNextSequence
00051 ( WordSequence& nextSeq, int wordLength )
00052 {
00053 
00054       if (lastSequenceNumber_ != 0) 
00055       {
00056         monitoringStream_ 
00057           << "String already read - call rewind before trying to reread" 
00058           << endl;
00059         return -1;
00060       } // ~if
00061 
00062       lastSequenceNumber_++;
00063  
00064       pEncoder_->setWordLength(wordLength);
00065       pEncoder_->linkSeq(nextSeq);
00066 
00067       pEncoder_->encode
00068       ( sequenceString_ );
00069 
00070       pEncoder_->unlinkSeq();
00071     // If the last word is not completely full (as will be the case if
00072     // wordLength does not divide numBases) then shift the word so the
00073     // valid bases occupy the most significant bits of the word.
00074 
00075 
00076     lastSequenceNumber_ = 1;
00077 
00078     return nextSeq.getNumBasesInLast();
00079 
00080 } // ~getNextSequence
00081 
00082 // Everything now in SequenceReaderString.h! (made into a template)
00083 // TC 10.4.1
00084 // Everything now back in SequenceReaderString.cpp! 
00085 // Templates on gcc are pathetic! TC 14.1.2
00086 
00087 // End of file SequenceReaderString.cpp
00088 

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