use of org.openscience.cdk.AtomContainerSet in project cdk by cdk.
the class MoSSOutputReaderTest method testExampleFile_SupportColumns.
@Test
public void testExampleFile_SupportColumns() throws Exception {
String filename = "TKO.mossoutput";
InputStream ins = this.getClass().getResourceAsStream(filename);
MoSSOutputReader reader = new MoSSOutputReader(ins);
IAtomContainerSet moleculeSet = new AtomContainerSet();
moleculeSet = reader.read(moleculeSet);
Assert.assertEquals(5.06, Double.valueOf(moleculeSet.getAtomContainer(0).getProperty("focusSupport").toString()), 0.01);
Assert.assertEquals(1.74, Double.valueOf(moleculeSet.getAtomContainer(0).getProperty("complementSupport").toString()), 0.01);
}
use of org.openscience.cdk.AtomContainerSet in project cdk by cdk.
the class SMILESReaderTest method testReadingSmiFile_1.
@Test
public void testReadingSmiFile_1() throws Exception {
String filename = "smiles.smi";
logger.info("Testing: " + filename);
InputStream ins = this.getClass().getResourceAsStream(filename);
SMILESReader reader = new SMILESReader(ins);
IAtomContainerSet som = reader.read(new AtomContainerSet());
String name;
IAtomContainer thisMol = som.getAtomContainer(0);
name = ((String) thisMol.getProperty("SMIdbNAME")).toString();
Assert.assertEquals("benzene", name);
}
use of org.openscience.cdk.AtomContainerSet in project ambit-mirror by ideaconsult.
the class SMIRKSManager method applyTransformationWithSingleCopyForEachPos.
public IAtomContainerSet applyTransformationWithSingleCopyForEachPos(IAtomContainer target, IAcceptable selection, SMIRKSReaction reaction, SSM_MODE SSMode) throws Exception {
SmartsParser.prepareTargetForSMARTSSearch(reaction.reactantFlags, target);
if (reaction.reactantFlags.hasRecursiveSmarts)
mapRecursiveAtomsAgainstTarget(reaction.reactantRecursiveAtoms, target);
isoTester.setQuery(reaction.reactant);
List<List<IAtom>> rMaps0;
switch(SSMode) {
case SSM_NON_OVERLAPPING:
rMaps0 = getNonOverlappingMappings(target);
break;
case SSM_NON_IDENTICAL:
rMaps0 = getNonIdenticalMappings(target);
break;
case SSM_ALL:
rMaps0 = getAllMappings(target);
break;
default:
rMaps0 = getNonIdenticalMappings(target);
}
if (rMaps0.size() == 0)
return null;
List<List<IAtom>> rMaps;
// Preliminary filtration by means of IAcceptable
if (selection == null)
rMaps = rMaps0;
else {
rMaps = new ArrayList<List<IAtom>>();
for (int i = 0; i < rMaps0.size(); i++) {
if (selection.accept(rMaps0.get(i)))
rMaps.add(rMaps0.get(i));
}
}
if (rMaps.size() == 0)
return null;
if (FlagFilterEquivalentMappings) {
eqTester.setTarget(target);
eqTester.quickFindEquivalentTerminalHAtoms();
rMaps = eqTester.filterEquivalentMappings(rMaps);
}
IAtomContainerSet resSet = new AtomContainerSet();
for (int i = 0; i < rMaps.size(); i++) {
List<List<IAtom>> vMaps = new ArrayList<List<IAtom>>();
vMaps.add(rMaps.get(i));
IAtomContainer product = applyTransformationsAtLocationsWithCloning(target, vMaps, reaction);
if (FlagProcessResultStructures)
processProduct(product);
if (FlagCheckResultStereo)
StereoChemUtils.checkStereoElements(product);
resSet.addAtomContainer(product);
}
return resSet;
}
use of org.openscience.cdk.AtomContainerSet in project ambit-mirror by ideaconsult.
the class SMIRKSManager method applyTransformationWithCombinedOverlappedPos.
/*
* This transformation is applied in SSM_NON_IDENTICAL mode where the
* overlapping mappings at particular site produce multiple copies of the
* molecule.
*/
public IAtomContainerSet applyTransformationWithCombinedOverlappedPos(IAtomContainer target, IAcceptable selection, SMIRKSReaction reaction) throws Exception {
SmartsParser.prepareTargetForSMARTSSearch(reaction.reactantFlags, target);
if (reaction.reactantFlags.hasRecursiveSmarts)
mapRecursiveAtomsAgainstTarget(reaction.reactantRecursiveAtoms, target);
isoTester.setQuery(reaction.reactant);
List<List<IAtom>> rMaps0 = getNonIdenticalMappings(target);
if (rMaps0.size() == 0)
return null;
List<List<IAtom>> rMaps;
// Preliminary filtration by means of IAcceptable
if (selection == null)
rMaps = rMaps0;
else {
rMaps = new ArrayList<List<IAtom>>();
for (int i = 0; i < rMaps0.size(); i++) {
if (selection.accept(rMaps0.get(i)))
rMaps.add(rMaps0.get(i));
}
}
if (rMaps.size() == 0)
return null;
if (FlagFilterEquivalentMappings) {
eqTester.setTarget(target);
eqTester.quickFindEquivalentTerminalHAtoms();
rMaps = eqTester.filterEquivalentMappings(rMaps);
// System.out.println("FilteredMappings");
// for (int i = 0; i < rMaps2.size(); i++)
// printSSMap(target, rMaps2.get(i));
}
IAtomContainerSet resSet = new AtomContainerSet();
if (rMaps.size() == 1) {
IAtomContainer product = applyTransformationsAtLocationsWithCloning(target, rMaps, reaction);
if (FlagProcessResultStructures)
processProduct(product);
if (FlagCheckResultStereo)
StereoChemUtils.checkStereoElements(product);
resSet.addAtomContainer(product);
return (resSet);
}
// Make mapping clusters/groups
List<List<Integer>> clusterIndexes = isoTester.getOverlappedMappingClusters(rMaps);
// printMappingClusters(clusterIndexes, target);
// Generate all combinations:
// Each combination is represented as a number where each digit is
// represents the choice from each cluster
int[] comb = new int[clusterIndexes.size()];
for (int i = 0; i < comb.length; i++) comb[i] = 0;
int digit = 0;
do {
// Prepare current combination
List<List<IAtom>> combMaps = new ArrayList<List<IAtom>>();
for (int i = 0; i < comb.length; i++) {
int index = clusterIndexes.get(i).get(comb[i]).intValue();
combMaps.add(rMaps.get(index));
}
// Apply the transformation for the particular combination of
// locations with cloning
IAtomContainer product = applyTransformationsAtLocationsWithCloning(target, combMaps, reaction);
if (FlagProcessResultStructures)
processProduct(product);
if (FlagCheckResultStereo)
StereoChemUtils.checkStereoElements(product);
resSet.addAtomContainer(product);
// Generation of next combination
digit = 0;
while (digit < comb.length) {
comb[digit]++;
if (comb[digit] == clusterIndexes.get(digit).size()) {
comb[digit] = 0;
digit++;
} else
break;
}
} while (digit < comb.length);
return resSet;
}
use of org.openscience.cdk.AtomContainerSet in project MORTAR by FelixBaensch.
the class Importer method importSDFile.
//
/**
* Imports an SD file.
*
* @param aFile sdf
* @return the imported molecules in an IAtomContainerSet
* @throws FileNotFoundException if a file input stream cannot be opened for the given file
*/
private IAtomContainerSet importSDFile(File aFile) throws FileNotFoundException {
IAtomContainerSet tmpAtomContainerSet = new AtomContainerSet();
IteratingSDFReader tmpSDFReader = new IteratingSDFReader(new FileInputStream(aFile), DefaultChemObjectBuilder.getInstance());
int tmpCounter = 0;
while (!Thread.currentThread().isInterrupted() && tmpSDFReader.hasNext()) {
IAtomContainer tmpAtomContainer = tmpSDFReader.next();
String tmpName = this.findMoleculeName(tmpAtomContainer);
if (tmpName == null || tmpName.isBlank() || tmpName.isEmpty())
tmpName = FileUtil.getFileNameWithoutExtension(aFile) + tmpCounter;
tmpAtomContainer.setProperty(Importer.MOLECULE_NAME_PROPERTY_KEY, tmpName);
tmpAtomContainerSet.addAtomContainer(tmpAtomContainer);
tmpCounter++;
}
return tmpAtomContainerSet;
}
Aggregations