Commit 45f33e4b by Maarten L. Hekkelman

Merge branch 'trunk' into develop

parents cb3443ff 021487ed
...@@ -3,6 +3,10 @@ Version 3.0.0 ...@@ -3,6 +3,10 @@ Version 3.0.0
performance reasons. performance reasons.
- Upgraded mmcif::Structure - Upgraded mmcif::Structure
Version 2.0.3
- Fixed reading mmCIF files where model numbers are used and
model number 1 is missing.
Version 2.0.2 Version 2.0.2
- Added configuration flag to disable downloading CCD data during build - Added configuration flag to disable downloading CCD data during build
Note that there are now two flags for CCD data: Note that there are now two flags for CCD data:
......
...@@ -543,6 +543,8 @@ class Structure ...@@ -543,6 +543,8 @@ class Structure
void loadData(); void loadData();
void updateAtomIndex(); void updateAtomIndex();
void loadAtomsForModel(StructureOpenOptions options);
File &mFile; File &mFile;
size_t mModelNr; size_t mModelNr;
AtomView mAtoms; AtomView mAtoms;
......
...@@ -1790,6 +1790,33 @@ Structure::Structure(File &f, size_t modelNr, StructureOpenOptions options) ...@@ -1790,6 +1790,33 @@ Structure::Structure(File &f, size_t modelNr, StructureOpenOptions options)
auto &atomCat = (*db)["atom_site"]; 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) for (auto &a : atomCat)
{ {
std::string id, type_symbol; std::string id, type_symbol;
...@@ -1805,10 +1832,9 @@ Structure::Structure(File &f, size_t modelNr, StructureOpenOptions options) ...@@ -1805,10 +1832,9 @@ Structure::Structure(File &f, size_t modelNr, StructureOpenOptions options)
mAtoms.emplace_back(new AtomImpl(*db, id, a)); mAtoms.emplace_back(new AtomImpl(*db, id, a));
} }
loadData();
} }
Structure::Structure(const Structure &s) Structure::Structure(const Structure &s)
: mFile(s.mFile) : mFile(s.mFile)
, mModelNr(s.mModelNr) , 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