-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathintersectKeepingNames.cpp
More file actions
65 lines (60 loc) · 1.87 KB
/
Copy pathintersectKeepingNames.cpp
File metadata and controls
65 lines (60 loc) · 1.87 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
#include "bed_tools.hpp"
#include "vcf_tools.hpp"
#include "tools.hpp"
#include <iostream>
int main(int argc, char *argv[]) {
std::map <char, std::string> args = getArgs(std::vector<std::string>(argv, argv + argc));
std::string bed_filename, mask_filename, output_filename;
try {
bed_filename = args.at('a');
mask_filename = args.at('b');
output_filename = args.at('o');
} catch (std::out_of_range) {
std::cout << "Missing obligatory parameters. Parameters are : \n";
std::cout << "\t+a bed file \n";
std::cout << "\t+b mask bed file \n";
std::cout << "\t+o output file \n";
std::cout << "Optionnal :\n";
std::cout << "\t+m id : keep both, source or hit\n";
std::cout << "\t+v masked vcf\n";
throw;
}
id_status status = source;
try {
std::string statusS(args.at('m'));
if(statusS == "source") {
status = source;
} else if(statusS == "hit") {
status = hit;
} else {
status = both;
}
} catch (std::out_of_range) {
status = source;
}
bool is_a_vcf(false);
try {
args.at('v');
is_a_vcf = true;
} catch (std::out_of_range) {
// nothing bc then default is bed
}
std::cout << "Loading beds..." << std::endl;
bed_file id_source(bed_filename, read);
id_source.readWholeFile();
bio_file *mask;
vcf_file vcf_temp(mask_filename, none);
bed_file bed_temp(mask_filename, none);
if (is_a_vcf) {
mask = &vcf_temp;
} else {
mask = &bed_temp;
}
mask -> typeToRead("");
mask -> readWholeFile();
std::cout << "Intersecting" << std::endl;
id_source.apply_intersect(*mask, false, status);
std::cout << "Write results" << std::endl;
id_source.typeToWrite(output_filename);
id_source.writeToFile();
}