Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added working implementations for PartialFilledStructureMerger and Cr…

…ossoverMachine
  • Loading branch information...
commit c086a977a8c1af20aa1cba9d994c62c5f4aef135 1 parent 089103e
Stefan Kuhn authored committed
View
18 src/main/org/openscience/cdk/structgen/stochastic/PartialFilledStructureMerger.java
@@ -1,6 +1,6 @@
/* $Revision$ $Author$ $Date$
*
- * Copyright (C) 1997-2007 The CDK project
+ * Copyright (C) 1997-2009 Christoph Steinbeck, Stefan Kuhn <shk3@users.sf.net>
*
* Contact: cdk-devel@lists.sourceforge.net
*
@@ -64,14 +64,14 @@ public PartialFilledStructureMerger()
/**
* Randomly generates a single, connected, correctly bonded structure from
- * a number of fragments.
- *
- * @param atomContainers The fragments to generate for. IMPORTANT: The AtomContainers in the set must be connected.
- * If an AtomContainer is disconnected, the generated structure is not guaranteed to be connected.
- * @return
- * @throws CDKException
+ * a number of fragments. IMPORTANT: The AtomContainers in the set must be
+ * connected. If an AtomContainer is disconnected, no valid result will
+ * be formed
+ * @param atomContainers The fragments to generate for.
+ * @return The newly formed structure.
+ * @throws CDKException No valid result could be formed.
*/
- public IAtomContainerSet generate(IAtomContainerSet atomContainers) throws CDKException
+ public IAtomContainer generate(IAtomContainerSet atomContainers) throws CDKException
{
int iteration = 0;
boolean structureFound = false;
@@ -120,7 +120,7 @@ public IAtomContainerSet generate(IAtomContainerSet atomContainers) throws CDKEx
}
if(!structureFound)
throw new CDKException("Could not combine the fragments to combine a valid, satured structure");
- return atomContainers;
+ return atomContainers.getAtomContainer(0);
}
View
14 src/main/org/openscience/cdk/structgen/stochastic/operator/CrossoverMachine.java
@@ -1,6 +1,6 @@
/* $Revision$ $Author$ $Date$
*
- * Copyright (C) 2000-2007 The Chemistry Development Kit (CDK) project
+ * Copyright (C) 2000-2009 Christoph Steinbeck, Stefan Kuhn<shk3@users.sf.net>
*
* Contact: cdk-devel@lists.sourceforge.net
*
@@ -64,7 +64,11 @@ public CrossoverMachine()
}
/**
- * Performs the n point crossover of two <code>IAtomContainer</code>.
+ * Performs the n point crossover of two {@link IAtomContainer}.
+ * Precondition: The atoms in the molecules are ordered by properties to
+ * preserve (e. g. atom symbol). Due to its randomized nature, this method
+ * fails in around 3% of all cases. A CDKException with message "Could not
+ * mate these properly" will then be thrown.
*
* @return The children.
* @exception CDKException if it was not possible to form offsprings.
@@ -207,10 +211,10 @@ public CrossoverMachine()
for (int f = 0; f < 2; f++)
{
try{
- children.add(f, pfsm.generate(newstrucs[f]).getAtomContainer(0));
- //System.err.println("F "+writer.createSMILES(new Molecule(children.get(f))) );
+ children.add(f, pfsm.generate(newstrucs[f]));
}catch(Exception ex){
-
+ //if children are not correct, the outer loop will repeat,
+ //so we ignore this
}
}
if(children.size()==2 && ConnectivityChecker.isConnected(children.get(0)) && ConnectivityChecker.isConnected(children.get(1)))
Please sign in to comment.
Something went wrong with that request. Please try again.