librostlab  1.0.20
rostlab/mapAA2int.h
Go to the documentation of this file.
00001 /*
00002     Copyright (C) 2011 Laszlo Kajan, Technical University of Munich, Germany
00003 
00004     This file is part of librostlab.
00005 
00006     librostlab is free software: you can redistribute it and/or modify
00007     it under the terms of the GNU Lesser General Public License as published by
00008     the Free Software Foundation, either version 3 of the License, or
00009     (at your option) any later version.
00010 
00011     This program is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014     GNU Lesser General Public License for more details.
00015 
00016     You should have received a copy of the GNU Lesser General Public License
00017     along with this program.  If not, see <http://www.gnu.org/licenses/>.
00018 */
00019 #ifndef ROSTLAB_MAPAA2INT
00020 #define ROSTLAB_MAPAA2INT 1
00021 
00022 #include <ctype.h>
00023 #include <rostlab/rostlab_stdexcept.h>
00024 #include <sstream>
00025 
00026 namespace rostlab {
00027 
00028 inline char       int2AAchar (int __aanum)
00029 {
00030         switch(__aanum){
00031             case 0:
00032                 return 'A';
00033             case 1:
00034                 return 'R';
00035             case 2:
00036                 return 'N';
00037             case 3:
00038                 return 'D';
00039             case 4:
00040                 return 'C';
00041             case 5:
00042                 return 'Q';
00043             case 6:
00044                 return 'E';
00045             case 7:
00046                 return 'G';
00047             case 8:
00048                 return 'H';
00049             case 9:
00050                 return 'I';
00051             case 10: 
00052                 return 'L';
00053             case 11: 
00054                 return 'K';
00055             case 12: 
00056                 return 'M';
00057             case 13: 
00058                 return 'F';
00059             case 14: 
00060                 return 'P';
00061             case 15: 
00062                 return 'S';
00063             case 16: 
00064                 return 'T';
00065             case 17: 
00066                 return 'W';
00067             case 18: 
00068                 return 'Y';
00069             case 19: 
00070                 return 'V';
00071             default:
00072                 std::ostringstream buf; buf << "invalid amino acid numeric code '" << __aanum << "'";
00073                 throw runtime_error( buf.str() );
00074         }   
00075 }
00076 
00077 inline int        AAchar2int (char __aachar)
00078 {
00079         switch(toupper(__aachar)){
00080             case 'A':
00081                 return 0;
00082             case 'R':
00083                 return 1;
00084             case 'N':
00085                 return 2;
00086             case 'D':
00087                 return 3;
00088             case 'C':
00089                 return 4;
00090             case 'Q':
00091                 return 5;
00092             case 'E':
00093                 return 6;
00094             case 'G':
00095                 return 7;
00096             case 'H':
00097                 return 8;
00098             case 'I':
00099                 return 9;
00100             case 'L':
00101                 return 10; 
00102             case 'K':
00103                 return 11; 
00104             case 'M':
00105                 return 12; 
00106             case 'F':
00107                 return 13; 
00108             case 'P':
00109                 return 14; 
00110             case 'S':
00111                 return 15; 
00112             case 'T':
00113                 return 16; 
00114             case 'W':
00115                 return 17; 
00116             case 'Y':
00117                 return 18; 
00118             case 'V':
00119                 return 19; 
00120             default:
00121                 std::ostringstream buf; buf << "invalid amino acid '" << __aachar << "'";
00122                 throw runtime_error( buf.str() );
00123         }   
00124 }
00125 }
00126 #endif
00127 
00128 // vim:et:ts=2:
 All Classes Namespaces Files Functions Variables Typedefs