Commit d2716b4e by maarten

re-ref started

git-svn-id: svn+ssh://gitlab/srv/svn-repos/pdb-redo/trunk@237 a1961a4f-ab94-4bcc-80e8-33b5a54de466
parent 9af1dabb
...@@ -252,10 +252,7 @@ namespace detail ...@@ -252,10 +252,7 @@ namespace detail
template<typename T> template<typename T>
T as() const T as() const
{ {
T result = 0; return boost::lexical_cast<T>(c_str("0"));
if (not empty())
result = boost::lexical_cast<T>(c_str());
return result;
} }
template<typename T> template<typename T>
...@@ -285,6 +282,10 @@ namespace detail ...@@ -285,6 +282,10 @@ namespace detail
const char* c_str() const; const char* c_str() const;
// the following returns the defaultValue from either the parameter
// or, if specified, the value from _item_default.value in the dictionary
const char* c_str(const char* defaultValue) const;
bool operator!=(const string& s) const { return s != c_str(); } bool operator!=(const string& s) const { return s != c_str(); }
bool operator==(const string& s) const { return s == c_str(); } bool operator==(const string& s) const { return s == c_str(); }
}; };
...@@ -293,14 +294,14 @@ namespace detail ...@@ -293,14 +294,14 @@ namespace detail
inline inline
string ItemReference::as<string>() const string ItemReference::as<string>() const
{ {
return string(c_str()); return string(c_str(""));
} }
template<> template<>
inline inline
const char* ItemReference::as<const char*>() const const char* ItemReference::as<const char*>() const
{ {
return c_str(); return c_str("");
} }
template<> template<>
...@@ -908,7 +909,14 @@ Condition any::operator==(const std::regex& rx) const ...@@ -908,7 +909,14 @@ Condition any::operator==(const std::regex& rx) const
class RowSet : public vector<Row> class RowSet : public vector<Row>
{ {
typedef vector<Row> base_type;
public: public:
RowSet(const RowSet& rhs);
RowSet(RowSet&& rhs);
RowSet& operator=(const RowSet& rhs);
RowSet& operator=(RowSet&& rhs);
RowSet(Category& cat); RowSet(Category& cat);
RowSet& orderBy(const string& Item) RowSet& orderBy(const string& Item)
...@@ -917,7 +925,7 @@ class RowSet : public vector<Row> ...@@ -917,7 +925,7 @@ class RowSet : public vector<Row>
RowSet& orderBy(std::initializer_list<string> Items); RowSet& orderBy(std::initializer_list<string> Items);
private: private:
Category& mCat; Category* mCat;
}; };
// -------------------------------------------------------------------- // --------------------------------------------------------------------
......
...@@ -58,8 +58,9 @@ struct ValidateItem ...@@ -58,8 +58,9 @@ struct ValidateItem
{ {
std::string mTag; std::string mTag;
bool mMandatory; bool mMandatory;
const ValidateType* mType; const ValidateType* mType;
cif::iset mEnums; cif::iset mEnums;
std::string mDefault;
ValidateItem* mParent = nullptr; ValidateItem* mParent = nullptr;
std::set<ValidateItem*> std::set<ValidateItem*>
mChildren; mChildren;
......
...@@ -104,7 +104,7 @@ class Compound ...@@ -104,7 +104,7 @@ class Compound
std::string id() const { return mId; } std::string id() const { return mId; }
std::string name() const { return mName; } std::string name() const { return mName; }
std::string type() const; std::string type() const;
// std::string group() const { return mGroup; } std::string group() const { return mGroup; }
std::vector<CompoundAtom> atoms() const { return mAtoms; } std::vector<CompoundAtom> atoms() const { return mAtoms; }
std::vector<CompoundBond> bonds() const { return mBonds; } std::vector<CompoundBond> bonds() const { return mBonds; }
......
...@@ -38,8 +38,7 @@ class MapMaker ...@@ -38,8 +38,7 @@ class MapMaker
void recalculateFromMTZ(const boost::filesystem::path& mtzFile, void recalculateFromMTZ(const boost::filesystem::path& mtzFile,
const Structure& structure, const Structure& structure,
bool noBulk, AnisoScalingFlag anisoScaling, bool noBulk, AnisoScalingFlag anisoScaling,
float samplingRate = 4.5, float samplingRate = 4.5, bool electronScattering = false,
bool electronScattering = false,
std::initializer_list<std::string> foLabels = { "FP", "SIGFP" }, std::initializer_list<std::string> foLabels = { "FP", "SIGFP" },
std::initializer_list<std::string> freeLabels = { "FREE" }); std::initializer_list<std::string> freeLabels = { "FREE" });
void loadFromMapFiles(const boost::filesystem::path& fbMapFile, void loadFromMapFiles(const boost::filesystem::path& fbMapFile,
......
...@@ -167,6 +167,8 @@ class Residue ...@@ -167,6 +167,8 @@ class Residue
// Is this residue a single entity? // Is this residue a single entity?
bool isEntity() const; bool isEntity() const;
const Structure& structure() const { return *mStructure; }
protected: protected:
...@@ -260,8 +262,8 @@ class Polymer ...@@ -260,8 +262,8 @@ class Polymer
iterator begin(); iterator begin();
iterator end(); iterator end();
size_t size() const { return mPolySeq.size(); } size_t size() const { return mPolySeq.size(); }
Monomer operator[](size_t index) const; Monomer operator[](size_t index) const { return Monomer(const_cast<Polymer&>(*this), index); }
Structure* structure() const { return mStructure; } Structure* structure() const { return mStructure; }
......
...@@ -102,13 +102,21 @@ BondMap::BondMap(const Structure& p) ...@@ -102,13 +102,21 @@ BondMap::BondMap(const Structure& p)
"ptnr1_label_atom_id", "ptnr2_label_atom_id", "ptnr1_label_atom_id", "ptnr2_label_atom_id",
"ptnr1_label_seq_id", "ptnr2_label_seq_id"); "ptnr1_label_seq_id", "ptnr2_label_seq_id");
auto a = db["atom_site"].find(cif::Key("label_asym_id") == asym1 and cif::Key("label_seq_id") == seqId1 and cif::Key("label_atom_id") == atomId1); auto a =
l["ptnr1_label_seq_id"].empty() ?
db["atom_site"].find(cif::Key("label_asym_id") == asym1 and cif::Key("label_atom_id") == atomId1) :
db["atom_site"].find(cif::Key("label_asym_id") == asym1 and cif::Key("label_seq_id") == seqId1 and cif::Key("label_atom_id") == atomId1);
if (a.size() != 1) if (a.size() != 1)
cerr << "Unexpected number (" << a.size() << ") of atoms for link with asym_id " << asym1 << " seq_id " << seqId1 << " atom_id " << atomId1 << endl; cerr << "Unexpected number (" << a.size() << ") of atoms for link with asym_id " << asym1 << " seq_id " << seqId1 << " atom_id " << atomId1 << endl;
auto b = db["atom_site"].find(cif::Key("label_asym_id") == asym2 and cif::Key("label_seq_id") == seqId2 and cif::Key("label_atom_id") == atomId2); auto b =
l["ptnr2_label_seq_id"].empty() ?
db["atom_site"].find(cif::Key("label_asym_id") == asym2 and cif::Key("label_atom_id") == atomId2) :
db["atom_site"].find(cif::Key("label_asym_id") == asym2 and cif::Key("label_seq_id") == seqId2 and cif::Key("label_atom_id") == atomId2);
if (b.size() != 1) if (b.size() != 1)
cerr << "Unexpected number (" << b.size() << ") of atoms for link with asym_id " << asym2 << " seq_id " << seqId2 << " atom_id " << atomId2 << endl; cerr << "Unexpected number (" << b.size() << ") of atoms for link with asym_id " << asym2 << " seq_id " << seqId2 << " atom_id " << atomId2 << endl;
if (not (a.empty() or b.empty())) if (not (a.empty() or b.empty()))
bindAtoms(a.front()["id"].as<string>(), b.front()["id"].as<string>()); bindAtoms(a.front()["id"].as<string>(), b.front()["id"].as<string>());
......
...@@ -90,7 +90,7 @@ void ItemValue::operator delete(void* p) ...@@ -90,7 +90,7 @@ void ItemValue::operator delete(void* p)
struct ItemColumn struct ItemColumn
{ {
string mName; // store lower-case, for optimization string mName; // store lower-case, for optimization
const ValidateItem* mValidator; const ValidateItem* mValidator;
}; };
// itemRow contains the actual values for a Row in a Category // itemRow contains the actual values for a Row in a Category
...@@ -183,7 +183,6 @@ void ItemRow::drop(uint32 columnIx) ...@@ -183,7 +183,6 @@ void ItemRow::drop(uint32 columnIx)
#if DEBUG #if DEBUG
for (auto iv = mValues; iv != nullptr; iv = iv->mNext) for (auto iv = mValues; iv != nullptr; iv = iv->mNext)
assert(iv != iv->mNext and (iv->mNext == nullptr or iv != iv->mNext->mNext)); assert(iv != iv->mNext and (iv->mNext == nullptr or iv != iv->mNext->mNext));
#endif #endif
} }
...@@ -215,8 +214,7 @@ ItemReference& ItemReference::operator=(const string& value) ...@@ -215,8 +214,7 @@ ItemReference& ItemReference::operator=(const string& value)
return *this; return *this;
} }
const char* const char* ItemReference::c_str() const
ItemReference::c_str() const
{ {
const char* result = kEmptyResult; const char* result = kEmptyResult;
...@@ -241,6 +239,39 @@ ItemReference::c_str() const ...@@ -241,6 +239,39 @@ ItemReference::c_str() const
return result; return result;
} }
const char* ItemReference::c_str(const char* defaultValue) const
{
const char* result = defaultValue;
if (mRow != nullptr and mRow->mCategory != nullptr)
{
// assert(mRow->mCategory);
auto cix = mRow->mCategory->getColumnIndex(mName);
if (cix < mRow->mCategory->mColumns.size())
{
auto iv = mRow->mCategory->mColumns[cix].mValidator;
if (iv != nullptr and not iv->mDefault.empty())
result = iv->mDefault.c_str();
for (auto iv = mRow->mValues; iv != nullptr; iv = iv->mNext)
{
if (iv->mColumnIndex == cix)
{
// only really non-empty values
if (iv->mText[0] != 0 and ((iv->mText[0] != '.' and iv->mText[0] != '?') or iv->mText[1] != 0))
result = iv->mText;
break;
}
}
}
}
return result;
}
bool ItemReference::empty() const bool ItemReference::empty() const
{ {
return c_str() == kEmptyResult; return c_str() == kEmptyResult;
...@@ -991,14 +1022,48 @@ void CatIndex::validate(entry* h, bool isParentRed, uint32 blackDepth, uint32& m ...@@ -991,14 +1022,48 @@ void CatIndex::validate(entry* h, bool isParentRed, uint32 blackDepth, uint32& m
// -------------------------------------------------------------------- // --------------------------------------------------------------------
RowSet::RowSet(const RowSet& rhs)
: base_type(rhs)
, mCat(rhs.mCat)
{
}
RowSet::RowSet(RowSet&& rhs)
: base_type(move(rhs))
, mCat(rhs.mCat)
{
}
RowSet& RowSet::operator=(const RowSet& rhs)
{
if (this != &rhs)
{
base_type::operator=(rhs);
mCat = rhs.mCat;
}
return *this;
}
RowSet& RowSet::operator=(RowSet&& rhs)
{
if (this != &rhs)
{
base_type::operator=(move(rhs));
mCat = rhs.mCat;
}
return *this;
}
RowSet::RowSet(Category& cat) RowSet::RowSet(Category& cat)
: mCat(cat) : mCat(&cat)
{ {
} }
RowSet& RowSet::orderBy(initializer_list<string> items) RowSet& RowSet::orderBy(initializer_list<string> items)
{ {
RowComparator c(&mCat, items.begin(), items.end()); RowComparator c(mCat, items.begin(), items.end());
stable_sort(begin(), end(), c); stable_sort(begin(), end(), c);
......
...@@ -784,6 +784,8 @@ void DictParser::parseSaveFrame() ...@@ -784,6 +784,8 @@ void DictParser::parseSaveFrame()
for (auto e: dict["item_enumeration"]) for (auto e: dict["item_enumeration"])
ess.insert(e["value"].as<string>()); ess.insert(e["value"].as<string>());
string defaultValue = dict.firstItem("_item_default.value");
// 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"])
{ {
...@@ -806,7 +808,7 @@ void DictParser::parseSaveFrame() ...@@ -806,7 +808,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}); ivs.push_back(ValidateItem{itemName, iequals(mandatory, "yes"), tv, ess, defaultValue});
else else
{ {
// need to update the itemValidator? // need to update the itemValidator?
......
...@@ -420,8 +420,8 @@ string Compound::type() const ...@@ -420,8 +420,8 @@ string Compound::type() const
result = "DNA linking"; result = "DNA linking";
else if (cif::iequals(mGroup, "RNA")) else if (cif::iequals(mGroup, "RNA"))
result = "RNA linking"; result = "RNA linking";
else // else
result = mGroup; // result = mGroup;
return result; return result;
} }
......
...@@ -108,7 +108,7 @@ void MapMaker<FTYPE>::loadFromMTZ(const fs::path& mtzFile, float samplingRate, ...@@ -108,7 +108,7 @@ void MapMaker<FTYPE>::loadFromMTZ(const fs::path& mtzFile, float samplingRate,
template<typename FTYPE> template<typename FTYPE>
void MapMaker<FTYPE>::fixMTZ(FPdata& fb, FPdata& fd, FOdata& fo, FPdata& fc) void MapMaker<FTYPE>::fixMTZ(FPdata& fb, FPdata& fd, FOdata& fo, FPdata& fc)
{ {
#warning("WARNING: Need the check first to see if fix is necessary!") #warning("WARNING: Need to check first to see if fix is necessary!")
using clipper::HKL_class; using clipper::HKL_class;
using clipper::data32::F_phi; using clipper::data32::F_phi;
...@@ -195,7 +195,6 @@ void MapMaker<FTYPE>::recalculateFromMTZ(const fs::path& mtzFile, ...@@ -195,7 +195,6 @@ void MapMaker<FTYPE>::recalculateFromMTZ(const fs::path& mtzFile,
HKL_data<F_phi> fc(hklInfo, mCell); HKL_data<F_phi> fc(hklInfo, mCell);
if (not electronScattering) if (not electronScattering)
{ {
auto& exptl = structure.getFile().data()["exptl"]; auto& exptl = structure.getFile().data()["exptl"];
......
...@@ -106,7 +106,10 @@ const set<string> kSupportedRecords{ ...@@ -106,7 +106,10 @@ const set<string> kSupportedRecords{
"SSBOND", "LINK ", "CISPEP", "SITE ", "CRYST1", "ORIGX1", "SCALE1", "SSBOND", "LINK ", "CISPEP", "SITE ", "CRYST1", "ORIGX1", "SCALE1",
"MTRIX1", "ORIGX2", "SCALE2", "MTRIX2", "ORIGX3", "SCALE3", "MTRIX3", "MTRIX1", "ORIGX2", "SCALE2", "MTRIX2", "ORIGX3", "SCALE3", "MTRIX3",
"MODEL ", "ATOM ", "ANISOU", "TER ", "HETATM", "ENDMDL", "CONECT", "MODEL ", "ATOM ", "ANISOU", "TER ", "HETATM", "ENDMDL", "CONECT",
"MASTER", "END " "MASTER", "END ",
// bah...
"LINKR "
}; };
bool isWater(const string& resname) bool isWater(const string& resname)
...@@ -4549,8 +4552,11 @@ void PDBFileParser::ParseConnectivtyAnnotation() ...@@ -4549,8 +4552,11 @@ void PDBFileParser::ParseConnectivtyAnnotation()
continue; continue;
} }
if (mRec->is("LINK ")) if (mRec->is("LINK ") or mRec->is("LINKR "))
{ {
if (VERBOSE and mRec->is("LINKR "))
cerr << "Accepting non-standard LINKR record, but ignoring extra information" << endl;
// 1 - 6 Record name "LINK " // 1 - 6 Record name "LINK "
string name1 = vS(13, 16); // 13 - 16 Atom name1 Atom name. string name1 = vS(13, 16); // 13 - 16 Atom name1 Atom name.
// 17 Character altLoc1 Alternate location indicator. // 17 Character altLoc1 Alternate location indicator.
...@@ -4606,6 +4612,18 @@ void PDBFileParser::ParseConnectivtyAnnotation() ...@@ -4606,6 +4612,18 @@ void PDBFileParser::ParseConnectivtyAnnotation()
continue; continue;
} }
string distance = vS(74, 78);
try
{
stod(distance);
}
catch (const invalid_argument&)
{
if (VERBOSE)
cerr << "Distance value '" << distance << "' is not a valid float" << endl;
distance.clear();
}
getCategory("struct_conn")->emplace({ getCategory("struct_conn")->emplace({
{ "id", type + to_string(linkNr) }, { "id", type + to_string(linkNr) },
{ "conn_type_id", type }, { "conn_type_id", type },
...@@ -4635,7 +4653,7 @@ void PDBFileParser::ParseConnectivtyAnnotation() ...@@ -4635,7 +4653,7 @@ void PDBFileParser::ParseConnectivtyAnnotation()
{ "ptnr2_symmetry", pdb2cifSymmetry(vS(67, 72)) }, { "ptnr2_symmetry", pdb2cifSymmetry(vS(67, 72)) },
{ "pdbx_dist_value", vS(74, 78) } { "pdbx_dist_value", distance }
}); });
continue; continue;
...@@ -5412,7 +5430,6 @@ int PDBFileParser::PDBChain::AlignResToSeqRes() ...@@ -5412,7 +5430,6 @@ int PDBFileParser::PDBChain::AlignResToSeqRes()
if (VERBOSE > 1) if (VERBOSE > 1)
printAlignment(); printAlignment();
try try
{ {
while (x >= 0 and y >= 0) while (x >= 0 and y >= 0)
...@@ -5462,9 +5479,6 @@ int PDBFileParser::PDBChain::AlignResToSeqRes() ...@@ -5462,9 +5479,6 @@ int PDBFileParser::PDBChain::AlignResToSeqRes()
throw; throw;
} }
if (VERBOSE > 1)
printAlignment();
// assign numbers to the residues that don't have them yet // assign numbers to the residues that don't have them yet
stack<int> unnumbered; stack<int> unnumbered;
for (x = 0; x < dimX; ++x) for (x = 0; x < dimX; ++x)
......
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