Contains methods for converting between the query sequence and reference. More...
#include <SamQuerySeqWithRefHelper.h>
Static Public Member Functions | |
| static void | seqWithEquals (const char *currentSeq, int32_t seq0BasedPos, Cigar &cigar, const char *referenceName, const GenomeSequence &refSequence, std::string &updatedSeq) |
| Gets the sequence with '=' in any position where the sequence matches the reference. | |
| static void | seqWithoutEquals (const char *currentSeq, int32_t seq0BasedPos, Cigar &cigar, const char *referenceName, const GenomeSequence &refSequence, std::string &updatedSeq) |
| Gets the sequence converting '=' to the appropriate base using the reference. | |
Contains methods for converting between the query sequence and reference.
Definition at line 101 of file SamQuerySeqWithRefHelper.h.
| void SamQuerySeqWithRef::seqWithEquals | ( | const char * | currentSeq, | |
| int32_t | seq0BasedPos, | |||
| Cigar & | cigar, | |||
| const char * | referenceName, | |||
| const GenomeSequence & | refSequence, | |||
| std::string & | updatedSeq | |||
| ) | [static] |
Gets the sequence with '=' in any position where the sequence matches the reference.
NOTE: 'N' in both the sequence and the reference is not considered a match.
| currentSeq | sequence that should be converted | |
| seq0BasedPos | 0 based start position of currentSeq on the reference. | |
| cigar | cigar string for currentSeq (used for determining how the sequence aligns to the reference) | |
| referenceName | reference name associated with this sequence | |
| refSequence | reference sequence object | |
| updatedSeq | return parameter that this method sets to the current sequence, replacing any matches to the reference with '='. |
Definition at line 221 of file SamQuerySeqWithRefHelper.cpp.
References GenomeSequence::getGenomePosition().
Referenced by SamRecord::getSequence().
00227 { 00228 updatedSeq = currentSeq; 00229 00230 int32_t seqLength = updatedSeq.length(); 00231 int32_t queryIndex = 0; 00232 00233 uint32_t startOfReadOnRefIndex = 00234 refSequence.getGenomePosition(referenceName) + seq0BasedPos; 00235 00236 // Loop until the entire sequence has been updated. 00237 while(queryIndex < seqLength) 00238 { 00239 // Still more bases, look for matches. 00240 00241 // Get the reference offset for this read position. 00242 int32_t refOffset = cigar.getRefOffset(queryIndex); 00243 if(refOffset != Cigar::INDEX_NA) 00244 { 00245 // Both the reference and the read have a base, so get the bases. 00246 char readBase = currentSeq[queryIndex]; 00247 char refBase = refSequence[startOfReadOnRefIndex + refOffset]; 00248 00249 // If neither base is unknown and they are the same, count it 00250 // as a match. 00251 if(!BaseUtilities::isAmbiguous(readBase) && 00252 !BaseUtilities::isAmbiguous(refBase) && 00253 (BaseUtilities::areEqual(readBase, refBase))) 00254 { 00255 // Match. 00256 updatedSeq[queryIndex] = '='; 00257 } 00258 } 00259 // Increment the query index to the next position. 00260 ++queryIndex; 00261 continue; 00262 } 00263 }
| void SamQuerySeqWithRef::seqWithoutEquals | ( | const char * | currentSeq, | |
| int32_t | seq0BasedPos, | |||
| Cigar & | cigar, | |||
| const char * | referenceName, | |||
| const GenomeSequence & | refSequence, | |||
| std::string & | updatedSeq | |||
| ) | [static] |
Gets the sequence converting '=' to the appropriate base using the reference.
| currentSeq | sequence that should be converted | |
| seq0BasedPos | 0 based start position of currentSeq on the reference. | |
| cigar | cigar string for currentSeq (used for determining how the sequence aligns to the reference) | |
| referenceName | reference name associated with this sequence | |
| refSequence | reference sequence object | |
| updatedSeq | return parameter that this method sets to the current sequence, replacing any '=' with the base from the reference. |
Definition at line 266 of file SamQuerySeqWithRefHelper.cpp.
References GenomeSequence::getGenomePosition().
Referenced by SamRecord::getSequence().
00272 { 00273 updatedSeq = currentSeq; 00274 00275 int32_t seqLength = updatedSeq.length(); 00276 int32_t queryIndex = 0; 00277 00278 uint32_t startOfReadOnRefIndex = 00279 refSequence.getGenomePosition(referenceName) + seq0BasedPos; 00280 00281 // Loop until the entire sequence has been updated. 00282 while(queryIndex < seqLength) 00283 { 00284 // Still more bases, look for matches. 00285 00286 // Get the reference offset for this read position. 00287 int32_t refOffset = cigar.getRefOffset(queryIndex); 00288 if(refOffset != Cigar::INDEX_NA) 00289 { 00290 // Both the reference and the read have a base, so get the bases. 00291 char readBase = currentSeq[queryIndex]; 00292 char refBase = refSequence[startOfReadOnRefIndex + refOffset]; 00293 00294 // If the bases are equal, set the sequence to the reference 00295 // base. (Skips the check for ambiguous to catch a case where 00296 // ambiguous had been converted to a '=', and if both are ambiguous, 00297 // it will still be set to ambiguous.) 00298 if(BaseUtilities::areEqual(readBase, refBase)) 00299 { 00300 // Match. 00301 updatedSeq[queryIndex] = refBase; 00302 } 00303 } 00304 00305 // Increment the query index to the next position. 00306 ++queryIndex; 00307 continue; 00308 } 00309 }
1.6.3