Skip to content

Commit

Permalink
resolved issue when no ctrls data are provided
Browse files Browse the repository at this point in the history
  • Loading branch information
riasc committed Jun 27, 2024
1 parent 49b6cea commit 86bc60e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 17 additions & 5 deletions src/Data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>>() == std::bitset<1>("1")) {
fs::path ctrlsPath = fs::path(params["outdir"].as<std::string>()) / "preproc/ctrls";
fs::path ctrlsPath = "";
if(params["ctrls"].as<std::string>() != "") {
ctrlsPath = fs::path(params["outdir"].as<std::string>()) / "preproc/ctrls";
}
fs::path trtmsPath = fs::path(params["outdir"].as<std::string>()) / "preproc/trtms";

/*
Expand All @@ -59,23 +62,32 @@ void Data::alignDataPrep() {
}

void Data::detectDataPrep() {
fs::path ctrlsPath = fs::path(params["outdir"].as<std::string>()) / "align/ctrls";
fs::path ctrlsPath = "";
if(params["ctrls"].as<std::string>() != "") {
ctrlsPath = fs::path(params["outdir"].as<std::string>()) / "align/ctrls";
}
fs::path trtmsPath = fs::path(params["outdir"].as<std::string>()) / "align/trtms";

GroupsPath groups = getGroupsPath(ctrlsPath, trtmsPath);
getCondition(groups);
}

void Data::clusteringDataPrep() {
fs::path ctrlsPath = fs::path(params["outdir"].as<std::string>()) / "detect/ctrls";
fs::path ctrlsPath = "";
if(params["ctrls"].as<std::string>() != "") {
ctrlsPath = fs::path(params["outdir"].as<std::string>()) / "detect/ctrls";
}
fs::path trtmsPath = fs::path(params["outdir"].as<std::string>()) / "detect/trtms";

GroupsPath groups = getGroupsPath(ctrlsPath, trtmsPath);
getCondition(groups);
}

void Data::analysisDataPrep() {
fs::path ctrlsPath = fs::path(params["outdir"].as<std::string>()) / "detect/ctrls";
fs::path ctrlsPath = "";
if(params["ctrls"].as<std::string>() != "") {
ctrlsPath = fs::path(params["outdir"].as<std::string>()) / "detect/ctrls";
}
fs::path trtmsPath = fs::path(params["outdir"].as<std::string>()) / "detect/trtms";

GroupsPath groups = getGroupsPath(ctrlsPath, trtmsPath);
Expand Down Expand Up @@ -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);
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/Preproc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()};

Expand All @@ -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<std::mutex> lock(progressMutex);
std::cout << "\r" << helper::getTime() << readcount << " reads processed " << std::flush;
}
readcount++;
Expand Down Expand Up @@ -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);
Expand All @@ -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<std::mutex> lock(progressMutex);
std::cout << "\r" << helper::getTime() << "Processed reads: " << readcount << std::flush;
}
readcount++;
Expand Down

0 comments on commit 86bc60e

Please sign in to comment.