vg
tools for working with variation graphs
Public Types | Public Member Functions | Public Attributes | Static Public Attributes | Static Private Attributes | List of all members
vg::GAFSorterRecord Struct Reference

#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
 

Detailed Description

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.

Member Enumeration Documentation

◆ key_type

Types of keys that can be derived from the value.

Enumerator
key_node_interval 

(minimum node id, maximum node id) in the path.

key_gbwt_pos 

GBWT starting position for the forward orientation. Derived from the path and tag "GB:i:".

key_hash 

Hash of the value for random shuffling.

Constructor & Destructor Documentation

◆ GAFSorterRecord() [1/2]

vg::GAFSorterRecord::GAFSorterRecord ( )
inline

Default constructor.

◆ GAFSorterRecord() [2/2]

vg::GAFSorterRecord::GAFSorterRecord ( std::string &&  value,
key_type  type 
)
inline

Constructor that consumes the given value and sets the key.

Member Function Documentation

◆ deserialize()

bool vg::GAFSorterRecord::deserialize ( std::istream &  in)

Deserializes the record from a stream. Returns true on success.

◆ flip_key()

void vg::GAFSorterRecord::flip_key ( )
inline

Flips they key to reverse the order. Sorting is based on ascending order, while priority queues return the largest element first.

◆ for_each_field()

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.

◆ get_field()

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.

◆ operator<()

bool vg::GAFSorterRecord::operator< ( const GAFSorterRecord another) const
inline

Records are sorted by key in ascending order.

◆ read_line()

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.

◆ serialize()

bool vg::GAFSorterRecord::serialize ( std::ostream &  out) const

Serializes the record to a stream. Returns true on success.

◆ set_key()

void vg::GAFSorterRecord::set_key ( key_type  type)

Sets a key of the given type, or MISSING_KEY if the key cannot be derived.

◆ write_line()

bool vg::GAFSorterRecord::write_line ( std::ostream &  out) const

Writes the underlying GAF line to a stream. Returns true on success.

Member Data Documentation

◆ GBWT_OFFSET_TAG

const std::string vg::GAFSorterRecord::GBWT_OFFSET_TAG = "GB:i:"
static

Node offset for the GBWT starting position of the forward orientation may be stored in this tag.

◆ hasher

std::hash<std::string> vg::GAFSorterRecord::hasher
static

Hasher used for random shuffling.

◆ key

std::uint64_t vg::GAFSorterRecord::key

Integer key.

◆ MANDATORY_FIELDS

constexpr static size_t vg::GAFSorterRecord::MANDATORY_FIELDS = 12
staticconstexprprivate

◆ MISSING_KEY

constexpr std::uint64_t vg::GAFSorterRecord::MISSING_KEY = std::numeric_limits<std::uint64_t>::max()
staticconstexpr

Missing key. Records without a key are sorted to the end.

◆ PATH_FIELD

constexpr static size_t vg::GAFSorterRecord::PATH_FIELD = 5
staticconstexprprivate

◆ value

std::string vg::GAFSorterRecord::value

GAF line.


The documentation for this struct was generated from the following files: