All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.actelion.research.chem.docking.LigandPose Maven / Gradle / Ivy

There is a newer version: 2024.12.1
Show newest version
package com.actelion.research.chem.docking;

import java.util.HashMap;
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.conf.BondRotationHelper;
import com.actelion.research.chem.conf.Conformer;
import com.actelion.research.chem.docking.scoring.AbstractScoringEngine;
import com.actelion.research.chem.optimization.Evaluable;
import com.actelion.research.chem.phesa.PheSAAlignment;
import com.actelion.research.chem.phesa.Quaternion;
import com.actelion.research.chem.potentialenergy.PositionConstraint;


public class LigandPose implements Evaluable{
	
	private static double MOVE_AMPLITUDE = 2.0;
	private BondRotationHelper torsionHelper;
	//private double[] torsionValues;
	//private Quaternion rotation; //quaternion
	//private double[] translation;
	private double[] state; //coordinates
	private Conformer ligConf;
	private StereoMolecule mol;
	private AbstractScoringEngine engine;
	private Map rearAtoms;
	public static long SEED = 12345L;
	
	public LigandPose(Conformer ligConf, AbstractScoringEngine engine, double e0) {
		
		this.engine = engine;
		this.ligConf = ligConf;
		init(e0);
	}
	
	private void init(double e0) {
		mol = ligConf.getMolecule();
		state = new double[3*mol.getAllAtoms()];
		torsionHelper = new BondRotationHelper(mol);
		engine.init(this,e0);
		updateState();
		rearAtoms = new HashMap();
		assessRearAtoms();
		
	}

	//constrain bonds that are not rotatable, constrain bond lengths and angles
	public double getFGValue(double[] gradient) {
		for(int i=0;i0.0001) {
				Coordinates axis = rot.scale(1.0/angle);
				q = new Quaternion(axis,angle);
			}
			Matrix m = q.getRotMatrix();
			Coordinates com = DockingUtils.getCOM(ligConf);
			ligConf.translate(-com.x, -com.y, -com.z);
			PheSAAlignment.rotateMol(ligConf, m);
			ligConf.translate(com.x, com.y, com.z);

			
		}
		else  {
			if(torsionHelper.getRotatableBonds().length==0)
				return;
			double rnd = random.nextDouble();
			rnd*=180.0;
			double rotateBy = random.nextBoolean() ? rnd : -rnd;
			rotateBy = rotateBy*Math.PI/180.0;
			int bond = random.nextInt(torsionHelper.getRotatableBonds().length);
			bond = torsionHelper.getRotatableBonds()[bond];
			
			torsionHelper.rotateAroundBond(bond, rotateBy,ligConf,random.nextBoolean());

			
		}
		updateState();
		
	}
	
	public void addPositionalConstraints(double d) {
		for(int a=0;a




© 2015 - 2025 Weber Informatics LLC | Privacy Policy