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

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

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

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
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.Molecule;
import com.actelion.research.chem.RingCollection;
import com.actelion.research.chem.StereoMolecule;
import com.actelion.research.chem.coords.CoordinateInventor;
import com.actelion.research.chem.io.RXNFileCreator;
import com.actelion.research.chem.reaction.Reaction;

public class SynthonCreator {
	
	
	/**
	 * only works for reactions with a single product
	 * @param rxn
	 * @return
	 * @throws Exception
	 */
	public static Reaction[] create(Reaction rxn) throws Exception {
		if(rxn.getProducts()>1)
			throw new Exception("only reactions with one product are supported");
		Reaction[] synthonTransformations = new Reaction[rxn.getReactants()];
		Map mappedAtomToReactant = new HashMap(); //stores the information on which mapped atom in the product ist contributed by which reactant
		for(int r=0;r homogeneousRingBonds = new ArrayList<>();
		for(int ringNo=0;ringNo ringReactant = new HashSet();
			int[] atoms = rc.getRingAtoms(ringNo);
			for(int a : atoms) {
				int mappedA = product.getAtomMapNo(a);
				if(mappedA==0)
					continue;
				int reactant = mappedAtomToReactant.get(mappedA);
				ringReactant.add(reactant);
			}
			if(ringReactant.size()==1) {//homogeneous ring!
				int[] ringBonds = rc.getRingBonds(ringNo);
				Arrays.stream(ringBonds).forEach(e -> homogeneousRingBonds.add(e));
			}
			
		}
		List bondsToCut = new ArrayList<>();
		for(int b=0;b stem from a reagent
			//we want to assign these atoms to one of the synthons, so such a cut is forbidden
			StereoMolecule tmpMol = new StereoMolecule(decomposedProduct);
			tmpMol.ensureHelperArrays(Molecule.cHelperNeighbours);
			tmpMol.setBondType(cutBond, Molecule.cBondTypeDeleted);
			tmpMol.deleteMarkedAtomsAndBonds();
			StereoMolecule[] tmpFrags = tmpMol.getFragments();
			boolean acceptCut = true;
			for(StereoMolecule tmpFrag : tmpFrags) {
				tmpFrag.ensureHelperArrays(Molecule.cHelperNeighbours);
				int mapSum = 0;
				for(int a=0;a htmcReactions = ReactionList.INSTANCE.getReactionsHTMC();
		for(Reaction reaction : htmcReactions) {
			System.out.println(reaction.getName());
			try {
				create(reaction, false);
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
	*/
	
	


}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy