Commit d3bc435a by maarten

met skip list

git-svn-id: svn+ssh://gitlab/srv/svn-repos/pdb-redo/trunk@336 a1961a4f-ab94-4bcc-80e8-33b5a54de466
parent 4436ad43
......@@ -392,6 +392,9 @@ namespace detail
getRowResult(const Row& r, C... columns)
: mRow(r), mColumns({{columns...}}) {}
template<typename... Ts>
operator std::tuple<Ts...>() const;
const Row& mRow;
std::array<const char*, N> mColumns;
};
......@@ -443,6 +446,53 @@ namespace detail
T& mVal;
next mNext;
};
// And to convert a getRowResult to a std::tuple
template<int IX, typename... Ts>
struct toTuple;
template<int IX, typename T>
struct toTuple<IX,T>
{
template<typename RR>
std::tuple<T> operator()(RR& rr)
{
typedef typename std::remove_reference<T>::type basicType;
const ItemReference v = rr[IX];
std::tuple<T> tv = std::make_tuple(v.as<basicType>());
return tv;
};
};
template<int IX, typename T, typename... Ts>
struct toTuple<IX,T,Ts...>
{
typedef toTuple<IX + 1, Ts...> next;
template<typename RR>
std::tuple<T,Ts...> operator()(RR& rr)
{
typedef typename std::remove_reference<T>::type basicType;
const ItemReference v = rr[IX];
std::tuple<T> tv = std::make_tuple(v.as<basicType>());
next n;
return std::tuple_cat(tv, n(rr));
};
};
template<typename... C>
template<typename... Ts>
getRowResult<C...>::operator std::tuple<Ts...>() const
{
typedef toTuple<0, Ts...> ToTuple;
ToTuple tt;
return tt(*this);
}
}
template<typename... Ts>
......
......@@ -409,8 +409,8 @@ class Structure
std::tuple<std::string,int,std::string,std::string> MapLabelToPDB(
const std::string& asymId, int seqId, const std::string& compId) const;
std::tuple<std::string,int,std::string,std::string> MapPDBToLabel(
const std::string& asymId, int seqId, const std::string& compId, const std::string& iCode);
std::tuple<std::string,int,std::string> MapPDBToLabel(
const std::string& asymId, int seqId, const std::string& compId, const std::string& iCode) const;
// Actions
void removeAtom(Atom& a);
......
......@@ -1520,6 +1520,62 @@ tuple<string,int,string,string> Structure::MapLabelToPDB(
return result;
}
tuple<string,int,string> Structure::MapPDBToLabel(const string& asymId, int seqId,
const string& compId, const string& iCode) const
{
auto& db = datablock();
tuple<string,int,string> result;
if (iCode.empty())
{
for (auto r: db["pdbx_poly_seq_scheme"].find(
cif::Key("pdb_strand_id") == asymId and
cif::Key("pdb_seq_num") == seqId and
cif::Key("pdb_mon_id") == compId and
cif::Key("pdb_ins_code") == cif::Empty()))
{
result = r.get("asym_id", "seq_id", "mon_id");
break;
}
for (auto r: db["pdbx_nonpoly_scheme"].find(
cif::Key("pdb_strand_id") == asymId and
cif::Key("pdb_seq_num") == seqId and
cif::Key("pdb_mon_id") == compId and
cif::Key("pdb_ins_code") == cif::Empty()))
{
result = r.get("asym_id", "ndb_seq_num", "mon_id");
break;
}
}
else
{
for (auto r: db["pdbx_poly_seq_scheme"].find(
cif::Key("pdb_strand_id") == asymId and
cif::Key("pdb_seq_num") == seqId and
cif::Key("pdb_mon_id") == compId and
cif::Key("pdb_ins_code") == iCode))
{
result = r.get("asym_id", "seq_id", "mon_id");
break;
}
for (auto r: db["pdbx_nonpoly_scheme"].find(
cif::Key("pdb_strand_id") == asymId and
cif::Key("pdb_seq_num") == seqId and
cif::Key("pdb_mon_id") == compId and
cif::Key("pdb_ins_code") == iCode))
{
result = r.get("asym_id", "ndb_seq_num", "mon_id");
break;
}
}
return result;
}
cif::Datablock& Structure::datablock() const
{
return *mImpl->mFile->impl().mDb;
......
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