Hi all,

What was your tweak? This seems like an important patch for others.

basically every conformer was reported to contain a steric clash or no starting
conformer could be found at all (giving messed-up output which the below patch
also corrects). That why I wanted to make the steric filter less tight and I
also wanted the parameters to be user-definable from the command-line.

I also changed the default values to the ones below (and the patch also corrects
the wrong keyword I mentioned in the other email), see patch [3]. The default
values turned out a lttle bit too tight for things like a short P3HT[2] molecule
with all the side chains and 4 repeat units already. The below ones work up to
16 repeat units without visible clashes. The problem is probably the genetic
algorithm not considering intermediate values for rotational angles (i.e.
slightly off from 120°) which would be found in quantum chemical calculations or
force-field based simulations. I always use calculations like these to further
optimize the initial conformers obtained from openbabel.

Please note that I also made other changes to the source so that the line
numbers might not agree with yours. I took commit [1] as basis and all changes
will be made available once my project is finished.

Cheers,
Torsten

[1]: 79000d56e85bd94b1eaebbeb79019e4f26b530fe
[2]: Poly(3-hexylthiophene-2,5-diyl), compare
     http://www.sigmaaldrich.com/catalog/product/aldrich/698997
[3]: Content of patch:
From: Torsten Sachse <torsten.sac...@uni-jena.de>
Date: Tue, 4 Aug 2015 13:07:38 +0200
Subject: [PATCH] steric filter can now be altered from the command line. a
 conformer search is automatically interrupted if the
 starting population is empty.

---
 src/conformersearch.cpp |  4 ++++
 src/ops/conformer.cpp   | 52 ++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 55 insertions(+), 1 deletion(-)

diff --git a/src/conformersearch.cpp b/src/conformersearch.cpp
index c1f71a4..8f31f34 100644
--- a/src/conformersearch.cpp
+++ b/src/conformersearch.cpp
@@ -577,6 +577,10 @@ namespace OpenBabel {
          // make the selection
          score = MakeSelection();
        }
+      if (std::isnan(score)){
+          (*m_logstream) << "The current score is not a number, will not continue."  
<< endl  << endl;
+          return;
+      }
       if (i == 0)
        last_score = score;

diff --git a/src/ops/conformer.cpp b/src/ops/conformer.cpp
index c973f92..f77a700 100644
--- a/src/ops/conformer.cpp
+++ b/src/ops/conformer.cpp
@@ -63,8 +63,13 @@ namespace OpenBabel
           " genetic algorithm based methods (default):\n"
           " --children #     number of children to generate for each parent 
(default = 5)\n"
           " --mutability #   mutation frequency (default = 5)\n"
-          " --converge #     number of identical generations before convergence is 
reached\n"
+          " --convergence #  number of identical generations before convergence is 
reached\n"
           " --score #        scoring function [rmsd|energy|minrmsd|minenergy] 
(default = rmsd)\n"
+          " customize the filter used to sort out wrong conformers\n"
+          " --filter #       the filtering algorithm [steric] 
(default=steric)\n"
+          " --cutoff #       absolute distance in Anstroms below which atoms are 
considered to clash\n"
+          " --vdw-factor #   apply this factor to all van-der-Waals radii before 
detecting clashes\n"
+          " --ignore-H       do not detect clashes with hydrogen atoms\n"
           ;
       }

@@ -85,6 +90,20 @@ namespace OpenBabel
     return ret;
   }

+  bool getDouble(const std::string &str, double &value)
+  {
+    std::istringstream iss(str);
+    bool ret = iss >> value;
+    return ret;
+  }
+
+  bool getBool(const std::string &str, bool &value)
+  {
+    std::istringstream iss(str);
+    bool ret = iss >> value;
+    return ret;
+  }
+
   //////////////////////////////////////////////////////////
   bool OpConformer::Do(OBBase* pOb, const char* OptionText, OpMap* pmap, 
OBConversion*)
   {
@@ -161,10 +180,16 @@ namespace OpenBabel
       pFF->GetConformers(*pmol);

     } else { // GA-based searching
+      //default values for score
       int numChildren = 5;
       int mutability = 5;
       int convergence = 25;
       std::string score = "rmsd";
+      //default values for filter
+      double cutoff = 0.75 ;
+      double vdw_factor = 0.45 ;
+      bool check_hydrogens = true ;
+      std::string filter = "steric";

       iter = pmap->find("children");
       if(iter!=pmap->end())
@@ -190,6 +215,31 @@ namespace OpenBabel
       else if (score == "minrmsd")
         cs.SetScore(new OBMinimizingRMSDConformerScore);

+      iter = pmap->find("filter");
+      if(iter!=pmap->end())
+        filter = iter->second;
+
+      iter = pmap->find("vdw-factor");
+      if(iter!=pmap->end())
+        getDouble(iter->second, vdw_factor);
+
+      iter = pmap->find("cutoff");
+      if(iter!=pmap->end())
+        getDouble(iter->second, cutoff);
+ + iter = pmap->find("ignore-H");
+      if(iter!=pmap->end())
+        check_hydrogens = false;
+
+      if (filter == "steric")
+        cs.SetFilter(new OBStericConformerFilter(cutoff, vdw_factor, 
check_hydrogens));
+
+      //std::cerr << "Values for filter:";
+      //std::cerr << " cutoff: " << cutoff;
+      //std::cerr << " vdw_factor: " << vdw_factor;
+      //std::cerr << " check_hydrogens: " << check_hydrogens;
+      //std::cerr << "\n\n" << std::flush;
+
       if (cs.Setup(*pmol, numConformers, numChildren, mutability, 
convergence)) {
         cs.Search();
         cs.GetConformers(*pmol);
--
1.7.12.4
------------------------------------------------------------------------------
Monitor Your Dynamic Infrastructure at Any Scale With Datadog!
Get real-time metrics from all of your servers, apps and tools
in one place.
SourceForge users - Click here to start your Free Trial of Datadog now!
http://pubads.g.doubleclick.net/gampad/clk?id=241902991&iu=/4140
_______________________________________________
OpenBabel-discuss mailing list
OpenBabel-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

Reply via email to