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

com.actelion.research.chem.sar.SARMolecule Maven / Gradle / Ivy

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

import com.actelion.research.chem.Canonizer;
import com.actelion.research.chem.IDCodeParser;
import com.actelion.research.chem.Molecule;
import com.actelion.research.chem.StereoMolecule;

import java.util.ArrayList;

public class SARMolecule {
	private StereoMolecule mMol,mBuffer;
	private SARScaffold mScaffold;
	private String[] mSubstituent;
	private int[] mSubstituentBondOrder;
	private boolean[] mSubstituentConnectsBack;

	protected SARMolecule(StereoMolecule mol, SARScaffold scaffold, int[] molToCoreAtom, StereoMolecule buffer) {
		mMol = mol;
		mScaffold = scaffold;
		mBuffer = buffer;

		buildSubstituents(molToCoreAtom);
	}

	public SARScaffold getScaffold() {
		return mScaffold;
	}

	public String[] getSubstituents() {
		return mSubstituent;
	}

	protected void clear() {
		mScaffold = null;
	}

	protected void checkSubstituents() {
		for (int exitVectorIndex = 0; exitVectorIndex backConnectionList = new ArrayList<>();

		isSubstituentAtom[rootAtom] = true;
		isSubstituentAtom[exitAtom] = true;
		isSubstituentBond[rootBond] = true;
		workAtom[0] = rootAtom;
		workAtom[1] = exitAtom;
		int current = 1;
		int highest = 1;
		while (current <= highest) {
			for (int i=0; i=0; bond--)
			if (mBuffer.getAtomicNo(mBuffer.getBondAtom(0, bond)) == 0
			 && mBuffer.getAtomicNo(mBuffer.getBondAtom(1, bond)) == 0)
				mBuffer.deleteBond(bond);

		mSubstituent[exitVectorIndex] = new Canonizer(mBuffer, Canonizer.ENCODE_ATOM_CUSTOM_LABELS).getIDCode();
		mSubstituentBondOrder[exitVectorIndex] = mMol.getBondOrder(rootBond);
	}

	/**
	 * In case of substituent atom connecting back to the core structure, the exit vector index is encoded as label
	 * in the substituent idcode.
	 * This is needed within the check for varying substituents, because of the label chains with inverted direction
	 * are recognized as different substituents. Also, otherwise equal chains that connect back to different exit
	 * vectors are also recognized as being different.
	 * After the check for varying substituents and once we have a mapping from exit vector index to R-group index,
	 * we need to exchange the label by a new one with the R-Group index, which should be finally displayed to the user.
	 */
	protected void correctSubstituentRingClosureLabels() {
		if (mSubstituentConnectsBack != null) {
			for (int exitVectorIndex = 0; exitVectorIndex




© 2015 - 2024 Weber Informatics LLC | Privacy Policy