-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
executable file
·70 lines (53 loc) · 1.42 KB
/
main.cpp
File metadata and controls
executable file
·70 lines (53 loc) · 1.42 KB
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
//
// main.cpp
// HPFolding
//
// Created by Stéphane Sercu on 29/10/16.
// Copyright © 2016 Stéphane Sercu. All rights reserved.
//
#ifdef GRAPH
bool graphic = true;
#define run(obj) projetgraph(argc, argv, &hp)
#include "HPGUI.h"
#else
bool graphic = false;
#define run(obj) obj.fold()
#endif
#include <iostream>
#include <string>
#include <fstream>
#include <functional>
#include "HPFolding.hpp"
using namespace std;
int main(int argc, char * argv[]) {
ifstream infile;
ofstream outfile;
if (argc > 1) {
infile.open(argv[1]); // First arg is the input file
}
if (argc > 2) {
outfile.open(argv[2]); // Second arg is the output file
}
ostream & output = (outfile.is_open() ? outfile : cout);
string chain;
if (infile.is_open()) {
HPFolding hp;
function<void()> callback = NULL;
if (graphic)
callback = [&](){if (hp.getScore()>0) {hp.finalGrid.draw_conformation(output);}};
while (getline(infile, chain)) {
hp.setChain(chain);
hp.fold(callback);
output << chain << "\t" << hp.getScore() << endl;
}
infile.close();
} else {
// ask for chain
cout << "Chain: \t";
cin >> chain;
HPFolding hp(chain);
run(hp);
output << chain << "\t" << hp.getScore() << endl;
}
return 0;
}