Commits

Andrew Dalke  committed d638d91

Correctly handle min_num_atoms rejection. Previous it wasn't working
if the number of atoms in the enumerated fragment was larger than the
min size. This could return a small match. If that happens, reject it.

  • Participants
  • Parent commits 0bbf300

Comments (0)

Files changed (2)

         matches_all_targets.shift_targets()
         
     end_verbose()
-    
-    return hits.get_result(success)
+
+    result = hits.get_result(success)
+    if result.num_atoms < min_num_atoms:
+        return MCSResult(-1, -1, None, result.completed)
+    return result
         
 ########## Main driver for the MCS code
 

File tests/test_commandline.py

     def test_min_atoms_1(self):
         stdout, stderr = run("simple.smi --min-num-atoms 1", expect_sysexit=True)
         self.assertTrue("--min-num-atoms: must be at least 2, not 1" in stderr, stderr)
+    def test_when_the_enumerated_fragment_is_larger_than_min_num_atoms(self):
+        confirm("rings.smi --min-num-atoms 6", None, None)
+        confirm("rings.smi --min-num-atoms 5", 5, 4)
 
 class TextMaximize(unittest.TestCase):
     # C12CCC1CC2OCCCCCCC 2-rings-and-chain-with-O
 
     def test_that_size_rejection_does_not_affect_the_threshold_calculation(self):
         confirm("threshold.smi --min-num-atoms 7 --threshold 0.5", None, None)
-        confirm("threshold.smi --min-num-atoms 7 --threshold 0.3", 3, 2, "spam")
-        
+        confirm("threshold.smi --min-num-atoms 7 --threshold 0.3", None, None)
     
     def test_threshold_too_small(self):
         stdout, stderr = run("threshold.smi --compare topology --threshold -2.0", expect_sysexit=True)