The outage for Sunday 24th November has been cancelled.
Bioplib
Protein Structure C Library
 All Data Structures Files Functions Variables Typedefs Macros Pages
throne.c
Go to the documentation of this file.
1 /************************************************************************/
2 /**
3 
4  \file throne.c
5 
6  \version V1.9
7  \date 07.07.14
8  \brief Convert between 1 and 3 letter aa codes
9 
10  \copyright (c) UCL / Dr. Andrew C. R. Martin 1993-2014
11  \author Dr. Andrew C. R. Martin
12  \par
13  Institute of Structural & Molecular Biology,
14  University College London,
15  Gower Street,
16  London.
17  WC1E 6BT.
18  \par
19  andrew@bioinf.org.uk
20  andrew.martin@ucl.ac.uk
21 
22 **************************************************************************
23 
24  This code is NOT IN THE PUBLIC DOMAIN, but it may be copied
25  according to the conditions laid out in the accompanying file
26  COPYING.DOC.
27 
28  The code may be modified as required, but any modifications must be
29  documented so that the person responsible can be identified.
30 
31  The code may not be sold commercially or included as part of a
32  commercial product except as described in the file COPYING.DOC.
33 
34 **************************************************************************
35 
36  Description:
37  ============
38 
39 
40 **************************************************************************
41 
42  Usage:
43  ======
44 
45 **************************************************************************
46 
47  Revision History:
48  =================
49 - V1.0 29.09.92 Original By: ACRM
50 - V1.1 11.03.94 Added PCA, ASX and GLX to translation table.
51  PCA translates to E
52  Added routines to handle asx/glx
53 - V1.2 25.07.95 handles nucleic acids
54  Sets the gBioplibSeqNucleicAcid flag if it's a
55  nucleic acid.
56 - V1.3 08.03.07 Added PGA (Pyroglutamate) to translation table
57  (same as PCA: pyrrolidone carboxylic acid).
58  Note that it isn't clear whether this should translate
59  to Glu or Gln
60 - V1.4 21.07.08 Added CGN (5-OXO-PYRROLIDINE-2-CARBALDEHYDE) which
61  is again the same as PCA
62 - V1.5 19.12.08 Corrected NUMAAKNOWN - wasn't looking at U or X as
63  these were > NUMAAKNOWN!
64 - V1.6 04.02.09 onethr() was not properly working from end of list
65  for nucleic acids
66 - V1.7 18.02.09 Fixed for new PDB files which have " DT" etc for DNA
67  sequences
68 - V1.8 30.01.14 Added pyrrolysine and selenocysteine to translation
69  table. By: CTP
70  PYL translates to O, SEC translates to U.
71 - V1.9 07.07.14 Use bl prefix for functions By: CTP
72 
73 *************************************************************************/
74 /* Doxygen
75  -------
76  #GROUP Handling Sequence Data
77  #SUBGROUP Conversions
78  #FUNCTION blThrone()
79  Converts 3-letter code to 1-letter code.
80  Handles ASX and GLX as X
81 
82  #FUNCTION blThronex()
83  Converts 3-letter code to 1-letter code.
84  Handles ASX and GLX as B and Z.
85 
86  #FUNCTION blOnethr()
87  Converts 1-letter code to 3-letter code (actually as 4 chars).
88 */
89 /************************************************************************/
90 /* Includes
91 */
92 #include <string.h>
93 #include "SysDefs.h"
94 
95 /************************************************************************/
96 /* Defines and macros
97 */
98 #define NUMAAKNOWN 39
99 
100 /************************************************************************/
101 /* Globals
102 */
103 
104 /* N.B. The order in sTab1[] and sTab3[] must be the same and they must
105  end with X/UNK.
106  Also, nucleic acids must come *after* amino acids.
107 */
108 /* Don't forget to fix NUMAAKNOWN if adding to this table! */
109 static char sTab1[] = {'A','C','D','E','F',
110  'G','H','I','K','L',
111  'M','N','P','Q','R',
112  'S','T','V','W','Y',
113  'E','B','Z','E','E',
114  'O','U',
115  'A','T','C','G','U','I',
116  'A','T','C','G','I','X'
117  };
118 /* Don't forget to fix NUMAAKNOWN if adding to this table! */
119 static char sTab3[][8] = {"ALA ","CYS ","ASP ","GLU ","PHE ",
120  "GLY ","HIS ","ILE ","LYS ","LEU ",
121  "MET ","ASN ","PRO ","GLN ","ARG ",
122  "SER ","THR ","VAL ","TRP ","TYR ",
123  "PCA ","ASX ","GLX ","PGA ","CGN ",
124  "PYL ","SEC ",
125  " A "," T "," C "," G "," U "," I ",
126  " DA "," DT "," DC "," DG "," DI ","UNK "
127  };
128 /* Don't forget to fix NUMAAKNOWN if adding to this table! */
129 
131 
132 /************************************************************************/
133 /* Prototypes
134 */
135 
136 
137 /************************************************************************/
138 /*>char blThrone(char *three)
139  --------------------------
140 *//**
141 
142  \param[in] *three Three letter code
143  \return One letter code
144 
145  Converts 3-letter code to 1-letter code.
146  Handles ASX and GLX as X
147 
148 - 29.09.92 Original By: ACRM
149 - 11.03.94 Modified to handle ASX and GLX in the tables
150 - 25.07.95 Added handling of gBioplibSeqNucleicAcid
151 - 07.07.14 Use bl prefix for functions By: CTP
152 */
153 char blThrone(char *three)
154 {
155  int j;
156 
157  if(three[0] == ' ' && three[1] == ' ')
159  else
161 
162  if(three[2] == 'X')
163  return('X');
164 
165  for(j=0;j<NUMAAKNOWN;j++)
166  if(!strncmp(sTab3[j],three,3)) return(sTab1[j]);
167 
168  /* Only get here if the three letter code was not found */
169  return('X');
170 }
171 
172 
173 /************************************************************************/
174 /*>char blThronex(char *three)
175  ---------------------------
176 *//**
177 
178  \param[in] *three Three letter code
179  \return One letter code
180 
181  Converts 3-letter code to 1-letter code.
182  Handles ASX and GLX as B and Z.
183 
184 - 29.09.92 Original By: ACRM
185 - 25.07.95 Added handling of gBioplibSeqNucleicAcid
186 - 07.07.14 Use bl prefix for functions By: CTP
187 */
188 char blThronex(char *three)
189 {
190  int j;
191 
192  if(three[0] == ' ' && three[1] == ' ')
194  else
196 
197  for(j=0;j<NUMAAKNOWN;j++)
198  if(!strncmp(sTab3[j],three,3)) return(sTab1[j]);
199 
200  /* Only get here if the three letter code was not found */
201  return('X');
202 }
203 
204 
205 /************************************************************************/
206 /*>char *blOnethr(char one)
207  ------------------------
208 *//**
209 
210  \param[in] one One letter code
211  \return Three letter code (padded to 4 chars with a
212  space)
213 
214  Converts 1-letter code to 3-letter code (actually as 4 chars).
215 
216 - 07.06.93 Original By: ACRM
217 - 25.07.95 If the gBioplibSeqNucleicAcid flag is set, assumes nucleic
218  acids rather than amino acids
219 - 03.02.09 Fixed nucleic search - j was incrementing instead of
220  decrementing!
221 - 07.07.14 Use bl prefix for functions By: CTP
222 */
223 char *blOnethr(char one)
224 {
225  int j;
226 
227  if(gBioplibSeqNucleicAcid) /* Work from end of table */
228  {
229  for(j=NUMAAKNOWN-1;j>=0;j--)
230  if(sTab1[j] == one) return(sTab3[j]);
231  }
232  else /* Work from start of table */
233  {
234  for(j=0;j<NUMAAKNOWN;j++)
235  if(sTab1[j] == one) return(sTab3[j]);
236  }
237 
238  /* Only get here if the one letter code was not found */
239  return(sTab3[NUMAAKNOWN-1]);
240 }
241 
short BOOL
Definition: SysDefs.h:64
#define FALSE
Definition: macros.h:223
#define TRUE
Definition: macros.h:219
char blThrone(char *three)
Definition: throne.c:153
BOOL gBioplibSeqNucleicAcid
Definition: throne.c:130
char blThronex(char *three)
Definition: throne.c:188
System-type variable type definitions.
char * blOnethr(char one)
Definition: throne.c:223
#define NUMAAKNOWN
Definition: throne.c:98