-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconsensus.cpp
More file actions
170 lines (139 loc) · 7.77 KB
/
Copy pathconsensus.cpp
File metadata and controls
170 lines (139 loc) · 7.77 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/*
Copyright (C) 2018 Itoh Laboratory, Tokyo Institute of Technology
This file is part of Platanus_B.
Platanus_B is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
Platanus_B is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with Platanus_B; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "consensus.h"
#include <sys/stat.h>
#include <sys/types.h>
using std::vector;
using std::string;
//////////////////////////////////////////////////////////////////////////////////////
// constructor
//////////////////////////////////////////////////////////////////////////////////////
Consensus::Consensus()
{
optionSingleArgs["-o"] = "out";
optionSingleArgs["-e"] = "";
optionSingleArgs["-v"] = "32";
optionSingleArgs["-k"] = "1";
optionSingleArgs["-l"] = "3";
optionSingleArgs["-u"] = "0";
optionSingleArgs["-L"] = "200000";
optionSingleArgs["-t"] = "1";
optionMultiArgs["-c"] = vector<string>();
optionMultiArgs["-b"] = vector<string>();
optionMultiArgs["-p"] = vector<string>();
optionMultiArgs["-x"] = vector<string>();
optionMultiArgs["-X"] = vector<string>();
optionMultiArgs["-s"] = vector<string>(3);
optionMultiArgs["-s"][0] = "32";
optionMultiArgs["-s"][1] = "64";
optionMultiArgs["-s"][2] = "96";
optionMultiArgs["-S"] = vector<string>(1);
optionMultiArgs["-S"][0] = "20";
optionBool["-no_scaffold"] = false;
optionBool["-unphase"] = false;
pairedEndSingleFileType.push_back("-ip");
pairedEndSingleFileType.push_back("-op");
pairedEndPairFileType.push_back("-IP");
pairedEndPairFileType.push_back("-OP");
optionSingleArgs["-tmp"] = ".";
optionSingleArgs["-mapper"] = "";
optionBool["-minimap2_sensitive"] = false;
optionBool["-minimap2"] = false;
optionBool["-minialign"] = false;
optionBool["-kmer_align"] = false;
optionBool["-reduce_redundancy"] = false;
}
//////////////////////////////////////////////////////////////////////////////////////
// usage
//////////////////////////////////////////////////////////////////////////////////////
void Consensus::usage(void) const
{
std::cerr << "\nUsage: platanus_b consensus [Options]\n"
<< "Options:\n"
<< " -o STR : prefix of output file (default " << optionSingleArgs.at("-o") << ", length <= " << platanus::ConstParam::MAX_FILE_LEN << ")\n"
<< " -c FILE1 [FILE2 ...] : contig_file (fasta format)\n"
// << " -b FILE1 [FILE2 ...] : bubble_seq_file (fasta format)\n"
<< " -ip{INT} PAIR1 [PAIR2 ...] : lib_id inward_pair_file (interleaved file, fasta or fastq)\n"
<< " -IP{INT} FWD1 REV1 [FWD2 REV2 ...] : lib_id inward_pair_files (separate forward and reverse files, fasta or fastq)\n"
<< " -op{INT} PAIR1 [PAIR2 ...] : lib_id outward_pair_file (interleaved, fasta or fastq)\n"
<< " -OP{INT} FWD1 REV1 [FWD2 REV2 ...] : lib_id outward_pair_files (separate forward and reverse files, fasta or fastq)\n"
<< " -p PAIR1 [PAIR2 ...] : long-read file (PacBio, Nanopore) (fasta or fastq)\n"
<< " -x PAIR1 [PAIR2 ...] : linked-reads files (paired-ends, 10x Genomics) (interleaved, fasta or fastq)\n"
<< " -X FWD1 REV1 [FWD2 REV2 ...] : linked-reads files (paired-ends, 10x Genomics) (separate forward and reverse files, fasta or fastq)\n"
// << " -n{INT} INT : lib_id minimum_insert_size\n"
// << " -a{INT} INT : lib_id average_insert_size\n"
// << " -d{INT} INT : lib_id SD_insert_size\n"
<< " -e FLOAT : coverage depth of homozygous region (default auto)\n"
<< " -L INT : maximum fragment length of tag (10x Genomics) (default " << optionSingleArgs.at("-L") << ")\n"
<< " -s INT1 [INT2 ...] : mapping seed length for short reads (default " << optionMultiArgs.at("-s")[0] << " " << optionMultiArgs.at("-s")[1] << " " << optionMultiArgs.at("-s")[2] << ")\n"
<< " -l INT : minimum number of links to scaffold (default " << optionSingleArgs.at("-l") << ")\n"
<< " -t INT : number of threads (<= " << optionSingleArgs.at("-t") << ", default 1)\n"
<< " -mapper FILE : path of mapper executable file (default, minimap, only effective with -p option)\n"
<< " -minimap2_sensitive : sensitive mode for minimap2 (default, off; only effective with -p option)\n"
<< " -reduce_redundancy : reduce redundant sequences that exactly matche others (default, off)\n"
// << " -minimap2 : use minimap2 insterd of minimap (default) for alignment of long reads\n"
// << " -minialign : use minialign insterd of minimap (default) for alignment of long reads\n"
// << " -kmer_align : use built-in alignment based on k-mer match insterd of minimap (default) for long reads\n"
<< " -tmp DIR : directory for temporary files (default " << optionSingleArgs.at("-tmp") << ")\n"
<< "\n\n"
<< "Outputs:\n"
<< " PREFIX_consensusScaffold.fa\n"
<< " PREFIX_consensusScaffoldComponent.bed\n"
<< "\n"
<< "Note, PREFIX is specified by -o\n"
<< std::endl;
}
void Consensus::exec(void)
{
platanus::setGlobalTmpFileDir(optionSingleArgs["-tmp"].c_str());
std::cerr << "ececuting platanus_b solve_DBG internally ..." << std::endl;
this->execSolveDBG();
std::cerr << "phase completed!" << std::endl;
}
void Consensus::execSolveDBG(void)
{
vector<string> singleArgOptionList = {"-o", "-t", "-tmp", "-e", "-l", "-L", "-mapper"};
vector<string> multiArgOptionList = {"-c", "-b", "-p", "-x", "-X", "-s"};
vector<string> boolArgOptionList = {"-minimap2_sensitive", "-reduce_redundancy"};
std::ostringstream oss;
oss << this->platanusBinary << " solve_DBG -unphase";
for (auto itr = optionPairFile.begin(); itr != optionPairFile.end(); ++itr) {
oss << " " << itr->libraryType << itr->libraryID << " " << itr->fileFirst;
if (!(itr->fileSecond.empty())) {
oss << " " << itr->fileSecond;
}
}
for (auto optItr = singleArgOptionList.begin(); optItr != singleArgOptionList.end(); ++optItr) {
if (!(optionSingleArgs[*optItr].empty())) {
oss << " " << *optItr << " " << optionSingleArgs[*optItr];
}
}
for (auto optItr = multiArgOptionList.begin(); optItr != multiArgOptionList.end(); ++optItr) {
if (!(optionMultiArgs[*optItr].empty())) {
oss << " " << *optItr;
for (auto argItr = optionMultiArgs[*optItr].begin(); argItr != optionMultiArgs[*optItr].end(); ++argItr) {
oss << " " << *argItr;
}
}
}
for (auto optItr = boolArgOptionList.begin(); optItr != boolArgOptionList.end(); ++optItr) {
if (optionBool[*optItr])
oss << " " << *optItr;
}
if (system(oss.str().c_str()) != 0) {
throw platanus::SolveDBGError();
}
}