-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsame_mass.cpp
More file actions
49 lines (41 loc) · 1.59 KB
/
same_mass.cpp
File metadata and controls
49 lines (41 loc) · 1.59 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
#include "same_mass.h"
#include <unordered_map>
#include <iostream>
class MassTester {
private:
std::unordered_map < int, Scan > &sample_scans;
int same_counter;
const double MASS_EPS = 1e-1;
public:
MassTester(std::unordered_map < int, Scan > &ready_scans, double new_eps) :
sample_scans(ready_scans), same_counter(0), MASS_EPS(new_eps) {}
void operator() (Scan &scan) {
std::unordered_map < int, Scan >::iterator pos = sample_scans.find(scan.id);
if (pos != sample_scans.end()) {
Scan &same = pos->second;
if (abs(scan.mass - same.mass) < MASS_EPS) {
++same_counter;
}
}
}
int get_match_number() {
return same_counter;
}
};
void check_same_mass(std::vector < std::string > filenames, double evalue_border, double eps) {
for (std::string pref : filenames) {
ScansMapCreator map_creator;
go_through_tsv(pref + TSV_SUF, map_creator);
std::unordered_map < int, Scan > theoretic_scans_map = map_creator.get_map();
std::cout << "Looking for scans with the same mass in " << pref + XTRACT_SUF <<
' ' << pref + MSDECONV_SUF << std::endl;
EValueTester scan_checker(theoretic_scans_map, evalue_border);
std::unordered_map < int, Scan > good_thermo_scans;
ScansCollector < EValueTester > thermo_scans(good_thermo_scans, scan_checker);
go_through_mgf(Thermo_Xtract, pref + XTRACT_SUF, thermo_scans);
MassTester ms_tester(good_thermo_scans, eps);
go_through_mgf(MS_Deconv, pref + MSDECONV_SUF, ms_tester);
std::cout << ms_tester.get_match_number() << " scans have the same mass in both files.\n";
}
std::cout << std::endl;
}