$darkmode
DENOPTIM
MolecularModelBuilder.java
Go to the documentation of this file.
1/*
2 * DENOPTIM
3 * Copyright (C) 2019 Vishwesh Venkatraman <vishwesh.venkatraman@ntnu.no> and
4 * Marco Foscato <marco.foscato@uib.no>
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as published
8 * by the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
15 *
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20package denoptim.programs.moldecularmodelbuilder;
21
22import java.io.File;
23import java.util.ArrayList;
24import java.util.Map;
25import java.util.logging.Level;
26
27import org.openscience.cdk.interfaces.IAtomContainer;
28
29import denoptim.constants.DENOPTIMConstants;
30import denoptim.graph.Candidate;
31import denoptim.graph.DGraph;
32import denoptim.integration.tinker.TinkerException;
33import denoptim.io.DenoptimIO;
34import denoptim.molecularmodeling.MultiMolecularModelBuilder;
35import denoptim.task.ProgramTask;
36
45{
46
47//------------------------------------------------------------------------------
48
54 public MolecularModelBuilder(File configFile, File workDir)
55 {
56 super(configFile,workDir);
57 }
58
59//------------------------------------------------------------------------------
60
61 @Override
62 public void runProgram() throws Throwable
63 {
65 if (workDir != null)
66 {
67 mmbParams.setWorkDirectory(workDir.getAbsolutePath());
68 }
69
70 mmbParams.readParameterFile(configFilePathName.getAbsolutePath());
71 mmbParams.checkParameters();
72 mmbParams.processParameters();
74 mmbParams.printParameters();
75
76 // read the input molecule
78 new File(mmbParams.getInputSDFFile()), true).get(0);
79 DGraph grph = candidate.getGraph();
80 String mname = candidate.getName();
81 Map<Object,Object> properties = candidate.getChemicalRepresentation()
82 .getProperties();
83
85 new MultiMolecularModelBuilder(mname, grph, mmbParams);
86
87 boolean normalTerm = false;
88 try {
89 ArrayList<IAtomContainer> nmols = mbuild.buildMulti3DStructure();
90 for (int i = 0; i<nmols.size(); i++)
91 {
92 //NB: here we reset the IAC properties, so, any property that
93 // should be passed on to the future should be copied.
94 String propVIDs = nmols.get(i).getProperty(
96 Object propMolErr = nmols.get(i).getProperty(
98 nmols.get(i).setProperties(properties);
99 nmols.get(i).setProperty(
101 if (propMolErr != null)
102 {
103 nmols.get(i).setProperty(DENOPTIMConstants.MOLERRORTAG,
104 propMolErr.toString());
105 }
106 }
107 DenoptimIO.writeSDFFile(mmbParams.getOutputSDFFile(), nmols);
108 normalTerm = true;
109 } catch (TinkerException te)
110 {
111 String msg = "ERROR! Tinker failed on task '" + te.taskName
112 + "'!";
113 if (te.solution != "")
114 {
115 msg = msg + NL + te.solution;
116 }
117 mmbParams.getLogger().log(Level.SEVERE, msg);
118 }
119 catch (Exception de)
120 {
121 de.printStackTrace(System.err);
122 }
123 if (normalTerm)
124 {
125 mmbParams.getLogger().log(Level.INFO, "MolecularModelBuilder "
126 + "terminated normally!");
127 }
128 }
129}
General set of constants used in DENOPTIM.
static final String ATMPROPVERTEXID
String tag of Atom property used to store the unique ID of the Vertex corresponding to the molecular ...
static final String MOLERRORTAG
SDF tag containing errors during execution of molecule specific tasks.
A candidate is the combination of a denoptim graph with molecular representation and may include also...
Definition: Candidate.java:40
IAtomContainer getChemicalRepresentation()
Returns the atom container representing this candidate.
Definition: Candidate.java:389
Container for the list of vertices and the edges that connect them.
Definition: DGraph.java:102
Exceptions resulting from a failure of Tinker.
String solution
Proposed solution to the failure, or empty string.
Utility methods for input/output.
static ArrayList< Candidate > readCandidates(File file)
Reads SDF files that represent one or more tested candidates.
static void writeSDFFile(String fileName, IAtomContainer mol)
Writes IAtomContainer to SDF file.
ArrayList< IAtomContainer > buildMulti3DStructure()
Given the graph representation of the molecular constitution, along with the 3D coordinates of the fr...
Logger startProgramSpecificLogger(String loggerIdentifier)
Starts a logger with the given name.
void readParameterFile(String infile)
Read the parameter TXT file line by line and interpret its content.
Logger getLogger()
Get the name of the program specific logger.
void printParameters()
Print all parameters.
void setWorkDirectory(String pathname)
Gets the pathname to the working directory.
Parameters for the conformer generator (3D builder).
void processParameters()
Processes all parameters and initialize related objects.
MolecularModelBuilder(File configFile, File workDir)
Creates and configures the program task.
Task structure for any of the main programs in the denoptim project, such as genetic algorithm and co...
String loggerIdentifier
Identifier of this program's logger.
File configFilePathName
File containing configuration parameters for the program task.
File workDir
The file system location where we want to be placed when doing the work.
Definition: Task.java:78
final String NL
System-dependent line separator (newline)
Definition: Task.java:93