@@ -137,12 +137,13 @@ NumpyMatrix queryDatabase(const std::string &ref_db_name,
137137}
138138
139139sparse_coo
140- querySelfSparse (const std::string &ref_db_name, const std::vector<std::string> &ref_names,
141- std::vector<size_t > kmer_lengths, const bool random_correct = true ,
142- const bool jaccard = false , const unsigned long int kNN = 0 ,
143- const float dist_cutoff = 0 .0f , const size_t dist_col = 0 ,
144- const size_t num_threads = 1 , const bool use_gpu = false ,
145- const int device_id = 0 ) {
140+ querySelfSparse (const std::string &ref_db_name,
141+ const std::vector<std::string> &ref_names,
142+ std::vector<size_t > kmer_lengths,
143+ const bool random_correct = true , const bool jaccard = false ,
144+ const unsigned long int kNN = 0 , const float dist_cutoff = 0 .0f ,
145+ const size_t dist_col = 0 , const size_t num_threads = 1 ,
146+ const bool use_gpu = false , const int device_id = 0 ) {
146147 if (use_gpu && (jaccard || kmer_lengths.size () < 2 || dist_col > 1 )) {
147148 throw std::runtime_error (
148149 " Extracting Jaccard distances not supported on GPU" );
@@ -160,26 +161,28 @@ querySelfSparse(const std::string &ref_db_name, const std::vector<std::string> &
160161 sparse_coo sparse_dists;
161162 if (dist_cutoff > 0 ) {
162163 NumpyMatrix dists = queryDatabase (ref_db_name, ref_db_name, ref_names,
163- ref_names, kmer_lengths, random_correct,
164- false , num_threads, use_gpu, device_id);
164+ ref_names, kmer_lengths, random_correct,
165+ false , num_threads, use_gpu, device_id);
165166
166167 Eigen::VectorXf dummy_query_ref;
167168 Eigen::VectorXf dummy_query_query;
168169 NumpyMatrix long_form = long_to_square (dists.col (dist_col), dummy_query_ref,
169- dummy_query_query, num_threads);
170- sparse_dists = sparsify_dists (long_form, dist_cutoff, kNN );
170+ dummy_query_query, num_threads);
171+ sparse_dists =
172+ sparsify_dists_by_threshold (long_form, dist_cutoff, num_threads);
171173 } else {
172174#ifdef GPU_AVAILABLE
173175 if (use_gpu) {
174- sparse_dists = query_db_sparse_cuda (ref_sketches, kmer_lengths, random,
175- kNN , dist_col, device_id, num_threads);
176+ sparse_dists =
177+ query_db_sparse_cuda (ref_sketches, kmer_lengths, random, kNN ,
178+ dist_col, device_id, num_threads);
176179 } else {
177180 sparse_dists = query_db_sparse (ref_sketches, kmer_lengths, random,
178- jaccard, kNN , dist_col, num_threads);
181+ jaccard, kNN , dist_col, num_threads);
179182 }
180183#else
181- sparse_dists = query_db_sparse (ref_sketches, kmer_lengths, random,
182- jaccard, kNN , dist_col, num_threads);
184+ sparse_dists = query_db_sparse (ref_sketches, kmer_lengths, random, jaccard,
185+ kNN , dist_col, num_threads);
183186#endif
184187 }
185188
@@ -216,9 +219,11 @@ double jaccardDist(const std::string &db_name, const std::string &sample1,
216219}
217220
218221// Wrapper which makes a ref to the python/numpy array
219- sparse_coo sparsifyDists (const Eigen::Ref<NumpyMatrix> &denseDists,
220- const float distCutoff, const unsigned long int kNN ) {
221- sparse_coo coo_idx = sparsify_dists (denseDists, distCutoff, kNN );
222+ sparse_coo sparsifyDistsByThreshold (const Eigen::Ref<NumpyMatrix> &denseDists,
223+ const float distCutoff,
224+ const size_t num_threads) {
225+ sparse_coo coo_idx =
226+ sparsify_dists_by_threshold (denseDists, distCutoff, num_threads);
222227 return coo_idx;
223228}
224229
@@ -245,12 +250,11 @@ PYBIND11_MODULE(pp_sketchlib, m) {
245250 m.def (" querySelfSparse" , &querySelfSparse,
246251 py::return_value_policy::reference_internal,
247252 " Find self-self distances between sketches; return a sparse matrix" ,
248- py::arg (" ref_db_name" ), py::arg (" rList" ), py::arg (" klist" ), py::arg ( " random_correct " ) = true ,
249- py::arg (" jaccard" ) = false ,
253+ py::arg (" ref_db_name" ), py::arg (" rList" ), py::arg (" klist" ),
254+ py::arg (" random_correct " ) = true , py::arg ( " jaccard" ) = false ,
250255 py::arg (" kNN" ) = 0 , py::arg (" dist_cutoff" ) = 0 .0f ,
251- py::arg (" dist_col" ) = 0 ,
252- py::arg (" num_threads" ) = 1 , py::arg (" use_gpu" ) = false ,
253- py::arg (" device_id" ) = 0 );
256+ py::arg (" dist_col" ) = 0 , py::arg (" num_threads" ) = 1 ,
257+ py::arg (" use_gpu" ) = false , py::arg (" device_id" ) = 0 );
254258
255259 m.def (" addRandom" , &addRandomToDb,
256260 " Add random match chances into older databases" , py::arg (" db_name" ),
@@ -279,11 +283,11 @@ PYBIND11_MODULE(pp_sketchlib, m) {
279283 py::arg (" query_ref_distVec" ).noconvert (),
280284 py::arg (" query_query_distVec" ).noconvert (), py::arg (" num_threads" ) = 1 );
281285
282- m.def (" sparsifyDists " , &sparsifyDists ,
286+ m.def (" sparsifyDistsByThreshold " , &sparsifyDistsByThreshold ,
283287 py::return_value_policy::reference_internal,
284288 " Transform all distances into a sparse matrix" ,
285289 py::arg (" distMat" ).noconvert (), py::arg (" distCutoff" ) = 0 ,
286- py::arg (" kNN " ) = 0 );
290+ py::arg (" num_threads " ) = 1 );
287291
288292 m.attr (" version" ) = VERSION_INFO;
289293 m.attr (" sketchVersion" ) = SKETCH_VERSION;
0 commit comments