mirror of
https://github.com/PDB-REDO/libcifpp.git
synced 2026-06-04 22:14:24 +08:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
021487ed16 | ||
|
|
6b2c9dc3e3 |
@@ -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")
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
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;
|
||||
|
||||
@@ -636,17 +636,18 @@ void CompoundFactory::init(bool useThreadLocalInstanceOnly)
|
||||
CompoundFactory::CompoundFactory()
|
||||
: mImpl(nullptr)
|
||||
{
|
||||
auto ccd = cif::loadResource("components.cif");
|
||||
if (ccd)
|
||||
mImpl.reset(new CCDCompoundFactoryImpl(mImpl));
|
||||
else if (cif::VERBOSE)
|
||||
std::cerr << "CCD components.cif file was not found" << std::endl;
|
||||
|
||||
const char *clibd_mon = getenv("CLIBD_MON");
|
||||
if (clibd_mon != nullptr and fs::is_directory(clibd_mon))
|
||||
mImpl.reset(new CCP4CompoundFactoryImpl(clibd_mon));
|
||||
else if (cif::VERBOSE)
|
||||
std::cerr << "CCP4 monomers library not found, CLIBD_MON is not defined" << std::endl;
|
||||
|
||||
auto ccd = cif::loadResource("components.cif");
|
||||
if (ccd)
|
||||
mImpl.reset(new CCDCompoundFactoryImpl(mImpl));
|
||||
else if (cif::VERBOSE)
|
||||
std::cerr << "CCD components.cif file was not found" << std::endl;
|
||||
}
|
||||
|
||||
CompoundFactory::~CompoundFactory()
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user