File: AtomInfoHistory.h

package info (click to toggle)
pymol 2.5.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 42,288 kB
  • sloc: cpp: 476,472; python: 76,538; ansic: 29,510; javascript: 6,792; sh: 47; makefile: 24
file content (293 lines) | stat: -rw-r--r-- 8,771 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
/* 
A* -------------------------------------------------------------------
B* This file contains source code for the PyMOL computer program
C* copyright Schrodinger, LLC.
D* -------------------------------------------------------------------
E* It is unlawful to modify or remove this copyright notice.
F* -------------------------------------------------------------------
G* Please see the accompanying LICENSE file for further information. 
H* -------------------------------------------------------------------
I* Additional authors of this source file include:
-* 
-* 
-*
Z* -------------------------------------------------------------------
*/

#ifndef _H_AtomInfoHistory
#define _H_AtomInfoHistory

#include <map>

#include"AtomInfo.h"
#include"Util.h"
#include"Lex.h"

typedef struct AtomInfoType_1_7_6 {
  int resv;
  int customType;
  int priority;
  float b, q, vdw, partialCharge;
  int selEntry;
  int color;
  int id;                       // PDB ID
  unsigned int flags;
  int temp1;                    /* kludge fields - to remove */
  int unique_id;                /* introduced in version 0.77 */
  int discrete_state;           /* state+1 for atoms in discrete objects */
  float elec_radius;            /* radius for PB calculations */
  int rank;
  int textType;
  int custom;
  int label;
  int visRep;                   /* bitmask for all reps */

  /* be careful not to write at these as (int*) */

  signed char formalCharge;     // values typically in range -2..+2
  signed char stereo;           /* for 2D representation */
  signed char mmstereo;           /* from MMStereo */
  signed char cartoon;          /* 0 = default which is auto (use ssType) */

  // boolean flags
  signed char hetatm;
  signed char bonded;
  signed char chemFlag;         // 0,1,2
  signed char geom;             // cAtomInfo*

  signed char valence;

  // boolean flags
  signed char deleteFlag;
  signed char masked;

  signed char protekted;        // 0,1,2

  signed char protons;          /* atomic number */

  // boolean flags
  signed char hb_donor;
  signed char hb_acceptor;
  signed char has_setting;      /* setting based on unique_id */

  int chain;
  SegIdent segi;
  AtomName name;
  ElemName elem;                // redundant with "protons" ?
  ResIdent resi;
  char has_prop;
  SSType ssType;                /* blank or 'L' = turn/loop, 'H' = helix, 'S' = beta-strand/sheet */
  Chain alt;
  ResName resn;

  // replace with pointer?
  float U11, U22, U33, U12, U13, U23;

  int oldid; // for undo

  int prop_id;
  bool has_anisou() const { return U11 || U22 || U33 || U12 || U13 || U23; }
  const float * get_anisou() const { return &U11; } // for copying
  float * get_anisou() { return &U11; } // for copying

  inline void setResi(int resv_, char inscode_) {
    resv = resv_;
    AtomResiFromResv(resi, sizeof(resi), resv, inscode_);
  }

  inline char getInscode() const {
    int i = strlen(resi) - 1;
    if (i >= 0 && (resi[i] < '0' || '9' < resi[i]))
      return resi[i];
    return '\0';
  }
} AtomInfoType_1_7_6;

typedef struct AtomInfoType_1_7_7 {
  union {
    float * anisou;               // only allocate with get_anisou
    int64_t dummyanisou;
  };
  int resv;
  int customType;
  int priority;
  float b, q, vdw, partialCharge;
  int selEntry;
  int color;
  int id;                       // PDB ID
  unsigned int flags;
  int temp1;                    /* kludge fields - to remove */
  int unique_id;                /* introduced in version 0.77 */
  int discrete_state;           /* state+1 for atoms in discrete objects */
  float elec_radius;            /* radius for PB calculations */
  int rank;
  int textType;
  int custom;
  int label;
  int visRep;                   /* bitmask for all reps */
  int oldid;                    // for undo
  int prop_id;

  // boolean flags
  bool hetatm : 1;
  bool bonded : 1;
  bool deleteFlag : 1;
  bool masked : 1;
  bool hb_donor : 1;
  bool hb_acceptor : 1;
  bool has_setting : 1;      /* setting based on unique_id */
  bool has_prop : 1;

  /* be careful not to write at these as (int*) */

  signed char formalCharge;     // values typically in range -2..+2
  signed char mmstereo;           /* from MMStereo */
  signed char cartoon;          /* 0 = default which is auto (use ssType) */
  signed char geom;             // cAtomInfo*
  signed char valence;          // 0-4
  signed char protons;          /* atomic number */

  int chain;
  SegIdent segi;
  AtomName name;
  ElemName elem;                // redundant with "protons" ?
  ResIdent resi;
  SSType ssType;                /* blank or 'L' = turn/loop, 'H' = helix, 'S' = beta-strand/sheet */
  Chain alt;
  ResName resn;

  // small value optimized bitfields
  unsigned char stereo : 2;     // 0-3 Only for SDF (MOL) format in/out
  unsigned char chemFlag : 2;   // 0,1,2
  unsigned char protekted : 2;  // 0,1,2

  // no anisou support in 1.8.0
  bool has_anisou() const { return false; }
  const float * get_anisou() const { return NULL; }
  float * get_anisou() { return NULL; }

  inline void setResi(int resv_, char inscode_) {
    resv = resv_;
    AtomResiFromResv(resi, sizeof(resi), resv, inscode_);
  }

  inline char getInscode() const {
    int i = strlen(resi) - 1;
    if (i >= 0 && (resi[i] < '0' || '9' < resi[i]))
      return resi[i];
    return '\0';
  }
} AtomInfoType_1_7_7;

