-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscan.cpp
83 lines (70 loc) · 2.16 KB
/
scan.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
#include "scan.h"
#include <fstream>
#include <sstream>
void reset_scan(Scan &scan) {
scan.id = 0;
scan.mass = 0;
scan.isotope_error = 0;
scan.precursor_error = 0;
scan.charge = 0;
scan.spec_e_value = 0;
scan.e_value = 0;
scan.peaks.clear();
scan.mass_2 = 0;
}
void Scan::operator=(Scan &other) {
id = other.id;
mass = other.mass;
isotope_error = other.isotope_error;
precursor_error = other.precursor_error;
charge = other.charge;
peptide = other.peptide;
protein = other.protein;
de_novo_scope = other.de_novo_scope;
msgf_scope = other.msgf_scope;
spec_e_value = other.spec_e_value;
e_value = other.e_value;
peaks = other.peaks;
mass_2 = other.mass_2;
}
Scan parse_tsv_line(std::string &line) {
const std::string ID_PREF = "scan=";
Scan ans;
std::stringstream line_stream(line);
std::string temp;
line_stream >> temp;
line_stream >> temp;
line_stream >> ans.id;
line_stream >> temp;
line_stream >> ans.mass;
line_stream >> ans.isotope_error;
line_stream >> ans.precursor_error;
line_stream >> ans.charge;
ans.mass = (ans.mass - DA) * ans.charge;
line_stream >> ans.peptide;
line_stream >> ans.protein;
line_stream >> ans.de_novo_scope;
line_stream >> ans.msgf_scope;
line_stream >> ans.spec_e_value;
line_stream >> ans.e_value;
return ans;
}
int msalign_id(std::string title) {
return std::stoi(title.substr(ID_PREF.size() + 5, title.size() - (ID_PREF.size() + 5)));
}
int thermo_xtract_id(std::string title) {
int eq_pos = title.find_last_of("=");
return std::stoi(title.substr(eq_pos + 1, title.size() - eq_pos - 2));
}
void ScansMapCreator::operator() (Scan &scan) {
scans_map[scan.id] = scan;
}
std::unordered_map < int, Scan > ScansMapCreator::get_map() {
return scans_map;
}
EValueTester::EValueTester(std::unordered_map < int, Scan > &new_map, double new_e_value_border) :
E_VALUE_BORDER(new_e_value_border), theoretic_map(new_map) {}
bool EValueTester::operator()(Scan &scan) {
std::unordered_map < int, Scan >::iterator prediction = theoretic_map.find(scan.id);
return prediction != theoretic_map.end() && (prediction->second.e_value < E_VALUE_BORDER);
}