1 /* @include ajtranslate ******************************************************* 2 ** 3 ** AJAX translate functions 4 ** 5 ** These functions control all aspects of sequence translation 6 ** 7 ** These functions do not translate to the 'ambiguity' residues 8 ** 'B' (Asn or Asp) and 'Z' (Glu or Gln). So the codons: 9 ** RAC, RAT, RAY, RAU which could code for 'B' return 'X' 10 ** and SAA, SAG, SAR which could code for 'Z' return 'X'. 11 ** 12 ** This translation table doesn't have the doubly ambiguous 13 ** codons set up: 14 ** YTR - L 15 ** MGR - R 16 ** YUR - L 17 ** 18 ** This should be attended to at some time. 19 ** 20 ** @author Copyright (C) 1999 Gary Williams 21 ** @version $Revision: 1.24 $ 22 ** @modified Feb 15 1999 GWW First version 23 ** @modified April 19 1999 GWW Second version using NCBI's GC tables 24 ** @modified April 18 2000 GWW Reorganised many of the routines 25 ** @modified 2001-2011 Peter Rice 26 ** @modified $Date: 2013/02/07 10:32:50 $ by $Author: rice $ 27 ** @@ 28 ** 29 ** This library is free software; you can redistribute it and/or 30 ** modify it under the terms of the GNU Lesser General Public 31 ** License as published by the Free Software Foundation; either 32 ** version 2.1 of the License, or (at your option) any later version. 33 ** 34 ** This library is distributed in the hope that it will be useful, 35 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 36 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 37 ** Lesser General Public License for more details. 38 ** 39 ** You should have received a copy of the GNU Lesser General Public 40 ** License along with this library; if not, write to the Free Software 41 ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 42 ** MA 02110-1301, USA. 43 ** 44 ******************************************************************************/ 45 46 #ifndef AJTRANSLATE_H 47 #define AJTRANSLATE_H 48 49 /* ========================================================================= */ 50 /* ============================= include files ============================= */ 51 /* ========================================================================= */ 52 53 #include "ajdefine.h" 54 #include "ajstr.h" 55 #include "ajfile.h" 56 #include "ajseq.h" 57 58 AJ_BEGIN_DECLS 59 60 61 62 63 /* ========================================================================= */ 64 /* =============================== constants =============================== */ 65 /* ========================================================================= */ 66 67 68 69 70 /* ========================================================================= */ 71 /* ============================== public data ============================== */ 72 /* ========================================================================= */ 73 74 75 76 77 /* @data AjPTrn *************************************************************** 78 ** 79 ** Ajax Sequence translation object. 80 ** 81 ** Holds the Genetic Code specification and information needed to translate 82 ** the sequence and find initiation sites. 83 ** 84 ** @new ajTrnNew Default constructor 85 ** @new ajTrnNewI Default constructor 86 ** @new ajTrnNewC Default constructor 87 ** @delete ajTrnDel Default destructor 88 ** @input ajTrnReadFile Reads a Genetic Code file 89 ** @use ajTrnCodon Translating a codon from an AjPStr 90 ** @use ajTrnRevCodon Reverse complement translating a codon from an AjPStr 91 ** @use ajTrnCodonC Translating a codon from a char* text 92 ** @use ajTrnRevCodonC Translating a codon from a char* text 93 ** @use ajTrnCodonK Translating a codon from a char* to a char 94 ** @use ajTrnRevCodonK Reverse complement translating a codon 95 ** from a char* to a char 96 ** @use ajTrnC Translating a sequence from a char* text 97 ** @use ajTrnRevC Reverse complement translating a sequence from a char* text 98 ** @use ajTrnAltRevC (Alt) Reverse complement translating a sequence 99 ** from a char* text 100 ** @use ajTrnStr Translating a sequence from a AjPStr 101 ** @use ajTrnRevStr Reverse complement translating a sequence from a AjPStr 102 ** @use ajTrnAltRevStr (Alt) Reverse complement translating a sequence 103 ** from a AjPStr 104 ** @use ajTrnSeq Translating a sequence from a AjPSeq 105 ** @use ajTrnRevSeq Reverse complement translating a sequence from a AjPSeq 106 ** @use ajTrnAltRevSeq Reverse complement translating a sequence from a AjPSeq 107 ** @use ajTrnCFrame Translating a sequence from a char* in a frame 108 ** @use ajTrnStrFrame Translating a sequence from a AjPStr in a frame 109 ** @use ajTrnSeqFrame Translating a sequence from a AjPSeq in a frame 110 ** @use ajTrnSeqFramePep Translating a sequence from a AjPSeq in a frame 111 ** and returns a new peptide 112 ** @use ajTrnDangleC Translates the last 1 or two bases of a sequence 113 ** in a char* text 114 ** @use ajTrnDangleS Translates the last 1 or two bases of a sequence 115 ** in a AjStr 116 ** @use ajTrnSeqOrig Translating a sequence 117 ** @cast ajTrnGetTitle Returns description of the translation table 118 ** @cast ajTrnGetFilename Returns file name the translation table was read from 119 ** @use ajTrnCodonstrTypeS Checks whether the input codon is a Start codon, 120 ** a Stop codon or something else 121 ** @use ajTrnCodonstrTypeC Checks whether a const char* codon is 122 ** a Start codon, a Stop codon or something else 123 ** 124 ** @attr FileName [AjPStr] name of file that held the data 125 ** @attr Title [AjPStr] title of data read from file 126 ** @attr GC [char[16][16][16]] genetic codon table 127 ** @attr Starts [char[16][16][16]] initiation site table 128 ** 129 ** @alias AjSTrn 130 ** @alias AjOTrn 131 ** @@ 132 ******************************************************************************/ 133 134 typedef struct AjSTrn 135 { 136 AjPStr FileName; 137 AjPStr Title; 138 char GC[16][16][16]; 139 char Starts[16][16][16]; 140 } AjOTrn; 141 142 #define AjPTrn AjOTrn* 143 144 145 146 147 /* ========================================================================= */ 148 /* =========================== public functions ============================ */ 149 /* ========================================================================= */ 150 151 152 153 154 /* 155 ** Prototype definitions 156 */ 157 158 void ajTrnDel(AjPTrn* pthis); 159 void ajTrnExit(void); 160 AjPTrn ajTrnNew(const AjPStr trnFileName); 161 AjPTrn ajTrnNewI(ajint trnFileNameInt); 162 AjPTrn ajTrnNewC(const char *trnFileName); 163 void ajTrnReadFile(AjPTrn trnObj, AjPFile trnFile); 164 AjPSeq ajTrnNewPep(const AjPSeq nucleicSeq, ajint frame); 165 char ajTrnCodonS(const AjPTrn trnObj, const AjPStr codon); 166 char ajTrnCodonRevS(const AjPTrn trnObj, const AjPStr codon); 167 char ajTrnCodonC(const AjPTrn trnObj, const char *codon); 168 char ajTrnCodonRevC(const AjPTrn trnObj, const char *codon); 169 char ajTrnCodonK(const AjPTrn trnObj, const char *codon); 170 char ajTrnRevCodonK(const AjPTrn trnObj, const char *codon); 171 void ajTrnRevStr(const AjPTrn trnObj, const AjPStr str, 172 AjPStr *pep); 173 void ajTrnSeqC(const AjPTrn trnObj, const char *str, ajint len, 174 AjPStr *pep); 175 void ajTrnSeqInitC(const AjPTrn trnObj, const char *str, ajint len, 176 AjPStr *pep); 177 void ajTrnSeqRevC(const AjPTrn trnObj, const char *str, ajint len, 178 AjPStr *pep); 179 void ajTrnSeqRevinitC(const AjPTrn trnObj, const char *str, ajint len, 180 AjPStr *pep); 181 void ajTrnSeqAltRevC(const AjPTrn trnObj, const char *str, ajint len, 182 AjPStr *pep); 183 void ajTrnSeqAltRevinitC(const AjPTrn trnObj, const char *str, 184 ajint len, AjPStr *pep); 185 void ajTrnSeqS(const AjPTrn trnObj, const AjPStr str, 186 AjPStr *pep); 187 void ajTrnSeqAltRevS(const AjPTrn trnObj, const AjPStr str, 188 AjPStr *pep); 189 void ajTrnSeqSeq(const AjPTrn trnObj, const AjPSeq seq, 190 AjPStr *pep); 191 void ajTrnSeqRevSeq(const AjPTrn trnObj, const AjPSeq seq, 192 AjPStr *pep); 193 void ajTrnSeqAltRevSeq(const AjPTrn trnObj, const AjPSeq seq, 194 AjPStr *pep); 195 void ajTrnSeqFrameC(const AjPTrn trnObj, const char *seq, ajint len, 196 ajint frame, AjPStr *pep); 197 void ajTrnSeqFrameInitC(const AjPTrn trnObj, const char *seq, 198 ajint len, ajint frame, AjPStr *pep); 199 const AjPStr ajTrnName(ajint trnFileNameInt); 200 void ajTrnSeqFrameS(const AjPTrn trnObj, const AjPStr seq, 201 ajint frame, AjPStr *pep); 202 void ajTrnSeqFrameInitS(const AjPTrn trnObj, const AjPStr seq, 203 ajint frame, AjPStr *pep); 204 void ajTrnSeqFrameSeq(const AjPTrn trnObj, const AjPSeq seq, 205 ajint frame, AjPStr *pep); 206 void ajTrnSeqFrameSeqInit(const AjPTrn trnObj, const AjPSeq seq, 207 ajint frame, AjPStr *pep); 208 ajint ajTrnSeqDangleC(const AjPTrn trnObj, const char *seq, 209 ajint frame, AjPStr *pep); 210 ajint ajTrnSeqDangleS(const AjPTrn trnObj, const AjPStr seq, 211 ajint frame, AjPStr *pep); 212 AjPSeq ajTrnSeqFramePep(const AjPTrn trnObj, const AjPSeq seq, 213 ajint frame); 214 AjPStr ajTrnGetTitle(const AjPTrn thys); 215 AjPStr ajTrnGetFilename(const AjPTrn thys); 216 ajint ajTrnCodonstrTypeC(const AjPTrn trnObj, 217 const char *codon, char *aa); 218 ajint ajTrnCodonstrTypeS(const AjPTrn trnObj, 219 const AjPStr codon, char *aa); 220 AjPSeq ajTrnSeqInit(const AjPTrn trnObj, const AjPSeq seq, 221 ajint frame); 222 AjPSeq ajTrnSeqOrig(const AjPTrn trnObj, const AjPSeq seq, 223 ajint frame); 224 225 /* 226 ** End of prototype definitions 227 */ 228 229 230 231 232 233 #ifdef AJ_COMPILE_DEPRECATED_BOOK 234 #endif /* AJ_COMPILE_DEPRECATED_BOOK */ 235 236 #ifdef AJ_COMPILE_DEPRECATED 237 238 __deprecated ajint ajTrnStartStop(const AjPTrn trnObj, 239 const AjPStr codon, char *aa); 240 __deprecated ajint ajTrnStartStopC(const AjPTrn trnObj, 241 const char *codon, char *aa); 242 __deprecated AjPStr ajTrnGetFileName(const AjPTrn thys); 243 __deprecated const AjPStr ajTrnCodon(const AjPTrn trnObj, const AjPStr codon); 244 __deprecated const AjPStr ajTrnRevCodon(const AjPTrn trnObj, 245 const AjPStr codon); 246 __deprecated void ajTrnC(const AjPTrn trnObj, const char *str, ajint len, 247 AjPStr *pep); 248 __deprecated void ajTrnRevC(const AjPTrn trnObj, const char *str, 249 ajint len, AjPStr *pep); 250 __deprecated void ajTrnAltRevC(const AjPTrn trnObj, const char *str, 251 ajint len, AjPStr *pep); 252 __deprecated void ajTrnStr(const AjPTrn trnObj, const AjPStr str, 253 AjPStr *pep); 254 __deprecated void ajTrnAltRevStr(const AjPTrn trnObj, const AjPStr str, 255 AjPStr *pep); 256 __deprecated void ajTrnSeq(const AjPTrn trnObj, const AjPSeq seq, 257 AjPStr *pep); 258 __deprecated void ajTrnRevSeq(const AjPTrn trnObj, const AjPSeq seq, 259 AjPStr *pep); 260 __deprecated void ajTrnAltRevSeq(const AjPTrn trnObj, const AjPSeq seq, 261 AjPStr *pep); 262 __deprecated void ajTrnCFrame(const AjPTrn trnObj, const char *seq, 263 ajint len, ajint frame, AjPStr *pep); 264 __deprecated void ajTrnStrFrame(const AjPTrn trnObj, const AjPStr seq, 265 ajint frame, AjPStr *pep); 266 __deprecated void ajTrnSeqFrame(const AjPTrn trnObj, const AjPSeq seq, 267 ajint frame, AjPStr *pep); 268 __deprecated ajint ajTrnCDangle(const AjPTrn trnObj, const char *seq, 269 ajint len, ajint frame, AjPStr *pep); 270 __deprecated ajint ajTrnStrDangle(const AjPTrn trnObj, const AjPStr seq, 271 ajint frame, AjPStr *pep); 272 273 #endif /* AJ_COMPILE_DEPRECATED */ 274 275 276 277 278 AJ_END_DECLS 279 280 #endif /* !AJTRANSLATE_H */ 281