com.actelion.research.chem.chemicalspaces.synthon.SynthonCreator 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.chemicalspaces.synthon;
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;
import java.io.BufferedWriter;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.nio.charset.StandardCharsets;
import java.util.*;
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)
ringReactant.add(mappedAtomToReactant.get(mappedA));
}
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();
}
}
}
*/
}