libStatGen Software 1
Loading...
Searching...
No Matches
BaseAsciiMap Class Reference

Map between characters and the associated base type. More...

#include <BaseAsciiMap.h>

Public Types

enum  SPACE_TYPE { UNKNOWN , BASE_SPACE , COLOR_SPACE }
 The type of space (color or base) to use in the mapping. More...
 

Public Member Functions

void setBaseMapType (SPACE_TYPE spaceType)
 Set the base type based on the passed in option.
 
int getBaseIndex (const char &letter)
 Returns the baseIndex value for the character passed in.
 
SPACE_TYPE getSpaceType ()
 Return the space type that is currently set.
 
void setNumPrimerBases (int numPrimerBases)
 Set the number of primer bases expected before the actual base/color space type occurs for the rest of the entries.
 
void resetPrimerCount ()
 Reset the number of primers to 0.
 
void resetBaseMapType ()
 Reset the base mapping type to UNKNOWN.
 

Static Public Attributes

static const int baseNIndex = 004
 Value associated with 'N' in the ascii to base map (bad read).
 
static const int baseXIndex = 005
 Value associated with any non-base character in the ascii to base map (unknown, bad data).
 
static const char int2base [] = "ACGTNMXXXXXXXXXX"
 Convert from int representation to the base.
 
static const char int2colorSpace [] = "0123NXXXXXXXXXXX"
 Convert from int representation to colorspace representation.
 
static unsigned char base2complement []
 This table maps 5' base space to the 3' complement base space values, as well as 5' color space values to the corresponding 3' complement color space values.
 
static unsigned char baseColor2int [256+1]
 Map ASCII values to a 2 (or 3) bit encoding for the base pair value for both base and color space.
 
static unsigned char base2int [256+1]
 Map ASCII values to a 2 (or 3) bit encoding for the base pair value for just base space (ACTGNactgn).
 
static unsigned char color2int [256+1]
 Map ASCII values to a 2 (or 3) bit encoding for the base pair value for just color space (0123).
 

Detailed Description

Map between characters and the associated base type.

Definition at line 24 of file BaseAsciiMap.h.

Member Enumeration Documentation

◆ SPACE_TYPE

The type of space (color or base) to use in the mapping.

Enumerator
UNKNOWN 

Base decision on the first raw seq character/type has yet to be determined.

BASE_SPACE 

Bases only (A,C,G,T,N).

COLOR_SPACE 

Color space only (0,1,2,3,.).

Definition at line 44 of file BaseAsciiMap.h.

44 {
45 /// Base decision on the first raw seq character/type has yet
46 /// to be determined.
47 UNKNOWN,
48 BASE_SPACE, ///< Bases only (A,C,G,T,N).
49 COLOR_SPACE ///< Color space only (0,1,2,3,.).
50 };
@ COLOR_SPACE
Color space only (0,1,2,3,.).
@ UNKNOWN
Base decision on the first raw seq character/type has yet to be determined.
@ BASE_SPACE
Bases only (A,C,G,T,N).

Constructor & Destructor Documentation

◆ BaseAsciiMap()

BaseAsciiMap::BaseAsciiMap ( )

Definition at line 137 of file BaseAsciiMap.cpp.

138 : myNumPrimerBases(1)
139{
140 myBase2IntMapPtr = NULL;
141}

◆ ~BaseAsciiMap()

BaseAsciiMap::~BaseAsciiMap ( )

Definition at line 143 of file BaseAsciiMap.cpp.

144{
145}

Member Function Documentation

◆ getBaseIndex()

int BaseAsciiMap::getBaseIndex ( const char &  letter)
inline

Returns the baseIndex value for the character passed in.

Definition at line 94 of file BaseAsciiMap.h.