/*
 * This is not identical to the 1.8.2 AtomInfoType, it's missing all members
 * which are not relevant or unsupported with pse_binary_dump (anisou,
 * selEntry, temp1, oldid, prop_id, deleteFlag)
 */
typedef int lexidx_int_t;
struct AtomInfoType_1_8_1 {
  // contiguous memory instead of pointer ("short" matches PDB precision)
  short anisou[6];

  lexidx_int_t segi;
  lexidx_int_t chain;
  lexidx_int_t resn;
  lexidx_int_t name;
  lexidx_int_t textType;
  lexidx_int_t custom;
  lexidx_int_t label;

  int resv;
  int customType;
  int priority;
  float b, q, vdw, partialCharge;
  int color;
  int id;                       // PDB ID
  unsigned int flags;
  int unique_id;                /* introduced in version 0.77 */
  int discrete_state;           /* state+1 for atoms in discrete objects */
  float elec_radius;            /* radius for PB calculations */
  int rank;
  int visRep;                   /* bitmask for all reps */

  // boolean flags
  bool hetatm : 1;
  bool bonded : 1;
  bool masked : 1;
  bool hb_donor : 1;
  bool hb_acceptor : 1;
  bool has_setting : 1;      /* setting based on unique_id */

  signed char formalCharge;     // values typically in range -2..+2
  signed char cartoon;          /* 0 = default which is auto (use ssType) */
  signed char geom;             // cAtomInfo*
  signed char valence;          // 0-4
  signed char protons;          /* atomic number */

  char inscode;

  ElemName elem;               // redundant with "protons" ?
  SSType ssType;               /* blank or 'L' = turn/loop, 'H' = helix, 'S' = beta-strand/sheet */
  Chain alt;

  // small value optimized bitfields
  unsigned char stereo : 2;     // 0-3 Only for SDF (MOL) format in/out
  unsigned char chemFlag : 2;   // 0,1,2
  unsigned char protekted : 2;  // 0,1,2

  char getInscode() const { return inscode; }
  void setInscode(char c) { inscode = makeInscode(c); }

  void setResi(const char * resi) {
    if (sscanf(resi, "%d%c", &resv, &inscode) == 1 || inscode <= ' ')
      inscode = '\0';
  }

  void setResi(int resv_, char inscode_) {
    resv = resv_;
    setInscode(inscode_);
  }

  bool has_anisou() const { return anisou[0] || anisou[1] || anisou[2] || anisou[3] || anisou[4] || anisou[5]; }
  const short * get_anisou() const { return anisou; } // for copying
  short * get_anisou() { return anisou; } // for copying
};

class AtomInfoTypeConverter {
  PyMOLGlobals * G;
  int NAtom;

  template <typename D, typename S> void copy1(D *dest, const S *src);
  template <typename D, typename S> void copyN(D *dest, const S *src);
  template <typename D> D * allocCopy(const AtomInfoType *src);

public:
  AtomInfoTypeConverter(PyMOLGlobals * G_, int natom) : G(G_), NAtom(natom) {}

  std::map<lexidx_int_t, lexidx_t> lexidxmap;

  lexidx_int_t to_lexidx_int(const lexidx_t& idx) {
    return idx;
  }

  void copy(AtomInfoType * dest, const void *src, int srcversion);
  void * allocCopy(int destversion, const AtomInfoType * src);

  /*
   * For copying Lex strings
   */
  inline void copy_attr_s(lexidx_t& dest, lexidx_t src) {
    if (!lexidxmap.empty())
      src = lexidxmap[src];
    LexAssign(G, dest, src);
  }
  inline void copy_attr_s(lexidx_t& dest, const char * src) {
    LexAssign(G, dest, src);
  }
  template <size_t N> inline void copy_attr_s(char (&dest)[N], const lexidx_t& src) {
    UtilNCopy(dest, LexStr(G, src), sizeof(dest));
  }
};

#endif