Commit 4436ad43 by maarten

een beetje multithread code en een start met LINK support


git-svn-id: svn+ssh://gitlab/srv/svn-repos/pdb-redo/trunk@334 a1961a4f-ab94-4bcc-80e8-33b5a54de466
parent 5af02960
...@@ -30,6 +30,9 @@ class BondMap ...@@ -30,6 +30,9 @@ class BondMap
return bond_1_4.count(key(ixa, ixb)); return bond_1_4.count(key(ixa, ixb));
} }
// links coming from the struct_conn records:
std::vector<std::string> linked(const Atom& a) const;
private: private:
bool isBonded(uint32 ai, uint32 bi) const bool isBonded(uint32 ai, uint32 bi) const
...@@ -55,6 +58,8 @@ class BondMap ...@@ -55,6 +58,8 @@ class BondMap
uint32 dim; uint32 dim;
std::unordered_map<std::string,uint32> index; std::unordered_map<std::string,uint32> index;
std::set<uint64> bond, bond_1_4; std::set<uint64> bond, bond_1_4;
std::map<std::string,std::set<std::string>> link;
}; };
} }
...@@ -35,6 +35,14 @@ BondMap::BondMap(const Structure& p) ...@@ -35,6 +35,14 @@ BondMap::BondMap(const Structure& p)
bond.insert(key(ixa, ixb)); bond.insert(key(ixa, ixb));
}; };
auto linkAtoms = [this,&bindAtoms](const string& a, const string& b)
{
bindAtoms(a, b);
link[a].insert(b);
link[b].insert(a);
};
cif::Datablock& db = p.getFile().data(); cif::Datablock& db = p.getFile().data();
// collect all compounds first // collect all compounds first
...@@ -111,7 +119,7 @@ BondMap::BondMap(const Structure& p) ...@@ -111,7 +119,7 @@ BondMap::BondMap(const Structure& p)
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>()); linkAtoms(a.front()["id"].as<string>(), b.front()["id"].as<string>());
} }
// then link all atoms in the compounds // then link all atoms in the compounds
...@@ -250,4 +258,17 @@ BondMap::BondMap(const Structure& p) ...@@ -250,4 +258,17 @@ BondMap::BondMap(const Structure& p)
//cout << "Afmeting b1_4: " << bond_1_4.size() << endl; //cout << "Afmeting b1_4: " << bond_1_4.size() << endl;
} }
vector<string> BondMap::linked(const Atom& a) const
{
auto i = link.find(a.id());
vector<string> result;
if (i != link.end())
result = vector<string>(i->second.begin(), i->second.end());
return result;
}
} }
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