95 {
96 if (myBase2IntMapPtr == NULL)
97 {
98 // Check to see if we have hit the number of primer bases.
99 if (myPrimerCount < myNumPrimerBases)
100 {
101 // Still expecting primer bases, so lookup
102 // the letter in the base map.
103 ++myPrimerCount;
104 return(base2int[(int)letter]);
105 }
106
107 // Have already processed all the primers, so determine
108 // whether this is base or color space.
109
110 // Need to determime the base type.
111 setBaseMapType(letter);
112
113 // If it is still null, return invalid. Will be set when the first
114 // letter is either color or base.
115 if (myBase2IntMapPtr == NULL)
116 {
117 return(baseXIndex);
118 }
119 }
120
121 // Also check if configured as color space that the primers are correct.
122 if ((myBase2IntMapPtr == color2int) && (myPrimerCount < myNumPrimerBases))
123 {
124 // Still expecting primer bases, so lookup
125 // the letter in the base map.
126 ++myPrimerCount;
127 return(base2int[(int)letter]);
128 }
129
130 return myBase2IntMapPtr[(int)letter];
131 }
void setBaseMapType(SPACE_TYPE spaceType)
Set the base type based on the passed in option.
static unsigned char color2int[256+1]
Map ASCII values to a 2 (or 3) bit encoding for the base pair value for just color space (0123).
static const int baseXIndex
Value associated with any non-base character in the ascii to base map (unknown, bad data).
static unsigned char base2int[256+1]
Map ASCII values to a 2 (or 3) bit encoding for the base pair value for just base space (ACTGNactgn).

References base2int, baseXIndex, color2int, and setBaseMapType().

Referenced by BaseComposition::updateComposition().

◆ getSpaceType()

SPACE_TYPE BaseAsciiMap::getSpaceType ( )
inline

Return the space type that is currently set.

Definition at line 134 of file BaseAsciiMap.h.

135 {
136 if (myBase2IntMapPtr == base2int)
137 {
138 return(BASE_SPACE);
139 }
140 else if (myBase2IntMapPtr == color2int)
141 {
142 return(COLOR_SPACE);
143 }
144 else
145 {
146 return(UNKNOWN);
147 }
148 }

References base2int, BASE_SPACE, color2int, COLOR_SPACE, and UNKNOWN.

Referenced by BaseComposition::getSpaceType().

◆ resetBaseMapType()

void BaseAsciiMap::resetBaseMapType ( )
inline

Reset the base mapping type to UNKNOWN.

Definition at line 164 of file BaseAsciiMap.h.

165 {
166 myBase2IntMapPtr = NULL;
168 };
void resetPrimerCount()
Reset the number of primers to 0.

References resetPrimerCount().

Referenced by BaseComposition::resetBaseMapType().

◆ resetPrimerCount()

void BaseAsciiMap::resetPrimerCount ( )
inline

Reset the number of primers to 0.

Definition at line 158 of file BaseAsciiMap.h.

159 {
160 myPrimerCount = 0;
161 };

Referenced by resetBaseMapType(), setBaseMapType(), and BaseComposition::updateComposition().

◆ setBaseMapType()

void BaseAsciiMap::setBaseMapType ( SPACE_TYPE  spaceType)
inline

Set the base type based on the passed in option.

Definition at line 72 of file BaseAsciiMap.h.

73 {
75 //First check to see if it is in base space.
76 switch (spaceType)
77 {
78 case BASE_SPACE:
79 // base space.
80 myBase2IntMapPtr = base2int;
81 break;
82 case COLOR_SPACE:
83 // color space.
84 myBase2IntMapPtr = color2int;
85 break;
86 default:
87 // Unknown map type, zero the pointer.
88 myBase2IntMapPtr = NULL;
89 break;
90 }
91 };

References base2int, BASE_SPACE, color2int, COLOR_SPACE, and resetPrimerCount().

Referenced by getBaseIndex(), and BaseComposition::setBaseMapType().

◆ setNumPrimerBases()

void BaseAsciiMap::setNumPrimerBases ( int  numPrimerBases)
inline

Set the number of primer bases expected before the actual base/color space type occurs for the rest of the entries.

Definition at line 152 of file BaseAsciiMap.h.

153 {
154 myNumPrimerBases = numPrimerBases;
155 }

Member Data Documentation

◆ base2complement

unsigned char BaseAsciiMap::base2complement
static
Initial value:
=
"NNNNNNNNNNNNNNNN"
"NNNNNNNNNNNNNNNN"
"NNNNNNNNNNNNNNNN"
"0123NNNNNNNNNNNN"
"NTNGNNNCNNNNNNNN"
"NNNNANNNNNNNNNNN"
"NTNGNNNCNNNNNNNN"
"NNNNANNNNNNNNNNN"
"NNNNNNNNNNNNNNNN"
"NNNNNNNNNNNNNNNN"
"NNNNNNNNNNNNNNNN"
"NNNNNNNNNNNNNNNN"
"NNNNNNNNNNNNNNNN"
"NNNNNNNNNNNNNNNN"
"NNNNNNNNNNNNNNNN"
"NNNNNNNNNNNNNNNN"

