com.actelion.research.chem.shredder.MoleculeShredder 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
/*
* @(#)MoleculeShredder.java
*
* Copyright 1997-2001 Actelion Ltd., Inc. All Rights Reserved.
*
* This software is the proprietary information of Actelion Pharmaceuticals, Ltd.
* Use is subject to license terms.
*
* @author Thomas Sander
*/
package com.actelion.research.chem.shredder;
import com.actelion.research.chem.Molecule;
import com.actelion.research.chem.StereoMolecule;
import java.util.*;
public class MoleculeShredder {
public static final int cModeSetAtomQFNoMoreNeighbours = 1;
public static final int cModeExcludeCoreFragments = 64;
// mode may contain one or none of those:
public static final int cModeRetainSubstituentTypes = 2;
public static final int cModeDiscardSubstitutionInfo = 128;
// mode may contain one or none of these:
public static final int cModeCoreFragmentsOnly = 4;
public static final int cModeOneSpereAroundCoreOnly = 32;
// mode may contain one or none of the 'Cut' options:
public static final int cModeCutTerminalBondsAlso = 8;
public static final int cModeCutSpacersOffRings = 16;
public static final int cColorFragmentsInMolecule = 256;
private final int cMaxCoreFragments = 8;
private StereoMolecule mMol;
private boolean[] mIsCuttableBond;
private boolean[][] mAreNeighbours;
private int mMode;
private int mCuttableBonds;
private int mCoreFragments;
private int[] mCoreFragmentNo;
private ArrayList mFragmentList;
public MoleculeShredder(StereoMolecule mol, int mode) {
mMol = mol;
mMol.ensureHelperArrays(Molecule.cHelperRings);
mMode = mode;
locateCuttableBonds();
locateCoreFragments();
if ((mode & cModeCoreFragmentsOnly) == 0)
createCoreNeighbourMatrix();
createFragmentList();
}
public int getFragments() {
return mFragmentList.size();
}
public int getCoreFragments() {
return mCoreFragments;
}
public StereoMolecule getFragment(StereoMolecule theFragment, int fragmentNo) {
boolean[] isMember = new boolean[mMol.getAtoms()];
long fragmentBits = mFragmentList.get(fragmentNo).longValue();
for (int coreFragment=0; coreFragment 1
&& mMol.getConnAtoms(mMol.getBondAtom(1, bond)) > 1))) {
mIsCuttableBond[bond] = true;
mCuttableBonds++;
}
}
}
}
private void locateCoreFragments() {
mCoreFragmentNo = new int[mMol.getAtoms()];
for (int atom=0; atom();
if (mCoreFragments == 1) // if the only fragment is the entire molecule then return no fragments
return;
if (mCoreFragments > 64) // fragment combinations cannot be coded in long -> don't shredder
return;
if ((mMode & cModeCoreFragmentsOnly) == 0
&& mCoreFragments > cMaxCoreFragments) // do not create fragments of to flexible molecules
return;
for (int fragment=0; fragment centralCoreList = new ArrayList();
for (int fragment=0; fragment