com.actelion.research.chem.docking.LigandPose Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of openchemlib Show documentation
Show all versions of openchemlib Show documentation
Open Source Chemistry Library
package com.actelion.research.chem.docking;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import com.actelion.research.calc.Matrix;
import com.actelion.research.chem.Coordinates;
import com.actelion.research.chem.StereoMolecule;
import com.actelion.research.chem.alignment3d.transformation.ExponentialMap;
import com.actelion.research.chem.alignment3d.transformation.Quaternion;
import com.actelion.research.chem.alignment3d.transformation.Rotation;
import com.actelion.research.chem.alignment3d.transformation.RotationDerivatives;
import com.actelion.research.chem.alignment3d.transformation.TransformationSequence;
import com.actelion.research.chem.alignment3d.transformation.Translation;
import com.actelion.research.chem.conf.BondRotationHelper;
import com.actelion.research.chem.conf.Conformer;
import com.actelion.research.chem.conf.TorsionDB;
import com.actelion.research.chem.docking.scoring.AbstractScoringEngine;
import com.actelion.research.chem.optimization.Evaluable;
import com.actelion.research.chem.optimization.MCHelper;
import com.actelion.research.chem.potentialenergy.PositionConstraint;
import com.actelion.research.chem.potentialenergy.PotentialEnergyTerm;
public class LigandPose implements Evaluable{
private static double MOVE_AMPLITUDE = 2.0;
private BondRotationHelper torsionHelper;
//private Coordinates rotationCenter;
private double[] state; //internal coordinates: translation,rotation,dihedral
private Conformer ligConf;
private Coordinates[] origCoords;
private Coordinates[] cachedCoords; //used for gradient calculation: ligand coordinates with adjusted dihedral angles, but before rotation and translation
private double[][] dRdvi1;
private double[][] dRdvi2;
private double[][] dRdvi3;
private StereoMolecule mol;
private AbstractScoringEngine engine;
public static long SEED = 12345L;
private Coordinates origCOM;
private MCHelper mcHelper;
//private int[] mcsRotBondIndeces; //for MCS docking, only bonds not part of the MCS are sampled
public LigandPose(Conformer ligConf, AbstractScoringEngine engine, double e0) {
this.engine = engine;
this.ligConf = ligConf;
init(e0);
}
/**
* for MCS docking:create array of bond indices that are allowed to be permuted
* @param constraints
*/
public void setMCSBondConstraints(List constraints) {
int[] rotBonds = torsionHelper.getRotatableBonds();
List allowedIndices = new ArrayList<>();
for(int rbIndex=0;rbIndex getContributions() {
return engine.getContributions();
}
public void setInitialState() {
int elements = 3+3+torsionHelper.getRotatableBonds().length; //3 translational, 3 rotational, 3 torsion
state = new double[elements];
state[0] = 0.0;
state[1] = 0.0;
state[2] = 0.0;
Quaternion quat = new Quaternion(1.0,0.0,0.0,0.0);
ExponentialMap emap = new ExponentialMap(quat);
state[3] = emap.getP().x;
state[4] = emap.getP().y;
state[5] = emap.getP().z;
for(int b=0;b5) { //torsions
if(state[i]>Math.PI) {
state[i] -= 2*Math.PI;
}
}
this.state[i] = state[i];
}
updateLigandCoordinates();
}
public double[] getState(double[] v){
for(int i=0;i