libStatGen Software 1
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.

40{
41 // If they are the same, return true.
42 if(base1 == base2)
43 {
44 return(true);
45 }
46 // If one of the bases is '=', return true.
47 if((base1 == '=') || (base2 == '='))
48 {
49 return(true);
50 }
51
52 // Check both in upercase.
53 if(toupper(base1) == toupper(base2))
54 {
55 // same in upper case.
56 return(true);
57 }
58
59 // The bases are different.
60 return(false);
61}

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.

77{
78 if(phredQuality == UNKNOWN_QUALITY_INT)
79 {
81 }
82 return(phredQuality + 33);
83}
static const char UNKNOWN_QUALITY_CHAR
Character used when the quality is unknown.
static const uint8_t UNKNOWN_QUALITY_INT
Int value used when the quality is unknown.

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.

66{
67 if(charQuality == UNKNOWN_QUALITY_CHAR)
68 {
69 return(UNKNOWN_QUALITY_INT);
70 }
71
72 return(charQuality - 33);
73}

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.

24{
25 switch(base)
26 {
27 case 'N':
28 case 'n':
29 case '.':
30 return(true);
31 default:
32 break;
33 };
34
35 // Not 'N', 'n', or '.', so return false.
36 return(false);
37}

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.

87{
88 int start = 0;
89 int end = sequence.size() - 1;
90 char tempChar;
91
92 while(start < end)
93 {
94 tempChar = sequence[start];
95 sequence[start] = BaseAsciiMap::base2complement[(int)(sequence[end])];
96 sequence[end] = BaseAsciiMap::base2complement[(int)tempChar];
97 // Move both pointers.
98 ++start;
99 --end;
100 }
101
102 // there was an odd number of entries, complement the middle one.
103 if(start == end)
104 {
105 tempChar = sequence[start];
106 sequence[start] = BaseAsciiMap::base2complement[(int)tempChar];
107 }
108}
static unsigned char base2complement[]
This table maps 5' base space to the 3' complement base space values, as well as 5' color space value...

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: