diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 33433e1..a1de19b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -5,6 +5,8 @@ on: branches: [ master ] paths-ignore: - '**.md' + pull_request: + branches: [ master ] workflow_dispatch: jobs: @@ -27,6 +29,15 @@ jobs: run: | $EXE -k28 -ci1 -jstats.json $KMC_SINGLE_READ 28mers . cmp <(cat stats.json | grep '#Total no. of k-mers' | cut -f 2 -d ':' | cut -f 2 -d ' ' | cut -f 1 -d ',') <(echo "70") + + - name: small k, no counters + run: | + $EXE -k4 -cs1 -v $KMC_SINGLE_READ 4mers . + + - name: count k-mers from KMC1 database when small-k-opt may be applied + run: | + $EXE -k10 -v $KMC_SINGLE_READ 10mers . + $EXE -k9 -v -fkmc 10mers 9mers . macos-remote: name: macOS build (remote) diff --git a/kmc_core/binary_reader.h b/kmc_core/binary_reader.h index 9f157f2..0c310a8 100644 --- a/kmc_core/binary_reader.h +++ b/kmc_core/binary_reader.h @@ -339,13 +339,7 @@ class CBinaryFilesReader std::ostringstream ostr; ostr << "Cannot open KMC database: " << f_name; CCriticalErrorHandler::Inst().HandleCriticalError(ostr.str()); - } - if (!kmc_file.IsKMC2()) - { - std::ostringstream ostr; - ostr << "Error: currently only KMC databases in version 2 can be readed. If needed to read other version please post an GitHub issue."; - CCriticalErrorHandler::Inst().HandleCriticalError(ostr.str()); - } + } CKMCFileInfo info; kmc_file.Info(info); fsize = info.total_kmers; diff --git a/kmc_core/kb_completer.h b/kmc_core/kb_completer.h index 8d3733e..cf46043 100644 --- a/kmc_core/kb_completer.h +++ b/kmc_core/kb_completer.h @@ -160,7 +160,11 @@ bool CSmallKCompleter::CompleteKMCFormat(CSmallKBuf result) uint32 lut_buf_recs = (uint32)(MIN(lut_recs * sizeof(uint64), (uint64)mem_tot_small_k_completer / 2) / sizeof(uint64)); uint32 lut_buf_pos = 0; uint32 suf_size = (uint32)(mem_tot_small_k_completer - lut_buf_recs * sizeof(uint64)); - uint32 suf_recs = (uint32)(suf_size / (counter_size + kmer_suf_bytes) * (counter_size + kmer_suf_bytes)); + uint32 suf_recs; + if (counter_size + kmer_suf_bytes == 0) //fixes #178 + suf_recs = 0; + else + suf_recs = (uint32)(suf_size / (counter_size + kmer_suf_bytes) * (counter_size + kmer_suf_bytes)); uint32 suf_pos = 0; uint64* lut = (uint64*)raw_buffer; diff --git a/kmc_core/s_mapper.h b/kmc_core/s_mapper.h index 27d4a9b..1c777f3 100644 --- a/kmc_core/s_mapper.h +++ b/kmc_core/s_mapper.h @@ -44,7 +44,6 @@ class CSignatureMapper }; public: - void InitKMC(const std::string& path) { std::string pre_file_name = path + ".kmc_pre"; @@ -58,6 +57,16 @@ class CSignatureMapper my_fseek(file, 0, SEEK_END); + my_fseek(file, -12, SEEK_END); + uint32_t kmc_version; + fread(&kmc_version, sizeof(uint32), 1, file); + if (kmc_version != 0x200) + { + std::ostringstream ostr; + ostr << "currently only KMC databases in version 2 can be readed. If needed to read other version please post an GitHub issue."; + CCriticalErrorHandler::Inst().HandleCriticalError(ostr.str()); + } + uint32_t header_offset; my_fseek(file, -8, SEEK_END); fread(&header_offset, sizeof(uint32_t), 1, file);