Skip to content

Commit

Permalink
MMTF loader: Use entityList for HETATM flag (#296)
Browse files Browse the repository at this point in the history
Fixes #295
  • Loading branch information
speleo3 authored Jul 18, 2023
1 parent 17be7d0 commit b034d5c
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion layer2/MmtfMoleculeReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
#include <mmtf_parser.h>

#include <algorithm>
#include <vector>

#include "pymol/zstring_view.h"
#include "AssemblyHelpers.h"
#include "AtomInfo.h"
#include "Err.h"
Expand Down Expand Up @@ -177,6 +179,16 @@ ObjectMolecule * ObjectMoleculeReadMmtfStr(PyMOLGlobals * G, ObjectMolecule * I,
I->Symmetry->setSpaceGroup(container->spaceGroup);
}

// entities
auto chain2entity = std::vector<MMTF_Entity const*>(container->numChains);
for (int entityIndex = 0; entityIndex < container->entityListCount; ++entityIndex) {
auto const entity = &container->entityList[entityIndex];

for (int i = 0; i < entity->chainIndexListCount; ++i) {
chain2entity[entity->chainIndexList[i]] = entity;
}
}

// models (states)
for (int modelIndex = 0; modelIndex < container->numModels; ++modelIndex) {
int modelChainCount = container->chainsPerModel[modelIndex];
Expand All @@ -189,6 +201,8 @@ ObjectMolecule * ObjectMoleculeReadMmtfStr(PyMOLGlobals * G, ObjectMolecule * I,

// chains
for (int j = 0; j < modelChainCount; ++j, ++chainIndex) {
auto const entity = chain2entity[chainIndex];

if (container->chainNameList)
LexAssign(G, tai.chain, container->chainNameList[chainIndex]);
if (use_auth)
Expand All @@ -208,7 +222,11 @@ ObjectMolecule * ObjectMoleculeReadMmtfStr(PyMOLGlobals * G, ObjectMolecule * I,
}

LexAssign(G, tai.resn, group->groupName);
tai.hetatm = group->singleLetterCode == '?';
if (entity) {
tai.hetatm = pymol::null_safe_zstring_view(entity->type) != "polymer";
} else {
tai.hetatm = group->singleLetterCode == '?';
}
tai.flags = tai.hetatm ? cAtomFlag_ignore : 0;

if (use_auth) {
Expand Down

0 comments on commit b034d5c

Please sign in to comment.