Skip to content

Commit 16fc4b6

Browse files
committed
fixed complete command
1 parent 2142402 commit 16fc4b6

File tree

5 files changed

+49
-36
lines changed

5 files changed

+49
-36
lines changed

include/Data.hpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,19 @@ class Data{
3737

3838
// get Data
3939
GroupsPath getGroupsPath(fs::path& ctrls, fs::path& trtms);
40-
void getCondition(GroupsPath& groups);
41-
pt::ptree getData(const std::string group, fs::path& condition);
40+
void getCondition(GroupsPath& groups, std::string subcall);
41+
pt::ptree getData(const std::string group, fs::path& condition, std::string& subcall);
4242

4343
// get output data
44-
pt::ptree getOutputData(pt::ptree& input, fs::path& conditionOutDir);
44+
pt::ptree getOutputData(pt::ptree& input, fs::path& conditionOutDir, std::string& subcall);
4545
pt::ptree getPreprocOutputData(pt::ptree& input, fs::path& conditionOutDir);
4646
pt::ptree getAlignOutputData(pt::ptree& input, fs::path& conditionOutDir);
4747
pt::ptree getDetectOutputData(pt::ptree& input, fs::path& conditionOutDir);
4848
pt::ptree getAnalysisOutputData(pt::ptree& input, fs::path& conditionOutDir);
4949

5050
//
51-
int getNumberElements(PathVector& vec);
52-
std::vector<std::string> getSampleKeys();
51+
int getNumberElements(PathVector& vec, std::string& subcall);
52+
std::vector<std::string> getSampleKeys(std::string& subcall);
5353

5454
// prep functions
5555
void preprocDataPrep();
@@ -60,7 +60,7 @@ class Data{
6060

6161
//
6262
template <typename Callable>
63-
void callInAndOut(Callable f);
63+
void callInAndOut(Callable f, std::string subcallStr);
6464

6565
// callables
6666
void preproc();

src/Base.cpp

+13-4
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,25 @@ Base::Base(po::variables_map params) : params(params), paramsVal(params), data(p
3030
data.analysis();
3131
} else {
3232
if(subcall == "complete") {
33+
if(params["preproc"].as<std::bitset<1>>() != std::bitset<1>("1")) {
34+
std::cout << helper::getTime() << " 'preproc' has not been set correctly - check parameters" << std::endl;
35+
exit(EXIT_FAILURE);
36+
}
37+
data.preprocDataPrep();
3338
data.preproc();
34-
data.detect();
39+
// align
40+
data.alignDataPrep();
3541
data.align();
42+
// detect
43+
data.detectDataPrep();
44+
data.detect();
3645
if(params["clust"].as<std::bitset<1>>() == std::bitset<1>("1")) {
46+
data.clusteringDataPrep();
3747
data.clustering();
3848
}
49+
// analysis
50+
data.analysisDataPrep();
3951
data.analysis();
40-
} else {
41-
std::cout << "subcall: " << params["subcall"].as<std::string>() << " invalid!" << std::endl;
42-
exit(EXIT_FAILURE);
4352
}
4453
}
4554
}

src/Data.cpp

+26-26
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ void Data::preprocDataPrep() {
3636
fs::path trtmsPath = fs::path(this->params["trtms"].as<std::string>());
3737

3838
GroupsPath groups = getGroupsPath(ctrlsPath, trtmsPath);
39-
getCondition(groups);
39+
getCondition(groups, "preproc");
4040
}
4141

4242
void Data::alignDataPrep() {
@@ -57,7 +57,7 @@ void Data::alignDataPrep() {
5757
* (ctrls -> "/Users/.../crtls")
5858
*/
5959
GroupsPath groups = getGroupsPath(ctrlsPath, trtmsPath);
60-
getCondition(groups);
60+
getCondition(groups, "align");
6161
}
6262
}
6363
}
@@ -70,7 +70,7 @@ void Data::detectDataPrep() {
7070
fs::path trtmsPath = fs::path(params["outdir"].as<std::string>()) / "align/trtms";
7171

7272
GroupsPath groups = getGroupsPath(ctrlsPath, trtmsPath);
73-
getCondition(groups);
73+
getCondition(groups, "detect");
7474
}
7575

