From 7030b108e78e1c986937a8cc03dc812a861a7ed8 Mon Sep 17 00:00:00 2001 From: Valerio Mariani <valerio.mariani@unibas.ch> Date: Wed, 28 Nov 2012 15:25:10 +0100 Subject: [PATCH] Refactored iinterface and export of ClashingDistance class --- modules/mol/alg/doc/molalg.rst | 11 ++++++++++- modules/mol/alg/pymod/__init__.py | 4 ++-- modules/mol/alg/pymod/wrap_mol_alg.cc | 7 ++++++- modules/mol/alg/src/filter_clashes.cc | 6 ++++++ modules/mol/alg/src/filter_clashes.hh | 3 +++ 5 files changed, 27 insertions(+), 4 deletions(-) diff --git a/modules/mol/alg/doc/molalg.rst b/modules/mol/alg/doc/molalg.rst index 66b142940..5a3e5e7c9 100644 --- a/modules/mol/alg/doc/molalg.rst +++ b/modules/mol/alg/doc/molalg.rst @@ -276,7 +276,7 @@ The following function detects steric clashes in atomic structures. Two atoms ar :param clash_distance: minimum clashing distance (in Angstroms) :param tolerance: tolerance threshold (in Angstroms) - .. method GetClashingDistance() + .. method:: GetClashingDistance() Recovers a reference distance and a tolerance threshold from the list @@ -285,6 +285,15 @@ The following function detects steric clashes in atomic structures. Two atoms ar :returns: a tuple containing the minimum clashing distance and the tolerance threshold + .. method:: GetAdjustedClashingDistance() + + Recovers a reference distance from the list, already adjusted by the tolerance threshold + + :param ele1: string containing the first element's name + :param ele2: string containing the second element's name + + :returns: the adjusted minimum clashing distance + .. method:: GetMaxAdjustedDistance() Returns the longest clashing distance in the list, after adjustment with tolerance threshold diff --git a/modules/mol/alg/pymod/__init__.py b/modules/mol/alg/pymod/__init__.py index 126d0196f..36d93a720 100644 --- a/modules/mol/alg/pymod/__init__.py +++ b/modules/mol/alg/pymod/__init__.py @@ -6,11 +6,11 @@ import ost.mol.alg.structure_analysis import ost.mol.alg.helix_kinks # Fills a list of reference clashing distances from a file (requires a path to the file) -def FillClashingDistancesFromFile(filename,default_clashing_distance,default_tolerance): +def FillClashingDistancesFromFile(filename): fh=open(filename,'r') lines=fh.readlines() fh.close() - return FillClashingDistances(lines,default_clashing_distance,default_tolerance) + return FillClashingDistances(lines) # Fills a list of bond stereo-chemical statistics from a file (requires a path to the file) def FillBondStereoChemicalParamsFromFile(filename): diff --git a/modules/mol/alg/pymod/wrap_mol_alg.cc b/modules/mol/alg/pymod/wrap_mol_alg.cc index 08ad6631e..bdf141aa5 100644 --- a/modules/mol/alg/pymod/wrap_mol_alg.cc +++ b/modules/mol/alg/pymod/wrap_mol_alg.cc @@ -24,6 +24,7 @@ #include <ost/mol/alg/superpose_frames.hh> #include <ost/mol/alg/filter_clashes.hh> #include <ost/mol/alg/consistency_checks.hh> +#include <ost/export_helper/pair_to_tuple_conv.hh> using namespace boost::python; using namespace ost; @@ -60,7 +61,7 @@ ost::mol::alg::StereoChemicalParams fill_stereochemical_params_wrapper (const St return ost::mol::alg::FillStereoChemicalParams(header,stereo_chemical_props_file_vector); } -ost::mol::alg::ClashingDistances fill_clashing_distances_wrapper (const list& stereo_chemical_props_file, Real min_default_distance, Real min_distance_tolerance) +ost::mol::alg::ClashingDistances fill_clashing_distances_wrapper (const list& stereo_chemical_props_file) { int stereo_chemical_props_file_length = boost::python::extract<int>(stereo_chemical_props_file.attr("__len__")()); std::vector<String> stereo_chemical_props_file_vector(stereo_chemical_props_file_length); @@ -103,6 +104,9 @@ BOOST_PYTHON_MODULE(_ost_mol_alg) export_entity_to_density(); #endif + to_python_converter<std::pair<Real,Real>, + PairToTupleConverter<Real, Real> >(); + def("LocalDistDiffTest", lddt_a, (arg("sequence_separation")=0,arg("local_lddt_property_string")="")); def("LocalDistDiffTest", lddt_c, (arg("local_lddt_property_string")="")); def("LocalDistDiffTest", lddt_b, (arg("ref_index")=0, arg("mdl_index")=1)); @@ -124,6 +128,7 @@ BOOST_PYTHON_MODULE(_ost_mol_alg) class_<mol::alg::ClashingDistances> ("ClashingDistances",init<>()) .def("SetClashingDistance",&mol::alg::ClashingDistances::SetClashingDistance) .def("GetClashingDistance",&mol::alg::ClashingDistances::GetClashingDistance) + .def("GetAdjustedClashingDistance",&mol::alg::ClashingDistances::GetAdjustedClashingDistance) .def("GetMaxAdjustedDistance",&mol::alg::ClashingDistances::GetMaxAdjustedDistance) .def("IsEmpty",&mol::alg::ClashingDistances::IsEmpty) diff --git a/modules/mol/alg/src/filter_clashes.cc b/modules/mol/alg/src/filter_clashes.cc index 235464544..dc450498e 100644 --- a/modules/mol/alg/src/filter_clashes.cc +++ b/modules/mol/alg/src/filter_clashes.cc @@ -108,6 +108,12 @@ std::pair<Real,Real> ClashingDistances::GetClashingDistance(const String& ele1,c return find_ci->second; } +Real ClashingDistances::GetAdjustedClashingDistance(const String& ele1,const String& ele2) const +{ + std::pair <Real,Real> clash_dist = GetClashingDistance(ele1,ele2); + return clash_dist.first-clash_dist.second; +} + void ClashingDistances::PrintAllDistances() const { for (std::map <String,std::pair<float,float> >::const_iterator index = min_distance_.begin();index != min_distance_.end();++index) { diff --git a/modules/mol/alg/src/filter_clashes.hh b/modules/mol/alg/src/filter_clashes.hh index f9d7473b6..e294cd489 100644 --- a/modules/mol/alg/src/filter_clashes.hh +++ b/modules/mol/alg/src/filter_clashes.hh @@ -40,6 +40,9 @@ public: /// \brief Recovers a reference distance and a tolerance threshold (respectively) from the list std::pair<Real,Real> GetClashingDistance(const String& ele1,const String& ele2) const; + /// \brief Recovers a reference distance already adjusted by the tolerance threshold from the list + Real GetAdjustedClashingDistance(const String& ele1,const String& ele2) const; + /// \brief Recovers the longest distance in the list, corrected by tolerance Real GetMaxAdjustedDistance() const; -- GitLab