"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "layer2/AtomInfo.cpp" between
pymol-open-source-2.2.0.tar.gz and pymol-open-source-2.3.0.tar.gz

About: PyMOL is a Python-enhanced molecular graphics tool. It excels at 3D visualization of proteins, small molecules, density, surfaces, and trajectories. It also includes molecular editing, ray tracing, and movies. Open Source version.

AtomInfo.cpp  (pymol-open-source-2.2.0):AtomInfo.cpp  (pymol-open-source-2.3.0)
skipping to change at line 168 skipping to change at line 168
} }
void BondTypeInit(BondType *bt){ void BondTypeInit(BondType *bt){
#ifdef _PYMOL_IP_EXTRAS #ifdef _PYMOL_IP_EXTRAS
bt->oldid = -1; bt->oldid = -1;
#endif #endif
bt->unique_id = 0; bt->unique_id = 0;
bt->has_setting = 0; bt->has_setting = 0;
} }
/* /**
* Set atom indices and bond order, and invalidate all other fields. * Set atom indices and bond order, and invalidate all other fields.
*/ */
void BondTypeInit2(BondType *bond, int i1, int i2, int order) void BondTypeInit2(BondType *bond, int i1, int i2, int order)
{ {
BondTypeInit(bond); BondTypeInit(bond);
bond->index[0] = i1; bond->index[0] = i1;
bond->index[1] = i2; bond->index[1] = i2;
bond->order = order; bond->order = order;
bond->id = -1; bond->id = -1;
} }
skipping to change at line 1107 skipping to change at line 1107
if (I->ActiveIDs) if (I->ActiveIDs)
OVOneToAny_DelKey(I->ActiveIDs, ai->unique_id); OVOneToAny_DelKey(I->ActiveIDs, ai->unique_id);
} }
#ifdef _PYMOL_IP_EXTRAS #ifdef _PYMOL_IP_EXTRAS
#endif #endif
DeleteAP(ai->anisou); DeleteAP(ai->anisou);
} }
/*========================================================================*/ /*========================================================================*/
/* /**
* Transfer `mask` selected atomic properties (such as b, q, text_type, etc.) * Transfer `mask` selected atomic properties (such as b, q, text_type, etc.)
* from `src` to `dst`, while keeping all atomic identifiers untouched. * from `src` to `dst`, while keeping all atomic identifiers untouched.
* Purges `src`. * Purges `src`.
*
* @param mask bitmask of `cAIC_*` bits
*/ */
void AtomInfoCombine(PyMOLGlobals * G, AtomInfoType * dst, AtomInfoType * src, i nt mask) void AtomInfoCombine(PyMOLGlobals * G, AtomInfoType * dst, AtomInfoType&& src_, int mask)
{ {
AtomInfoType* src = &src_;
if(mask & cAIC_tt) { if(mask & cAIC_tt) {
std::swap(dst->textType, src->textType); std::swap(dst->textType, src->textType);
} }
if(mask & cAIC_ct) if(mask & cAIC_ct)
dst->customType = src->customType; dst->customType = src->customType;
if(mask & cAIC_pc) if(mask & cAIC_pc)
dst->partialCharge = src->partialCharge; dst->partialCharge = src->partialCharge;
if(mask & cAIC_fc) if(mask & cAIC_fc)
dst->formalCharge = src->formalCharge; dst->formalCharge = src->formalCharge;
if(mask & cAIC_flags) if(mask & cAIC_flags)
skipping to change at line 1746 skipping to change at line 1749
default: default:
result += 1.54F; result += 1.54F;
break; break;
} }
result /= 2.0F; result /= 2.0F;
break; break;
} }
return (result); return (result);
} }
/* /**
* Periodic table of elements * Periodic table of elements
* *
* Note: Default VDW radius is 1.80 * Note: Default VDW radius is 1.80
*/ */
const ElementTableItemType ElementTable[] = { const ElementTableItemType ElementTable[] = {
{"lonepair", "LP", 0.50, 0.000000}, {"lonepair", "LP", 0.50, 0.000000},
{"hydrogen", "H", 1.20, 1.007940}, {"hydrogen", "H", 1.20, 1.007940},
{"helium", "He", 1.40, 4.002602}, {"helium", "He", 1.40, 4.002602},
{"lithium", "Li", 1.82, 6.941000}, {"lithium", "Li", 1.82, 6.941000},
{"beryllium", "Be", 1.80, 9.012182}, {"beryllium", "Be", 1.80, 9.012182},
skipping to change at line 1876 skipping to change at line 1879
{"flerovium", "Fl", 1.80, 289.000000}, {"flerovium", "Fl", 1.80, 289.000000},
{"moscovium", "Mc", 1.80, 290.000000}, {"moscovium", "Mc", 1.80, 290.000000},
{"livermorium", "Lv", 1.80, 293.000000}, {"livermorium", "Lv", 1.80, 293.000000},
{"tennessine", "Ts", 1.80, 294.000000}, {"tennessine", "Ts", 1.80, 294.000000},
{"oganesson", "Og", 1.80, 294.000000}, {"oganesson", "Og", 1.80, 294.000000},
{NULL, NULL, 0.00, 0.000000} {NULL, NULL, 0.00, 0.000000}
}; };
const int ElementTableSize = sizeof(ElementTable) / sizeof(ElementTable[0]) - 1; const int ElementTableSize = sizeof(ElementTable) / sizeof(ElementTable[0]) - 1;
/* /**
* Assign atomic color, or G->AtomInfo->CColor in case of carbon. * Assign atomic color, or G->AtomInfo->CColor in case of carbon.
*/ */
void AtomInfoAssignColors(PyMOLGlobals * G, AtomInfoType * at1) void AtomInfoAssignColors(PyMOLGlobals * G, AtomInfoType * at1)
{ {
at1->color = AtomInfoGetColor(G, at1); at1->color = AtomInfoGetColor(G, at1);
} }
/* /**
* Get atomic color, based on protons and elem * Get atomic color, based on protons and elem
* @return color index
*/ */
int AtomInfoGetColor(PyMOLGlobals * G, const AtomInfoType * at1) int AtomInfoGetColor(PyMOLGlobals * G, const AtomInfoType * at1)
{ {
// fast lookup for most common elements // fast lookup for most common elements
switch (at1->protons) { switch (at1->protons) {
case cAN_H: case cAN_H:
if (at1->elem[0] == 'D') if (at1->elem[0] == 'D')
return G->AtomInfo->DColor; return G->AtomInfo->DColor;
return G->AtomInfo->HColor; return G->AtomInfo->HColor;
case cAN_N: return G->AtomInfo->NColor; case cAN_N: return G->AtomInfo->NColor;
skipping to change at line 1941 skipping to change at line 1945
else else
n2 = name2; n2 = name2;
cmp = WordCompare(G, n1, n2, true); cmp = WordCompare(G, n1, n2, true);
if(cmp) if(cmp)
return cmp; return cmp;
return WordCompare(G, name1, name2, true); return WordCompare(G, name1, name2, true);
} }
static int AtomInfoNameCompare(PyMOLGlobals * G, lexidx_t name1, lexidx_t name2) static int AtomInfoNameCompare(PyMOLGlobals * G, const lexidx_t& name1, const le xidx_t& name2)
{ {
if (name1 == name2) if (name1 == name2)
return 0; return 0;
return AtomInfoNameCompare(G, LexStr(G, name1), LexStr(G, name2)); return AtomInfoNameCompare(G, LexStr(G, name1), LexStr(G, name2));
} }
int AtomInfoCompareAll(PyMOLGlobals * G, const AtomInfoType * at1, const AtomInf oType * at2) int AtomInfoCompareAll(PyMOLGlobals * G, const AtomInfoType * at1, const AtomInf oType * at2)
{ {
return (at1->resv != at2->resv || return (at1->resv != at2->resv ||
at1->customType != at2->customType || at1->customType != at2->customType ||
skipping to change at line 1997 skipping to change at line 2001
at1->resn != at2->resn || at1->resn != at2->resn ||
at1->name != at2->name || at1->name != at2->name ||
strcmp(at1->alt, at2->alt) || strcmp(at1->alt, at2->alt) ||
at1->inscode != at2->inscode || at1->inscode != at2->inscode ||
strcmp(at1->elem, at2->elem) || strcmp(at1->elem, at2->elem) ||
strcmp(at1->ssType, at2->ssType)); strcmp(at1->ssType, at2->ssType));
// should these variables be in here? // should these variables be in here?
// float U11, U22, U33, U12, U13, U23; // float U11, U22, U33, U12, U13, U23;
} }
/* /**
* Compares atoms based on all atom identifiers, discrete state, priority, * Compares atoms based on all atom identifiers, discrete state, priority,
* hetatm (optional) and rank (optional) * hetatm (optional) and rank (optional)
* *
* Insertion code sorting depends on settings: * Insertion code sorting depends on settings:
* - pdb_insertions_go_first * - pdb_insertions_go_first
* - rank_assisted_sorts * - rank_assisted_sorts
* *
* Returns: * Returns:
* 0: at1 == at2 * 0: at1 == at2
* -1: at1 < at2 * -1: at1 < at2
skipping to change at line 2074 skipping to change at line 2078
int AtomInfoCompareIgnoreRank(PyMOLGlobals * G, const AtomInfoType * at1, const AtomInfoType * at2) int AtomInfoCompareIgnoreRank(PyMOLGlobals * G, const AtomInfoType * at1, const AtomInfoType * at2)
{ {
return AtomInfoCompare(G, at1, at2, false, true); return AtomInfoCompare(G, at1, at2, false, true);
} }
int AtomInfoCompareIgnoreHet(PyMOLGlobals * G, const AtomInfoType * at1, const A tomInfoType * at2) int AtomInfoCompareIgnoreHet(PyMOLGlobals * G, const AtomInfoType * at1, const A tomInfoType * at2)
{ {
return AtomInfoCompare(G, at1, at2, true, false); return AtomInfoCompare(G, at1, at2, true, false);
} }
/* /**
* Function only used for matching atoms of two aligned residues. * Function only used for matching atoms of two aligned residues.
* *
* Changed (PyMOL 2.1): * Changed (PyMOL 2.1):
* Consider alt codes to be equal if at least one is empty. * Consider alt codes to be equal if at least one is empty.
* Otherwise, alt-code (C-alpha) atoms can't be aligned to non-alt atoms * Otherwise, alt-code (C-alpha) atoms can't be aligned to non-alt atoms
* (also affects morphing). * (also affects morphing).
*/ */
int AtomInfoNameOrder(PyMOLGlobals * G, const AtomInfoType * at1, const AtomInfo Type * at2) int AtomInfoNameOrder(PyMOLGlobals * G, const AtomInfoType * at1, const AtomInfo Type * at2)
{ {
int result; int result;
skipping to change at line 2175 skipping to change at line 2179
} else { } else {
return 1; /* no segi check */ return 1; /* no segi check */
} }
} }
} else { } else {
return 1; /* no hetatm check */ return 1; /* no hetatm check */
} }
return 0; return 0;
} }
/* /**
* Used in "rms" and "update" for matching two selections * Used in "rms" and "update" for matching two selections
* @return 1 if atoms match, 0 otherwise
*/ */
int AtomInfoMatch(PyMOLGlobals * G, const AtomInfoType * at1, const AtomInfoType * at2, int AtomInfoMatch(PyMOLGlobals * G, const AtomInfoType * at1, const AtomInfoType * at2,
bool ignore_case, bool ignore_case_chain) bool ignore_case, bool ignore_case_chain)
{ {
if(at1->resv == at2->resv) if(at1->resv == at2->resv)
if(WordMatchExact(G, at1->chain, at2->chain, ignore_case_chain)) if(WordMatchExact(G, at1->chain, at2->chain, ignore_case_chain))
if(WordMatchExact(G, at1->name, at2->name, ignore_case)) if(WordMatchExact(G, at1->name, at2->name, ignore_case))
if(WordMatchExact(G, at1->inscode, at2->inscode, ignore_case)) if(WordMatchExact(G, at1->inscode, at2->inscode, ignore_case))
if(WordMatchExact(G, at1->resn, at2->resn, ignore_case)) if(WordMatchExact(G, at1->resn, at2->resn, ignore_case))
if(WordMatchExact(G, at1->segi, at2->segi, ignore_case_chain)) if(WordMatchExact(G, at1->segi, at2->segi, ignore_case_chain))
skipping to change at line 2329 skipping to change at line 2334
result = -2; result = -2;
break; break;
case cAN_P: case cAN_P:
result = -3; result = -3;
break; break;
} }
} }
return (result); return (result);
} }
/* /**
* Get number of protons for element symbol * Get number of protons for element symbol
*/ */
static int get_protons(const char * symbol) static int get_protons(const char * symbol)
{ {
char titleized[4]; char titleized[4];
static std::map<const char *, int, cstrless_t> lookup; static std::map<const char *, int, cstrless_t> lookup;
if (lookup.empty()) { if (lookup.empty()) {
for (int i = 0; i < ElementTableSize; i++) for (int i = 0; i < ElementTableSize; i++)
lookup[ElementTable[i].symbol] = i; lookup[ElementTable[i].symbol] = i;
skipping to change at line 2370 skipping to change at line 2375
case 'C': case 'C':
return cAN_C; return cAN_C;
case 'H': case 'H':
return cAN_H; return cAN_H;
} }
} }
return -1; return -1;
} }
/* /**
* Assign "protons" from "elem" or "name" property * Assign "protons" from "elem" or "name" property
*/ */
static void set_protons(PyMOLGlobals * G, AtomInfoType * I) static void set_protons(PyMOLGlobals * G, AtomInfoType * I)
{ {
int protons = get_protons(I->elem); int protons = get_protons(I->elem);
if (protons < 0) { if (protons < 0) {
// try again with atom name, skip numbers // try again with atom name, skip numbers
const char * name = LexStr(G, I->name); const char * name = LexStr(G, I->name);
while((*name >= '0') && (*name <= '9') && (*(name + 1))) while((*name >= '0') && (*name <= '9') && (*(name + 1)))
name++; name++;
protons = get_protons(name); protons = get_protons(name);
} }
I->protons = protons; I->protons = protons;
} }
/* /**
* Assign (based on name, elem, protons): * Assign (based on name, elem, protons):
* - elem (if empty string) * - elem (if empty string)
* - protons (if < 1) * - protons (if < 1)
* - vdw (if 0.0) * - vdw (if 0.0)
* - priority * - priority
*/ */
void AtomInfoAssignParameters(PyMOLGlobals * G, AtomInfoType * I) void AtomInfoAssignParameters(PyMOLGlobals * G, AtomInfoType * I)
{ {
const char *n = NULL; const char *n = NULL;
char *e = NULL; char *e = NULL;
skipping to change at line 2793 skipping to change at line 2798
int BondTypeCompare(PyMOLGlobals * G, const BondType * bt1, const BondType * bt2 ){ int BondTypeCompare(PyMOLGlobals * G, const BondType * bt1, const BondType * bt2 ){
return (bt1->index[0] != bt2->index[0] || return (bt1->index[0] != bt2->index[0] ||
bt1->index[1] != bt2->index[1] || bt1->index[1] != bt2->index[1] ||
bt1->order != bt2->order || bt1->order != bt2->order ||
bt1->id != bt2->id || bt1->id != bt2->id ||
bt1->unique_id != bt2->unique_id || bt1->unique_id != bt2->unique_id ||
bt1->stereo != bt2->stereo || bt1->stereo != bt2->stereo ||
bt1->has_setting != bt2->has_setting); bt1->has_setting != bt2->has_setting);
} }
/**
* Get the element symbol. E.g. "He" for Helium.
* @param[out] dst output buffer of length cElemNameLen
* @param protons atomic number, e.g. 2 for Helium
*/
void atomicnumber2elem(char * dst, int protons) { void atomicnumber2elem(char * dst, int protons) {
if (protons > -1 && protons < ElementTableSize) if (protons > -1 && protons < ElementTableSize)
strncpy(dst, ElementTable[protons].symbol, cElemNameLen); strncpy(dst, ElementTable[protons].symbol, cElemNameLen);
} }
/* /**
* Get a string representation of the stereo configuration. Either * Get a string representation of the stereo configuration. Either
* R/S chirality, if set, or the SDF odd/even parity, if set. * R/S chirality, if set, or the SDF odd/even parity, if set.
*/ */
const char * AtomInfoGetStereoAsStr(const AtomInfoType * ai) { const char * AtomInfoGetStereoAsStr(const AtomInfoType * ai) {
switch (ai->mmstereo) { switch (ai->mmstereo) {
case 1 /* MMSTEREO_CHIRALITY_R */: return "R"; case 1 /* MMSTEREO_CHIRALITY_R */: return "R";
case 2 /* MMSTEREO_CHIRALITY_S */: return "S"; case 2 /* MMSTEREO_CHIRALITY_S */: return "S";
} }
switch (ai->stereo) { switch (ai->stereo) {
skipping to change at line 2820 skipping to change at line 2830
case SDF_CHIRALITY_EVEN: return "even"; case SDF_CHIRALITY_EVEN: return "even";
} }
if (ai->mmstereo || ai->stereo) { if (ai->mmstereo || ai->stereo) {
return "?"; return "?";
} }
return ""; return "";
} }
/* /**
* Set stereochemistry. Valid are: R, S, N[one], E[ven], O[dd] * Set stereochemistry. Valid are: R, S, N[one], E[ven], O[dd]
*/ */
void AtomInfoSetStereo(AtomInfoType * ai, const char * stereo) { void AtomInfoSetStereo(AtomInfoType * ai, const char * stereo) {
switch (toupper(stereo[0])) { switch (toupper(stereo[0])) {
case 'R': ai->mmstereo = 1; ai->stereo = 0; break; // MMSTEREO_CHIRALITY_R case 'R': ai->mmstereo = 1; ai->stereo = 0; break; // MMSTEREO_CHIRALITY_R
case 'S': ai->mmstereo = 2; ai->stereo = 0; break; // MMSTEREO_CHIRALITY_S case 'S': ai->mmstereo = 2; ai->stereo = 0; break; // MMSTEREO_CHIRALITY_S
case 'E': ai->mmstereo = 0; ai->stereo = SDF_CHIRALITY_EVEN; break; case 'E': ai->mmstereo = 0; ai->stereo = SDF_CHIRALITY_EVEN; break;
case 'O': ai->mmstereo = 0; ai->stereo = SDF_CHIRALITY_ODD; break; case 'O': ai->mmstereo = 0; ai->stereo = SDF_CHIRALITY_ODD; break;
case 'A': // ANS (s), ANR (r) pseudochirality case 'A': // ANS (s), ANR (r) pseudochirality
case 'N': case 0: ai->mmstereo = ai->stereo = 0; break; case 'N': case 0: ai->mmstereo = ai->stereo = 0; break;
default: ai->mmstereo = ai->stereo = 3; break; default: ai->mmstereo = ai->stereo = 3; break;
} }
} }
/* /**
* Get column aligned (left space padded) PDB residue name * Get column aligned (left space padded) PDB residue name
* *
* resn: output buffer * @param[out] resn output buffer
*/ */
void AtomInfoGetAlignedPDBResidueName(PyMOLGlobals * G, void AtomInfoGetAlignedPDBResidueName(PyMOLGlobals * G,
const AtomInfoType * ai, const AtomInfoType * ai,
ResName & resn) ResName & resn)
{ {
sprintf(resn, "%3.4s", LexStr(G, ai->resn)); sprintf(resn, "%3.4s", LexStr(G, ai->resn));
if(SettingGetGlobal_b(G, cSetting_pdb_truncate_residue_name)) { if(SettingGetGlobal_b(G, cSetting_pdb_truncate_residue_name)) {
resn[3] = 0; /* enforce 3-letter residue name in PDB files */ resn[3] = 0; /* enforce 3-letter residue name in PDB files */
} }
} }
/* /**
* Get column aligned (left space padded) PDB atom name * Get column aligned (left space padded) PDB atom name
* *
* resn: space padded residue name * @param resn space padded residue name
* name: output buffer * @param[out] name output buffer
*/ */
void AtomInfoGetAlignedPDBAtomName(PyMOLGlobals * G, void AtomInfoGetAlignedPDBAtomName(PyMOLGlobals * G,
const AtomInfoType * ai, const AtomInfoType * ai,
const ResName & resn, const ResName & resn,
AtomName & name) AtomName & name)
{ {
int literal = SettingGetGlobal_b(G, cSetting_pdb_literal_names); int literal = SettingGetGlobal_b(G, cSetting_pdb_literal_names);
int reformat = SettingGetGlobal_i(G, cSetting_pdb_reformat_names_mode); int reformat = SettingGetGlobal_i(G, cSetting_pdb_reformat_names_mode);
// default is "literal=0" and "reformat=0" (no reformatting) // default is "literal=0" and "reformat=0" (no reformatting)
 End of changes. 24 change blocks. 
20 lines changed or deleted 30 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)