7676
void Data::clusteringDataPrep() {
@@ -81,7 +81,7 @@ void Data::clusteringDataPrep() {
8181
fs::path trtmsPath = fs::path(params["outdir"].as<std::string>()) / "detect/trtms";
8282

8383
GroupsPath groups = getGroupsPath(ctrlsPath, trtmsPath);
84-
getCondition(groups);
84+
getCondition(groups, "clustering");
8585
}
8686

8787
void Data::analysisDataPrep() {
@@ -92,7 +92,7 @@ void Data::analysisDataPrep() {
9292
fs::path trtmsPath = fs::path(params["outdir"].as<std::string>()) / "detect/trtms";
9393

9494
GroupsPath groups = getGroupsPath(ctrlsPath, trtmsPath);
95-
getCondition(groups);
95+
getCondition(groups, "analysis");
9696
}
9797

9898
GroupsPath Data::getGroupsPath(fs::path& ctrls, fs::path& trtms) {
@@ -115,7 +115,7 @@ GroupsPath Data::getGroupsPath(fs::path& ctrls, fs::path& trtms) {
115115
}
116116

117117
//
118-
void Data::getCondition(GroupsPath& groups) {
118+
void Data::getCondition(GroupsPath& groups, std::string subcall) {
119119
// ptree object containing
120120
pt::ptree ptData, ptSubcall, ptPath, ptGroup, ptCondition;
121121

@@ -134,7 +134,7 @@ void Data::getCondition(GroupsPath& groups) {
134134
continue;
135135
}
136136

137-
ptCondition = getData(group.first, condition);
137+
ptCondition = getData(group.first, condition, subcall);
138138
ptGroup.push_back(std::make_pair("", ptCondition));
139139

140140
}
@@ -152,16 +152,16 @@ void Data::getCondition(GroupsPath& groups) {
152152
}
153153

154154
// write data structure to file
155-
std::string subcall = params["subcall"].as<std::string>();
155+
// std::string subcall = params["subcall"].as<std::string>();
156156
dataStructure.add_child(subcall, ptSubcall);
157157
fs::path dataStructurePath = fs::path(params["outdir"].as<std::string>()) / fs::path("data.json");
158158
jp::write_json(dataStructurePath.string(), dataStructure);
159159
std::cout << helper::getTime() << "Data structure has been written to " << dataStructurePath << "\n";
160160
}
161161

162162
//
163-
pt::ptree Data::getData(std::string group, fs::path& condition) {
164-
std::string subcall = params["subcall"].as<std::string>();
163+
pt::ptree Data::getData(std::string group, fs::path& condition, std::string& subcall) {
164+
// std::string subcall = params["subcall"].as<std::string>();
165165
std::string outdir = params["outdir"].as<std::string>();
166166

167167
pt::ptree ptCondition, ptFiles, ptSamples, ptSample, ptOutput;
@@ -176,8 +176,8 @@ pt::ptree Data::getData(std::string group, fs::path& condition) {
176176
}*/
177177

178178
// define helper variables
179-
int numberElements = getNumberElements(dataFiles);
180-
std::vector<std::string> sampleKeys = getSampleKeys();
179+
int numberElements = getNumberElements(dataFiles, subcall);
180+
std::vector<std::string> sampleKeys = getSampleKeys(subcall);
181181

182182
fs::path conditionOutDir = fs::path(outdir);
183183
conditionOutDir /= fs::path(subcall);
@@ -190,7 +190,7 @@ pt::ptree Data::getData(std::string group, fs::path& condition) {
190190
if(elementCounter == numberElements-1) {
191191
ptSample.add_child("input", ptFiles);
192192
// determine output TODO
193-
ptOutput = getOutputData(ptSample, conditionOutDir);
193+
ptOutput = getOutputData(ptSample, conditionOutDir, subcall);
194194
ptSample.add_child("output", ptOutput);
195195

196196
ptSamples.push_back(std::make_pair("", ptSample));
@@ -211,8 +211,8 @@ pt::ptree Data::getData(std::string group, fs::path& condition) {
211211
}
212212

213213

214-
int Data::getNumberElements(PathVector& vec) {
215-
std::string subcall = params["subcall"].as<std::string>();
214+
int Data::getNumberElements(PathVector& vec, std::string& subcall) {
215+
// std::string subcall = params["subcall"].as<std::string>();
216216
int numberElements;
217217

218218
if(subcall == "preproc") { numberElements = (params["readtype"].as<std::string>() == "PE") ? 2 : 1; }
@@ -228,8 +228,8 @@ int Data::getNumberElements(PathVector& vec) {
228228
return numberElements;
229229
}
230230

231-
std::vector<std::string> Data::getSampleKeys() {
232-
std::string subcall = params["subcall"].as<std::string>();
231+
std::vector<std::string> Data::getSampleKeys(std::string& subcall) {
232+
// std::string subcall = params["subcall"].as<std::string>();
233233
std::vector<std::string> sampleKeys;
234234
if(subcall == "preproc") { sampleKeys = {"forward", "reverse"}; }
235235

@@ -249,8 +249,8 @@ std::vector<std::string> Data::getSampleKeys() {
249249
return sampleKeys;
250250
}
251251

252-
pt::ptree Data::getOutputData(pt::ptree& input, fs::path& conditionOutDir) {
253-
std::string subcall = params["subcall"].as<std::string>();
252+
pt::ptree Data::getOutputData(pt::ptree& input, fs::path& conditionOutDir, std::string& subcall) {
253+
// std::string subcall = params["subcall"].as<std::string>();
254254

255255
pt::ptree output;
256256
if(subcall == "preproc") { output = getPreprocOutputData(input, conditionOutDir); }
@@ -349,11 +349,11 @@ pt::ptree Data::getAnalysisOutputData(pt::ptree& input, fs::path& conditionOutDi
349349
}
350350

351351
template <typename Callable>
352-
void Data::callInAndOut(Callable f) {
352+
void Data::callInAndOut(Callable f, std::string subcallStr) {
353353

354354
// retrieve paths for parameters
355355
fs::path outDir = fs::path(params["outdir"].as<std::string>());
356-
std::string subcallStr = params["subcall"].as<std::string>();
356+
// std::string subcallStr = params["subcall"].as<std::string>();
357357
fs::path outSubcallDir = outDir / fs::path(subcallStr);
358358

359359
pt::ptree subcall = dataStructure.get_child(subcallStr);
@@ -397,33 +397,33 @@ void Data::callInAndOut(Callable f) {
397397
void Data::preproc() {
398398
std::cout << helper::getTime() << "Start the Preprocessing\n";
399399
SeqRickshaw srs(params);
400-
callInAndOut(std::bind(&SeqRickshaw::start, srs, std::placeholders::_1));
400+
callInAndOut(std::bind(&SeqRickshaw::start, srs, std::placeholders::_1), "preproc");
401401
}
402402

403403
void Data::align() {
404404
std::cout << helper::getTime() << "Start the Alignment\n";
405405
Align aln(params);
406-
callInAndOut(std::bind(&Align::start, aln, std::placeholders::_1));
406+
callInAndOut(std::bind(&Align::start, aln, std::placeholders::_1), "align");
407407
}
408408

409409
void Data::detect() {
410410
std::cout << helper::getTime() << "Start the Split Read Calling\n";
411411
SplitReadCalling src(params);
412-
callInAndOut(std::bind(&SplitReadCalling::start, &src, std::placeholders::_1, std::placeholders::_2));
412+
callInAndOut(std::bind(&SplitReadCalling::start, &src, std::placeholders::_1, std::placeholders::_2), "detect");
413413
src.writeStats();
414414
}
415415

416416
void Data::clustering() {
417417
std::cout << helper::getTime() << "Start the Clustering of the Split Reads\n";
418418
Clustering clu(params);
419-
callInAndOut(std::bind(&Clustering::start, &clu, std::placeholders::_1));
419+
callInAndOut(std::bind(&Clustering::start, &clu, std::placeholders::_1), "clustering");
420420
clu.sumup();
421421
}
422422

423423
void Data::analysis() {
424424
std::cout << helper::getTime() << "Start the Analysis of the Split Reads\n";
425425
Analysis ana(params);
426-
callInAndOut(std::bind(&Analysis::start, &ana, std::placeholders::_1, std::placeholders::_2));
426+
callInAndOut(std::bind(&Analysis::start, &ana, std::placeholders::_1, std::placeholders::_2), "analysis");
427427
// write file output files
428428
ana.writeAllInts();
429429
ana.writeAllIntsCounts();

src/ParameterValidation.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ ParameterValidation::ParameterValidation(po::variables_map& params) : params(par
1717

1818
} else if (subcall == "analysis") {
1919

20+
} else if (subcall == "complete") {
21+
2022
} else {
2123
std::cout << helper::getTime() << "Invalid subcall: " << subcall << "\n";
2224
exit(EXIT_FAILURE);

src/main.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,10 @@ int main(int argc, char* argv[]) {
223223
fs::path configFileDir = fs::path(configFile).parent_path();
224224
correctPaths(params, configFileDir);
225225

226+
// regular workflow
226227
Base base(params);
227228

229+
228230
} catch(po::error& e) {
229231
std::cerr << "ERROR: " << e.what() << "\n";
230232
}

0 commit comments

Comments
 (0)