Commit db164a20 by maarten

aanpassen van gelinkte data bij swapAtoms

git-svn-id: svn+ssh://gitlab/srv/svn-repos/pdb-redo/trunk@478 a1961a4f-ab94-4bcc-80e8-33b5a54de466
parent 9b1e9356
...@@ -152,7 +152,15 @@ class Item ...@@ -152,7 +152,15 @@ class Item
void value(const string& v) { mValue = v; } void value(const string& v) { mValue = v; }
bool empty() const { return mValue.empty(); } // empty means either null or unknown
bool empty() const;
// is_null means the field contains '.'
bool is_null() const;
// is_unknown means the field contains '?'
bool is_unknown() const;
size_t length() const { return mValue.length(); } size_t length() const { return mValue.length(); }
const char* c_str() const { return mValue.c_str(); } const char* c_str() const { return mValue.c_str(); }
...@@ -284,9 +292,15 @@ namespace detail ...@@ -284,9 +292,15 @@ namespace detail
return result; return result;
} }
// empty means either null or unknown
bool empty() const; bool empty() const;
// bool unapplicable() const;
// is_null means the field contains '.'
bool is_null() const;
// is_unknown means the field contains '?'
bool is_unknown() const;
const char* c_str() const; const char* c_str() const;
// the following returns the defaultValue from either the parameter // the following returns the defaultValue from either the parameter
...@@ -615,6 +629,8 @@ struct Condition ...@@ -615,6 +629,8 @@ struct Condition
return mImpl ? mImpl->str() : ""; return mImpl ? mImpl->str() : "";
} }
bool empty() const { return mImpl == nullptr; }
detail::ConditionImpl* mImpl; detail::ConditionImpl* mImpl;
bool mPrepared = false; bool mPrepared = false;
}; };
......
...@@ -63,6 +63,7 @@ struct ValidateItem ...@@ -63,6 +63,7 @@ struct ValidateItem
const ValidateType* mType; const ValidateType* mType;
cif::iset mEnums; cif::iset mEnums;
std::string mDefault; std::string mDefault;
bool mDefaultIsNull;
ValidateCategory* mCategory = nullptr; ValidateCategory* mCategory = nullptr;
// ItemLinked is used for non-key links // ItemLinked is used for non-key links
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <boost/iostreams/filtering_stream.hpp> #include <boost/iostreams/filtering_stream.hpp>
#include <boost/iostreams/filter/bzip2.hpp> #include <boost/iostreams/filter/bzip2.hpp>
#include <boost/iostreams/filter/gzip.hpp> #include <boost/iostreams/filter/gzip.hpp>
#include <boost/logic/tribool.hpp>
#include "cif++/mrsrc.h" #include "cif++/mrsrc.h"
...@@ -48,6 +49,10 @@ struct ItemValue ...@@ -48,6 +49,10 @@ struct ItemValue
ItemValue(const char* v, uint32_t columnIndex); ItemValue(const char* v, uint32_t columnIndex);
~ItemValue(); ~ItemValue();
bool empty() const { return mText[0] == 0 or ((mText[0] == '.' or mText[0] == '?') and mText[1] == 0); }
bool null() const { return mText[0] == '.' and mText[1] == 0; }
bool unknown() const { return mText[0] == '?' and mText[1] == 0; }
void* operator new(size_t size, size_t dataSize); void* operator new(size_t size, size_t dataSize);
void operator delete(void* p); void operator delete(void* p);
}; };
...@@ -274,6 +279,32 @@ bool ItemReference::empty() const ...@@ -274,6 +279,32 @@ bool ItemReference::empty() const
return c_str() == kEmptyResult; return c_str() == kEmptyResult;
} }
bool ItemReference::is_null() const
{
boost::tribool result;
if (mRow.mData != nullptr and mRow.mData->mCategory != nullptr)
{
for (auto iv = mRow.mData->mValues; iv != nullptr; iv = iv->mNext)
{
if (iv->mColumnIndex == mColumn)
{
result = iv->mText[0] == '.' and iv->mText[1] == 0;
break;
}
}
if (result == boost::indeterminate and mColumn < mRow.mData->mCategory->mColumns.size()) // not found, perhaps the category has a default defined?
{
auto iv = mRow.mData->mCategory->mColumns[mColumn].mValidator;
if (iv != nullptr)
result = iv->mDefaultIsNull;
}
}
return result;
}
void ItemReference::swap(ItemReference& b) void ItemReference::swap(ItemReference& b)
{ {
Row::swap(mColumn, mRow.mData, b.mRow.mData); Row::swap(mColumn, mRow.mData, b.mRow.mData);
...@@ -1603,17 +1634,39 @@ Category::const_iterator Category::end() const ...@@ -1603,17 +1634,39 @@ Category::const_iterator Category::end() const
bool Category::hasParent(Row r, const Category& parentCat, const ValidateLink& link) const bool Category::hasParent(Row r, const Category& parentCat, const ValidateLink& link) const
{ {
assert(mValidator != nullptr);
assert(mCatValidator != nullptr);
bool result = true;
Condition cond; Condition cond;
for (size_t ix = 0; ix < link.mChildKeys.size(); ++ix) for (size_t ix = 0; ix < link.mChildKeys.size(); ++ix)
{ {
const char* value = r[link.mChildKeys[ix]].c_str(); auto& name = link.mChildKeys[ix];
cond = move(cond) && (Key(link.mParentKeys[ix]) == value); auto field = r[name];
if (field.empty())
{
if (mCatValidator->mMandatoryFields.count(name) and field.is_null())
cond = move(cond) and (Key(link.mParentKeys[ix]) == Empty());
}
else
{
const char* value = field.c_str();
cond = move(cond) and (Key(link.mParentKeys[ix]) == value);
}
} }
if (VERBOSE > 2) if (result and not cond.empty())
cerr << "Check condition '" << cond << "' in parent category " << link.mParentCategory << " for child cat " << mName << endl; {
result = parentCat.exists(std::move(cond));
if (VERBOSE > 3 or (result == false and VERBOSE > 2))
cerr << "result = " << boolalpha << result << " for: '" << cond << "' in parent category " << link.mParentCategory << " for child cat " << mName << endl;
}
else if (VERBOSE > 3 and cond.empty())
cerr << "Condition is empty due to missing data in parent category " << link.mParentCategory << " for child cat " << mName << endl;
return parentCat.exists(std::move(cond)); return result;
} }
bool Category::isOrphan(Row r) bool Category::isOrphan(Row r)
...@@ -2263,9 +2316,9 @@ void Row::swap(size_t cix, ItemRow* a, ItemRow* b) ...@@ -2263,9 +2316,9 @@ void Row::swap(size_t cix, ItemRow* a, ItemRow* b)
cat->mIndex->erase(b); cat->mIndex->erase(b);
} }
ItemValue* ap = nullptr; ItemValue* ap = nullptr; // parent of ai
ItemValue* ai = nullptr; ItemValue* ai = nullptr;
ItemValue* bp = nullptr; ItemValue* bp = nullptr; // parent of bi
ItemValue* bi = nullptr; ItemValue* bi = nullptr;
if (a->mValues == nullptr) if (a->mValues == nullptr)
...@@ -2337,39 +2390,118 @@ void Row::swap(size_t cix, ItemRow* a, ItemRow* b) ...@@ -2337,39 +2390,118 @@ void Row::swap(size_t cix, ItemRow* a, ItemRow* b)
cat->mIndex->insert(b); cat->mIndex->insert(b);
} }
#pragma warning("doen!") if ((ai != nullptr or bi != nullptr))
// // see if we need to update any child categories that depend on these values {
// auto iv = col.mValidator; auto parentColName = cat->getColumnName(cix);
// if ((ai != nullptr or bi != nullptr) and
// iv != nullptr and not iv->mChildren.empty()) // see if we need to update any child categories that depend on these values
// { auto& validator = cat->getValidator();
// for (auto child: iv->mChildren) auto parentCatValidator = cat->getCatValidator();
// {
// if (child->mCategory == nullptr) for (auto& link: validator.getLinksForParent(cat->mName))
// continue; {
// if (find(link->mParentKeys.begin(), link->mParentKeys.end(), parentColName) == link->mParentKeys.end())
// auto childCat = db.get(child->mCategory->mName); continue;
// if (childCat == nullptr)
// continue; auto childCat = cat->db().get(link->mChildCategory);
// if (childCat == nullptr or childCat->empty())
//#if DEBUG continue;
//cerr << "fixing linked item " << child->mCategory->mName << '.' << child->mTag << endl;
//#endif auto childCatValidator = childCat->getCatValidator();
// if (ai != nullptr) if (childCatValidator == nullptr)
// { continue;
// auto rows = childCat->find(Key(child->mTag) == string(ai->mText));
// for (auto& cr: rows) string linkChildColName;
// cr.assign(child->mTag, bi == nullptr ? "" : bi->mText, false);
// } Condition cond[2];
// for (size_t ab = 0; ab < 2; ++ab)
// if (bi != nullptr) {
// { auto i = ab == 0 ? ai : bi;
// auto rows = childCat->find(Key(child->mTag) == string(bi->mText)); auto r = ab == 0 ? a : b;
// for (auto& cr: rows)
// cr.assign(child->mTag, ai == nullptr ? "" : ai->mText, false); for (size_t ix = 0; ix < link->mChildKeys.size(); ++ix)
// } {
// } assert(ix < link->mParentKeys.size());
// } auto pcix = cat->getColumnIndex(link->mParentKeys[ix]);
auto childColName = link->mChildKeys[ix];
bool mandatory =
find(childCatValidator->mMandatoryFields.begin(), childCatValidator->mMandatoryFields.end(), childColName) != childCatValidator->mMandatoryFields.end() or
find(parentCatValidator->mMandatoryFields.begin(), parentCatValidator->mMandatoryFields.end(), link->mParentKeys[ix]) != parentCatValidator->mMandatoryFields.end();
string childValue;
if (pcix == cix)
{
linkChildColName = childColName;
if (not (i == nullptr or strcmp(i->mText, ".") == 0 or strcmp(i->mText, "?") == 0))
childValue = i->mText;
}
else
{
string ps = r->c_str(pcix);
if (not (ps.empty() or ps == "." or ps == "?"))
childValue = ps;
}
if (not childValue.empty())
{
if (mandatory or pcix == cix)
cond[ab] = move(cond[ab]) and Key(childColName) == childValue;
else
cond[ab] = move(cond[ab]) and (Key(childColName) == childValue or Key(childColName) == Empty());
}
else
cond[ab] = move(cond[ab]) and Key(childColName) == Empty();
}
}
RowSet rs[2] = { *childCat, *childCat };
// first find the respective rows, then flip values, otherwise you won't find them anymore!
for (size_t ab = 0; ab < 2; ++ab)
{
if (cond[ab].empty())
continue;
if (VERBOSE > 1)
cerr << "Fixing link from " << cat->mName << " to " << childCat->mName << " with " << endl
<< cond[ab] << endl;
rs[ab] = childCat->find(move(cond[ab]));
}
for (size_t ab = 0; ab < 2; ++ab)
{
auto i = ab == 0 ? bi : ai;
for (auto r: rs[ab])
{
// now due to the way links are defined, we might have found a row
// that contains an empty value for all child columns...
// Now, that's not a real hit, is it?
size_t n = 0;
for (auto c: link->mChildKeys)
if (r[c].empty())
++n;
if (n == link->mChildKeys.size())
{
if (VERBOSE > 1)
cerr << "All empty columns, skipping" << endl;
}
else
{
if (VERBOSE)
cerr << "In " << childCat->mName << " changing " << linkChildColName << ": " << r[linkChildColName] << " => " << (i ? i->mText : "") << endl;
r[linkChildColName] = i ? i->mText : "";
}
}
}
}
}
} }
void Row::assign(const Item& value, bool emplacing) void Row::assign(const Item& value, bool emplacing)
......
...@@ -780,6 +780,15 @@ void DictParser::parseSaveFrame() ...@@ -780,6 +780,15 @@ void DictParser::parseSaveFrame()
ess.insert(e["value"].as<string>()); ess.insert(e["value"].as<string>());
string defaultValue = dict.firstItem("_item_default.value"); string defaultValue = dict.firstItem("_item_default.value");
bool defaultIsNull = false;
if (defaultValue.empty())
{
for (auto& r: dict["_item_default"])
{
defaultIsNull = r["value"].is_null();
break;
}
}
// collect the dict from our dataBlock and construct validators // collect the dict from our dataBlock and construct validators
for (auto i: dict["item"]) for (auto i: dict["item"])
...@@ -803,7 +812,7 @@ void DictParser::parseSaveFrame() ...@@ -803,7 +812,7 @@ void DictParser::parseSaveFrame()
auto vi = find(ivs.begin(), ivs.end(), ValidateItem{itemName}); auto vi = find(ivs.begin(), ivs.end(), ValidateItem{itemName});
if (vi == ivs.end()) if (vi == ivs.end())
ivs.push_back(ValidateItem{itemName, iequals(mandatory, "yes"), tv, ess, defaultValue}); ivs.push_back(ValidateItem{itemName, iequals(mandatory, "yes"), tv, ess, defaultValue, defaultIsNull});
else else
{ {
// need to update the itemValidator? // need to update the itemValidator?
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <clipper/clipper-contrib.h> #include <clipper/clipper-contrib.h>
#include <clipper/clipper-ccp4.h> #include <clipper/clipper-ccp4.h>
#include "cif++/Cif++.h"
#include "cif++/MapMaker.h" #include "cif++/MapMaker.h"
#include "cif++/ResolutionCalculator.h" #include "cif++/ResolutionCalculator.h"
...@@ -21,8 +22,6 @@ namespace fs = boost::filesystem; ...@@ -21,8 +22,6 @@ namespace fs = boost::filesystem;
namespace io = boost::iostreams; namespace io = boost::iostreams;
namespace ba = boost::algorithm; namespace ba = boost::algorithm;
extern int VERBOSE;
namespace mmcif namespace mmcif
{ {
...@@ -312,7 +311,7 @@ void Map<FTYPE>::read(const fs::path& mapFile) ...@@ -312,7 +311,7 @@ void Map<FTYPE>::read(const fs::path& mapFile)
{ {
fs::path dataFile = mapFile; fs::path dataFile = mapFile;
if (VERBOSE) if (cif::VERBOSE)
cout << "Reading map from " << mapFile << endl; cout << "Reading map from " << mapFile << endl;
if (mapFile.extension() == ".gz" or mapFile.extension() == ".bz2") if (mapFile.extension() == ".gz" or mapFile.extension() == ".bz2")
...@@ -401,7 +400,7 @@ void MapMaker<FTYPE>::loadMTZ(const fs::path& hklin, float samplingRate, ...@@ -401,7 +400,7 @@ void MapMaker<FTYPE>::loadMTZ(const fs::path& hklin, float samplingRate,
initializer_list<string> foLabels, initializer_list<string> fcLabels, initializer_list<string> foLabels, initializer_list<string> fcLabels,
initializer_list<string> faLabels) initializer_list<string> faLabels)
{ {
if (VERBOSE) if (cif::VERBOSE)
cerr << "Reading map from " << hklin << endl cerr << "Reading map from " << hklin << endl
<< " with labels: FB: " << ba::join(fbLabels, ",") << endl << " with labels: FB: " << ba::join(fbLabels, ",") << endl
<< " with labels: FD: " << ba::join(fdLabels, ",") << endl << " with labels: FD: " << ba::join(fdLabels, ",") << endl
...@@ -523,7 +522,7 @@ void MapMaker<FTYPE>::loadMTZ(const fs::path& hklin, float samplingRate, ...@@ -523,7 +522,7 @@ void MapMaker<FTYPE>::loadMTZ(const fs::path& hklin, float samplingRate,
faMap.fft_from(mFaData); faMap.fft_from(mFaData);
} }
if (VERBOSE) if (cif::VERBOSE)
{ {
cerr << "Read Xmaps with sampling rate: " << samplingRate << endl cerr << "Read Xmaps with sampling rate: " << samplingRate << endl
<< " stored resolution: " << mHKLInfo.resolution().limit() << endl << " stored resolution: " << mHKLInfo.resolution().limit() << endl
...@@ -660,7 +659,7 @@ void MapMaker<FTYPE>::loadFoFreeFromReflectionsFile(const fs::path& hklin) ...@@ -660,7 +659,7 @@ void MapMaker<FTYPE>::loadFoFreeFromReflectionsFile(const fs::path& hklin)
if (ix < 0) if (ix < 0)
{ {
if (VERBOSE) if (cif::VERBOSE)
cerr << "Ignoring hkl(" << h << ", " << k << ", " << l << ")" << endl; cerr << "Ignoring hkl(" << h << ", " << k << ", " << l << ")" << endl;
continue; continue;
} }
...@@ -692,7 +691,7 @@ void MapMaker<FTYPE>::loadFoFreeFromReflectionsFile(const fs::path& hklin) ...@@ -692,7 +691,7 @@ void MapMaker<FTYPE>::loadFoFreeFromReflectionsFile(const fs::path& hklin)
break; break;
default: default:
if (VERBOSE > 1) if (cif::VERBOSE > 1)
cerr << "Unexpected value in status: '" << flag << "' for hkl(" << h << ", " << k << ", " << l << ")" << endl; cerr << "Unexpected value in status: '" << flag << "' for hkl(" << h << ", " << k << ", " << l << ")" << endl;
break; break;
} }
...@@ -705,7 +704,7 @@ template<typename FTYPE> ...@@ -705,7 +704,7 @@ template<typename FTYPE>
void MapMaker<FTYPE>::loadFoFreeFromMTZFile(const fs::path& hklin, void MapMaker<FTYPE>::loadFoFreeFromMTZFile(const fs::path& hklin,
initializer_list<std::string> foLabels, initializer_list<std::string> freeLabels) initializer_list<std::string> foLabels, initializer_list<std::string> freeLabels)
{ {
if (VERBOSE) if (cif::VERBOSE)
cerr << "Recalculating maps from " << hklin << endl; cerr << "Recalculating maps from " << hklin << endl;
const string kBasePath("/%1%/%2%/[%3%]"); const string kBasePath("/%1%/%2%/[%3%]");
...@@ -761,7 +760,7 @@ void MapMaker<FTYPE>::recalc(const Structure& structure, ...@@ -761,7 +760,7 @@ void MapMaker<FTYPE>::recalc(const Structure& structure,
clipper::SFcalc_obs_bulk<float> sfcb; clipper::SFcalc_obs_bulk<float> sfcb;
sfcb(mFcData, mFoData, atoms); sfcb(mFcData, mFoData, atoms);
if (VERBOSE) if (cif::VERBOSE)
cerr << "Bulk correction volume: " << sfcb.bulk_frac() << endl cerr << "Bulk correction volume: " << sfcb.bulk_frac() << endl
<< "Bulk correction factor: " << sfcb.bulk_scale() << endl; << "Bulk correction factor: " << sfcb.bulk_scale() << endl;
} }
...@@ -775,7 +774,7 @@ void MapMaker<FTYPE>::recalc(const Structure& structure, ...@@ -775,7 +774,7 @@ void MapMaker<FTYPE>::recalc(const Structure& structure,
else else
sfscl(mFcData, mFoData); // scale Fcal sfscl(mFcData, mFoData); // scale Fcal
if (VERBOSE) if (cif::VERBOSE)
cerr << "Anisotropic scaling:" << endl cerr << "Anisotropic scaling:" << endl
<< sfscl.u_aniso_orth(F).format() << endl; << sfscl.u_aniso_orth(F).format() << endl;
} }
...@@ -819,7 +818,7 @@ void MapMaker<FTYPE>::recalc(const Structure& structure, ...@@ -819,7 +818,7 @@ void MapMaker<FTYPE>::recalc(const Structure& structure,
mResLow = res; mResLow = res;
} }
if (VERBOSE > 1) if (cif::VERBOSE > 1)
cerr << "calculated reshi = " << mResHigh << " reslo = " << mResLow << endl; cerr << "calculated reshi = " << mResHigh << " reslo = " << mResLow << endl;
samplingRate /= 2; samplingRate /= 2;
...@@ -836,7 +835,7 @@ void MapMaker<FTYPE>::recalc(const Structure& structure, ...@@ -836,7 +835,7 @@ void MapMaker<FTYPE>::recalc(const Structure& structure,
fdMap.init(spacegroup, cell, mGrid); // define map fdMap.init(spacegroup, cell, mGrid); // define map
fdMap.fft_from(mFdData); // generate map fdMap.fft_from(mFdData); // generate map
if (VERBOSE) if (cif::VERBOSE)
{ {
cerr << "Read Xmaps with sampling rate: " << samplingRate << endl cerr << "Read Xmaps with sampling rate: " << samplingRate << endl
<< " resolution: " << mResHigh << " resolution: " << mResHigh
...@@ -873,7 +872,7 @@ void MapMaker<FTYPE>::fixMTZ() ...@@ -873,7 +872,7 @@ void MapMaker<FTYPE>::fixMTZ()
// first run the tests to see if we need to fix anything // first run the tests to see if we need to fix anything
if (VERBOSE) if (cif::VERBOSE)
cerr << "Testing MTZ file" << endl; cerr << "Testing MTZ file" << endl;
for (auto ih = mFbData.first(); not ih.last(); ih.next()) for (auto ih = mFbData.first(); not ih.last(); ih.next())
...@@ -903,13 +902,13 @@ void MapMaker<FTYPE>::fixMTZ() ...@@ -903,13 +902,13 @@ void MapMaker<FTYPE>::fixMTZ()
if (tests[T10] and abs(FM - FC) > 0.05) if (tests[T10] and abs(FM - FC) > 0.05)
{ {
tests[T10] = false; tests[T10] = false;
if (VERBOSE) cerr << "Test 10 failed at " << ih.hkl() << endl; if (cif::VERBOSE) cerr << "Test 10 failed at " << ih.hkl() << endl;
} }
if (tests[T11] and abs(FD) > 0.05) if (tests[T11] and abs(FD) > 0.05)
{ {
tests[T11] = false; tests[T11] = false;
if (VERBOSE) cerr << "Test 11 failed at " << ih.hkl() << endl; if (cif::VERBOSE) cerr << "Test 11 failed at " << ih.hkl() << endl;
} }
} }
else if (cls.centric()) else if (cls.centric())
...@@ -917,31 +916,31 @@ void MapMaker<FTYPE>::fixMTZ() ...@@ -917,31 +916,31 @@ void MapMaker<FTYPE>::fixMTZ()
if (tests[C5] and abs(FC + FM - 2 * WFO) > 0.05) if (tests[C5] and abs(FC + FM - 2 * WFO) > 0.05)
{ {
tests[C5] = false; tests[C5] = false;
if (VERBOSE) cerr << "Test C5 failed at " << ih.hkl() << endl; if (cif::VERBOSE) cerr << "Test C5 failed at " << ih.hkl() << endl;
} }
if (tests[C6] and abs(FM - WFO) > 0.05) if (tests[C6] and abs(FM - WFO) > 0.05)
{ {
tests[C6] = false; tests[C6] = false;
if (VERBOSE) cerr << "Test C6 failed at " << ih.hkl() << endl; if (cif::VERBOSE) cerr << "Test C6 failed at " << ih.hkl() << endl;
} }
if (tests[C7] and abs(FC + FD - WFO) > 0.05) if (tests[C7] and abs(FC + FD - WFO) > 0.05)
{ {
tests[C7] = false; tests[C7] = false;
if (VERBOSE) cerr << "Test C7 failed at " << ih.hkl() << endl; if (cif::VERBOSE) cerr << "Test C7 failed at " << ih.hkl() << endl;
} }
if (tests[C8] and abs(FC + 0.5 * FD - WFO) > 0.05) if (tests[C8] and abs(FC + 0.5 * FD - WFO) > 0.05)
{ {
tests[C8] = false; tests[C8] = false;
if (VERBOSE) cerr << "Test C8 failed at " << ih.hkl() << endl; if (cif::VERBOSE) cerr << "Test C8 failed at " << ih.hkl() << endl;
} }
if (tests[C9] and (1.01 * FC + Gd - WFO) < -0.05) if (tests[C9] and (1.01 * FC + Gd - WFO) < -0.05)
{ {
tests[C9] = false; tests[C9] = false;
if (VERBOSE) cerr << "Test C9 failed at " << ih.hkl() << endl; if (cif::VERBOSE) cerr << "Test C9 failed at " << ih.hkl() << endl;
} }
} }
...@@ -950,25 +949,25 @@ void MapMaker<FTYPE>::fixMTZ() ...@@ -950,25 +949,25 @@ void MapMaker<FTYPE>::fixMTZ()
if (tests[A1] and abs(FC + FM - 2 * WFO) > 0.05) if (tests[A1] and abs(FC + FM - 2 * WFO) > 0.05)
{ {
tests[A1] = false; tests[A1] = false;
if (VERBOSE) cerr << "Test A1 failed at " << ih.hkl() << endl; if (cif::VERBOSE) cerr << "Test A1 failed at " << ih.hkl() << endl;
} }
if (tests[A2] and 1.01 * FC + FM - 2 * WFO < -0.05) if (tests[A2] and 1.01 * FC + FM - 2 * WFO < -0.05)
{ {
tests[A2] = false; tests[A2] = false;
if (VERBOSE) cerr << "Test A2 failed at " << ih.hkl() << endl; if (cif::VERBOSE) cerr << "Test A2 failed at " << ih.hkl() << endl;
} }
if (tests[A3] and abs(FM - FD - WFO) > 0.05) if (tests[A3] and abs(FM - FD - WFO) > 0.05)
{ {
tests[A3] = false; tests[A3] = false;
if (VERBOSE) cerr << "Test A3 failed at " << ih.hkl() << endl; if (cif::VERBOSE) cerr << "Test A3 failed at " << ih.hkl() << endl;
} }
if (tests[A4] and abs(FM - 0.5 * FD - WFO) > 0.05) if (tests[A4] and abs(FM - 0.5 * FD - WFO) > 0.05)
{ {
tests[A4] = false; tests[A4] = false;
if (VERBOSE) cerr << "Test A4 failed at " << ih.hkl() << endl; if (cif::VERBOSE) cerr << "Test A4 failed at " << ih.hkl() << endl;
} }
} }
} }
......
...@@ -22,7 +22,7 @@ namespace ba = boost::algorithm; ...@@ -22,7 +22,7 @@ namespace ba = boost::algorithm;
namespace fs = boost::filesystem; namespace fs = boost::filesystem;
namespace io = boost::iostreams; namespace io = boost::iostreams;
extern int VERBOSE; extern int cif::VERBOSE;
namespace mmcif namespace mmcif
{ {
...@@ -72,14 +72,14 @@ void FileImpl::load(fs::path p) ...@@ -72,14 +72,14 @@ void FileImpl::load(fs::path p)
{ {
try try
{ {
if (VERBOSE) if (cif::VERBOSE)
cerr << "unrecognized file extension, trying cif" << endl; cerr << "unrecognized file extension, trying cif" << endl;
mData.load(in); mData.load(in);
} }
catch (const cif::CifParserError& e) catch (const cif::CifParserError& e)
{ {
if (VERBOSE) if (cif::VERBOSE)
cerr << "Not cif, trying plain old PDB" << endl; cerr << "Not cif, trying plain old PDB" << endl;
// pffft... // pffft...
...@@ -114,7 +114,7 @@ void FileImpl::load(fs::path p) ...@@ -114,7 +114,7 @@ void FileImpl::load(fs::path p)
// if (mData.getValidator() == nullptr) // if (mData.getValidator() == nullptr)
mData.loadDictionary("mmcif_pdbx"); mData.loadDictionary("mmcif_pdbx");
if (not mData.isValid()) if (not mData.isValid())
cerr << "Invalid mmCIF file" << (VERBOSE ? "." : " use --verbose option to see errors") << endl; cerr << "Invalid mmCIF file" << (cif::VERBOSE ? "." : " use --verbose option to see errors") << endl;
} }
void FileImpl::save(fs::path p) void FileImpl::save(fs::path p)
...@@ -313,7 +313,7 @@ struct AtomImpl ...@@ -313,7 +313,7 @@ struct AtomImpl
mCompound = Compound::create(compId); mCompound = Compound::create(compId);
if (VERBOSE and mCompound == nullptr) if (cif::VERBOSE and mCompound == nullptr)
cerr << "Compound not found: '" << compId << '\'' << endl; cerr << "Compound not found: '" << compId << '\'' << endl;
} }
...@@ -587,7 +587,7 @@ void Atom::calculateRadius(float resHigh, float resLow, float perc) ...@@ -587,7 +587,7 @@ void Atom::calculateRadius(float resHigh, float resLow, float perc)
mImpl->mRadius = shape.radius(); mImpl->mRadius = shape.radius();
// verbose // verbose
if (VERBOSE > 1) if (cif::VERBOSE > 1)
cout << "Calculated radius for " << AtomTypeTraits(mImpl->mType).name() << " with charge " << charge() << " is " << mImpl->mRadius << endl; cout << "Calculated radius for " << AtomTypeTraits(mImpl->mType).name() << " with charge " << charge() << " is " << mImpl->mRadius << endl;
} }
...@@ -864,7 +864,7 @@ float Monomer::phi() const ...@@ -864,7 +864,7 @@ float Monomer::phi() const
} }
catch (const exception& ex) catch (const exception& ex)
{ {
if (VERBOSE) if (cif::VERBOSE)
cerr << ex.what() << endl; cerr << ex.what() << endl;
} }
...@@ -887,7 +887,7 @@ float Monomer::psi() const ...@@ -887,7 +887,7 @@ float Monomer::psi() const
} }
catch (const exception& ex) catch (const exception& ex)
{ {
if (VERBOSE) if (cif::VERBOSE)
cerr << ex.what() << endl; cerr << ex.what() << endl;
} }
...@@ -911,7 +911,7 @@ float Monomer::alpha() const ...@@ -911,7 +911,7 @@ float Monomer::alpha() const
} }
catch (const exception& ex) catch (const exception& ex)
{ {
if (VERBOSE) if (cif::VERBOSE)
cerr << ex.what() << endl; cerr << ex.what() << endl;
} }
...@@ -939,7 +939,7 @@ float Monomer::kappa() const ...@@ -939,7 +939,7 @@ float Monomer::kappa() const
} }
catch (const exception& ex) catch (const exception& ex)
{ {
if (VERBOSE) if (cif::VERBOSE)
cerr << "When trying to calculate kappa for " << asymID() << ':' << seqID() << ": " cerr << "When trying to calculate kappa for " << asymID() << ':' << seqID() << ": "
<< ex.what() << endl; << ex.what() << endl;
} }
......
...@@ -266,7 +266,7 @@ struct TLSSelectionNot : public TLSSelection ...@@ -266,7 +266,7 @@ struct TLSSelectionNot : public TLSSelection
for (auto& r: residues) for (auto& r: residues)
r.selected = not r.selected; r.selected = not r.selected;
if (VERBOSE) if (cif::VERBOSE)
{ {
cout << string(indentLevel * 2, ' ') << "NOT" << endl; cout << string(indentLevel * 2, ' ') << "NOT" << endl;
DumpSelection(residues, indentLevel); DumpSelection(residues, indentLevel);
...@@ -285,7 +285,7 @@ struct TLSSelectionAll : public TLSSelection ...@@ -285,7 +285,7 @@ struct TLSSelectionAll : public TLSSelection
for (auto& r: residues) for (auto& r: residues)
r.selected = true; r.selected = true;
if (VERBOSE) if (cif::VERBOSE)
{ {
cout << string(indentLevel * 2, ' ') << "ALL" << endl; cout << string(indentLevel * 2, ' ') << "ALL" << endl;
DumpSelection(residues, indentLevel); DumpSelection(residues, indentLevel);
...@@ -305,7 +305,7 @@ struct TLSSelectionChain : public TLSSelectionAll ...@@ -305,7 +305,7 @@ struct TLSSelectionChain : public TLSSelectionAll
for (auto& r: residues) for (auto& r: residues)
r.selected = allChains or r.chainID == m_chain; r.selected = allChains or r.chainID == m_chain;
if (VERBOSE) if (cif::VERBOSE)
{ {
cout << string(indentLevel * 2, ' ') << "CHAIN " << m_chain << endl; cout << string(indentLevel * 2, ' ') << "CHAIN " << m_chain << endl;
DumpSelection(residues, indentLevel); DumpSelection(residues, indentLevel);
...@@ -325,7 +325,7 @@ struct TLSSelectionResID : public TLSSelectionAll ...@@ -325,7 +325,7 @@ struct TLSSelectionResID : public TLSSelectionAll
for (auto& r: residues) for (auto& r: residues)
r.selected = r.seqNr == m_seq_nr and r.iCode == m_icode; r.selected = r.seqNr == m_seq_nr and r.iCode == m_icode;
if (VERBOSE) if (cif::VERBOSE)
{ {
cout << string(indentLevel * 2, ' ') << "ResID " << m_seq_nr << (m_icode ? string { m_icode} : "") << endl; cout << string(indentLevel * 2, ' ') << "ResID " << m_seq_nr << (m_icode ? string { m_icode} : "") << endl;
DumpSelection(residues, indentLevel); DumpSelection(residues, indentLevel);
...@@ -349,7 +349,7 @@ struct TLSSelectionRangeSeq : public TLSSelectionAll ...@@ -349,7 +349,7 @@ struct TLSSelectionRangeSeq : public TLSSelectionAll
(r.seqNr <= m_last or m_last == kResidueNrWildcard)); (r.seqNr <= m_last or m_last == kResidueNrWildcard));
} }
if (VERBOSE) if (cif::VERBOSE)
{ {
cout << string(indentLevel * 2, ' ') << "Range " << m_first << ':' << m_last << endl; cout << string(indentLevel * 2, ' ') << "Range " << m_first << ':' << m_last << endl;
DumpSelection(residues, indentLevel); DumpSelection(residues, indentLevel);
...@@ -392,7 +392,7 @@ struct TLSSelectionRangeID : public TLSSelectionAll ...@@ -392,7 +392,7 @@ struct TLSSelectionRangeID : public TLSSelectionAll
} }
} }
if (VERBOSE) if (cif::VERBOSE)
{ {
cout << string(indentLevel * 2, ' ') << "Through " << m_first << ':' << m_last << endl; cout << string(indentLevel * 2, ' ') << "Through " << m_first << ':' << m_last << endl;
DumpSelection(residues, indentLevel); DumpSelection(residues, indentLevel);
...@@ -425,7 +425,7 @@ struct TLSSelectionUnion : public TLSSelection ...@@ -425,7 +425,7 @@ struct TLSSelectionUnion : public TLSSelection
for (auto ai = a.begin(), bi = b.begin(), ri = residues.begin(); ri != residues.end(); ++ai, ++bi, ++ri) for (auto ai = a.begin(), bi = b.begin(), ri = residues.begin(); ri != residues.end(); ++ai, ++bi, ++ri)
ri->selected = ai->selected or bi->selected; ri->selected = ai->selected or bi->selected;
if (VERBOSE) if (cif::VERBOSE)
{ {
cout << string(indentLevel * 2, ' ') << "Union" << endl; cout << string(indentLevel * 2, ' ') << "Union" << endl;
DumpSelection(residues, indentLevel); DumpSelection(residues, indentLevel);
...@@ -458,7 +458,7 @@ struct TLSSelectionIntersection : public TLSSelection ...@@ -458,7 +458,7 @@ struct TLSSelectionIntersection : public TLSSelection
for (auto ai = a.begin(), bi = b.begin(), ri = residues.begin(); ri != residues.end(); ++ai, ++bi, ++ri) for (auto ai = a.begin(), bi = b.begin(), ri = residues.begin(); ri != residues.end(); ++ai, ++bi, ++ri)
ri->selected = ai->selected and bi->selected; ri->selected = ai->selected and bi->selected;
if (VERBOSE) if (cif::VERBOSE)
{ {
cout << string(indentLevel * 2, ' ') << "Intersection" << endl; cout << string(indentLevel * 2, ' ') << "Intersection" << endl;
DumpSelection(residues, indentLevel); DumpSelection(residues, indentLevel);
...@@ -480,7 +480,7 @@ struct TLSSelectionByName : public TLSSelectionAll ...@@ -480,7 +480,7 @@ struct TLSSelectionByName : public TLSSelectionAll
for (auto& r: residues) for (auto& r: residues)
r.selected = r.name == m_name; r.selected = r.name == m_name;
if (VERBOSE) if (cif::VERBOSE)
{ {
cout << string(indentLevel * 2, ' ') << "Name " << m_name << endl; cout << string(indentLevel * 2, ' ') << "Name " << m_name << endl;
DumpSelection(residues, indentLevel); DumpSelection(residues, indentLevel);
...@@ -506,7 +506,7 @@ struct TLSSelectionByElement : public TLSSelectionAll ...@@ -506,7 +506,7 @@ struct TLSSelectionByElement : public TLSSelectionAll
for (auto& r: residues) for (auto& r: residues)
r.selected = iequals(r.name, m_element); r.selected = iequals(r.name, m_element);
if (VERBOSE) if (cif::VERBOSE)
{ {
cout << string(indentLevel * 2, ' ') << "Element " << m_element << endl; cout << string(indentLevel * 2, ' ') << "Element " << m_element << endl;
DumpSelection(residues, indentLevel); DumpSelection(residues, indentLevel);
...@@ -1051,7 +1051,7 @@ TLSSelectionPtr TLSSelectionParserImplPhenix::ParseFactor() ...@@ -1051,7 +1051,7 @@ TLSSelectionPtr TLSSelectionParserImplPhenix::ParseFactor()
result.reset(new TLSSelectionRangeID(from, to, icode_from, icode_to)); result.reset(new TLSSelectionRangeID(from, to, icode_from, icode_to));
else else
{ {
if (VERBOSE and (icode_from or icode_to)) if (cif::VERBOSE and (icode_from or icode_to))
cerr << "Warning, ignoring insertion codes" << endl; cerr << "Warning, ignoring insertion codes" << endl;
result.reset(new TLSSelectionRangeSeq(from, to)); result.reset(new TLSSelectionRangeSeq(from, to));
...@@ -1307,7 +1307,7 @@ tuple<string,int> TLSSelectionParserImplBuster::ParseAtom() ...@@ -1307,7 +1307,7 @@ tuple<string,int> TLSSelectionParserImplBuster::ParseAtom()
Match(':'); Match(':');
string atom = m_value_s; string atom = m_value_s;
if (VERBOSE) if (cif::VERBOSE)
cerr << "Warning: ignoring atom ID '" << atom << "' in TLS selection" << endl; cerr << "Warning: ignoring atom ID '" << atom << "' in TLS selection" << endl;
Match(bt_IDENT); Match(bt_IDENT);
...@@ -1852,14 +1852,14 @@ TLSSelectionPtr ParseSelectionDetails(const string& program, const string& selec ...@@ -1852,14 +1852,14 @@ TLSSelectionPtr ParseSelectionDetails(const string& program, const string& selec
if (not result) if (not result)
{ {
if (VERBOSE) if (cif::VERBOSE)
cerr << "Falling back to old BUSTER" << endl; cerr << "Falling back to old BUSTER" << endl;
result = busterOld.Parse(selection); result = busterOld.Parse(selection);
} }
if (not result) if (not result)
{ {
if (VERBOSE) if (cif::VERBOSE)
cerr << "Falling back to PHENIX" << endl; cerr << "Falling back to PHENIX" << endl;
result = phenix.Parse(selection); result = phenix.Parse(selection);
} }
...@@ -1870,35 +1870,35 @@ TLSSelectionPtr ParseSelectionDetails(const string& program, const string& selec ...@@ -1870,35 +1870,35 @@ TLSSelectionPtr ParseSelectionDetails(const string& program, const string& selec
if (not result) if (not result)
{ {
if (VERBOSE) if (cif::VERBOSE)
cerr << "Falling back to BUSTER" << endl; cerr << "Falling back to BUSTER" << endl;
result = buster.Parse(selection); result = buster.Parse(selection);
} }
if (not result) if (not result)
{ {
if (VERBOSE) if (cif::VERBOSE)
cerr << "Falling back to old BUSTER" << endl; cerr << "Falling back to old BUSTER" << endl;
result = busterOld.Parse(selection); result = busterOld.Parse(selection);
} }
} }
else else
{ {
if (VERBOSE) if (cif::VERBOSE)
cerr << "No known program specified, trying PHENIX" << endl; cerr << "No known program specified, trying PHENIX" << endl;
result = phenix.Parse(selection); result = phenix.Parse(selection);
if (not result) if (not result)
{ {
if (VERBOSE) if (cif::VERBOSE)
cerr << "Falling back to BUSTER" << endl; cerr << "Falling back to BUSTER" << endl;
result = buster.Parse(selection); result = buster.Parse(selection);
} }
if (not result) if (not result)
{ {
if (VERBOSE) if (cif::VERBOSE)
cerr << "Falling back to old BUSTER" << endl; cerr << "Falling back to old BUSTER" << endl;
result = busterOld.Parse(selection); result = busterOld.Parse(selection);
} }
......
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