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.11.2
Show newest version
/*
 * Copyright (c) 1997 - 2016
 * Actelion Pharmaceuticals Ltd.
 * Gewerbestrasse 16
 * CH-4123 Allschwil, Switzerland
 *
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice, this
 *    list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 *    this list of conditions and the following disclaimer in the documentation
 *    and/or other materials provided with the distribution.
 * 3. Neither the name of the the copyright holder nor the
 *    names of its contributors may be used to endorse or promote products
 *    derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * @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 molecule 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 passed 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 - 2024 Weber Informatics LLC | Privacy Policy