Skip to content
Snippets Groups Projects
Commit bd587ede authored by Martin Larralde's avatar Martin Larralde
Browse files

Expose additional private fields of `skch::Sketch` in Cython headers

parent bc8967c2
No related branches found
No related tags found
No related merge requests found
from libc.stdint cimport uint64_t
from libcpp.string cimport string
from libcpp.vector cimport vector
from fastani.map.base_types cimport hash_t, seqno_t
cdef extern from "map/include/commonFunc.hpp" namespace "skch::CommonFunc" nogil:
cdef int seed
void reverseComplement(const char * src, char * dest, int length)
hash_t getHash(const char * seq, int length)
void addMinimizers[T, KSEQ](
vector[T] &minimizerIndex,
KSEQ kseq,
int kmerSize,
int windowSize,
int alphabetSize,
seqno_t seqCounter
)
uint64_t getReferenceSize(const vector[string] &refSequences)
void ltrim(string &s)
void rtrim(string &s)
void trim(string &s)
cimport libcpp11.iostream
from libcpp.map cimport map
from libcpp.unordered_map cimport unordered_map
from libcpp.vector cimport vector
......@@ -15,18 +16,47 @@ from fastani.map.map_parameters cimport Parameters
cdef extern from "map/include/winSketch.hpp" namespace "skch" nogil:
cdef cppclass Sketch:
IF FASTANI_PRIVATE_ACCESS:
ctypedef vector[MinimizerInfo].const_iterator MIIter_t
ctypedef unordered_map[MinimizerMapKeyType, MinimizerMapValueType] MI_Map_t
ctypedef vector[MinimizerInfo] MI_Type
cdef cppclass Sketch:
vector[ContigInfo] metadata
vector[seqno_t] sequencesByFileInfo
MI_Map_t minimizerPosLookupIndex
ctypedef vector[MinimizerInfo].const_iterator MIIter_t
ctypedef unordered_map[MinimizerMapKeyType, MinimizerMapValueType] MI_Map_t
ctypedef vector[MinimizerInfo] MI_Type
Sketch(const Parameters &p)
float percentageThreshold # private
int freqThreshold # private
Parameters& param # private
MI_Type minimizerIndex # private
map[int, int] minimizerFreqHistogram # private
vector[ContigInfo] metadata
vector[seqno_t] sequencesByFileInfo
MI_Map_t minimizerPosLookupIndex
int getFreqThreshold()
MIIter_t searchIndex(seqno_t seqId, offset_t winpos)
MIIter_t getMinimizerIndexEnd()
Sketch() # private
Sketch(const Parameters &p)
void build() # private
void index() # private
void computeFreqHist() # private
int getFreqThreshold()
MIIter_t searchIndex(seqno_t seqId, offset_t winpos)
MIIter_t getMinimizerIndexEnd()
ELSE:
cdef cppclass Sketch:
ctypedef vector[MinimizerInfo].const_iterator MIIter_t
ctypedef unordered_map[MinimizerMapKeyType, MinimizerMapValueType] MI_Map_t
ctypedef vector[MinimizerInfo] MI_Type
vector[ContigInfo] metadata
vector[seqno_t] sequencesByFileInfo
MI_Map_t minimizerPosLookupIndex
Sketch(const Parameters &p)
int getFreqThreshold()
MIIter_t searchIndex(seqno_t seqId, offset_t winpos)
MIIter_t getMinimizerIndexEnd()
......@@ -93,9 +93,13 @@ class publicize_headers(_build_ext):
def patch_header(self, old_path, new_path):
self.mkpath(os.path.dirname(new_path))
with open(old_path, "r") as src:
with open(new_path, "w") as dst:
for line in src:
dst.write( line.replace("private:", "public:") )
source = src.read()
source = re.sub("private:", "public:", source)
source = re.sub(r"class (.+\s*)\{(\s*)", r"class \1 {\npublic:\n\2", source)
with open(new_path, "w") as dst:
dst.write(source)
class build_ext(_build_ext):
......@@ -121,7 +125,7 @@ class build_ext(_build_ext):
# use debug directives with Cython if building in debug mode
cython_args = {"include_path": ["include", "pyfastani"], "compiler_directives": {}}
cython_args["compile_time_env"] = {"SYS_IMPLEMENTATION": SYS_IMPLEMENTATION}
cython_args["compile_time_env"] = {"FASTANI_PRIVATE_ACCESS": 1}
if self.force:
cython_args["force"] = True
if self.debug:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment