Skip to content

Commit

Permalink
Stop computation if index parameter are different to index version.
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-steinegger committed Nov 29, 2018
1 parent 0030801 commit 4e23d5f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/commons/Parameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,7 @@ Parameters::Parameters():
// create index
indexdb.push_back(PARAM_SUB_MAT);
indexdb.push_back(PARAM_K);
indexdb.push_back(PARAM_NO_COMP_BIAS_CORR);
indexdb.push_back(PARAM_ALPH_SIZE);
indexdb.push_back(PARAM_MAX_SEQS);
indexdb.push_back(PARAM_MAX_SEQ_LEN);
Expand Down
32 changes: 32 additions & 0 deletions src/prefiltering/Prefiltering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,37 @@ Prefiltering::Prefiltering(const std::string &targetDB,
tdbr = PrefilteringIndexReader::openNewReader(tdbr, false, touch);
PrefilteringIndexReader::printSummary(tidxdbr);
PrefilteringIndexData data = PrefilteringIndexReader::getMetadata(tidxdbr);
for(size_t i = 0; i < par.prefilter.size(); i++){
if(par.prefilter[i].wasSet && par.prefilter[i].uniqid == par.PARAM_K.uniqid){
if(kmerSize != 0 && data.kmerSize != kmerSize){
Debug(Debug::ERROR) << "Index was created with -k " << data.kmerSize << " but the prefilter was called with -k" << kmerSize << "!\n";
Debug(Debug::ERROR) << "createindex -k " << kmerSize << "\n";
EXIT(EXIT_FAILURE);
}
}
if(par.prefilter[i].wasSet && par.prefilter[i].uniqid == par.PARAM_ALPH_SIZE.uniqid){
if(data.alphabetSize != alphabetSize){
Debug(Debug::ERROR) << "Index was created with --alph-size " << data.alphabetSize << " but the prefilter was called with --alph-size " << alphabetSize << "!\n";
Debug(Debug::ERROR) << "createindex --alph-size " << alphabetSize << "\n";
EXIT(EXIT_FAILURE);
}
}
if(par.prefilter[i].wasSet && par.prefilter[i].uniqid == par.PARAM_SPACED_KMER_MODE.uniqid){
if(data.spacedKmer != spacedKmer){
Debug(Debug::ERROR) << "Index was created with --spaced-kmer-mode " << data.spacedKmer << " but the prefilter was called with --spaced-kmer-mode " << spacedKmer << "!\n";
Debug(Debug::ERROR) << "createindex --spaced-kmer-mode " << spacedKmer << "\n";
EXIT(EXIT_FAILURE);
}
}
if(par.prefilter[i].wasSet && par.prefilter[i].uniqid == par.PARAM_NO_COMP_BIAS_CORR.uniqid){
if(data.compBiasCorr != aaBiasCorrection){
Debug(Debug::ERROR) << "Index was created with --comp-bias-corr " << data.compBiasCorr <<" please recreate index with --comp-bias-corr " << aaBiasCorrection << "!\n";
Debug(Debug::ERROR) << "createindex --comp-bias-corr " << aaBiasCorrection << "\n";
EXIT(EXIT_FAILURE);
}
}
}

kmerSize = data.kmerSize;
alphabetSize = data.alphabetSize;
targetSeqType = data.seqType;
Expand Down Expand Up @@ -1121,3 +1152,4 @@ std::pair<int, int> Prefiltering::optimizeSplit(size_t totalMemoryInByte, DBRead
return std::make_pair(-1, -1);
}


0 comments on commit 4e23d5f

Please sign in to comment.