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 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 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
© 2015 - 2025 Weber Informatics LLC | Privacy Policy