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 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539
|
/**
* @file
*/
/*
A* -------------------------------------------------------------------
B* This file contains source code for the PyMOL computer program
C* copyright 1998-2000 by Warren Lyford Delano of DeLano Scientific.
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_AtomInfo
#define _H_AtomInfo
#include"Rep.h"
#include"Setting.h"
#include"SymOp.h"
#include"Version.h"
#if _PyMOL_VERSION_int < 1770
#define AtomInfoVERSION 176
#define BondInfoVERSION 176
#elif _PyMOL_VERSION_int < 1810
#define AtomInfoVERSION 177
#define BondInfoVERSION 177
#else
#define AtomInfoVERSION 181
#define BondInfoVERSION 181
#endif
enum {
cAtomProtected_off = 0,
cAtomProtected_explicit = 1,
cAtomProtected_drag = 2,
};
/* FLAGS 0-3 have the following conventional usage for molecular modeling */
/* FLAG 0 - Atoms of interest - i.e. a ligand in an active site */
#define cAtomFlag_focus 0x00000001
/* FLAG 1 - Free atoms - those which can move subject to a force-field */
#define cAtomFlag_free 0x00000002
/* FLAG 2 - Restrained atoms - atoms subject to a harmonic restraint */
#define cAtomFlag_restrain 0x00000004
/* FLAG 3 - Fixed atoms - no movement allowed */
#define cAtomFlag_fix 0x00000008
/* FLAG 4 - Exclude these atoms when performing simulation, minimization */
#define cAtomFlag_exclude 0x00000010
/* FLAG 5 - Study atoms */
#define cAtomFlag_study 0x00000020
/* FLAGS 6-7 are for polymer sub-classification */
#define cAtomFlag_protein 0x00000040
#define cAtomFlag_nucleic 0x00000080
/* FLAGS 8-15 are free for end users to manipulate */
/* FLAGS 16-21 are reserved for external GUIs and linked applications */
/* FLAGS 22-23 are for temporary use only (inside of self-contained loops) */
/* FLAGS 24-31 are reserved for PyMOL's internal use */
/* FLAG 24 - don't surface these atoms (waters, ligands, etc.) */
// DEPRECATED (PYMOL-3500): Instead of `flag exfoliate, sele`, use `hide
// surface, sele` or some equivalent command.
#define cAtomFlag_exfoliate 0x01000000
/* FLAG 25 - ignore atoms altogether when surfacing */
#define cAtomFlag_ignore 0x02000000
/* FLAG 26 - disable cartoon smoothing for these atoms */
#define cAtomFlag_no_smooth 0x04000000
/* FLAG 27 - polymer */
#define cAtomFlag_polymer 0x08000000
/* FLAG 28 - waters */
#define cAtomFlag_solvent 0x10000000
/* FLAG 29 - organics */
#define cAtomFlag_organic 0x20000000
/* FLAG 30 - inorganics */
#define cAtomFlag_inorganic 0x40000000
/* FLAG 31 - guide atom: e.g. CA in proteins */
#define cAtomFlag_guide 0x80000000
#define cAtomFlag_class 0xF8000000
#define cAtomFlag_class_mask 0x07FFFFFF
#define cResnLen 5
#define cResiLen 5
#define cAtomNameLen 4
#define cElemNameLen 4
#define cSegiLen 4
#define cTextTypeLen 20
#define cLabelTypeLen 20
#define cAtomInfoTetrahedral 4
#define cAtomInfoPlanar 3
#define cAtomInfoLinear 2
#define cAtomInfoSingle 1
#define cAtomInfoNone 5
#define cAN_LP 0
#define cAN_H 1
#define cAN_He 2
#define cAN_Li 3
#define cAN_Be 4
#define cAN_B 5
#define cAN_C 6
#define cAN_N 7
#define cAN_O 8
#define cAN_F 9
#define cAN_Ne 10
#define cAN_Na 11
#define cAN_Mg 12
#define cAN_Al 13
#define cAN_Si 14
#define cAN_P 15
#define cAN_S 16
#define cAN_Cl 17
#define cAN_Ar 18
#define cAN_K 19
#define cAN_Ca 20
#define cAN_Ti 22
#define cAN_V 23
#define cAN_Cr 24
#define cAN_Mn 25
#define cAN_Fe 26
#define cAN_Co 27
#define cAN_Ni 28
#define cAN_Cu 29
#define cAN_Zn 30
#define cAN_Ga 31
#define cAN_Ge 32
#define cAN_As 33
#define cAN_Se 34
#define cAN_Br 35
#define cAN_Kr 36
#define cAN_Rb 37
#define cAN_Sr 38
#define cAN_Y 39
#define cAN_Pd 46
#define cAN_Ag 47
#define cAN_Cd 48
#define cAN_In 49
#define cAN_Sn 50
#define cAN_Sb 51
#define cAN_Te 52
#define cAN_I 53
#define cAN_Xe 54
#define cAN_Cs 55
#define cAN_Ba 56
#define cAN_Ce 58
#define cAN_Pt 78
#define cAN_Au 79
#define cAN_Hg 80
#define cAN_Tl 81
#define cAN_Pb 82
#define cAN_U 92
#define SDF_CHIRALITY_ODD 1 // odd / clockwise
#define SDF_CHIRALITY_EVEN 2 // even / counterclockwise
#define SDF_CHIRALITY_EITHER 3 // either or unmarked
typedef char Chain[2];
typedef char SSType[2];
typedef char SegIdent[cSegiLen + 1];
typedef char ResIdent[cResiLen + 1];
typedef char ResName[cResnLen + 1];
typedef char AtomName[cAtomNameLen + 1];
typedef char ElemName[cElemNameLen + 1];
// for customType (not geom)
#define cAtomInfoNoType -9999
#define cBondOrderDeloc 4
inline char makeInscode(char c) {
return (c <= ' ') ? '\0' : c;
}
struct ElementTableItemType {
const char * name;
const char * symbol;
float vdw;
float weight;
};
extern const ElementTableItemType ElementTable[];
extern const int ElementTableSize;
typedef struct BondType {
int index[2];
int unique_id;
/// Symmetry operation of the second atom. The implicit symmetry for the first
/// atom is 1_555. (We assume that there is no use case for `symop_1 != 1_555
/// && symop_2 != 1_555`).
pymol::SymOp symop_2;
signed char order; // 0-4
bool has_setting; /* setting based on unique_id */
/// True if this is a bond to a symmetry mate
bool hasSymOp() const;
} BondType;
typedef struct AtomInfoType {
float * anisou; // only allocate with get_anisou
lexidx_t segi;
lexidx_t chain;
lexidx_t resn;
lexidx_t name;
lexidx_t textType;
lexidx_t custom;
lexidx_t label;
int resv;
int customType;
int priority;
float b, q, vdw, partialCharge;
SelectorMemberOffset_t selEntry;
int color;
int id; // PDB ID
unsigned int flags;
int temp1; /* kludge fields - to remove */
int unique_id; /* introduced in version 0.77 */
StateIndexPython_t discrete_state; ///< state+1 for atoms in discrete objects
float elec_radius; /* radius for PB calculations */
int rank;
int visRep; /* bitmask for all reps */
#ifdef _PYMOL_IP_EXTRAS
int prop_id;
#endif
// 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 */
/* be careful not to write at these as (int*) */
signed char formalCharge; // values typically in range -2..+2
signed char cartoon; /* 0 = default which is auto (use ssType) */
signed char geom; // cAtomInfo*
// "valence" should be renamed to "degree" (or "total_degree"). It's the
// number of explicit and implicit neighbors, independent of bond order.
// Should be equivalent to RDKit::Atom::getTotalDegree() and
// OBAtom::GetTotalDegree().
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
unsigned char mmstereo : 2; // 0/R/S/?
// methods
bool isHydrogen() const {
return protons == cAN_H;
}
bool isMetal() const {
return (
(protons > 2 && protons < 5) ||
(protons > 10 && protons < 14) ||
(protons > 18 && protons < 32) ||
(protons > 36 && protons < 51) ||
(protons > 54 && protons < 85) ||
protons > 86);
}
char getInscode(bool space=false) const {
if (space && !inscode)
return ' ';
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';
}
// for AtomInfoHistory
void setResi(int resv_, char inscode_) {
resv = resv_;
setInscode(inscode_);
}
/*
* Return true if any representation, which is displayable by this
* atom, is shown
*/
bool isVisible() const {
if(visRep & (
// point reps
cRepSphereBit | cRepEllipsoidBit | cRepLabelBit |
// surface reps
cRepSurfaceBit | cRepDotBit | cRepMeshBit |
// polymer reps (actually only shown for guide atoms or if
// *_trace_atoms=1 or cartoon_ring_finder=4)
cRepCartoonBit | cRepRibbonBit)) {
return true;
} else if(bonded) {
// bond reps
if (visRep & (cRepCylBit | cRepLineBit))
return true;
} else {
// nonbonded reps
if (visRep & (cRepNonbondedSphereBit | cRepNonbondedBit))
return true;
}
return false;
}
// get the anisou array, allocate if null
float * get_anisou() { return (anisou ? anisou : (anisou = new float[6])); }
// read-only anisou access, no allocation
const float * get_anisou() const { return anisou; }
bool has_anisou() const { return anisou; }
} AtomInfoType;
void AtomInfoFree(PyMOLGlobals * G);
int AtomInfoInit(PyMOLGlobals * G);
void BondTypeInit(BondType *bt);
void BondTypeInit2(BondType *bt, int i1, int i2, int order = 1);
void AtomInfoPurge(PyMOLGlobals * G, AtomInfoType * ai);
void AtomInfoCopy(PyMOLGlobals * G, const AtomInfoType * src, AtomInfoType * dst, int copy_properties=true);
int AtomInfoReserveUniqueID(PyMOLGlobals * G, int unique_id);
int AtomInfoIsUniqueIDActive(PyMOLGlobals * G, int unique_id);
int AtomInfoGetNewUniqueID(PyMOLGlobals * G);
void AtomInfoCleanAtomName(char *name);
#ifndef _PYMOL_NOPY
int AtomInfoSetSettingFromPyObject(PyMOLGlobals * G, AtomInfoType *ai, int setting_id, PyObject *val);
#endif
PyObject *SettingGetIfDefinedPyObject(PyMOLGlobals * G, AtomInfoType * ai, int setting_id);
void AtomInfoBondCopy(PyMOLGlobals * G, const BondType * src, BondType * dst);
int AtomInfoCheckUniqueID(PyMOLGlobals * G, AtomInfoType * ai);
void AtomInfoAssignParameters(PyMOLGlobals * G, AtomInfoType * I);
void AtomInfoFreeSortedIndexes(PyMOLGlobals * G, int **index, int **outdex);
void AtomInfoPrimeColors(PyMOLGlobals * G);
void AtomInfoAssignColors(PyMOLGlobals * G, AtomInfoType * at1);
int AtomInfoGetColor(PyMOLGlobals * G, const AtomInfoType * at1);
int AtomInfoGetExpectedValence(PyMOLGlobals * G, const AtomInfoType * I);
int AtomInfoIsFreeCation(PyMOLGlobals * G, const AtomInfoType * I);
PyObject *AtomInfoAsPyList(PyMOLGlobals * G, const AtomInfoType * at);
int AtomInfoFromPyList(PyMOLGlobals * G, AtomInfoType * at, PyObject * list);
int AtomInfoMatch(PyMOLGlobals * G, const AtomInfoType * at1, const AtomInfoType * at2, bool, bool);
int AtomInfoCompare(PyMOLGlobals * G, const AtomInfoType * at1, const AtomInfoType * at2);
int AtomInfoCompareIgnoreRank(PyMOLGlobals * G, const AtomInfoType * at1, const AtomInfoType * at2);
int AtomInfoCompareIgnoreHet(PyMOLGlobals * G, const AtomInfoType * at1, const AtomInfoType * at2);
int AtomInfoCompareIgnoreRankHet(PyMOLGlobals * G, const AtomInfoType * at1,
const AtomInfoType * at2);
float AtomInfoGetBondLength(PyMOLGlobals * G, const AtomInfoType * ai1, const AtomInfoType * ai2);
int AtomInfoSameResidue(PyMOLGlobals * G, const AtomInfoType * at1, const AtomInfoType * at2);
int AtomInfoSameResidueP(PyMOLGlobals * G, const AtomInfoType * at1, const AtomInfoType * at2);
int AtomInfoSameChainP(PyMOLGlobals * G, const AtomInfoType * at1, const AtomInfoType * at2);
int AtomInfoSameSegmentP(PyMOLGlobals * G, const AtomInfoType * at1, const AtomInfoType * at2);
int AtomInfoSequential(PyMOLGlobals * G, const AtomInfoType * at1, const AtomInfoType * at2,
int mode);
#define AtomInfoCheckUniqueBondID AtomInfoCheckUniqueID
int AtomInfoCheckUniqueBondID(PyMOLGlobals * G, BondType * bi);
void AtomInfoPurgeBond(PyMOLGlobals * G, BondType * bi);
void AtomInfoBracketResidue(PyMOLGlobals * G, const AtomInfoType * ai0, int n0,
const AtomInfoType * ai, int *st, int *nd);
void AtomInfoBracketResidueFast(PyMOLGlobals * G, const AtomInfoType * ai0, int n0, int cur,
int *st, int *nd);
int AtomInfoUniquefyNames(PyMOLGlobals * G, const AtomInfoType * atInfo0, int n0,
AtomInfoType * atInfo1, int *flag1, int n1,
const ObjectMolecule* mol = nullptr);
int AtomInfoUniquefyNames(
const ObjectMolecule* mol, AtomInfoType* atoms, size_t natoms);
bool AtomResiFromResv(char *resi, size_t size, int resv, char inscode);
inline bool AtomResiFromResv(char *resi, size_t size, const AtomInfoType * ai) {
return AtomResiFromResv(resi, size, ai->resv, ai->inscode);
}
int AtomInfoKnownWaterResName(PyMOLGlobals * G, const char *resn);
int AtomInfoKnownPolymerResName(const char *resn);
int AtomInfoKnownProteinResName(const char *resn);
int AtomInfoKnownNucleicResName(const char *resn);
void AtomInfoGetPDB3LetHydroName(PyMOLGlobals * G, const char *resn, const char *iname, char *oname);
#define cAIC_ct 0x0001
#define cAIC_fc 0x0002
#define cAIC_pc 0x0004
#define cAIC_b 0x0008
#define cAIC_q 0x0010
#define cAIC_id 0x0020
#define cAIC_flags 0x0080
#define cAIC_tt 0x0100
#define cAIC_state 0x0200
#define cAIC_rank 0x0400
#define cAIC_custom 0x0800
#define cAIC_IDMask (cAIC_id|cAIC_rank)
#define cAIC_PDBMask (cAIC_b|cAIC_q|cAIC_id|cAIC_rank)
#define cAIC_MMDMask (cAIC_pc|cAIC_ct|cAIC_id|cAIC_rank)
#define cAIC_MOLMask (cAIC_fc|cAIC_id|cAIC_rank)
#define cAIC_AllMask 0xFFFF
void AtomInfoCombine(PyMOLGlobals * G, AtomInfoType * dst, AtomInfoType&& src, int mask);
int AtomInfoNameOrder(PyMOLGlobals * G, const AtomInfoType * at1, const AtomInfoType * at2);
int AtomInfoUpdateAutoColor(PyMOLGlobals * G);
typedef struct {
int resv1, resv2;
char inscode1, inscode2;
unsigned char chain1, chain2;
unsigned char type;
int next;
} SSEntry;
void atomicnumber2elem(char * dst, int protons);
/*
* atom-level and bond-level settings
*/
template <typename T>
int AtomInfoCheckSetting(PyMOLGlobals * G, T * item, int index) {
return (item->has_setting && SettingUniqueCheck(G, item->unique_id, index));
}
#define AtomInfoCheckBondSetting AtomInfoCheckSetting
template <typename V, typename T> void SettingSet(PyMOLGlobals * G, int index, V value, T * ai) {
AtomInfoCheckUniqueID(G, ai);
ai->has_setting = true;
SettingUniqueSet(G, ai->unique_id, index, value);
}
/**
* Return true if `item` has the requested setting defined and the
* value could be assigned to `out`.
*/
template <typename V, typename T>
bool AtomSettingGetIfDefined(PyMOLGlobals * G, T * item, int index, V * out) {
return item->has_setting &&
SettingUniqueGetIfDefined<V>(G, item->unique_id, index, out);
}
/**
* Return the `item`-level setting value or `default_`, if `index` is not
* defined for `item`.
*/
template <typename V, typename T>
V AtomSettingGetWD(PyMOLGlobals * G, T * item, int index, V default_) {
V out;
if (AtomSettingGetIfDefined<V, T>(G, item, index, &out))
return out;
return default_;
}
#define BondSettingGetWD AtomSettingGetWD
// stereochemistry
const char * AtomInfoGetStereoAsStr(const AtomInfoType * ai);
void AtomInfoSetStereo(AtomInfoType * ai, const char * stereo);
void AtomInfoGetAlignedPDBResidueName(PyMOLGlobals * G,
const AtomInfoType * ai,
ResName & resn);
void AtomInfoGetAlignedPDBAtomName(PyMOLGlobals * G,
const AtomInfoType * ai,
const ResName & resn,
AtomName & name);
#endif
|