Skip to content

Commit

Permalink
Removed deadlock in the -multisample-fasta mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
agudys authored Mar 6, 2023
1 parent 1d60933 commit 04f2dd4
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ Parameters:
* `common_table` (output) - file containing table with common k-mer counts.
* `-multisample-fasta` / `-from-kmers` / `-from-minhash` - see `build` mode for details.
* `-sparse` - stores output matrix in a sparse form,
* `-above <a_th>` - retains elements larger then <a_th>,
* `-below <b_th>` - retains elements smaller then <b_th>,
* `-t <threads>` - number of threads (default: number of available cores).

### Single sample against the database:
Expand Down
8 changes: 2 additions & 6 deletions src/input_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,6 @@ bool GenomeInputFile::loadNext(
std::string& sampleName
) {

// no more sequences in multifasta
if (multifastaIndex == chromosomes.size()) {
return false;
}

std::shared_ptr<MinHashFilter> minhashFilter = dynamic_pointer_cast<MinHashFilter>(filter);

if (!minhashFilter) {
Expand All @@ -219,7 +214,8 @@ bool GenomeInputFile::loadNext(

++multifastaIndex;

return true;
// no more sequences in multifasta
return multifastaIndex < chromosomes.size();
}


Expand Down
17 changes: 9 additions & 8 deletions src/loader_ex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,12 @@ void LoaderEx::multifastaReaderJob() {
// initialize multifasta file
if (genomicFile->initMultiFasta()) {

LOG_DEBUG << "multifasta initialized " << endl ;
LOG_DEBUG << "multifasta initialized: " << inputTask->fileId + 1 << endl ;

while (true) {

LOG_DEBUG << "wait for buf for sample " << sample_id + 1 << endl;
this->queues.freeBuffers.Pop(bufferId); // wait for free buffer
LOG_DEBUG << "acquired buf " << bufferId << " for sample " << sample_id + 1 << endl;

auto sampleTask = make_shared<SampleTask>(
sample_id,
Expand All @@ -207,17 +208,17 @@ void LoaderEx::multifastaReaderJob() {
kmersCollections[bufferId], positionsCollections[bufferId],
sampleTask->kmers, sampleTask->kmersCount, sampleTask->kmerLength, sampleTask->fraction, sampleTask->sampleName);

// no more samples
if (!ok) {
break;
}

++sample_id;
++bufferRefCounters[bufferId];
queues.output.Push((int)sampleTask->id, sampleTask);
++count;

LOG_DEBUG << "(sample " << sampleTask->id + 1 << ") -> output queue, buf: " << bufferId << std::endl ;
LOG_DEBUG << "(sample " << sampleTask->id + 1 << ") -> output queue, buf: " << bufferId << std::endl;

// no more samples
if (!ok) {
break;
}
}
}

Expand Down
7 changes: 5 additions & 2 deletions src/version.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
#pragma once

#define VERSION "1.11.0"
#define DATE "27.02.2023"
#define VERSION "1.11.1"
#define DATE "07.03.2023"

/*
Version history
1.11.1 (07.03.2023)
- Removed deadlock in the -multisample-fasta mode.
1.11.0 (27.02.2023)
- Added -below and -above thresholds for all2all and new2all modes.
Expand Down

0 comments on commit 04f2dd4

Please sign in to comment.