This table maps 5' base space to the 3' complement base space values, as well as 5' color space values to the corresponding 3' complement color space values.

In both cases, invalids are mapped to 'N', which isn't accurate for ABI SOLiD, but internally it shouldn't matter (on output it will).

Definition at line 41 of file BaseAsciiMap.h.

◆ base2int

unsigned char BaseAsciiMap::base2int
static
Initial value:
=
"\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005"
"\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005"
"\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005"
"\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005"
"\005\000\005\001\005\005\005\002\005\005\005\005\005\005\004\005"
"\005\005\005\005\003\005\005\005\005\005\005\005\005\005\005\005"
"\005\000\005\001\005\005\005\002\005\005\005\005\005\005\004\005"
"\005\005\005\005\003\005\005\005\005\005\005\005\005\005\005\005"
"\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005"
"\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005"
"\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005"
"\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005"
"\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005"
"\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005"
"\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005"
"\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005"

Map ASCII values to a 2 (or 3) bit encoding for the base pair value for just base space (ACTGNactgn).

'A'/'a' -> 0; 'C'/'c' -> 1; 'G'/'g' -> 2; 'T'/'t' -> 3; 'N'/'n' -> 4; anything else -> 5.

Definition at line 61 of file BaseAsciiMap.h.

Referenced by getBaseIndex(), getSpaceType(), and setBaseMapType().

◆ baseColor2int

unsigned char BaseAsciiMap::baseColor2int
static
Initial value:
=
"\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005"
"\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005"
"\005\005\005\005\005\005\005\005\005\005\005\005\005\005\004\005"
"\000\001\002\003\005\005\005\005\005\005\005\005\005\005\005\005"
"\005\000\005\001\005\005\005\002\005\005\005\005\005\005\004\005"
"\005\005\005\005\003\005\005\005\005\005\005\005\005\005\005\005"
"\005\000\005\001\005\005\005\002\005\005\005\005\005\005\004\005"
"\005\005\005\005\003\005\005\005\005\005\005\005\005\005\005\005"
"\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005"
"\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005"
"\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005"
"\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005"
"\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005"
"\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005"
"\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005"
"\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005"

Map ASCII values to a 2 (or 3) bit encoding for the base pair value for both base and color space.

'A'/'a'/'0' -> 0; 'C'/'c'/'1' -> 1; 'G'/'g'/'2' -> 2; 'T'/'t'/'3' -> 3; 'N'/'n'/'4' -> 4; anything else -> 5.

Definition at line 56 of file BaseAsciiMap.h.

◆ baseNIndex

const int BaseAsciiMap::baseNIndex = 004
static

Value associated with 'N' in the ascii to base map (bad read).

Definition at line 28 of file BaseAsciiMap.h.

Referenced by GenomeSequence::operator[]().

◆ baseXIndex

const int BaseAsciiMap::baseXIndex = 005
static

Value associated with any non-base character in the ascii to base map (unknown, bad data).

Definition at line 31 of file BaseAsciiMap.h.

Referenced by getBaseIndex().

◆ color2int

unsigned char BaseAsciiMap::color2int
static
Initial value:
=
"\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005"
"\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005"
"\005\005\005\005\005\005\005\005\005\005\005\005\005\005\004\005"
"\000\001\002\003\005\005\005\005\005\005\005\005\005\005\005\005"
"\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005"
"\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005"
"\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005"
"\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005"
"\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005"
"\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005"
"\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005"
"\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005"
"\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005"
"\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005"
"\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005"
"\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005\005"

Map ASCII values to a 2 (or 3) bit encoding for the base pair value for just color space (0123).

'0' -> 0; '1' -> 1; '2' -> 2; '3' -> 3; '4' -> 4; anything else -> 5.

Definition at line 65 of file BaseAsciiMap.h.

Referenced by getBaseIndex(), getSpaceType(), and setBaseMapType().

◆ int2base

const char BaseAsciiMap::int2base = "ACGTNMXXXXXXXXXX"
static

Convert from int representation to the base.

Definition at line 38 of file BaseAsciiMap.h.

Referenced by GenomeSequence::operator[]().

◆ int2colorSpace

const char BaseAsciiMap::int2colorSpace = "0123NXXXXXXXXXXX"
static

Convert from int representation to colorspace representation.

Definition at line 40 of file BaseAsciiMap.h.

Referenced by GenomeSequence::operator[]().


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