1package denoptim.fragmenter;
3import static org.junit.jupiter.api.Assertions.assertEquals;
4import static org.junit.jupiter.api.Assertions.assertTrue;
25import java.util.ArrayList;
27import org.junit.jupiter.api.Test;
28import org.junit.jupiter.api.io.TempDir;
29import org.openscience.cdk.Atom;
30import org.openscience.cdk.interfaces.IAtomContainer;
31import org.openscience.cdk.interfaces.IChemObjectBuilder;
32import org.openscience.cdk.silent.SilentChemObjectBuilder;
34import denoptim.constants.DENOPTIMConstants;
35import denoptim.io.DenoptimIO;
36import denoptim.io.IteratingAtomContainerReader;
37import denoptim.programs.fragmenter.FragmenterParameters;
47 private static final String
SEP = System.getProperty(
"file.separator");
48 private static final String
NL = System.getProperty(
"line.separator");
53 private IChemObjectBuilder
builder = SilentChemObjectBuilder.getInstance();
63 assertTrue(
tempDir.isDirectory(),
"Should be a directory ");
64 String structureFile =
tempDir.getAbsolutePath() +
SEP +
"mols.sdf";
65 String formulaeFile =
tempDir.getAbsolutePath() +
SEP +
"forms.txt";
67 StringBuilder formulaeTextBuilder =
new StringBuilder();
68 ArrayList<IAtomContainer> mols =
new ArrayList<IAtomContainer>();
69 for (
int i=0; i<7; i++)
71 IAtomContainer mol =
builder.newAtomContainer();
72 mol.addAtom(
new Atom(
"C"));
75 formulaeTextBuilder.append(
"REFCODE: mol"+i).append(
NL).append(
NL);
76 formulaeTextBuilder.append(
"Chemical").append(
NL);
77 formulaeTextBuilder.append(
" Formula: formula-"+i).append(
NL);
78 formulaeTextBuilder.append(
NL);
97 int[] expectedEntries = {3, 2, 2};
98 for (
int i=0; i<3; i++)
102 File structFile =
new File(newStructureFile);
103 assertTrue(newStructureFile.contains(
tempDir.getAbsolutePath()));
104 assertTrue(structFile.exists());
108 for (String line : lines)
111 assertEquals(expectedEntries[i],n);
General set of constants used in DENOPTIM.
static final Object FORMULASTR
Property name used to store molecular formula as string in an atom container.
Fragments a list of chemical systems by running parallel fragmentation tasks.
static String getStructureFileNameBatch(FragmenterParameters settings, int i)
Builds the pathname of the structure file generated for one of the parallel threads.
static void splitInputForThreads(FragmenterParameters settings, IteratingAtomContainerReader reader)
Splits the input data (from FragmenterParameters) into batches suitable for parallel batch processing...
Unit test for fparallel ragmentation algorithm components.
void testSplitInputForThreads()
IChemObjectBuilder builder
Private builder of atom containers.
Utility methods for input/output.
static void writeSDFFile(String fileName, IAtomContainer mol)
Writes IAtomContainer to SDF file.
static ArrayList< String > readList(String fileName)
Read list of data as text.
static void writeData(String fileName, String data, boolean append)
Write text-like data file.
An iterator that take IAtomContainers from a file, possibly using an available iterating reader,...
void setWorkDirectory(String pathname)
Gets the pathname to the working directory.
Parameters controlling execution of the fragmenter.
void setStructuresFile(String structuresFile)
Sets the pathname of the file containing input structures.
void setCheckFormula(boolean checkFormula)
Sets the value of the flag controlling the execution of elemental analysis on the structures.
void checkParameters()
Evaluate consistency of input parameters.
void setNumTasks(int numParallelTasks)
Sets the number of parallel tasks to run.
void setFormulaeFile(String formulaeFile)
Sets the pathname of the file containing molecular formula with a format respecting Cambridge Structu...
String getStructuresFile()
void processParameters()
Processes all parameters and initialize related objects.