diff --git a/layer1/SettingInfo.h b/layer1/SettingInfo.h index a905aa3eb..fded283d8 100644 --- a/layer1/SettingInfo.h +++ b/layer1/SettingInfo.h @@ -905,6 +905,9 @@ enum { REC_f( 795, salt_bridge_distance , global , 5.0f ), REC_b( 796, use_tessellation_shaders , global , true ), REC_c( 797, cell_color , ostate , "-1" ), + REC_b( 798, _unused_2 , unused , 0 ), + REC_b( 799, _unused_3 , unused , 0 ), + REC_b( 800, preserve_classified , global , 0 ), #ifdef SETTINGINFO_IMPLEMENTATION #undef SETTINGINFO_IMPLEMENTATION diff --git a/layer2/CifMoleculeReader.cpp b/layer2/CifMoleculeReader.cpp index 650102185..50edea246 100644 --- a/layer2/CifMoleculeReader.cpp +++ b/layer2/CifMoleculeReader.cpp @@ -1391,6 +1391,22 @@ static void add_missing_ca_sub(PyMOLGlobals * G, } } +/** + * Set the atom classification according to the entity annotation. + */ +static void classify_entities( + PyMOLGlobals* G, pymol::vla& atInfo, CifContentInfo& info) +{ + for (int i = 0, n = atInfo.size(); i < n; ++i) { + auto& atom = atInfo[i]; + const char* entity_id = LexStr(G, atom.custom); + if (info.is_polypeptide(entity_id)) { + assert(!(atom.flags & cAtomFlag_class)); + atom.flags |= cAtomFlag_polymer | cAtomFlag_protein; + } + } +} + /** * Read missing residues / full sequence * @@ -2104,6 +2120,8 @@ static ObjectMolecule *ObjectMoleculeReadCifData(PyMOLGlobals * G, if (!I->DiscreteFlag && !SettingGetGlobal_i(G, cSetting_retain_order)) { add_missing_ca(G, I->AtomInfo, info); } + + classify_entities(G, I->AtomInfo, info); } else if ((csets = read_chem_comp_atom_model(G, datablock, &I->AtomInfo))) { info.type = CIF_CHEM_COMP; } else { diff --git a/layer3/Selector.cpp b/layer3/Selector.cpp index 06c24e5d4..03e5042ae 100644 --- a/layer3/Selector.cpp +++ b/layer3/Selector.cpp @@ -1077,6 +1077,9 @@ int SelectorClassifyAtoms(PyMOLGlobals * G, int sele, int preserve, n_dummies = cNDummyAtoms; } a = 0; + + int n_preserved = 0; + while(a < I->Table.size()) { obj = I->Obj[I->Table[a].model]; at = I->Table[a].atom; @@ -1114,7 +1117,11 @@ int SelectorClassifyAtoms(PyMOLGlobals * G, int sele, int preserve, a0++; a1--; - mask = 0; + mask = (ai->flags & cAtomFlag_class); + + if (mask && SettingGet(G, cSetting_preserve_classified)) { + ++n_preserved; + } else if(!ai->hetatm && AtomInfoKnownProteinResName(LexStr(G, ai->resn))) mask = cAtomFlag_polymer | cAtomFlag_protein; else if(!ai->hetatm && AtomInfoKnownNucleicResName(LexStr(G, ai->resn))) @@ -1347,6 +1354,13 @@ int SelectorClassifyAtoms(PyMOLGlobals * G, int sele, int preserve, } a++; } + + if (n_preserved) { + PRINTFB(G, FB_Selector, FB_Details) + " %s-Detail: Preserved class flags on %d atoms\n", __func__, + n_preserved ENDFB(G); + } + return true; }