Skip to content

Commit

Permalink
WIP: preserve_classified, mmCIF classify_entities
Browse files Browse the repository at this point in the history
Use mmCIF polypeptide information for atom classification if
`preserve_classified` setting is on.

Limitations: Bypasses auto_show_classified

Related to schrodinger#317
  • Loading branch information
speleo3 committed Dec 19, 2023
1 parent 912d856 commit 5a9638e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
1 change: 1 addition & 0 deletions layer1/SettingInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,7 @@ enum {
REC_i( 786, cartoon_smooth_cylinder_window , global , 2 ),
REC_i( 787, isosurface_algorithm , global , 0, 0, 2 ),
REC_b( 788, cell_centered , global , false ),
REC_b( 789, preserve_classified , global , 0 ),


#ifdef SETTINGINFO_IMPLEMENTATION
Expand Down
18 changes: 18 additions & 0 deletions layer2/CifMoleculeReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1413,6 +1413,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<AtomInfoType>& 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
*
Expand Down Expand Up @@ -2125,6 +2141,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 {
Expand Down
16 changes: 15 additions & 1 deletion layer3/Selector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1082,6 +1082,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;
Expand Down Expand Up @@ -1119,7 +1122,11 @@ int SelectorClassifyAtoms(PyMOLGlobals * G, int sele, int preserve,
a0++;
a1--;

mask = 0;
mask = (ai->flags & cAtomFlag_class);

if (mask && SettingGet<bool>(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)))
Expand Down Expand Up @@ -1352,6 +1359,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;
}

Expand Down

0 comments on commit 5a9638e

Please sign in to comment.