Skip to content

Commit

Permalink
ca3m segfault same db
Browse files Browse the repository at this point in the history
  • Loading branch information
ClovisG committed Jun 29, 2023
1 parent 2568829 commit f5f780a
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/util/result2msa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ int result2msa(int argc, const char **argv, const Command &command) {
IndexReader *tDbrIdx = NULL;
DBReader<unsigned int> *targetHeaderReader = NULL;
IndexReader *targetHeaderReaderIdx = NULL;
const bool sameDatabase = (par.db1.compare(par.db2) == 0) ? true : false;

if (Parameters::isEqualDbtype(FileUtil::parseDbType(par.db2.c_str()), Parameters::DBTYPE_INDEX_DB)) {
if (isCA3M == true) {
Expand All @@ -58,7 +59,7 @@ int result2msa(int argc, const char **argv, const Command &command) {
if (par.preloadMode != Parameters::PRELOAD_MODE_MMAP) {
tDbr->readMmapedDataInMemory();
}
if (isCA3M == false) {
if (isCA3M == false || sameDatabase) {
targetHeaderReader = new DBReader<unsigned int>(par.hdr2.c_str(), par.hdr2Index.c_str(), par.threads, DBReader<unsigned int>::USE_INDEX | DBReader<unsigned int>::USE_DATA);
targetHeaderReader->open(DBReader<unsigned int>::NOSORT);
if (par.preloadMode != Parameters::PRELOAD_MODE_MMAP) {
Expand All @@ -69,7 +70,6 @@ int result2msa(int argc, const char **argv, const Command &command) {

DBReader<unsigned int> *qDbr = NULL;
DBReader<unsigned int> *queryHeaderReader = NULL;
const bool sameDatabase = (par.db1.compare(par.db2) == 0) ? true : false;
if (!sameDatabase) {
qDbr = new DBReader<unsigned int>(par.db1.c_str(), par.db1Index.c_str(), par.threads, DBReader<unsigned int>::USE_INDEX | DBReader<unsigned int>::USE_DATA);
qDbr->open(DBReader<unsigned int>::NOSORT);
Expand Down Expand Up @@ -209,15 +209,13 @@ int result2msa(int argc, const char **argv, const Command &command) {
#pragma omp for schedule(dynamic, 10)
for (size_t id = dbFrom; id < (dbFrom + dbSize); id++) {
progress.updateProgress();

unsigned int queryKey = resultReader.getDbKey(id);
size_t queryId = qDbr->getId(queryKey);
if (queryId == UINT_MAX) {
Debug(Debug::WARNING) << "Invalid query sequence " << queryKey << "\n";
continue;
}
centerSequence.mapSequence(queryId, queryKey, qDbr->getData(queryId, thread_idx), qDbr->getSeqLen(queryId));

// TODO: Do we still need this?
// if (centerSequence.L) {
// // remove last in it is a *
Expand All @@ -231,18 +229,19 @@ int result2msa(int argc, const char **argv, const Command &command) {
Debug(Debug::WARNING) << "Invalid query header " << queryKey << "\n";
continue;
}

char *centerSequenceHeader = queryHeaderReader->getData(centerHeaderId, thread_idx);
size_t centerHeaderLength = queryHeaderReader->getEntryLen(centerHeaderId) - 1;

if (par.msaFormatMode == Parameters::FORMAT_MSA_STOCKHOLM_FLAT) {
accession = Util::parseFastaHeader(centerSequenceHeader);
}


bool isQueryInit = false;
char *data = resultReader.getData(id, thread_idx);
while (*data != '\0') {
Util::parseKey(data, dbKey);

const unsigned int key = (unsigned int) strtoul(dbKey, NULL, 10);
// in the same database case, we have the query repeated
if (key == queryKey && sameDatabase == true) {
Expand Down Expand Up @@ -520,7 +519,6 @@ int result2msa(int argc, const char **argv, const Command &command) {
}
result.append("\n;");
}

Matcher::result_t queryAln;
unsigned int newQueryKey = seqConcat->dbAKeyMap(queryKey);
queryAln.qStartPos = 0;
Expand Down

0 comments on commit f5f780a

Please sign in to comment.