-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathoptions.cpp
55 lines (44 loc) · 1.2 KB
/
options.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
#include "options.h"
#include "util.h"
#include <iostream>
#include <fstream>
#include <string.h>
Options::Options(){
faFile = "";
refFile = "";
outdir = "";
kmerKeyLen = 25;
genomeLimit = 0;
kmerSpacing = 0;
edThreshold = 3;
}
void Options::init() {
}
bool Options::validate() {
if(faFile.empty()) {
error_exit("FASTA file (-f) should be specified");
} else {
check_file_valid(faFile);
}
if(!faFile.empty()) {
check_file_valid(faFile);
}
if(!refFile.empty()) {
check_file_valid(refFile);
}
if(!outdir.empty()) {
if(!file_exists(outdir)) {
if(mkdir(outdir.c_str(), 0755)!=0)
error_exit("Failed to create directory: " + outdir);
}
if(!is_directory(outdir))
error_exit("Not a directory: " + outdir);
}
if(kmerKeyLen < 3 || kmerKeyLen > 32)
error_exit("KMER length (-k) should be between 3 ~ 32, suggest 25");
if(edThreshold < 0 || edThreshold > 16)
error_exit("Edit distance threshold (-e) should be between 0 ~ 16, suggest 3");
if(genomeLimit < 0)
error_exit("Genome limit (-g) cannot be negative");
return true;
}