Skip to content

Commit

Permalink
Kmc db input fixes (#14)
Browse files Browse the repository at this point in the history
Fixes #178 and #179
  • Loading branch information
marekkokot authored Jan 3, 2022
1 parent cc843b8 commit 61ee8d8
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:
branches: [ master ]
paths-ignore:
- '**.md'
pull_request:
branches: [ master ]
workflow_dispatch:

jobs:
Expand All @@ -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)
Expand Down
8 changes: 1 addition & 7 deletions kmc_core/binary_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 5 additions & 1 deletion kmc_core/kb_completer.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,11 @@ bool CSmallKCompleter::CompleteKMCFormat(CSmallKBuf<COUNTER_TYPE> 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;
Expand Down
11 changes: 10 additions & 1 deletion kmc_core/s_mapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class CSignatureMapper
};

public:

void InitKMC(const std::string& path)
{
std::string pre_file_name = path + ".kmc_pre";
Expand All @@ -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);
Expand Down

0 comments on commit 61ee8d8

Please sign in to comment.