From f740aa67620f53e482a3575d5c2b1e488c78c968 Mon Sep 17 00:00:00 2001 From: Martin Steinegger Date: Mon, 13 Jan 2025 00:01:16 +0900 Subject: [PATCH] Squashed 'lib/mmseqs/' changes from a53cf9159..73b2244de 73b2244de Improve no k-mer index handling git-subtree-dir: lib/mmseqs git-subtree-split: 73b2244de323d9a1ddbfeedfa3ed7d5fd919f6e0 --- src/prefiltering/IndexBuilder.cpp | 75 +++++++++++++++---------------- 1 file changed, 37 insertions(+), 38 deletions(-) diff --git a/src/prefiltering/IndexBuilder.cpp b/src/prefiltering/IndexBuilder.cpp index 685a0635..57d81ec1 100644 --- a/src/prefiltering/IndexBuilder.cpp +++ b/src/prefiltering/IndexBuilder.cpp @@ -180,55 +180,54 @@ void IndexBuilder::fillDatabase(IndexTable *indexTable, SequenceLookup ** extern } delete info; - Debug::Progress progress2(dbTo-dbFrom); - - Debug(Debug::INFO) << "Index table: fill\n"; - #pragma omp parallel - { - unsigned int thread_idx = 0; + if(indexTable != NULL) { + Debug::Progress progress2(dbTo - dbFrom); + Debug(Debug::INFO) << "Index table: fill\n"; +#pragma omp parallel + { + unsigned int thread_idx = 0; #ifdef OPENMP - thread_idx = static_cast(omp_get_thread_num()); + thread_idx = static_cast(omp_get_thread_num()); #endif - Sequence s(seq->getMaxLen(), seq->getSeqType(), &subMat, seq->getKmerSize(), seq->isSpaced(), false, true, seq->getUserSpacedKmerPattern()); - unsigned int alphabetSize = (indexTable != NULL) ? static_cast(indexTable->getAlphabetSize()) - : static_cast(subMat.alphabetSize); - Indexer idxer(alphabetSize, seq->getKmerSize()); - IndexEntryLocalTmp *buffer = static_cast(malloc( seq->getMaxLen() * sizeof(IndexEntryLocalTmp))); - size_t bufferSize = seq->getMaxLen(); - KmerGenerator *generator = NULL; - if (isTargetSimiliarKmerSearch) { - generator = new KmerGenerator(seq->getKmerSize(), indexTable->getAlphabetSize(), kmerThr); - if(isProfile){ - generator->setDivideStrategy(s.profile_matrix); - }else{ - generator->setDivideStrategy(&three, &two); + Sequence s(seq->getMaxLen(), seq->getSeqType(), &subMat, seq->getKmerSize(), seq->isSpaced(), false, true, + seq->getUserSpacedKmerPattern()); + unsigned int alphabetSize = (indexTable != NULL) ? static_cast(indexTable->getAlphabetSize()) + : static_cast(subMat.alphabetSize); + Indexer idxer(alphabetSize, seq->getKmerSize()); + IndexEntryLocalTmp *buffer = static_cast(malloc( + seq->getMaxLen() * sizeof(IndexEntryLocalTmp))); + size_t bufferSize = seq->getMaxLen(); + KmerGenerator *generator = NULL; + if (isTargetSimiliarKmerSearch) { + generator = new KmerGenerator(seq->getKmerSize(), indexTable->getAlphabetSize(), kmerThr); + if (isProfile) { + generator->setDivideStrategy(s.profile_matrix); + } else { + generator->setDivideStrategy(&three, &two); + } } - } - #pragma omp for schedule(dynamic, 100) - for (size_t id = dbFrom; id < dbTo; id++) { - s.resetCurrPos(); - progress2.updateProgress(); +#pragma omp for schedule(dynamic, 100) + for (size_t id = dbFrom; id < dbTo; id++) { + s.resetCurrPos(); + progress2.updateProgress(); - unsigned int qKey = dbr->getDbKey(id); - if (isTargetSimiliarKmerSearch) { - s.mapSequence(id - dbFrom, qKey, dbr->getData(id, thread_idx), dbr->getSeqLen(id)); - if(indexTable != NULL) { + unsigned int qKey = dbr->getDbKey(id); + if (isTargetSimiliarKmerSearch) { + s.mapSequence(id - dbFrom, qKey, dbr->getData(id, thread_idx), dbr->getSeqLen(id)); indexTable->addSimilarSequence(&s, generator, &buffer, bufferSize, &idxer); - } - } else { - s.mapSequence(id - dbFrom, qKey, sequenceLookup->getSequence(id - dbFrom)); - if(indexTable != NULL) { + } else { + s.mapSequence(id - dbFrom, qKey, sequenceLookup->getSequence(id - dbFrom)); indexTable->addSequence(&s, &idxer, &buffer, bufferSize, kmerThr, idScoreLookup); } } - } - if (generator != NULL) { - delete generator; - } + if (generator != NULL) { + delete generator; + } - free(buffer); + free(buffer); + } } if(idScoreLookup!=NULL){ delete[] idScoreLookup;