Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Enable automatic detecting and loading all filter/sketch types #1717

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions include/oxli/oxli.hh
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,20 @@ private:\

# define SAVED_SIGNATURE "OXLI"
# define SAVED_FORMAT_VERSION 4
# define SAVED_COUNTING_HT 1
# define SAVED_HASHBITS 2
# define SAVED_TAGS 3
# define SAVED_STOPTAGS 4
# define SAVED_SUBSET 5
# define SAVED_LABELSET 6
# define SAVED_SMALLCOUNT 7

typedef enum saved_sketch_type {
SAVED_NODETABLE,
SAVED_COUNTTABLE,
SAVED_SMALLCOUNTTABLE,
// The following are set explicitly for backwards compatibility
SAVED_NODEGRAPH = 2,
SAVED_COUNTGRAPH = 1,
SAVED_SMALLCOUNTGRAPH = 7
} saved_sketch_type;

# define TRAVERSAL_LEFT 0
# define TRAVERSAL_RIGHT 1
Expand Down
6 changes: 3 additions & 3 deletions src/khmer/_cpy_khmer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -350,13 +350,13 @@ MOD_INIT(_khmer)
}

PyObject * filetype_dict = Py_BuildValue("{s,i,s,i,s,i,s,i,s,i,s,i,s,i}",
"COUNTING_HT", SAVED_COUNTING_HT,
"HASHBITS", SAVED_HASHBITS,
"COUNTING_HT", SAVED_COUNTGRAPH,
"HASHBITS", SAVED_NODEGRAPH,
"TAGS", SAVED_TAGS,
"STOPTAGS", SAVED_STOPTAGS,
"SUBSET", SAVED_SUBSET,
"LABELSET", SAVED_LABELSET,
"SMALLCOUNT", SAVED_SMALLCOUNT);
"SMALLCOUNT", SAVED_SMALLCOUNTGRAPH);
if (PyModule_AddObject( m, "FILETYPES", filetype_dict ) < 0) {
return MOD_ERROR_VAL;
}
Expand Down
18 changes: 9 additions & 9 deletions src/oxli/storage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ void BitStorage::save(std::string outfilename, WordLength ksize)
unsigned char version = SAVED_FORMAT_VERSION;
outfile.write((const char *) &version, 1);

unsigned char ht_type = SAVED_HASHBITS;
unsigned char ht_type = SAVED_NODEGRAPH;
outfile.write((const char *) &ht_type, 1);

outfile.write((const char *) &save_ksize, sizeof(save_ksize));
Expand Down Expand Up @@ -200,7 +200,7 @@ void BitStorage::load(std::string infilename, WordLength &ksize)
<< " while reading k-mer graph from " << infilename
<< "; should be " << (int) SAVED_FORMAT_VERSION;
throw oxli_file_exception(err.str());
} else if (!(ht_type == SAVED_HASHBITS)) {
} else if (!(ht_type == SAVED_NODEGRAPH)) {
std::ostringstream err;
err << "Incorrect file format type " << (int) ht_type
<< " while reading k-mer graph from " << infilename;
Expand Down Expand Up @@ -330,7 +330,7 @@ ByteStorageFileReader::ByteStorageFileReader(
<< " while reading k-mer count file from " << infilename
<< "; should be " << (int) SAVED_FORMAT_VERSION;
throw oxli_file_exception(err.str());
} else if (!(ht_type == SAVED_COUNTING_HT)) {
} else if (!(ht_type == SAVED_COUNTGRAPH)) {
std::ostringstream err;
err << "Incorrect file format type " << (int) ht_type
<< " while reading k-mer count file from " << infilename;
Expand Down Expand Up @@ -446,15 +446,15 @@ ByteStorageGzFileReader::ByteStorageGzFileReader(
SAVED_SIGNATURE;
throw oxli_file_exception(err.str());
} else if (!(version == SAVED_FORMAT_VERSION)
|| !(ht_type == SAVED_COUNTING_HT)) {
|| !(ht_type == SAVED_COUNTGRAPH)) {
if (!(version == SAVED_FORMAT_VERSION)) {
std::ostringstream err;
err << "Incorrect file format version " << (int) version
<< " while reading k-mer count file from " << infilename
<< "; should be " << (int) SAVED_FORMAT_VERSION;
gzclose(infile);
throw oxli_file_exception(err.str());
} else if (!(ht_type == SAVED_COUNTING_HT)) {
} else if (!(ht_type == SAVED_COUNTGRAPH)) {
std::ostringstream err;
err << "Incorrect file format type " << (int) ht_type
<< " while reading k-mer count file from " << infilename;
Expand Down Expand Up @@ -599,7 +599,7 @@ ByteStorageFileWriter::ByteStorageFileWriter(
unsigned char version = SAVED_FORMAT_VERSION;
outfile.write((const char *) &version, 1);

unsigned char ht_type = SAVED_COUNTING_HT;
unsigned char ht_type = SAVED_COUNTGRAPH;
outfile.write((const char *) &ht_type, 1);

unsigned char use_bigcount = 0;
Expand Down Expand Up @@ -666,7 +666,7 @@ ByteStorageGzFileWriter::ByteStorageGzFileWriter(
unsigned char version = SAVED_FORMAT_VERSION;
gzwrite(outfile, (const char *) &version, 1);

unsigned char ht_type = SAVED_COUNTING_HT;
unsigned char ht_type = SAVED_COUNTGRAPH;
gzwrite(outfile, (const char *) &ht_type, 1);

unsigned char use_bigcount = 0;
Expand Down Expand Up @@ -786,7 +786,7 @@ void NibbleStorage::save(std::string outfilename, WordLength ksize)
unsigned char version = SAVED_FORMAT_VERSION;
outfile.write((const char *) &version, 1);

unsigned char ht_type = SAVED_SMALLCOUNT;
unsigned char ht_type = SAVED_SMALLCOUNTGRAPH;
outfile.write((const char *) &ht_type, 1);

outfile.write((const char *) &save_ksize, sizeof(save_ksize));
Expand Down Expand Up @@ -860,7 +860,7 @@ void NibbleStorage::load(std::string infilename, WordLength& ksize)
<< " while reading k-mer count file from " << infilename
<< "; should be " << (int) SAVED_FORMAT_VERSION;
throw oxli_file_exception(err.str());
} else if (!(ht_type == SAVED_SMALLCOUNT)) {
} else if (!(ht_type == SAVED_SMALLCOUNTGRAPH)) {
std::ostringstream err;
err << "Incorrect file format type " << (int) ht_type
<< " while reading k-mer count file from " << infilename;
Expand Down