ARB
SEC_bonddef.cxx
Go to the documentation of this file.
1 // ================================================================= //
2 // //
3 // File : SEC_bonddef.cxx //
4 // Purpose : //
5 // //
6 // Coded by Ralf Westram (coder@reallysoft.de) in September 2007 //
7 // Institute of Microbiology (Technical University Munich) //
8 // http://www.arb-home.de/ //
9 // //
10 // ================================================================= //
11 
12 #include "SEC_bonddef.hxx"
13 #include "SEC_defs.hxx"
14 
15 #include <arbdbt.h>
16 
17 #include <cctype>
18 
19 GB_ERROR SEC_bond_def::fill_translation_table(const char *from, const char *to) {
20  int i;
21 
22  for (i = 0; i<256; ++i) {
23  edit4_to_secedit[i] = i;
24  }
25 
27  for (i = 0; from[i] && !error; ++i) {
28  if (!to[i]) {
29  error = "translate-into is too short (requires one char for each listed EDIT4 helix symbol)";
30  }
31  else {
32  char& e2s = edit4_to_secedit[safeCharIndex(from[i])];
33 
34  bool alreadyChanged = e2s != from[i];
35  if (alreadyChanged) {
36  error = GBS_global_string("Duplicate translation for helix symbol '%c' (into '%c' and '%c')",
37  from[i], e2s, to[i]);
38  }
39  else if (from[i] == to[i]) {
40  error = GBS_global_string("Useless translation from '%c' to '%c'", from[i], to[i]);
41  }
42  else {
43  e2s = to[i];
44  }
45  }
46  }
47 
48  if (!from[i] && to[i] && !error) {
49  error = "translate-into is too long (requires exactly one char for each listed EDIT4 helix symbol)";
50  }
51 
52  return error;
53 }
54 
55 
56 
const char * GB_ERROR
Definition: arb_core.h:25
CONSTEXPR_INLINE unsigned char safeCharIndex(char c)
Definition: dupstr.h:73
const char * GBS_global_string(const char *templat,...)
Definition: arb_msg.cxx:203
static void error(const char *msg)
Definition: mkptypes.cxx:96
#define NULp
Definition: cxxforward.h:116