The outage for Sunday 24th November has been cancelled.
Bioplib
Protein Structure C Library
 All Data Structures Files Functions Variables Typedefs Macros Pages
DNAtoAA.c
Go to the documentation of this file.
1 /************************************************************************/
2 /**
3 
4  \file DNAtoAA.c
5 
6  \version V1.1
7  \date 07.07.14
8  \brief Convert DNA codons to amino acid 1-letter code
9 
10  \copyright (c) UCL / Dr. Andrew C. R. Martin 1994-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  #include "bioplib/seq.h" to define prototype
47 
48 **************************************************************************
49 
50  Revision History:
51  =================
52 
53 - V1.1 07.07.14 Use bl prefix for functions By: CTP
54 
55 *************************************************************************/
56 /* Doxygen
57  -------
58  #GROUP Handling Sequence Data
59  #SUBGROUP Conversions
60  #FUNCTION blDNAtoAA()
61  Converts a nucleic acid codon to the 1-letter amino acid equivalent.
62  Termination codons are returned as X. No special action is taken
63  for initiation codons.
64 */
65 /************************************************************************/
66 /* Includes
67 */
68 #include "macros.h"
69 #include <string.h>
70 #include <ctype.h>
71 
72 /************************************************************************/
73 /* Defines and macros
74 */
75 #define NUCINDEX(x) ((x)=='T' ? (0) : \
76  ((x)=='U' ? (0) : \
77  ((x)=='C' ? (1) : \
78  ((x)=='A' ? (2) : \
79  (3)))))
80 
81 /************************************************************************/
82 /* Globals
83 */
84 static char *sAACode[4][4] =
85 { { "FFLL", "SSSS", "YYXX", "CCXW" }, /* TTX, TCX, TAX, TGX */
86  { "LLLL", "PPPP", "HHQQ", "RRRR" }, /* CTX, CCX, CAX, CGX */
87  { "IIIM", "TTTT", "NNKK", "SSRR" }, /* ATX, ACX, AAX, AGX */
88  { "VVVV", "AAAA", "DDEE", "GGGG" } /* GTX, GCX, GAX, GGX */
89 } ;
90 
91 /************************************************************************/
92 /* Prototypes
93 */
94 
95 /************************************************************************/
96 /*>char blDNAtoAA(char *dna)
97  -------------------------
98 *//**
99 
100  \param[in] *dna DNA/RNA codon
101  \return 1-letter amino acid code (X=termination)
102 
103  Converts a nucleic acid codon to the 1-letter amino acid equivalent.
104  Termination codons are returned as X. No special action is taken
105  for initiation codons.
106 
107 - 18.04.94 Original By: ACRM
108 - 07.07.14 Use bl prefix for functions By: CTP
109 */
110 char blDNAtoAA(char *dna)
111 {
112  char buffer[8], *p;
113  int idx1, idx2, idx3;
114 
115  KILLLEADSPACES(p,dna);
116 
117  strncpy(buffer,p,8);
118  buffer[7] = '\0';
119  UPPER(buffer);
120 
121  idx1 = NUCINDEX(buffer[0]);
122  idx2 = NUCINDEX(buffer[1]);
123  idx3 = NUCINDEX(buffer[2]);
124 
125  return(sAACode[idx1][idx2][idx3]);
126 }
127 
Useful macros.
#define NUCINDEX(x)
Definition: DNAtoAA.c:75
char blDNAtoAA(char *dna)
Definition: DNAtoAA.c:110
#define KILLLEADSPACES(y, x)
Definition: macros.h:408
#define UPPER(x)
Definition: macros.h:390