librostlab 1.0.20
Loading...
Searching...
No Matches
mapAA2int.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2011 Laszlo Kajan, Technical University of Munich, Germany
3
4 This file is part of librostlab.
5
6 librostlab is free software: you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18*/
19#ifndef ROSTLAB_MAPAA2INT
20#define ROSTLAB_MAPAA2INT 1
21
22#include <ctype.h>
24#include <sstream>
25
26namespace rostlab {
27
28inline char int2AAchar (int __aanum)
29{
30 switch(__aanum){
31 case 0:
32 return 'A';
33 case 1:
34 return 'R';
35 case 2:
36 return 'N';
37 case 3:
38 return 'D';
39 case 4:
40 return 'C';
41 case 5:
42 return 'Q';
43 case 6:
44 return 'E';
45 case 7:
46 return 'G';
47 case 8:
48 return 'H';
49 case 9:
50 return 'I';
51 case 10:
52 return 'L';
53 case 11:
54 return 'K';
55 case 12:
56 return 'M';
57 case 13:
58 return 'F';
59 case 14:
60 return 'P';
61 case 15:
62 return 'S';
63 case 16:
64 return 'T';
65 case 17:
66 return 'W';
67 case 18:
68 return 'Y';
69 case 19:
70 return 'V';
71 default:
72 std::ostringstream buf; buf << "invalid amino acid numeric code '" << __aanum << "'";
73 throw runtime_error( buf.str() );
74 }
75}
76
77inline int AAchar2int (char __aachar)
78{
79 switch(toupper(__aachar)){
80 case 'A':
81 return 0;
82 case 'R':
83 return 1;
84 case 'N':
85 return 2;
86 case 'D':
87 return 3;
88 case 'C':
89 return 4;
90 case 'Q':
91 return 5;
92 case 'E':
93 return 6;
94 case 'G':
95 return 7;
96 case 'H':
97 return 8;
98 case 'I':
99 return 9;
100 case 'L':
101 return 10;
102 case 'K':
103 return 11;
104 case 'M':
105 return 12;
106 case 'F':
107 return 13;
108 case 'P':
109 return 14;
110 case 'S':
111 return 15;
112 case 'T':
113 return 16;
114 case 'W':
115 return 17;
116 case 'Y':
117 return 18;
118 case 'V':
119 return 19;
120 default:
121 std::ostringstream buf; buf << "invalid amino acid '" << __aachar << "'";
122 throw runtime_error( buf.str() );
123 }
124}
125}
126#endif
127
128// vim:et:ts=2:
int AAchar2int(char __aachar)
Definition mapAA2int.h:77
char int2AAchar(int __aanum)
Definition mapAA2int.h:28