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

com.actelion.research.chem.chemicalspaces.synthon.SynthonReactor Maven / Gradle / Ivy

There is a newer version: 2024.11.2
Show newest version
package com.actelion.research.chem.chemicalspaces.synthon;

import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import com.actelion.research.chem.Coordinates;
import com.actelion.research.chem.Molecule;
import com.actelion.research.chem.MoleculeStandardizer;
import com.actelion.research.chem.SmilesCreator;
import com.actelion.research.chem.StereoMolecule;
import com.actelion.research.chem.coords.CoordinateInventor;

public class SynthonReactor {
	
	public static final int CONNECTOR_OFFSET = 92;
	
	public static StereoMolecule react(List synthons) {		
		List buildingBlocks = new ArrayList();
		synthons.stream().forEach(e -> buildingBlocks.add(new StereoMolecule(e)));
		buildingBlocks.forEach(e -> e.ensureHelperArrays(Molecule.cHelperCIP));
		Set rgrps = new HashSet();
		for(int m=0;m=CONNECTOR_OFFSET) {
					rgrps.add(atomNo-CONNECTOR_OFFSET+1);

				}

				
			}
		}
		StereoMolecule prod = null;
		for(int i : rgrps) {
			for(int j=0;j-1) {
						SynthonConnector sc1 = new SynthonConnector();
						sc1.connAtom = connAtom1;
						sc1.bb = bb1;
						sc1.neighbourAtom = bb1.getConnAtom(connAtom1, 0);
						int b1 = bb1.getBond(connAtom1, sc1.neighbourAtom);
						sc1.bondType = bb1.getBondType(b1);
						sc1.bond = b1;
						sc1.bondOrder = bb1.getBondOrder(b1);
						for(int k=0;k findConnectorAtoms(int rGrp, StereoMolecule bb) {
		List atoms = new ArrayList<>();
		for(int a=0;a=CONNECTOR_OFFSET) {
				if(atomNo-CONNECTOR_OFFSET+1==rGrp) {
					atoms.add(a);
				}
			}
		}
		return atoms;
	}
	
	/**
	 * align synthons in 2D so that they are in the correct orientation for the formation of the new bond
	 * consider the bonds A1---U1 in Synthon1 and A2---U2 in Synthon2, the two bond vectors should be aligned antiparallel
	 * and A2 should be translated to U1, this is important for the correct assignment of the stereochemistry, which should be
	 * preserved for the synthon reaction
	 * @param s1
	 * @param s2
	 * @param u1
	 * @param u2
	 * @param a1
	 * @param a2
	 */
	public static void alignSynthons(StereoMolecule s1, StereoMolecule s2,int u1, int u2, int a1, int a2) {
		Coordinates v1 = s1.getCoordinates(u1).subC(s1.getCoordinates(a1));
		Coordinates v2 = s2.getCoordinates(a2).subC(s2.getCoordinates(u2));
		v1.unit();
		v2.unit();

		double alpha = Math.acos(v1.dot(v2));

		Coordinates n;
		Coordinates cross = v1.cross(v2);
		if(cross.dist()<0.001) {
			n = new Coordinates(0.0,0.0,1.0);
			alpha = Math.PI;
		}
		else {
			n = cross.unit();
		}
			

		//Rodrigues' rotation formula 

		Coordinates t = s1.getCoordinates(a1).scaleC(-1.0);
		for(int a=0;a




© 2015 - 2024 Weber Informatics LLC | Privacy Policy