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

Compilation and code reuse improvements. #229

Merged
merged 2 commits into from
Mar 7, 2024
Merged
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
6 changes: 4 additions & 2 deletions kmc_CLI/kmc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <random>
using namespace std;

struct CLIParams
Expand Down Expand Up @@ -36,7 +37,7 @@ void usage()
<< " -sm - use strict memory mode (memory limit from -m<n> switch will not be exceeded)\n"
<< " -hc - count homopolymer compressed k-mers (approximate and experimental)\n"
<< " -p<par> - signature length (5, 6, 7, 8, 9, 10, 11); default: 9\n"
<< " -f<a/q/m/bam/kmc> - input in FASTA format (-fa), FASTQ format (-fq), multi FASTA (-fm) or BAM (-fbam) or KMC(-fkmc); default: FASTQ\n"
<< " -f<a/q/m/bam/kmc> - input in FASTA format (-fa), FASTQ format (-fq), multi FASTA (-fm) or BAM (-fbam) or KMC (-fkmc); default: FASTQ\n"
<< " -ci<value> - exclude k-mers occurring less than <value> times (default: 2)\n"
<< " -cs<value> - maximal value of a counter (default: 255)\n"
<< " -cx<value> - exclude k-mers occurring more of than <value> times (default: 1e9)\n"
Expand Down Expand Up @@ -264,7 +265,8 @@ bool parse_parameters(int argc, char* argv[], Params& params)
input_file_names.push_back(s);

in.close();
std::random_shuffle(input_file_names.begin(), input_file_names.end());
std::mt19937 gen;
std::shuffle(input_file_names.begin(), input_file_names.end(), gen);
}
stage1Params.SetInputFiles(input_file_names);

Expand Down
10 changes: 5 additions & 5 deletions kmc_api/kmer_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class CKmerAPI

// ----------------------------------------------------------------------------------
template<typename RandomAccessIterator>
inline void to_string_impl(RandomAccessIterator iter)
inline void to_string_impl(RandomAccessIterator iter) const
{
uchar *byte_ptr;
uchar c;
Expand Down Expand Up @@ -431,7 +431,7 @@ class CKmerAPI
// Convert kmer into string (an alphabet ACGT)
// RET : string kmer
//-----------------------------------------------------------------------
inline std::string to_string()
inline std::string to_string() const
{
std::string string_kmer;
string_kmer.resize(kmer_length);
Expand All @@ -442,14 +442,14 @@ class CKmerAPI
// Convert kmer into string (an alphabet ACGT). The function assumes enough memory was allocated
// OUT : str - string kmer.
//-----------------------------------------------------------------------
inline void to_string(char *str)
inline void to_string(char *str) const
{
to_string_impl(str);
str[kmer_length] = '\0';
};


inline void to_long(std::vector<uint64>& kmer)
inline void to_long(std::vector<uint64>& kmer) const
{
kmer.resize(no_of_rows);
uint32 offset = 62 - ((kmer_length - 1 + byte_alignment) & 31) * 2;
Expand All @@ -473,7 +473,7 @@ class CKmerAPI
// Convert kmer into string (an alphabet ACGT)
// OUT : str - string kmer
//-----------------------------------------------------------------------
inline void to_string(std::string &str)
inline void to_string(std::string &str) const
{
str.resize(kmer_length);
to_string_impl(str.begin());
Expand Down
1 change: 1 addition & 0 deletions py_kmc_api/libs/pybind11/include/pybind11/attr.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#pragma once

#include "cast.h"
#include <cstdint>

NAMESPACE_BEGIN(PYBIND11_NAMESPACE)

Expand Down
Loading