libStatGen Software 1
Loading...
Searching...
No Matches
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.
 
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.

Constructor & Destructor Documentation

◆ BaseComposition()

BaseComposition::BaseComposition ( )

Constructor.

Definition at line 23 of file BaseComposition.cpp.

23 :
24 myBaseAsciiMap()
25{
26}

Member Function Documentation

◆ clear()

void BaseComposition::clear ( )

Clear the composition stored in the base count vector.

Definition at line 89 of file BaseComposition.cpp.

90{
91 myBaseCountVector.clear();
92}

◆ getSpaceType()

BaseAsciiMap::SPACE_TYPE BaseComposition::getSpaceType ( )
inline

Get the space type for this composition.

Definition at line 40 of file BaseComposition.h.

41 {
42 return(myBaseAsciiMap.getSpaceType());
43 }
SPACE_TYPE getSpaceType()
Return the space type that is currently set.

References BaseAsciiMap::getSpaceType().

Referenced by FastQFile::getSpaceType().

◆ print()

void BaseComposition::print ( )

Print the composition.

Definition at line 70 of file BaseComposition.cpp.

71{
72 std::cout << std::endl << "Base Composition Statistics:" << std::endl;
73 std::cout.precision(2);
74 // This assumes the relationship between indexes that are printed
75 // by a BaseCount object to be in a specific order based on ATGCN.
76 std::cout << std::fixed << "Read Index"
77 << "\t%A" << "\t%C" << "\t%G" << "\t%T" << "\t%N" << "\tTotal Reads At Index"
78 << std::endl;
79 for(unsigned int i = 0; i < myBaseCountVector.size(); i++)
80 {
81 std::cout << std::setw(10) << i << " ";
82 myBaseCountVector[i].printPercent();
83 }
84 std::cout << std::endl;
85}

Referenced by FastQFile::validateFastQFile().

◆ resetBaseMapType()

void BaseComposition::resetBaseMapType ( )
inline

Reset the base map type for this composition.

Definition at line 46 of file BaseComposition.h.

47 {
48 myBaseAsciiMap.resetBaseMapType();
49 };
void resetBaseMapType()
Reset the base mapping type to UNKNOWN.

References BaseAsciiMap::resetBaseMapType().

Referenced by FastQFile::openFile().

◆ setBaseMapType()

void BaseComposition::setBaseMapType ( BaseAsciiMap::SPACE_TYPE  spaceType)
inline

Set the base map type for this composition.

Definition at line 52 of file BaseComposition.h.

53 {
54 myBaseAsciiMap.setBaseMapType(spaceType);
55 }
void setBaseMapType(SPACE_TYPE spaceType)
Set the base type based on the passed in option.

References BaseAsciiMap::setBaseMapType().

Referenced by FastQFile::openFile().

◆ 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.

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.
int getBaseIndex(const char &letter)
Returns the baseIndex value for the character passed in.
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:28

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


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