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

com.actelion.research.chem.StereoIsomerEnumerator Maven / Gradle / Ivy

There is a newer version: 2024.12.1
Show newest version
/*
 * Copyright 2017 Idorsia Pharmaceuticals Ltd., Hegenheimermattweg 91, CH-4123 Allschwil, Switzerland
 *
 * This file is part of DataWarrior.
 *
 * DataWarrior is free software: you can redistribute it and/or modify it under the terms of the
 * GNU General Public License as published by the Free Software Foundation, either version 3 of
 * the License, or (at your option) any later version.
 *
 * DataWarrior is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License along with DataWarrior.
 * If not, see http://www.gnu.org/licenses/.
 *
 * @author Thomas Sander
 */
package com.actelion.research.chem;

import com.actelion.research.chem.coords.CoordinateInventor;

import java.util.TreeMap;

public class StereoIsomerEnumerator {
	private boolean mSkipEnantiomers;
	private StereoMolecule mMol;
	private int[][] mAtomGroupList,mBondGroupList,mUnknownDoubleBondList;
	private boolean[][] mAtomIsParity1,mBondIsParity1;

	/**
	 * If the passed molecules has stereo-chemically undefined configurations
	 * (double bonds, stereo centers) or/and one or more AND/OR groups of
	 * defined relative stereo configurations, then it represents multiple
	 * stereo isomers. The StereoIsomerEnumerator generates all individual
	 * stereo isomers of the passes molecule. If the passed molecule does
	 * not include absolute stereo centers (or atrop isomeric configuration),
	 * but unknown stereo centers or groups with defined relative configuration,
	 * then we have pairs of enantiomers. In this case the StereoIsomerEnumerator
	 * may either generate one or both stereo isomers of each enantiomeric pair.
	 * @param mol WARNING
	 * @param skipEnantiomers
	 */
	public StereoIsomerEnumerator(StereoMolecule mol, boolean skipEnantiomers) {
		mMol = mol;
		mMol.ensureHelperArrays(Molecule.cHelperParities);
		TreeMap groupMap = new TreeMap();
		mSkipEnantiomers = skipEnantiomers;
		for (int atom=0; atom
	 * This method does not sort out stereo isomers that are impossible because of geometric strain.
	 * @param index parity permutation
	 * @return
	 */
	public StereoMolecule getStereoIsomer(int index) {
		StereoMolecule mol = new StereoMolecule(mMol);

		// if we produce one enantiomer only, we don't permute the first atom group
		// (or bond group if there are no atom groups)
		boolean skipFirst = mSkipEnantiomers;
		for (int i=0; i>= 1;
			}

		for (int i=0; i>= 1;
			}

		for (int i=0; i>= 1;
			}

		mol.setParitiesValid(0);
		mol.setStereoBondsFromParity();

		// if we have unknown double bonds, we need to generate new 2D-coordinates for E and Z configuration
		if (mUnknownDoubleBondList.length != 0) {
			mol.setParitiesValid(0);
			new CoordinateInventor(0).invent(mol);
			}

		return mol;
		}

	/**
	 * Checks, whether the given molecule's atom and bond parities are the expected one's
	 * for the given stereo isomer index. This may be useful when creating conformers
	 * from the stereo isomer returned by getStereoIsomer() to check, whether conformers
	 * still have the correct stereo configurations. If the correct stereo configuration is
	 * an impossible one due to ring strains, then conformer generators or force field may
	 * change the configuration in order to create a conformer at all.
	 * @param mol
	 * @param index
	 * @return true, if the given molecule's atom and bond parities are correct the given index
	 */
	public boolean isCorrectStereoIsomer(StereoMolecule mol, int index) {
		mol. ensureHelperArrays(Molecule.cHelperParities);

		// if we produce one enantiomer only, we don't permute the first atom group
		// (or bond group if there are no atom groups)
		boolean skipFirst = mSkipEnantiomers;
		for (int i=0; i>= 1;
			}

		for (int i=0; i>= 1;
			}

		for (int i=0; i>= 1;
			}

		return true;
		}
	}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy