@@ -388,6 +388,66 @@ public DockingResult dockMolecule(StereoMolecule mol) throws DockingFailedExcept
388388 }
389389 }
390390
391+ public DockingResult [] dockMolecule (StereoMolecule mol , int maxPoseCount ) throws DockingFailedException {
392+ // mGlobalConformerEnergyMin = Double.MAX_VALUE; // this was the old handling
393+ mGlobalConformerEnergyMin = calculateMinConformerEnergy (mol );
394+
395+ Conformer bestPose = null ;
396+ double bestEnergy = Double .MAX_VALUE ;
397+ if (ForceFieldMMFF94 .table (ForceFieldMMFF94 .MMFF94SPLUS )==null )
398+ ForceFieldMMFF94 .initialize (ForceFieldMMFF94 .MMFF94SPLUS );
399+ List <Conformer > startPoints = new ArrayList <>();
400+ int steps = mcSteps ;
401+ if (mcsRef !=null ) {
402+ mGlobalConformerEnergyMin = getStartingPositionsMCS (mol , startPoints , mGlobalConformerEnergyMin );
403+ steps =steps /MCS_EXHAUSTIVENESS ;
404+ }
405+ else {
406+ mGlobalConformerEnergyMin = getStartingPositions (mol , startPoints , mGlobalConformerEnergyMin );
407+ }
408+
409+ ArrayList <PreliminaryResult > resultList = new ArrayList <>();
410+
411+ for (Conformer ligConf : startPoints ) {
412+ Conformer newLigConf = new Conformer (ligConf );
413+ LigandPose pose = new LigandPose (newLigConf , engine , mGlobalConformerEnergyMin );
414+ if (mcsRef !=null ) {
415+ pose .setMCSBondConstraints (mcsConstrainedBonds );
416+ for (int a : mcsConstrainedAtoms ) {
417+ PositionConstraint constr = new PositionConstraint (newLigConf ,a ,50 ,1.0 );
418+ pose .addConstraint (constr );
419+ }
420+ }
421+ double energy = mcSearch (pose ,steps );
422+ int index = 0 ;
423+ for (; index <resultList .size (); index ++)
424+ if (energy < resultList .get (index ).energy )
425+ break ;
426+ if (index < maxPoseCount )
427+ resultList .add (index , new PreliminaryResult (pose .getLigConf (), energy , pose .getContributions ()));
428+ if (resultList .size () > maxPoseCount )
429+ resultList .remove (maxPoseCount );
430+ if (threadMaster !=null && threadMaster .threadMustDie ())
431+ break ;
432+ }
433+
434+ if (resultList .isEmpty ())
435+ throw new DockingFailedException ("docking failed" );
436+
437+ DockingResult [] result = new DockingResult [resultList .size ()];
438+ Rotation rot = rotation .getInvert ();
439+ Translation translate = new Translation (new double [] {origCOM .x , origCOM .y , origCOM .z });
440+ for (int i =0 ; i <resultList .size (); i ++) {
441+ PreliminaryResult pr = resultList .get (i );
442+ StereoMolecule best = pr .conformer .toMolecule (pr .conformer .getMolecule ().getCompactCopy ());
443+ rot .apply (best );
444+ translate .apply (best );
445+ result [i ] = new DockingResult (mol , best , pr .energy , pr .contributions );
446+ }
447+
448+ return result ;
449+ }
450+
391451 /**
392452 * use monte carlo steps to permute molecular rotation, translation, torsion angles
393453 * promising poses (below a certain cutoff) are optimized
@@ -558,7 +618,7 @@ private static double getCoreRMSD(Coordinates[] coords1, Coordinates[] coords2)
558618 rmsd = Math .sqrt (rmsd );
559619 return rmsd ;
560620 }
561-
621+
562622 public static class DockingResult implements Comparable <DockingResult > {
563623 private final double score ;
564624 private final StereoMolecule pose ;
@@ -663,3 +723,15 @@ public int compareTo(DockingResult o) {
663723 }
664724 }
665725}
726+
727+ class PreliminaryResult {
728+ public Conformer conformer ;
729+ public double energy ;
730+ public Map <String ,Double > contributions ;
731+
732+ public PreliminaryResult (Conformer conformer , double energy , Map <String ,Double > contributions ) {
733+ this .conformer = conformer ;
734+ this .energy = energy ;
735+ this .contributions = contributions ;
736+ }
737+ }
0 commit comments