Skip to content

Commit

Permalink
More const correctness
Browse files Browse the repository at this point in the history
  • Loading branch information
bschiffthaler committed Apr 3, 2020
1 parent 0784023 commit 0eee497
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 6 deletions.
2 changes: 1 addition & 1 deletion apps/kmer_map/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ uint64_t get_k(std::string const & kmer_file)
return r.size();
}

k_map_t build_reference(std::string const & genome_file, uint64_t k)
k_map_t build_reference(std::string const & genome_file, uint64_t const & k)
{
std::cerr << "Building index...\n";
k_map_t ret;
Expand Down
45 changes: 40 additions & 5 deletions src/fastxio_record.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,21 @@ class Record {
*
* @return The sequence of the object.
*/
std::string get_seq(void) const { return _seq; }
const std::string & get_seq(void) const { return _seq; }

/**
* @brief Get the quality as ACII ancoded characters.
*
* @return The quality values.
*/
std::string get_qual(void) const { return _qual; }
const std::string & get_qual(void) const { return _qual; }

/**
* @brief Get the ID.
*
* @return The ID (without '>' or '@').
*/
std::string get_id(void) const { return _id; }
const std::string & get_id(void) const { return _id; }

/**
* @brief Modify the ID
Expand Down Expand Up @@ -84,7 +84,7 @@ class Record {
*
* @return The bit encoded type of the record
*/
char get_type(void) const { return _type; }
const char & get_type(void) const { return _type; }

/**
* @brief Get a shared pointer to sequence.
Expand All @@ -109,7 +109,7 @@ class Record {
*
* @return The length of the record.
*/
length_t size(void) const {return _seq.length(); }
const length_t size(void) const {return _seq.length(); }

/**
* @brief Print the record to a sink.
Expand Down Expand Up @@ -623,6 +623,31 @@ class kmer_walker
* @return True if the beginning was reached, false otherwise
*/
bool begin() {return _begin;}

/**
* @brief Get current coordinates of the window
*
* @return A pair [start, stop)
*/
std::pair<size_t, size_t> get_coord() {
if ((_current_pos + _k) >= _parent.size())
{
return std::pair<size_t, size_t>(_current_pos, _parent.size() - _current_pos);
}
else
{
return std::pair<size_t, size_t>(_current_pos, _k);
}
}

/**
* @brief Get the ID of the parent
*
* @return The parent ID
*/
std::string get_parent_id() {
return _parent.get_id();
}
private:
size_t _k;
size_t _current_pos;
Expand Down Expand Up @@ -741,6 +766,11 @@ class window_walker
*/
bool begin() {return _begin;}

/**
* @brief Get current coordinates of the window
*
* @return A pair [start, stop)
*/
std::pair<size_t, size_t> get_coord() {
if ((_current_pos + _ws) >= _parent.size())
{
Expand All @@ -752,6 +782,11 @@ class window_walker
}
}

/**
* @brief Get the ID of the parent
*
* @return The parent ID
*/
std::string get_parent_id() {
return _parent.get_id();
}
Expand Down

0 comments on commit 0eee497

Please sign in to comment.