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
template<typename T>
T as() const
{
T result = 0;
if (not empty())
result = boost::lexical_cast<T>(c_str());
return result;
return boost::lexical_cast<T>(c_str("0"));
}
template<typename T>
......@@ -285,6 +282,10 @@ namespace detail
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(); }
};
......@@ -293,14 +294,14 @@ namespace detail
inline
string ItemReference::as<string>() const
{
return string(c_str());
return string(c_str(""));
}
template<>
inline
const char* ItemReference::as<const char*>() const
{
return c_str();
return c_str("");
}
template<>
......@@ -908,7 +909,14 @@ Condition any::operator==(const std::regex& rx) const
class RowSet : public vector<Row>
{
typedef vector<Row> base_type;
public:
RowSet(const RowSet& rhs);
RowSet(RowSet&& rhs);
RowSet& operator=(const RowSet& rhs);
RowSet& operator=(RowSet&& rhs);
RowSet(Category& cat);
RowSet& orderBy(const string& Item)
......@@ -917,7 +925,7 @@ class RowSet : public vector<Row>
RowSet& orderBy(std::initializer_list<string> Items);
private:
Category& mCat;
Category* mCat;
};
// --------------------------------------------------------------------
......
......@@ -58,8 +58,9 @@ struct ValidateItem
{
std::string mTag;
bool mMandatory;
const ValidateType* mType;
const ValidateType* mType;
cif::iset mEnums;
std::string mDefault;
ValidateItem* mParent = nullptr;
std::set<ValidateItem*>
mChildren;
......
......@@ -104,7 +104,7 @@ class Compound
std::string id() const { return mId; }
std::string name() const { return mName; }
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<CompoundBond> bonds() const { return mBonds; }
......
......@@ -38,8 +38,7 @@ class MapMaker
void recalculateFromMTZ(const boost::filesystem::path& mtzFile,
const Structure& structure,
bool noBulk, AnisoScalingFlag anisoScaling,
float samplingRate = 4.5,
bool electronScattering = false,
float samplingRate = 4.5, bool electronScattering = false,
std::initializer_list<std::string> foLabels = { "FP", "SIGFP" },
std::initializer_list<std::string> freeLabels = { "FREE" });
void loadFromMapFiles(const boost::filesystem::path& fbMapFile,
......
......@@ -167,6 +167,8 @@ class Residue
// Is this residue a single entity?
bool isEntity() const;
const Structure& structure() const { return *mStructure; }
protected:
......@@ -260,8 +262,8 @@ class Polymer
iterator begin();
iterator end();
size_t size() const { return mPolySeq.size(); }
Monomer operator[](size_t index) const;
size_t size() const { return mPolySeq.size(); }
Monomer operator[](size_t index) const { return Monomer(const_cast<Polymer&>(*this), index); }
Structure* structure() const { return mStructure; }
......
......@@ -102,13 +102,21 @@ BondMap::BondMap(const Structure& p)
"ptnr1_label_atom_id", "ptnr2_label_atom_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)
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)
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()))
bindAtoms(a.front()["id"].as<string>(), b.front()["id"].as<string>());
......
......@@ -90,7 +90,7 @@ void ItemValue::operator delete(void* p)
struct ItemColumn
{
string mName; // store lower-case, for optimization
const ValidateItem* mValidator;
const ValidateItem* mValidator;
};
// itemRow contains the actual values for a Row in a Category
......@@ -183,7 +183,6 @@ void ItemRow::drop(uint32 columnIx)
#if DEBUG
for (auto iv = mValues; iv != nullptr; iv = iv->mNext)
assert(iv != iv->mNext and (iv->mNext == nullptr or iv != iv->mNext->mNext));
#endif
}
......@@ -215,8 +214,7 @@ ItemReference& ItemReference::operator=(const string& value)
return *this;
}
const char*
ItemReference::c_str() const
const char* ItemReference::c_str() const
{
const char* result = kEmptyResult;
......@@ -241,6 +239,39 @@ ItemReference::c_str() const
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
{
return c_str() == kEmptyResult;
......@@ -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)
: mCat(cat)
: mCat(&cat)
{
}
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);
......
......@@ -784,6 +784,8 @@ void DictParser::parseSaveFrame()
for (auto e: dict["item_enumeration"])
ess.insert(e["value"].as<string>());
string defaultValue = dict.firstItem("_item_default.value");
// collect the dict from our dataBlock and construct validators
for (auto i: dict["item"])
{
......@@ -806,7 +808,7 @@ void DictParser::parseSaveFrame()
auto vi = find(ivs.begin(), ivs.end(), ValidateItem{itemName});
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
{
// need to update the itemValidator?
......
......@@ -420,8 +420,8 @@ string Compound::type() const
result = "DNA linking";
else if (cif::iequals(mGroup, "RNA"))
result = "RNA linking";
else
result = mGroup;
// else
// result = mGroup;
return result;
}
......
......@@ -108,7 +108,7 @@ void MapMaker<FTYPE>::loadFromMTZ(const fs::path& mtzFile, float samplingRate,
template<typename FTYPE>
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::data32::F_phi;
......@@ -195,7 +195,6 @@ void MapMaker<FTYPE>::recalculateFromMTZ(const fs::path& mtzFile,
HKL_data<F_phi> fc(hklInfo, mCell);
if (not electronScattering)
{
auto& exptl = structure.getFile().data()["exptl"];
......
......@@ -106,7 +106,10 @@ const set<string> kSupportedRecords{
"SSBOND", "LINK ", "CISPEP", "SITE ", "CRYST1", "ORIGX1", "SCALE1",
"MTRIX1", "ORIGX2", "SCALE2", "MTRIX2", "ORIGX3", "SCALE3", "MTRIX3",
"MODEL ", "ATOM ", "ANISOU", "TER ", "HETATM", "ENDMDL", "CONECT",
"MASTER", "END "
"MASTER", "END ",
// bah...
"LINKR "
};
bool isWater(const string& resname)
......@@ -4549,8 +4552,11 @@ void PDBFileParser::ParseConnectivtyAnnotation()
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 "
string name1 = vS(13, 16); // 13 - 16 Atom name1 Atom name.
// 17 Character altLoc1 Alternate location indicator.
......@@ -4606,6 +4612,18 @@ void PDBFileParser::ParseConnectivtyAnnotation()
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({
{ "id", type + to_string(linkNr) },
{ "conn_type_id", type },
......@@ -4635,7 +4653,7 @@ void PDBFileParser::ParseConnectivtyAnnotation()
{ "ptnr2_symmetry", pdb2cifSymmetry(vS(67, 72)) },
{ "pdbx_dist_value", vS(74, 78) }
{ "pdbx_dist_value", distance }
});
continue;
......@@ -5412,7 +5430,6 @@ int PDBFileParser::PDBChain::AlignResToSeqRes()
if (VERBOSE > 1)
printAlignment();
try
{
while (x >= 0 and y >= 0)
......@@ -5462,9 +5479,6 @@ int PDBFileParser::PDBChain::AlignResToSeqRes()
throw;
}
if (VERBOSE > 1)
printAlignment();
// assign numbers to the residues that don't have them yet
stack<int> unnumbered;
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