@@ -36,6 +36,7 @@ int result2msa(int argc, const char **argv, const Command &command) {
3636 IndexReader *tDbrIdx = NULL ;
3737 DBReader<unsigned int > *targetHeaderReader = NULL ;
3838 IndexReader *targetHeaderReaderIdx = NULL ;
39+ const bool sameDatabase = (par.db1 .compare (par.db2 ) == 0 ) ? true : false ;
3940
4041 if (Parameters::isEqualDbtype (FileUtil::parseDbType (par.db2 .c_str ()), Parameters::DBTYPE_INDEX_DB)) {
4142 if (isCA3M == true ) {
@@ -58,7 +59,7 @@ int result2msa(int argc, const char **argv, const Command &command) {
5859 if (par.preloadMode != Parameters::PRELOAD_MODE_MMAP) {
5960 tDbr->readMmapedDataInMemory ();
6061 }
61- if (isCA3M == false ) {
62+ if (isCA3M == false || sameDatabase ) {
6263 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);
6364 targetHeaderReader->open (DBReader<unsigned int >::NOSORT);
6465 if (par.preloadMode != Parameters::PRELOAD_MODE_MMAP) {
@@ -69,7 +70,6 @@ int result2msa(int argc, const char **argv, const Command &command) {
6970
7071 DBReader<unsigned int > *qDbr = NULL ;
7172 DBReader<unsigned int > *queryHeaderReader = NULL ;
72- const bool sameDatabase = (par.db1 .compare (par.db2 ) == 0 ) ? true : false ;
7373 if (!sameDatabase) {
7474 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);
7575 qDbr->open (DBReader<unsigned int >::NOSORT);
@@ -209,15 +209,13 @@ int result2msa(int argc, const char **argv, const Command &command) {
209209#pragma omp for schedule(dynamic, 10)
210210 for (size_t id = dbFrom; id < (dbFrom + dbSize); id++) {
211211 progress.updateProgress ();
212-
213212 unsigned int queryKey = resultReader.getDbKey (id);
214213 size_t queryId = qDbr->getId (queryKey);
215214 if (queryId == UINT_MAX) {
216215 Debug (Debug::WARNING) << " Invalid query sequence " << queryKey << " \n " ;
217216 continue ;
218217 }
219218 centerSequence.mapSequence (queryId, queryKey, qDbr->getData (queryId, thread_idx), qDbr->getSeqLen (queryId));
220-
221219 // TODO: Do we still need this?
222220// if (centerSequence.L) {
223221// // remove last in it is a *
@@ -231,18 +229,19 @@ int result2msa(int argc, const char **argv, const Command &command) {
231229 Debug (Debug::WARNING) << " Invalid query header " << queryKey << " \n " ;
232230 continue ;
233231 }
232+
234233 char *centerSequenceHeader = queryHeaderReader->getData (centerHeaderId, thread_idx);
235234 size_t centerHeaderLength = queryHeaderReader->getEntryLen (centerHeaderId) - 1 ;
236235
237236 if (par.msaFormatMode == Parameters::FORMAT_MSA_STOCKHOLM_FLAT) {
238237 accession = Util::parseFastaHeader (centerSequenceHeader);
239238 }
240239
241-
242240 bool isQueryInit = false ;
243241 char *data = resultReader.getData (id, thread_idx);
244242 while (*data != ' \0 ' ) {
245243 Util::parseKey (data, dbKey);
244+
246245 const unsigned int key = (unsigned int ) strtoul (dbKey, NULL , 10 );
247246 // in the same database case, we have the query repeated
248247 if (key == queryKey && sameDatabase == true ) {
@@ -520,7 +519,6 @@ int result2msa(int argc, const char **argv, const Command &command) {
520519 }
521520 result.append (" \n ;" );
522521 }
523-
524522 Matcher::result_t queryAln;
525523 unsigned int newQueryKey = seqConcat->dbAKeyMap (queryKey);
526524 queryAln.qStartPos = 0 ;
0 commit comments