$darkmode
DENOPTIM
Mol2Graph.java
Go to the documentation of this file.
1/*
2 * DENOPTIM
3 * Copyright (C) 2019 Marco Foscato <marco.foscato@uib.no>
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Affero General Public License as published
7 * by the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Affero General Public License for more details.
14 *
15 * You should have received a copy of the GNU Affero General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19package denoptim.programs.mol2graph;
20
21import java.io.File;
22import java.util.ArrayList;
23import java.util.List;
24import java.util.logging.Level;
25
26import javax.swing.JOptionPane;
27import javax.swing.UIManager;
28
29import org.openscience.cdk.interfaces.IAtomContainer;
30
31import denoptim.exception.DENOPTIMException;
32import denoptim.fragspace.FragmentSpaceParameters;
33import denoptim.ga.EAUtils;
34import denoptim.graph.DGraph;
35import denoptim.io.DenoptimIO;
36import denoptim.programs.RunTimeParameters.ParametersType;
37import denoptim.programs.fragmenter.FragmenterParameters;
38import denoptim.task.ProgramTask;
39
40
47public class Mol2Graph extends ProgramTask
48{
49
50//------------------------------------------------------------------------------
51
57 public Mol2Graph(File configFile, File workDir)
58 {
59 super(configFile,workDir);
60 }
61
62//------------------------------------------------------------------------------
63
64 @Override
65 public void runProgram() throws Throwable
66 {
68 m2gParams.readParameterFile(configFilePathName.getAbsolutePath());
69 m2gParams.checkParameters();
70 m2gParams.processParameters();
71 m2gParams.startProgramSpecificLogger(loggerIdentifier, false); //to STDOUT
72
73 List<DGraph> graphs = new ArrayList<DGraph>();
74 for (int i=0; i<m2gParams.getInputMolsCount(); i++)
75 {
76 IAtomContainer mol = m2gParams.getInputMol(i);
77 DGraph graph = null;
78 try {
80 m2gParams.getCuttingRules(),
81 m2gParams.getLogger(),
82 m2gParams.getScaffoldingPolicy(),
83 m2gParams.getLinearAngleLimit(),
84 m2gParams.getFragmentSpace());
85 } catch (DENOPTIMException de)
86 {
87 m2gParams.getLogger().log(Level.SEVERE, "Unable to convert "
88 + "molecule " + i + " to DENOPTIM graph. "
89 + de.getMessage());
90 return;
91 }
92
93 graphs.add(graph);
94 }
95
96 if (graphs.size()>1)
97 {
98 DenoptimIO.writeGraphsToFile(new File(m2gParams.getOutFile()),
99 m2gParams.getOutFormat(), graphs, m2gParams.getLogger(),
100 m2gParams.getRandomizer());
101 } else {
102 DenoptimIO.writeGraphToFile(new File(m2gParams.getOutFile()),
103 m2gParams.getOutFormat(), graphs.get(0), m2gParams.getLogger(),
104 m2gParams.getRandomizer());
105 }
106 }
107
108//-----------------------------------------------------------------------------
109
110}
Helper methods for the genetic algorithm.
Definition: EAUtils.java:107
static DGraph makeGraphFromFragmentationOfMol(IAtomContainer mol, List< CuttingRule > cuttingRules, Logger logger, ScaffoldingPolicy scaffoldingPolicy)
Converts a molecule into a DGraph by fragmentation and re-assembling of the fragments.
Definition: EAUtils.java:1044
Container for the list of vertices and the edges that connect them.
Definition: DGraph.java:102
Utility methods for input/output.
static File writeGraphToFile(File file, FileFormat format, DGraph graph, Logger logger, Randomizer randomizer)
Writes the a graph to file.
static File writeGraphsToFile(File file, FileFormat format, List< DGraph > modGraphs, Logger logger, Randomizer randomizer)
Writes the graphs to file.
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.
Randomizer getRandomizer()
Returns the current program-specific randomizer.
Tool for creating DGraphs from molecules.
Definition: Mol2Graph.java:48
Mol2Graph(File configFile, File workDir)
Creates and configures the program task.
Definition: Mol2Graph.java:57
Parameters controlling execution of GraphEditor.
void processParameters()
Processes all parameters and initialize related objects.
void checkParameters()
Evaluate consistency of input parameters.
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