-
Notifications
You must be signed in to change notification settings - Fork 1
/
Main.cpp
131 lines (102 loc) · 2.82 KB
/
Main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#include <vector>
#include <queue>
#include <iostream>
//
// Open Babel
//
#include <openbabel/obconversion.h>
#include <openbabel/mol.h>
//
// This project molecular representation
//
#include "Molecule.h"
#include "Rigid.h"
#include "Linker.h"
//
// Synthesis-Based Functionality
//
#include "HyperGraph.h"
#include "EdgeAnnotation.h"
#include "Instantiator.h"
#include "PebblerHyperGraph.h"
#include "Utilities.h"
void Cleanup(std::vector<Linker>& linkers, std::vector<Rigid>& rigids);
//
// Read the input data files
//
void readInputFiles(int argc, char** argv,
std::vector<Linker>& linkers, std::vector<Rigid>& rigids)
{
// Input parser functionality for Open babel
OpenBabel::OBConversion obConversion;
obConversion.SetInFormat("sdf");
//
// For each file
//
for (int f = 1; f < argc; f++)
{
//
// For each molecule in this file.
//
OpenBabel::OBMol* mol = new OpenBabel::OBMol();
bool notatend = obConversion.ReadFile(mol, argv[f]);
while (notatend)
{
//
// Create this particular molecule type.
//
// Is there a better way to handle distinguising linkers vs. rigids
// other than the name of the file (prefix)?
switch(argv[f][0])
{
case 'l':
linkers.push_back(*(new Linker(*mol)));
break;
case 'r':
rigids.push_back(*(new Rigid(*mol)));
break;
default:
cerr << "Unexpected file prefix: " << argv[f][0] << " with file " << argv[f][0] << endl;
}
//
// Read the next molecule in from the file.
//
mol = new OpenBabel::OBMol();
notatend = obConversion.Read(mol);
}
}
}
int main(int argc, char** argv)
{
if (argc == 1)
{
cerr << "Usage: <program> <SDF-file-list>" << endl;
return 1;
}
std::vector<Linker> linkers;
std::vector<Rigid> rigids;
readInputFiles(argc, argv, linkers, rigids);
cerr << "1" << endl;
Instantiator instantiator(cout);
cerr << "2" << endl;
HyperGraph<Molecule, EdgeAnnotationT> graph = instantiator.Instantiate(linkers, rigids);
cerr << "3" << endl;
PebblerHyperGraph<Molecule, EdgeAnnotationT> pebblerGraph = graph.GetPebblerHyperGraph();
cerr << "4" << endl;
if (DEBUG) cout << graph;
cerr << "5" << endl;
Cleanup(linkers, rigids);
cerr << "6" << endl;
return 0;
}
void Cleanup(std::vector<Linker>& linkers, std::vector<Rigid>& rigids)
{
for (int ell = 0; ell < linkers.size(); ell++)
{
delete &linkers[ell];
}
for (int r = 0; r < rigids.size(); r++)
{
delete &rigids[r];
}
}