libStatGen Software  1
BaseComposition Class Reference

Class that tracks the composition of base by read location. More...

#include <BaseComposition.h>

Public Member Functions

 BaseComposition ()
 Constructor.
 
bool updateComposition (unsigned int rawSequenceCharIndex, char baseChar)
 Update the composition for the specified index with the specified character. More...
 
BaseAsciiMap::SPACE_TYPE getSpaceType ()
 Get the space type for this composition.
 
void resetBaseMapType ()
 Reset the base map type for this composition.
 
void setBaseMapType (BaseAsciiMap::SPACE_TYPE spaceType)
 Set the base map type for this composition.
 
void print ()
 Print the composition.
 
void clear ()
 Clear the composition stored in the base count vector.
 

Detailed Description

Class that tracks the composition of base by read location.

Definition at line 27 of file BaseComposition.h.

Member Function Documentation

◆ updateComposition()

bool BaseComposition::updateComposition ( unsigned int  rawSequenceCharIndex,
char  baseChar 
)

Update the composition for the specified index with the specified character.

Returns
false if the character is not a valid raw sequence character, true if it is valid.

Definition at line 32 of file BaseComposition.cpp.

References BaseAsciiMap::getBaseIndex(), and BaseAsciiMap::resetPrimerCount().

Referenced by FastQFile::readFastQSequence().

34 {
35  bool validIndex = true;
36 
37  // Each time we return to index 0, reset the primer count in the base/ascii
38  // map.
39  if(rawSequenceCharIndex == 0)
40  {
41  myBaseAsciiMap.resetPrimerCount();
42  }
43 
44  // Check to see if the vector size is already sized to include this
45  // index. If it is not sized appropriately, add entries until it contains
46  // the rawSequenceCharIndex.
47  while(rawSequenceCharIndex >= myBaseCountVector.size())
48  {
49  // Add an entry of the base count array object to the vector.
50  BaseCount baseCountEntry;
51  myBaseCountVector.push_back(baseCountEntry);
52  }
53 
54  // Get the base info for the specified character.
55  int baseIndex = myBaseAsciiMap.getBaseIndex(baseChar);
56 
57  // Increment the count for the given character. This method returns false
58  // if the character's index falls outside the range of the base array.
59  // This relies on the myBaseAsciiMap indexes and the BaseCOunt object array
60  // to use the same indexing values for valid bases.
61  validIndex =
62  myBaseCountVector[rawSequenceCharIndex].incrementCount(baseIndex);
63 
64  // Return whether or not the specified character was valid.
65  return(validIndex);
66 }
void resetPrimerCount()
Reset the number of primers to 0.
Definition: BaseAsciiMap.h:158
This class is a wrapper around an array that has one index per base and an extra index for a total co...
Definition: BaseCount.h:27
int getBaseIndex(const char &letter)
Returns the baseIndex value for the character passed in.
Definition: BaseAsciiMap.h:94

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