-
Notifications
You must be signed in to change notification settings - Fork 5
/
alphabet.cpp
101 lines (96 loc) · 2.13 KB
/
alphabet.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
//-----------------------------------------------
// Copyright 2009 Wellcome Trust Sanger Institute
// Written by Jared Simpson (js18@sanger.ac.uk)
// Released under the GPL
//-----------------------------------------------
//
// Alphabet.h - Abstraction of the alphabet
// that is used in the suffix array, fm-index,
// etc data structures
//
#include "alphabet.h"
#include <iostream>
#include <iterator>
// IUPAC alphabet
bool IUPAC::isUnambiguous(char c)
{
switch(c)
{
case 'A':
case 'C':
case 'G':
case 'T':
return true;
default:
return false;
}
}
// Returns true if c is a valid ambiguity code
bool IUPAC::isAmbiguous(char c)
{
switch(c)
{
case 'M':
case 'R':
case 'W':
case 'S':
case 'Y':
case 'K':
case 'V':
case 'H':
case 'D':
case 'B':
case 'N':
return true;
default:
return false;
}
}
// Returns true if c is a valid symbol in this alphabet
bool IUPAC::isValid(char c)
{
return isUnambiguous(c) || isAmbiguous(c);
}
//
std::string IUPAC::getPossibleSymbols(char c)
{
switch(c)
{
case 'A':
return "A";
case 'C':
return "C";
case 'G':
return "G";
case 'T':
return "T";
case 'M':
return "AC";
case 'R':
return "AG";
case 'W':
return "AT";
case 'S':
return "CG";
case 'Y':
return "CT";
case 'K':
return "GT";
case 'V':
return "ACG";
case 'H':
return "ACT";
case 'D':
return "AGT";
case 'B':
return "CGT";
case 'N':
return "ACGT";
default:
return "";
}
}
// AlphaCount
template<> const size_t AlphaCount8::maxValue = std::numeric_limits<uint8_t>::max();
template<> const size_t AlphaCount16::maxValue = std::numeric_limits<uint16_t>::max();
template<> const size_t AlphaCount64::maxValue = std::numeric_limits<uint64_t>::max();