-
Notifications
You must be signed in to change notification settings - Fork 4
/
parse_neg_trio.cc
58 lines (49 loc) · 1.47 KB
/
parse_neg_trio.cc
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
/**
* @file parse_neg_trio.cc
* @author Melissa Ip
*
* This outputs all of the trios that have negative probabilities from an input
* file.
*/
#include <fstream>
#include <sstream>
#include "utility.h"
int main(int argc, const char *argv[]) {
if (argc < 2) {
Die("USAGE: parse_neg_trio <input>.txt <output>.txt");
}
const string input = argv[1];
const string output = argv[2];
ifstream fin(input);
if (!fin.is_open() || 0 != fin.fail()) {
Die("Input file cannot be read.");
}
string line;
int index = 0;
double probability = 0.0;
TrioVector trio_vec = GetTrioVector(kNucleotideCount);
ofstream fout(output);
while (getline(fin, line)) {
line.erase(remove(line.begin(), line.end(), '\n'), line.end());
stringstream str(line);
str >> probability;
if (probability < 0.0) {
fout << trio_vec[index][0].reads[0] << " "
<< trio_vec[index][0].reads[1] << " "
<< trio_vec[index][0].reads[2] << " "
<< trio_vec[index][0].reads[3] << "\t"
<< trio_vec[index][1].reads[0] << " "
<< trio_vec[index][1].reads[1] << " "
<< trio_vec[index][1].reads[2] << " "
<< trio_vec[index][1].reads[3] << "\t"
<< trio_vec[index][2].reads[0] << " "
<< trio_vec[index][2].reads[1] << " "
<< trio_vec[index][2].reads[2] << " "
<< trio_vec[index][2].reads[3] << endl;
}
index++;
}
fin.close();
fout.close();
return 0;
}