Loading...
Searching...
No Matches
BaseUtilities Class Reference

This class contains static utilities for performing basic operations on bases. More...

`#include <BaseUtilities.h>`

## Static Public Member Functions

static bool | isAmbiguous (char base)
| Returns whether or not the specified bases is an indicator for ambiguity.
static bool | areEqual (char base1, char base2)
| Returns whether or not two bases are equal (case insensitive), if one of the bases is '=', the bases are consided to be equal.
static uint8_t | getPhredBaseQuality (char charQuality)
| Get phred base quality from the specified ascii quality.
static char | getAsciiQuality (uint8_t phredQuality)
| Get ascii quality from the specified phred quality.
static void | reverseComplement (std::string &sequence)

## Static Public Attributes

static const char | UNKNOWN_QUALITY_CHAR = ' '
| Character used when the quality is unknown.
static const uint8_t | UNKNOWN_QUALITY_INT = 0xFF
| Int value used when the quality is unknown.

## Detailed Description

This class contains static utilities for performing basic operations on bases.

Definition at line 27 of file BaseUtilities.h.

## Member Function Documentation

## areEqual()

bool BaseUtilities::areEqual | ( | char | base1,
|  | char | base2
| ) |  |

static

Returns whether or not two bases are equal (case insensitive), if one of the bases is '=', the bases are consided to be equal.

Definition at line 39 of file BaseUtilities.cpp.

{
// If they are the same, return true.
if(base1 == base2)
{
return(true);
}
// If one of the bases is '=', return true.
if((base1 == '=') || (base2 == '='))
{
return(true);
}
// Check both in upercase.
if(toupper(base1) == toupper(base2))
{
// same in upper case.
return(true);
}
// The bases are different.
return(false);
}

Referenced by SamTags::createMDTag(), SamQuerySeqWithRefIter::getNextMatchMismatch(), SamQuerySeqWithRef::seqWithEquals(), and SamQuerySeqWithRef::seqWithoutEquals().

## getAsciiQuality()

char BaseUtilities::getAsciiQuality | ( | uint8_t | phredQuality | ) |

static

Get ascii quality from the specified phred quality.

Definition at line 76 of file BaseUtilities.cpp.

{
if(phredQuality == UNKNOWN_QUALITY_INT)
{
return(UNKNOWN_QUALITY_CHAR);
}
return(phredQuality + 33);
}
BaseUtilities::UNKNOWN_QUALITY_CHAR
static const char UNKNOWN_QUALITY_CHAR
Character used when the quality is unknown.
Definition BaseUtilities.h:49
BaseUtilities::UNKNOWN_QUALITY_INT
static const uint8_t UNKNOWN_QUALITY_INT
Int value used when the quality is unknown.
Definition BaseUtilities.h:51

References UNKNOWN_QUALITY_CHAR, and UNKNOWN_QUALITY_INT.

## getPhredBaseQuality()

uint8_t BaseUtilities::getPhredBaseQuality | ( | char | charQuality | ) |

static

Get phred base quality from the specified ascii quality.

Definition at line 65 of file BaseUtilities.cpp.

{
if(charQuality == UNKNOWN_QUALITY_CHAR)
{
return(UNKNOWN_QUALITY_INT);
}
return(charQuality - 33);
}

References UNKNOWN_QUALITY_CHAR, and UNKNOWN_QUALITY_INT.

Referenced by SamFilter::sumMismatchQuality().

## isAmbiguous()

bool BaseUtilities::isAmbiguous | ( | char | base | ) |

static

Returns whether or not the specified bases is an indicator for ambiguity.

Returns
  true if base = 'n' or 'N' or '.'

Definition at line 23 of file BaseUtilities.cpp.

{
switch(base)
{
case 'N':
case 'n':
case '.':
return(true);
default:
break;
};
// Not 'N', 'n', or '.', so return false.
return(false);
}

Referenced by SamTags::createMDTag(), SamQuerySeqWithRefIter::getNextMatchMismatch(), and SamQuerySeqWithRef::seqWithEquals().

## reverseComplement()

void BaseUtilities::reverseComplement | ( | std::string & | sequence | ) |

static

Definition at line 86 of file BaseUtilities.cpp.

{
int start = 0;
int end = sequence.size() - 1;
char tempChar;
while(start < end)
{
tempChar = sequence[start];
sequence[start] = BaseAsciiMap::base2complement[(int)(sequence[end])];
sequence[end] = BaseAsciiMap::base2complement[(int)tempChar];
// Move both pointers.
++start;
--end;
}
// there was an odd number of entries, complement the middle one.
if(start == end)
{
tempChar = sequence[start];
sequence[start] = BaseAsciiMap::base2complement[(int)tempChar];
}
}
BaseAsciiMap::base2complement
static unsigned char base2complement[]
This table maps 5' base space to the 3' complement base space values, as well as 5' color space value...
Definition BaseAsciiMap.h:41

## Member Data Documentation

## UNKNOWN_QUALITY_CHAR

const char BaseUtilities::UNKNOWN_QUALITY_CHAR = ' '

static

Character used when the quality is unknown.

Definition at line 49 of file BaseUtilities.h.

Referenced by getAsciiQuality(), getPhredBaseQuality(), and SamRecord::getQuality().

## UNKNOWN_QUALITY_INT

const uint8_t BaseUtilities::UNKNOWN_QUALITY_INT = 0xFF

static

Int value used when the quality is unknown.

Definition at line 51 of file BaseUtilities.h.

Referenced by getAsciiQuality(), getPhredBaseQuality(), and SamFilter::sumMismatchQuality().

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

- general/BaseUtilities.h
- general/BaseUtilities.cpp