diff --git a/CHANGELOG.md b/CHANGELOG.md index ee20bc3..459bcc4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +# [0.2.4] + +## Fix + +- Added lock guard for when writing progress (processed reads) to std::cout to ensure threads do not write over each other +- Fixed bug/added check when no control data is provided + # [0.2.3] ## Fix diff --git a/src/Data.cpp b/src/Data.cpp index 5009ef7..1548fb1 100644 --- a/src/Data.cpp +++ b/src/Data.cpp @@ -45,7 +45,10 @@ void Data::alignDataPrep() { } else { // make sure that data has been preprocessed (or at least selected) if(params["preproc"].as>() == std::bitset<1>("1")) { - fs::path ctrlsPath = fs::path(params["outdir"].as()) / "preproc/ctrls"; + fs::path ctrlsPath = ""; + if(params["ctrls"].as() != "") { + ctrlsPath = fs::path(params["outdir"].as()) / "preproc/ctrls"; + } fs::path trtmsPath = fs::path(params["outdir"].as()) / "preproc/trtms"; /* @@ -59,7 +62,10 @@ void Data::alignDataPrep() { } void Data::detectDataPrep() { - fs::path ctrlsPath = fs::path(params["outdir"].as()) / "align/ctrls"; + fs::path ctrlsPath = ""; + if(params["ctrls"].as() != "") { + ctrlsPath = fs::path(params["outdir"].as()) / "align/ctrls"; + } fs::path trtmsPath = fs::path(params["outdir"].as()) / "align/trtms"; GroupsPath groups = getGroupsPath(ctrlsPath, trtmsPath); @@ -67,7 +73,10 @@ void Data::detectDataPrep() { } void Data::clusteringDataPrep() { -fs::path ctrlsPath = fs::path(params["outdir"].as()) / "detect/ctrls"; + fs::path ctrlsPath = ""; + if(params["ctrls"].as() != "") { + ctrlsPath = fs::path(params["outdir"].as()) / "detect/ctrls"; + } fs::path trtmsPath = fs::path(params["outdir"].as()) / "detect/trtms"; GroupsPath groups = getGroupsPath(ctrlsPath, trtmsPath); @@ -75,7 +84,10 @@ fs::path ctrlsPath = fs::path(params["outdir"].as()) / "detect/ctrl } void Data::analysisDataPrep() { - fs::path ctrlsPath = fs::path(params["outdir"].as()) / "detect/ctrls"; + fs::path ctrlsPath = ""; + if(params["ctrls"].as() != "") { + ctrlsPath = fs::path(params["outdir"].as()) / "detect/ctrls"; + } fs::path trtmsPath = fs::path(params["outdir"].as()) / "detect/trtms"; GroupsPath groups = getGroupsPath(ctrlsPath, trtmsPath); @@ -133,7 +145,7 @@ void Data::getCondition(GroupsPath& groups) { exit(EXIT_FAILURE); } } else { - std::cout << helper::getTime() << "### ERROR - " << group.second << " has not been found in the filesystem!\n"; + std::cout << "has not been found in the filesystem! ### ERROR### \n"; exit(EXIT_FAILURE); } } diff --git a/src/Preproc.cpp b/src/Preproc.cpp index 75fdd96..89b80a5 100644 --- a/src/Preproc.cpp +++ b/src/Preproc.cpp @@ -17,7 +17,7 @@ Preproc::~Preproc() {} void Preproc::processing(fs::path& in, fs::path& out) { std::cout << helper::getTime() << "Trimming on sample: " << in << "\n"; - std::mutex inMutex, outMutex; // + std::mutex inMutex, outMutex, progressMutex; // seqan3::sequence_file_input fin{in.string()}; seqan3::sequence_file_output fout{out.string()}; @@ -28,6 +28,7 @@ void Preproc::processing(fs::path& in, fs::path& out) { for (auto & record : reads) { if(readcount != 0 && readcount % 100000 == 0) { + std::lock_guard lock(progressMutex); std::cout << "\r" << helper::getTime() << readcount << " reads processed " << std::flush; } readcount++; @@ -81,7 +82,7 @@ void Preproc::processing(fs::path& inFwd, fs::path& outFwd, fs::path& inRev, fs: seqan3::sequence_file_output outR1unmrgSeq{outR1unmerged.string()}; seqan3::sequence_file_output outR2unmrgSeq{outR2unmerged.string()}; - std::mutex outMutex; + std::mutex outMutex, progressMutex; int readcount = 0; auto inFwdSeqBuf = inFwdSeq | seqan3::views::async_input_buffer(100); @@ -93,6 +94,7 @@ void Preproc::processing(fs::path& inFwd, fs::path& outFwd, fs::path& inRev, fs: dtp::QualVector qualFwd, qualRev; if(readcount != 0 && readcount % 100000 == 0) { + std::lock_guard lock(progressMutex); std::cout << "\r" << helper::getTime() << "Processed reads: " << readcount << std::flush; } readcount++;