Commit 77389c20 by Maarten L. Hekkelman

Fix equals in condition_impl, columns might be unknown

parent 7c5f1ba8
...@@ -215,7 +215,8 @@ namespace detail ...@@ -215,7 +215,8 @@ namespace detail
if (m_single_hit.has_value() or ri->m_single_hit.has_value()) if (m_single_hit.has_value() or ri->m_single_hit.has_value())
return m_single_hit == ri->m_single_hit; return m_single_hit == ri->m_single_hit;
else else
return m_item_ix == ri->m_item_ix and m_value == ri->m_value; // watch out, both m_item_ix might be the same while tags might be diffent (in case they both do not exist in the category)
return m_item_ix == ri->m_item_ix and m_value == ri->m_value and m_item_tag == ri->m_item_tag;
} }
return this == rhs; return this == rhs;
} }
...@@ -272,7 +273,8 @@ namespace detail ...@@ -272,7 +273,8 @@ namespace detail
if (m_single_hit.has_value() or ri->m_single_hit.has_value()) if (m_single_hit.has_value() or ri->m_single_hit.has_value())
return m_single_hit == ri->m_single_hit; return m_single_hit == ri->m_single_hit;
else else
return m_item_ix == ri->m_item_ix and m_value == ri->m_value; // watch out, both m_item_ix might be the same while tags might be diffent (in case they both do not exist in the category)
return m_item_ix == ri->m_item_ix and m_value == ri->m_value and m_item_tag == ri->m_item_tag;
} }
return this == rhs; return this == rhs;
} }
......
...@@ -408,6 +408,8 @@ class residue ...@@ -408,6 +408,8 @@ class residue
{ {
} }
residue(const structure &structure, const std::vector<atom> &atoms);
residue(const residue &rhs) = delete; residue(const residue &rhs) = delete;
residue &operator=(const residue &rhs) = delete; residue &operator=(const residue &rhs) = delete;
...@@ -763,6 +765,9 @@ class structure ...@@ -763,6 +765,9 @@ class structure
/// \brief Return the atom closest to point \a p with atom type \a type in a residue of type \a res_type /// \brief Return the atom closest to point \a p with atom type \a type in a residue of type \a res_type
atom get_atom_by_position_and_type(point p, std::string_view type, std::string_view res_type) const; atom get_atom_by_position_and_type(point p, std::string_view type, std::string_view res_type) const;
/// \brief Create a non-poly residue based on atoms already present in this structure.
residue &create_residue(const std::vector<atom> &atoms);
/// \brief Get a non-poly residue for an asym with id \a asymID /// \brief Get a non-poly residue for an asym with id \a asymID
residue &get_residue(const std::string &asymID) residue &get_residue(const std::string &asymID)
{ {
...@@ -898,7 +903,7 @@ class structure ...@@ -898,7 +903,7 @@ class structure
void load_atoms_for_model(StructureOpenOptions options); void load_atoms_for_model(StructureOpenOptions options);
template <typename... Args> template <typename... Args>
atom &emplace_atom(Args... args) atom &emplace_atom(Args&... args)
{ {
return emplace_atom(atom{ std::forward<Args>(args)... }); return emplace_atom(atom{ std::forward<Args>(args)... });
} }
......
...@@ -63,7 +63,7 @@ namespace detail ...@@ -63,7 +63,7 @@ namespace detail
condition_impl *key_equals_condition_impl::prepare(const category &c) condition_impl *key_equals_condition_impl::prepare(const category &c)
{ {
m_item_ix = get_column_ix(c, m_item_tag); m_item_ix = c.get_column_ix(m_item_tag);
m_icase = is_column_type_uchar(c, m_item_tag); m_icase = is_column_type_uchar(c, m_item_tag);
if (c.get_cat_validator() != nullptr and if (c.get_cat_validator() != nullptr and
......
...@@ -305,6 +305,25 @@ std::ostream &operator<<(std::ostream &os, const atom &atom) ...@@ -305,6 +305,25 @@ std::ostream &operator<<(std::ostream &os, const atom &atom)
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// residue // residue
residue::residue(const structure &structure, const std::vector<atom> &atoms)
: m_structure(&structure)
{
if (atoms.empty())
throw std::runtime_error("Empty list of atoms");
auto &a = atoms.front();
m_compound_id = a.get_label_comp_id();
m_asym_id = a.get_label_asym_id();
m_seq_id = a.get_label_seq_id();
m_auth_asym_id = a.get_auth_asym_id();
m_auth_seq_id = a.get_auth_seq_id();
m_pdb_ins_code = a.get_pdb_ins_code();
for (auto atom : atoms)
m_atoms.push_back(atom);
}
// residue::residue(residue &&rhs) // residue::residue(residue &&rhs)
// : m_structure(rhs.m_structure) // : m_structure(rhs.m_structure)
// , m_compound_id(std::move(rhs.m_compound_id)) // , m_compound_id(std::move(rhs.m_compound_id))
...@@ -1514,6 +1533,11 @@ polymer &structure::get_polymer_by_asym_id(const std::string &asym_id) ...@@ -1514,6 +1533,11 @@ polymer &structure::get_polymer_by_asym_id(const std::string &asym_id)
throw std::runtime_error("polymer with asym id " + asym_id + " not found"); throw std::runtime_error("polymer with asym id " + asym_id + " not found");
} }
residue &structure::create_residue(const std::vector<atom> &atoms)
{
return m_non_polymers.emplace_back(*this, atoms);
}
residue &structure::get_residue(const std::string &asym_id, int seqID, const std::string &authSeqID) residue &structure::get_residue(const std::string &asym_id, int seqID, const std::string &authSeqID)
{ {
if (seqID == 0) if (seqID == 0)
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
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