-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAlphabet.H
55 lines (45 loc) · 1.29 KB
/
Alphabet.H
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
/***********************************************************************
Alphabet.H
BOOM : Bioinformatics Object Oriented Modules
Copyright (C)2012 William H. Majoros ([email protected]).
This is OPEN SOURCE SOFTWARE governed by the Gnu General Public
License (GPL) version 3, as described at www.opensource.org.
***********************************************************************/
#ifndef INCL_Alphabet_H
#define INCL_Alphabet_H
using namespace std;
#include "Symbol.H"
#include <iostream>
namespace BOOM {
class Alphabet {
public:
Alphabet(const char * = NULL);
int add(char);
bool load(istream &);
int getNumElements() const;
int size() const {return numElements;}
inline char lookup(int) const;
inline int lookup(char) const;
void printOn(ostream &);
char complement(char) const;
Symbol complement(Symbol) const;
bool save(ostream &);
bool isDefined(char) const;
private:
char intToChar[256]; // int->char
char charToInt[256]; // char->int
int numElements;
};
}
using namespace BOOM;
ostream &operator<<(ostream &,Alphabet &);
char BOOM::Alphabet::lookup(int index) const
{
//return intToChar[index];
return index>=0 ? intToChar[index] : '$';
}
int BOOM::Alphabet::lookup(char c) const
{
return static_cast<int>(charToInt[static_cast<int>(c)]);
}
#endif