From 4e23d5f1d13a435c7b6c9406137ed68ce297e0fc Mon Sep 17 00:00:00 2001 From: Martin Steinegger Date: Thu, 29 Nov 2018 17:07:27 -0500 Subject: [PATCH] Stop computation if index parameter are different to index version. --- src/commons/Parameters.cpp | 1 + src/prefiltering/Prefiltering.cpp | 32 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/src/commons/Parameters.cpp b/src/commons/Parameters.cpp index 15fcfc7d4..f0bb82eac 100644 --- a/src/commons/Parameters.cpp +++ b/src/commons/Parameters.cpp @@ -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); diff --git a/src/prefiltering/Prefiltering.cpp b/src/prefiltering/Prefiltering.cpp index 2678f0b24..626e684b7 100644 --- a/src/prefiltering/Prefiltering.cpp +++ b/src/prefiltering/Prefiltering.cpp @@ -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; @@ -1121,3 +1152,4 @@ std::pair Prefiltering::optimizeSplit(size_t totalMemoryInByte, DBRead return std::make_pair(-1, -1); } +