-
Notifications
You must be signed in to change notification settings - Fork 7
/
popins.cpp
87 lines (76 loc) · 3.57 KB
/
popins.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
84
85
86
#include <iostream>
#include <ctime>
#include <stdio.h>
#include <string.h>
#include "command_line_parsing.h"
#include "assemble/popins_assemble.h"
#include "merge/popins_merge.h"
#include "contigmap/popins_contigmap.h"
#include "place/popins_place.h"
#include "genotype/popins_genotype.h"
// ==========================================================================
void printHelp(char const * name)
{
std::cerr << "PopIns - population-scale detection of novel sequence insertions" << std::endl;
std::cerr << "================================================================" << std::endl;
std::cerr << std::endl;
std::cerr << "\033[1mSYNOPSIS\033[0m" << std::endl;
std::cerr << " \033[1m" << name << " COMMAND\033[0m [\033[4mOPTIONS\033[0m]" << std::endl;
std::cerr << std::endl;
std::cerr << "\033[1mCOMMAND\033[0m" << std::endl;
std::cerr << " \033[1massemble\033[0m Crop unmapped reads from a bam file and assemble them." << std::endl;
std::cerr << " \033[1mmerge\033[0m Merge contigs from assemblies of unmapped reads into supercontigs." << std::endl;
std::cerr << " \033[1mcontigmap\033[0m Map unmapped reads to (super-)contigs." << std::endl;
std::cerr << " \033[1mplace-refalign\033[0m Find position of (super-)contigs by aligning contig ends to the reference genome." << std::endl;
std::cerr << " \033[1mplace-splitalign\033[0m Find position of (super-)contigs by split-read alignment (per sample)." << std::endl;
std::cerr << " \033[1mplace-finish\033[0m Combine position found by split-read alignment from all samples." << std::endl;
std::cerr << " \033[1mgenotype\033[0m Determine genotypes of all insertions in a sample." << std::endl;
std::cerr << std::endl;
std::cerr << "\033[1mVERSION\033[0m" << std::endl;
std::cerr << " " << VERSION << ", Date: " << VERSION_DATE << std::endl;
std::cerr << std::endl;
std::cerr << "Try `" << name << " COMMAND --help' for more information on each command." << std::endl;
std::cerr << std::endl;
}
// ==========================================================================
// Function main()
// ==========================================================================
int main(int argc, char const ** argv)
{
std::time_t start_time = std::time(0);
int ret = 0;
const char * prog_name = argv[0];
if (argc < 2)
{
printHelp(prog_name);
return 1;
}
const char * command = argv[1];
if (strcmp(command,"assemble") == 0) ret = popins_assemble(argc, argv);
else if (strcmp(command,"merge") == 0) ret = popins_merge(argc, argv);
else if (strcmp(command,"contigmap") == 0) ret = popins_contigmap(argc, argv);
else if (strcmp(command,"place-refalign") == 0) ret = popins_place_refalign(argc, argv);
else if (strcmp(command,"place-splitalign") == 0) ret = popins_place_splitalign(argc, argv);
else if (strcmp(command,"place-finish") == 0) ret = popins_place_finish(argc, argv);
else if (strcmp(command,"genotype") == 0) ret = popins_genotype(argc, argv);
else if (strcmp(command, "--help") == 0 || strcmp(command, "-h") == 0)
{
printHelp(prog_name);
return 1;
}
else
{
std::cerr << "ERROR: Unknown command: " << command << std::endl;
printHelp(prog_name);
return 1;
}
if (ret == 7)
return 1;
if (ret == 0)
{
std::ostringstream msg;
msg << "popins " << command << " finished in " << (std::time(0) - start_time) << " seconds.";
printStatus(msg);
}
return 0;
}