source: branches/lib/SECEDIT/SEC_bonddef.cxx

Last change on this file was 19407, checked in by westram, 2 years ago
  • reintegrates 'ali' into 'trunk'
    • use bond settings from EDIT4 in SECEDIT
    • fix refresh logic
    • refactor underlying code
  • adds: log:branches/ali@19393:19406
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 1.9 KB
Line 
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
19GB_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
26    GB_ERROR error = NULp;
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
Note: See TracBrowser for help on using the repository browser.