SamQuerySeqWithRefHelper.h

00001 /*
00002  *  Copyright (C) 2010  Regents of the University of Michigan
00003  *
00004  *   This program is free software: you can redistribute it and/or modify
00005  *   it under the terms of the GNU General Public License as published by
00006  *   the Free Software Foundation, either version 3 of the License, or
00007  *   (at your option) any later version.
00008  *
00009  *   This program is distributed in the hope that it will be useful,
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *   GNU General Public License for more details.
00013  *
00014  *   You should have received a copy of the GNU General Public License
00015  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 
00018 #ifndef __SAM_QUERY_SEQ_WITH_REF_HELPER_H__
00019 #define __SAM_QUERY_SEQ_WITH_REF_HELPER_H__
00020 
00021 #include <stdint.h>
00022 
00023 #include "SamRecord.h"
00024 #include "GenomeSequence.h"
00025 
00026 // This class contains the match/mismatch information
00027 // between the reference and a read for a single base.
00028 class SamSingleBaseMatchInfo
00029 {
00030 public:
00031     // More types can be added later as needed.
00032     enum Type {UNKNOWN, MATCH, MISMATCH};
00033 
00034     SamSingleBaseMatchInfo();
00035     ~SamSingleBaseMatchInfo();
00036 
00037 
00038     // Get info from this class.
00039     Type getType();
00040     int32_t getQueryIndex();
00041 
00042     // Set info in this class.
00043     void setType(Type newType);
00044     void setQueryIndex(int32_t queryIndex);
00045 
00046 private:
00047     Type myType;
00048     int32_t myQueryIndex;
00049 };
00050 
00051 // Iterates through the query and compare with reference.
00052 // NOTE: References to the GenomeSequence and SamRecord are stored, the objects
00053 // are not copied, so they must remain valid as long as this class is used.
00054 class SamQuerySeqWithRefIter
00055 {
00056 public:
00057     SamQuerySeqWithRefIter(SamRecord& record, GenomeSequence& refSequence,
00058                            bool forward = true);
00059     virtual ~SamQuerySeqWithRefIter();
00060     
00061     // Reset to start at the beginning of the record.
00062     // This will re-read values from SamRecord, so can be used if it has
00063     // changed to contain information for a new record.
00064     // forward = true means to start from the beginning and go to the end.
00065     // forward = false means to start from the end and go to the beginning.
00066     bool reset(bool forward = true);
00067     
00068     bool getNextMatchMismatch(SamSingleBaseMatchInfo& matchMismatchInfo);
00069     
00070 private:
00071 
00072     SamQuerySeqWithRefIter();
00073     
00074     void nextIndex();
00075 
00076     // Tells whether or not the two bases are equal
00077     bool areEqual(char base1, char base2);
00078 
00079     SamRecord& myRecord;
00080     GenomeSequence& myRefSequence;
00081     Cigar* myCigar;
00082     uint32_t myStartOfReadOnRefIndex;
00083     int32_t myQueryIndex;
00084     bool myForward;
00085 };
00086 
00087 #endif
Generated on Wed Nov 17 15:38:27 2010 for StatGen Software by  doxygen 1.6.3