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 Mar 15, 2024
1 parent 656f0b8 commit c98c9f4
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
4 changes: 4 additions & 0 deletions layer1/SettingInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,10 @@ enum {
REC_f( 794, halogen_bond_as_acceptor_max_acceptor_angle , global , 170.0f ),
REC_f( 795, salt_bridge_distance , global , 5.0f ),
REC_b( 796, use_tessellation_shaders , global , true ),
REC_b( 797, _unused_1 , unused , 0 ),
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
Expand Down
18 changes: 18 additions & 0 deletions layer2/CifMoleculeReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<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 @@ -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 {
Expand Down
16 changes: 15 additions & 1 deletion layer3/Selector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1114,7 +1117,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 @@ -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;
}

Expand Down

0 comments on commit c98c9f4

Please sign in to comment.