Commit 021487ed by Maarten L. Hekkelman

Fix reading mmCIF file where model is defined but model 1 is missing. Version bump.

parent 6b2c9dc3
......@@ -25,7 +25,7 @@
cmake_minimum_required(VERSION 3.16)
# set the project name
project(cifpp VERSION 2.0.2 LANGUAGES CXX)
project(cifpp VERSION 2.0.3 LANGUAGES CXX)
list(PREPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
......
Version 2.0.3
- Fixed reading mmCIF files where model numbers are used and
model number 1 is missing.
Version 2.0.2
- Added configuration flag to disable downloading CCD data during build
Note that there are now two flags for CCD data:
......
......@@ -533,6 +533,8 @@ class Structure
void loadData();
void updateAtomIndex();
void loadAtomsForModel(StructureOpenOptions options);
File &mFile;
size_t mModelNr;
AtomView mAtoms;
......
......@@ -1790,6 +1790,33 @@ Structure::Structure(File &f, size_t modelNr, StructureOpenOptions options)
auto &atomCat = (*db)["atom_site"];
loadAtomsForModel(options);
// Check to see if we should actually load another model?
if (mAtoms.empty() and mModelNr == 1)
{
std::optional<size_t> model_nr;
cif::tie(model_nr) = atomCat.front().get("pdbx_PDB_model_num");
if (model_nr and *model_nr != mModelNr)
{
if (cif::VERBOSE)
std::cerr << "No atoms loaded for model 1, trying model " << *model_nr << std::endl;
mModelNr = *model_nr;
loadAtomsForModel(options);
}
}
if (mAtoms.empty())
throw std::runtime_error("No atoms loaded, refuse to continue");
loadData();
}
void Structure::loadAtomsForModel(StructureOpenOptions options)
{
auto db = mFile.impl().mDb;
auto &atomCat = (*db)["atom_site"];
for (auto &a : atomCat)
{
std::string id, type_symbol;
......@@ -1805,10 +1832,9 @@ Structure::Structure(File &f, size_t modelNr, StructureOpenOptions options)
mAtoms.emplace_back(new AtomImpl(*db, id, a));
}
loadData();
}
Structure::Structure(const Structure &s)
: mFile(s.mFile)
, mModelNr(s.mModelNr)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment