src/common/seq_tools.cc

00001 #include <string.h>
00002 
00003 #include"open_prospect.h"
00004 
00005 
00006 //--------------------------------------------------------------------
00007 int solvent_acc(char a, int template_acc)
00008 {
00009   int max;
00010 
00011   switch (a)
00012   {
00013     case 'A': max = 113;
00014     case 'C': max = 140;
00015     case 'D': max = 151;
00016     case 'E': max = 183;
00017     case 'F': max = 218;
00018     case 'G': max = 85;
00019     case 'H': max = 194;
00020     case 'I': max = 182;
00021     case 'K': max = 211;
00022     case 'L': max = 180;
00023     case 'M': max = 204;
00024     case 'N': max = 158;
00025     case 'P': max = 143;
00026     case 'Q': max = 189;
00027     case 'R': max = 241;
00028     case 'S': max = 122;
00029     case 'T': max = 146;
00030     case 'V': max = 160;
00031     case 'W': max = 259;
00032     case 'Y': max = 229;
00033     default : max = -1;
00034   }
00035 
00036   double check;
00037   check = template_acc/max;
00038 
00039   if (check <= 0.07)
00040   {
00041     return 0;
00042   }
00043   else
00044   {
00045     if (check <= 0.37)
00046     {
00047       return 1;
00048     }
00049     else
00050     {
00051       return 2;
00052     }
00053   }
00054 }
00055 
00056 //--------------------------------------------------------------------
00057 int SS1toSSNum(char a)
00058 {
00059   switch (a)
00060   {
00061     case 'H': case 'h': return 2;
00062     case 'G': case 'g': return 2;
00063     case 'I': case 'i': return 2;
00064     case 'E': case 'e': return 1;
00065     case 'B': case 'b': return 1;
00066     case 'T': case 't': return 0;
00067     case 'S': case 's': return 0;
00068     case 'L': case 'l': return 0;
00069         default : return 0;
00070   }
00071   return 0;
00072 }
00073 
00074 //--------------------------------------------------------------------
00075 int AA1toAANum(char a)
00076 {
00077   switch (a)
00078   {
00079     case 'A': return 0;
00080     case 'R': return 1;
00081     case 'N': return 2;
00082     case 'D': return 3;
00083     case 'C': return 4;
00084     case 'Q': return 5;
00085     case 'E': return 6;
00086     case 'G': return 7;
00087     case 'H': return 8;
00088     case 'I': return 9;
00089     case 'L': return 10;
00090     case 'K': return 11;
00091     case 'M': return 12;
00092     case 'F': return 13;
00093     case 'P': return 14;
00094     case 'S': return 15;
00095     case 'T': return 16;
00096     case 'W': return 17;
00097     case 'Y': return 18;
00098     case 'V': return 19;
00099     default : return 20;
00100   }
00101 }
00102 
00103 
00104 
00105 char AANumtoAA1(int a)
00106 {
00107         switch (a)
00108         {
00109                 case 0: return 'A';
00110                 case 1: return 'R';
00111                 case 2: return 'N';
00112                 case 3: return 'D';
00113                 case 4: return 'C';
00114                 case 5: return 'Q';
00115                 case 6: return 'E';
00116                 case 7: return 'G';
00117                 case 8: return 'H';
00118                 case 9: return 'I';
00119                 case 10: return 'L';
00120                 case 11: return 'K';
00121                 case 12: return 'M';
00122                 case 13: return 'F';
00123                 case 14: return 'P';
00124                 case 15: return 'S';
00125                 case 16: return 'T';
00126                 case 17: return 'W';
00127                 case 18: return 'Y';
00128                 case 19: return 'V';
00129                 default : return 'X';
00130         }
00131 }
00132 
00133 
00134 
00135 char AA3toAA1(char * res) {
00136         if (!strncmp(res,"ALA", 3)) return 'A';
00137         if (!strncmp(res,"ARG", 3)) return 'R';
00138         if (!strncmp(res,"ASN", 3)) return 'N';
00139         if (!strncmp(res,"ASP", 3)) return 'D';
00140         if (!strncmp(res,"CYS", 3)) return 'C';
00141         if (!strncmp(res,"GLN", 3)) return 'Q';
00142         if (!strncmp(res,"GLU", 3)) return 'E';
00143         if (!strncmp(res,"GLY", 3)) return 'G';
00144         if (!strncmp(res,"HIS", 3)) return 'H';
00145         if (!strncmp(res,"ILE", 3)) return 'I';
00146         if (!strncmp(res,"LEU", 3)) return 'L';
00147         if (!strncmp(res,"LYS", 3)) return 'K';
00148         if (!strncmp(res,"MET", 3)) return 'M';
00149         if (!strncmp(res,"PHE", 3)) return 'F';
00150         if (!strncmp(res,"PRO", 3)) return 'P';
00151         if (!strncmp(res,"SER", 3)) return 'S';
00152         if (!strncmp(res,"THR", 3)) return 'T';
00153         if (!strncmp(res,"TRP", 3)) return 'W';
00154         if (!strncmp(res,"TYR", 3)) return 'Y';
00155         if (!strncmp(res,"VAL", 3)) return 'V';
00156         
00157         //HETATMs
00158         if (!strncmp(res,"MSE", 3)) return 'M';
00159         if (!strncmp(res,"CSP", 3)) return 'C';
00160         if (!strncmp(res,"BFD", 3)) return 'D';
00161         if (!strncmp(res,"CSW", 3)) return 'C';
00162         if (!strncmp(res,"PTR", 3)) return 'Y'; //phosphonotyrosine
00163 
00164         
00165         return 'X';
00166 }
00167 
00168 
00169 void AA1toAA3(char res, char *res_name) {
00170         strcpy(res_name,"XXX");
00171         if (res == 'A') strcpy(res_name,"ALA");
00172         if (res == 'R') strcpy(res_name,"ARG");
00173         if (res == 'N') strcpy(res_name,"ASN");
00174         if (res == 'D') strcpy(res_name,"ASP");
00175         if (res == 'C') strcpy(res_name,"CYS");
00176         if (res == 'Q') strcpy(res_name,"GLN");
00177         if (res == 'E') strcpy(res_name,"GLU");
00178         if (res == 'G') strcpy(res_name,"GLY");
00179         if (res == 'H') strcpy(res_name,"HIS");
00180         if (res == 'I') strcpy(res_name,"ILE");
00181         if (res == 'L') strcpy(res_name,"LEU");
00182         if (res == 'K') strcpy(res_name,"LYS");
00183         if (res == 'M') strcpy(res_name,"MET");
00184         if (res == 'F') strcpy(res_name,"PHE");
00185         if (res == 'P') strcpy(res_name,"PRO");
00186         if (res == 'S') strcpy(res_name,"SER");
00187         if (res == 'T') strcpy(res_name,"THR");
00188         if (res == 'W') strcpy(res_name,"TRP");
00189         if (res == 'Y') strcpy(res_name,"TYR");
00190         if (res == 'V') strcpy(res_name,"VAL");
00191 }
00192 
00193 
00194 char pdb_atomname[288][4] = {
00195         "N  ",
00196         "CA ",
00197         "C  ",
00198         "O  ",
00199         "CB ",
00200         "1D2",
00201         "1D4",
00202         "1D6",
00203         "1DZ",
00204         "2**",
00205         "2D2",
00206         "2D4",
00207         "2D6",
00208         "2DZ",
00209         "3DZ",
00210         "5* ",
00211         "5**",
00212         "5T ",
00213         "AD1",
00214         "AD2",
00215         "AE1",
00216         "AE2",
00217         "C1 ",
00218         "C1'",
00219         "C1*",
00220         "C10",
00221         "C11",
00222         "C12",
00223         "C13",
00224         "C14",
00225         "C15",
00226         "C16",
00227         "C19",
00228         "C1A",
00229         "C2 ",
00230         "C2'",
00231         "C2*",
00232         "C21",
00233         "C24",
00234         "C2A",
00235         "C2B",
00236         "C3 ",
00237         "C3'",
00238         "C3*",
00239         "C4 ",
00240         "C4'",
00241         "C4*",
00242         "C5 ",
00243         "C5'",
00244         "C5*",
00245         "C5A",
00246         "C5M",
00247         "C6 ",
00248         "C7 ",
00249         "C8 ",
00250         "CA*",
00251         "CB*",
00252         "CC*",
00253         "CD ",
00254         "CD*",
00255         "CD1",
00256         "CD2",
00257         "CDA",
00258         "CDB",
00259         "CE ",
00260         "CE*",
00261         "CE1",
00262         "CE2",
00263         "CE3",
00264         "CEA",
00265         "CEB",
00266         "CG ",
00267         "CG*",
00268         "CG1",
00269         "CG2",
00270         "CH*",
00271         "CH2",
00272         "CH3",
00273         "CI1",
00274         "CI2",
00275         "CI3",
00276         "CI4",
00277         "CI5",
00278         "CI6",
00279         "CK*",
00280         "CZ ",
00281         "CZ2",
00282         "CZ3",
00283         "D  ",
00284         "D1 ",
00285         "D1R",
00286         "D2 ",
00287         "D3 ",
00288         "D3T",
00289         "D4 ",
00290         "D5T",
00291         "D8 ",
00292         "DA ",
00293         "DB ",
00294         "DD1",
00295         "DD2",
00296         "DE ",
00297         "DE1",
00298         "DE2",
00299         "DG ",
00300         "DG1",
00301         "DH ",
00302         "DH1",
00303         "DH2",
00304         "DXT",
00305         "DZ ",
00306         "EA ",
00307         "EB ",
00308         "G  ",
00309         "G11",
00310         "G12",
00311         "G13",
00312         "G21",
00313         "G22",
00314         "G23",
00315         "H  ",
00316         "H0 ",
00317         "H0A",
00318         "H0B",
00319         "H0C",
00320         "H1 ",
00321         "H1*",
00322         "H2 ",
00323         "H2*",
00324         "H21",
00325         "H22",
00326         "H2A",
00327         "H2B",
00328         "H3 ",
00329         "H3*",
00330         "H3T",
00331         "H4 ",
00332         "H4*",
00333         "H41",
00334         "H42",
00335         "H4A",
00336         "H4B",
00337         "H5 ",
00338         "H5*",
00339         "H51",
00340         "H52",
00341         "H53",
00342         "H5A",
00343         "H5M",
00344         "H5P",
00345         "H5T",
00346         "H6 ",
00347         "H61",
00348         "H62",
00349         "H8 ",
00350         "HA ",
00351         "HA1",
00352         "HB ",
00353         "HB1",
00354         "HB2",
00355         "HB3",
00356         "HC ",
00357         "HD ",
00358         "HD1",
00359         "HD2",
00360         "HD3",
00361         "HE ",
00362         "HE1",
00363         "HE2",
00364         "HE3",
00365         "HG ",
00366         "HG1",
00367         "HG2",
00368         "HH ",
00369         "HH1",
00370         "HH2",
00371         "HH3",
00372         "HN ",
00373         "HN1",
00374         "HN2",
00375         "HN3",
00376         "HN4",
00377         "HN6",
00378         "HNZ",
00379         "HO ",
00380         "HO*",
00381         "HO2",
00382         "HO3",
00383         "HT ",
00384         "HT1",
00385         "HT2",
00386         "HXT",
00387         "H  ",
00388         "HZ ",
00389         "HZ1",
00390         "HZ2",
00391         "HZ3",
00392         "I  ",
00393         "M5 ",
00394         "MB ",
00395         "MD ",
00396         "MD1",
00397         "MD2",
00398         "MG ",
00399         "MG1",
00400         "MG2",
00401         "N1 ",
00402         "N2 ",
00403         "N20",
00404         "N3 ",
00405         "N4 ",
00406         "N6 ",
00407         "N7 ",
00408         "N9 ",
00409         "ND1",
00410         "ND2",
00411         "NE ",
00412         "NE1",
00413         "NE2",
00414         "NH1",
00415         "NH2",
00416         "NI1",
00417         "NI2",
00418         "NT ",
00419         "NZ ",
00420         "O1 ",
00421         "O17",
00422         "O18",
00423         "O1P",
00424         "O2 ",
00425         "O2'",
00426         "O2*",
00427         "O22",
00428         "O23",
00429         "O2P",
00430         "O3 ",
00431         "O3'",
00432         "O3*",
00433         "O3P",
00434         "O4 ",
00435         "O4'",
00436         "O4*",
00437         "O5'",
00438         "O5*",
00439         "O6 ",
00440         "OB*",
00441         "OC ",
00442         "OC*",
00443         "OD ",
00444         "OD1",
00445         "OD2",
00446         "OE ",
00447         "OE1",
00448         "OE2",
00449         "OF*",
00450         "OG ",
00451         "OG1",
00452         "OH ",
00453         "OI*",
00454         "OT ",
00455         "OT1",
00456         "OT2",
00457         "OXT",
00458         "P  ",
00459         "PG1",
00460         "PG2",
00461         "QA ",
00462         "QB ",
00463         "QD ",
00464         "QD1",
00465         "QD2",
00466         "QE ",
00467         "QE1",
00468         "QE2",
00469         "QG ",
00470         "QG1",
00471         "QG2",
00472         "QH1",
00473         "QH2",
00474         "QQD",
00475         "QQG",
00476         "QR ",
00477         "QZ ",
00478         "S  ",
00479         "S1P",
00480         "SD ",
00481         "SG ",
00482         "UNK"
00483 };
00484 
00485 
00486 int PDBAtomtoNum( char *atom_name ) {
00487         //adjusting so the string is right filled with spaces...
00488         char search_name[ 4 ];
00489         memset( search_name, ' ', 4 );
00490         search_name[3] = 0;
00491         bool ended = false;
00492         for (int i = 0; i < 3; i++ ) {
00493                 if ( atom_name[i] == 0 || atom_name[i] == '\r' || atom_name[i] == '\n' ) 
00494                         ended = true;
00495                 if ( !ended ) 
00496                         search_name[i] = atom_name[i];
00497         }
00498         
00499         for (unsigned int i = 0; i < sizeof(pdb_atomname)/sizeof(pdb_atomname[0]); i++) {
00500                 if ( !strncmp( search_name, pdb_atomname[i], 3) ){
00501                         return i;
00502                 }
00503         }
00504         return -1;
00505 }

Generated on Wed Apr 11 16:50:50 2007 for open_prospect by  doxygen 1.4.6