com.actelion.research.chem.ScaffoldHelper 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
/*
* 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 java.util.Arrays;
public class ScaffoldHelper {
/**
* Modifies mol in-place to represent the Murcko scaffold from the original mol.
* If skeletonOnly is true, then all bond types are reduced to non-stereo-single bonds
* and all atoms are converted to carbon atoms.
* @param mol may be an empty molecule if there are no ring systems
* @param skeletonOnly reduce to simple skeleton
*/
public static void createMurckoScaffold(StereoMolecule mol, boolean skeletonOnly) {
boolean[] isScaffoldMember = findMurckoScaffold(mol);
if (isScaffoldMember == null) {
mol.deleteMolecule();
return;
}
for (int atom=0; atom 2) {
for (int i=0; i 1) {
isMember[connAtom] = true;
found |= (connAtom < atom);
}
}
}
}
} while (found);
return isMember;
}
private static void addShortestPathToMember(StereoMolecule mol, int atom1, int atom2, boolean[] isMember) {
int[] parentAtom = new int[mol.getAtoms()]; // serves as indication of being a path member and allows backtracking the path
int[] graphAtom = new int[mol.getAtoms()];
Arrays.fill(parentAtom, -1);
graphAtom[0] = atom2;
parentAtom[atom1] = -2; // != -1 to mark it being a part of the graph
parentAtom[atom2] = atom1;
int current = 0;
int highest = 0;
while (current <= highest) {
for (int i=0; i (double)fragmentDistanceSum[i]/fragmentAtomCount[i]) {
minSum = (double)fragmentDistanceSum[i]/fragmentAtomCount[i];
minFragment = i;
}
}
boolean[] isFragmentMember = new boolean[mol.getAtoms()];
for (int atom=0; atom