vg
tools for working with variation graphs
|
#include <gaf_sorter.hpp>
Public Types | |
enum | key_type { key_node_interval, key_gbwt_pos, key_hash } |
Types of keys that can be derived from the value. More... | |
Public Member Functions | |
GAFSorterRecord () | |
Default constructor. More... | |
GAFSorterRecord (std::string &&value, key_type type) | |
Constructor that consumes the given value and sets the key. More... | |
bool | operator< (const GAFSorterRecord &another) const |
Records are sorted by key in ascending order. More... | |
void | flip_key () |
void | set_key (key_type type) |
Sets a key of the given type, or MISSING_KEY if the key cannot be derived. More... | |
bool | serialize (std::ostream &out) const |
Serializes the record to a stream. Returns true on success. More... | |
bool | write_line (std::ostream &out) const |
Writes the underlying GAF line to a stream. Returns true on success. More... | |
bool | deserialize (std::istream &in) |
Deserializes the record from a stream. Returns true on success. More... | |
bool | read_line (std::istream &in, key_type type) |
Reads a GAF line from a stream and sets the key. Returns true on success. More... | |
str_view | get_field (size_t field) const |
Returns a view of the given 0-based field, or an empty string if the field is missing. More... | |
void | for_each_field (const std::function< bool(size_t, str_view)> &lambda) const |
Public Attributes | |
std::uint64_t | key |
Integer key. More... | |
std::string | value |
GAF line. More... | |
Static Public Attributes | |
static std::hash< std::string > | hasher |
Hasher used for random shuffling. More... | |
constexpr static std::uint64_t | MISSING_KEY = std::numeric_limits<std::uint64_t>::max() |
Missing key. Records without a key are sorted to the end. More... | |
const static std::string | GBWT_OFFSET_TAG = "GB:i:" |
Static Private Attributes | |
constexpr static size_t | PATH_FIELD = 5 |
constexpr static size_t | MANDATORY_FIELDS = 12 |
A record corresponding to a single line (alignment) in a GAF file. The record contains an integer key and the original line. Various types of keys can be derived from the value, but the line is not parsed beyond that.
|
inline |
Default constructor.
|
inline |
Constructor that consumes the given value and sets the key.
bool vg::GAFSorterRecord::deserialize | ( | std::istream & | in | ) |
Deserializes the record from a stream. Returns true on success.
|
inline |
Flips they key to reverse the order. Sorting is based on ascending order, while priority queues return the largest element first.
void vg::GAFSorterRecord::for_each_field | ( | const std::function< bool(size_t, str_view)> & | lambda | ) | const |
Calls the given function with a 0-based field index and the field value. Stops if the function returns false.
str_view vg::GAFSorterRecord::get_field | ( | size_t | field | ) | const |
Returns a view of the given 0-based field, or an empty string if the field is missing.
|
inline |
Records are sorted by key in ascending order.
bool vg::GAFSorterRecord::read_line | ( | std::istream & | in, |
key_type | type | ||
) |
Reads a GAF line from a stream and sets the key. Returns true on success.
bool vg::GAFSorterRecord::serialize | ( | std::ostream & | out | ) | const |
Serializes the record to a stream. Returns true on success.
void vg::GAFSorterRecord::set_key | ( | key_type | type | ) |
Sets a key of the given type, or MISSING_KEY if the key cannot be derived.
bool vg::GAFSorterRecord::write_line | ( | std::ostream & | out | ) | const |
Writes the underlying GAF line to a stream. Returns true on success.
|
static |
Node offset for the GBWT starting position of the forward orientation may be stored in this tag.
|
static |
Hasher used for random shuffling.
std::uint64_t vg::GAFSorterRecord::key |
Integer key.
|
staticconstexprprivate |
|
staticconstexpr |
Missing key. Records without a key are sorted to the end.
|
staticconstexprprivate |
std::string vg::GAFSorterRecord::value |
GAF line.