Gamgee
You miserable little maggot. I'll stove your head in!
|
class to build Sam objects from existing data or from scratch More...
#include <sam_builder.h>
Public Member Functions | |
SamBuilder (const SamHeader &header, const bool validate_on_build=true) | |
create a Sam from scratch, starting only with a header More... | |
SamBuilder (const Sam &starting_read, const bool validate_on_build=true) | |
create a Sam starting with an existing read and its header More... | |
SamBuilder (const SamHeader &header, const Sam &starting_read, const bool validate_on_build=true) | |
create a Sam starting with an existing read, and manually set the header to a custom value More... | |
SamBuilder (SamBuilder &&other)=default | |
SamBuilder & | operator= (SamBuilder &&other)=default |
SamBuilder (const SamBuilder &other)=delete | |
SamBuilder & | operator= (const SamBuilder &other)=delete |
~SamBuilder ()=default | |
SamBuilder & | set_name (const std::string &new_name) |
set the read's QNAME to the specified value More... | |
SamBuilder & | set_cigar (const Cigar &new_cigar) |
set the read's cigar to the cigar of an existing read More... | |
SamBuilder & | set_cigar (const std::vector< CigarElement > &new_cigar) |
set the read's cigar using a vector of CigarElements More... | |
SamBuilder & | set_cigar (const std::initializer_list< CigarElement > new_cigar) |
set the read's cigar using an initializer_list of CigarElements More... | |
SamBuilder & | set_cigar (const std::string &new_cigar) |
set the read's cigar using a string representation of a cigar (eg., "3M1I3M") More... | |
SamBuilder & | set_bases (const ReadBases &new_bases) |
set the read's bases to the bases of an existing read More... | |
SamBuilder & | set_bases (const std::vector< Base > &new_bases) |
set the read's bases using a vector of Bases More... | |
SamBuilder & | set_bases (const std::initializer_list< Base > new_bases) |
set the read's bases using an initializer_list of Bases More... | |
SamBuilder & | set_bases (const std::string &new_bases) |
set the read's bases using a string of base values (eg., "ACGT") More... | |
SamBuilder & | set_base_quals (const BaseQuals &new_base_quals) |
set the read's base qualities to the base qualities of an existing read More... | |
SamBuilder & | set_base_quals (const std::vector< uint8_t > &new_base_quals) |
set the read's base qualities using a vector of quality scores More... | |
SamBuilder & | set_base_quals (const std::initializer_list< uint8_t > new_base_quals) |
set the read's base qualities using an initializer_list of (uint8_t) quality scores More... | |
SamBuilder & | set_base_quals (const std::initializer_list< int > new_base_quals) |
set the read's base qualities using an initializer_list of (int) quality scores More... | |
SamBuilder & | set_chromosome (const uint32_t chr) |
simple setter for the chromosome index. Index is 0-based. More... | |
SamBuilder & | set_alignment_start (const uint32_t start) |
simple setter for the alignment start. More... | |
SamBuilder & | set_mate_chromosome (const uint32_t mchr) |
simple setter for the mate's chromosome index. Index is 0-based. More... | |
SamBuilder & | set_mate_alignment_start (const uint32_t mstart) |
simple setter for the mate's alignment start. More... | |
SamBuilder & | set_paired () |
SamBuilder & | set_not_paired () |
SamBuilder & | set_unmapped () |
SamBuilder & | set_not_unmapped () |
SamBuilder & | set_mate_unmapped () |
SamBuilder & | set_not_mate_unmapped () |
SamBuilder & | set_reverse () |
SamBuilder & | set_not_reverse () |
SamBuilder & | set_mate_reverse () |
SamBuilder & | set_not_mate_reverse () |
SamBuilder & | set_first () |
SamBuilder & | set_not_first () |
SamBuilder & | set_last () |
SamBuilder & | set_not_last () |
SamBuilder & | set_secondary () |
SamBuilder & | set_not_secondary () |
SamBuilder & | set_fail () |
SamBuilder & | set_not_fail () |
SamBuilder & | set_duplicate () |
SamBuilder & | set_not_duplicate () |
SamBuilder & | set_supplementary () |
SamBuilder & | set_not_supplementary () |
Sam | build () const |
build a Sam (can be called repeatedly) More... | |
Sam | one_time_build () |
build a Sam more efficiently by moving the builder's data out of it and invalidating future builds More... | |
class to build Sam objects from existing data or from scratch
Unlike the setters in the Sam class, which only allow in-place modification of the data for efficiency reasons, SamBuilder lets you construct a read in arbitrary ways (including resizing data elements like the number of quality scores and the cigar).
To use, either start from scratch with only a header:
auto builder = SamBuilder{header};
or start with the state in an existing read:
auto builder = SamBuilder{existing_read};
Then make the desired modifications and build repeatedly.
auto read1 = builder.set_cigar("1M1I1M").set_base_quals({1,2,3}).build(); auto read2 = builder.set_name("new_name").set_chromosome(3).build();
Alternatively, you may use the one_time_build() function if you only need to ever build one read using a given builder. This is slightly more efficient than the more general-purpose repeatable build() function.
You must provide a value for all essential data fields before building if you build from scratch, unless you disable validation (not recommended).
Some methods of setting values are more efficient than others. For example, setting a cigar using a vector is much more efficient than setting it via a string:
builder.set_cigar(vector<CigarElement>{Cigar::make_cigar_element(3, CigarOperator::M)}); is faster than: builder.set_cigar("3M");
since the string must be parsed and validated.
The builder always copies the data it's given in the set_* methods, even when it belongs to another read, for safety reasons. Altering a read after passing some of its data into a builder will not affect the state of the builder.
Before building, the builder performs a validation step to ensure that the read it will create is logically consistent (eg., number of base qualities must match the number of bases). This validation step can be disabled during construction of the builder, but disabling validation is dangerous and not recommended.
|
explicit |
create a Sam from scratch, starting only with a header
|
explicit |
create a Sam starting with an existing read and its header
|
explicit |
create a Sam starting with an existing read, and manually set the header to a custom value
|
default |
|
delete |
|
default |
Sam gamgee::SamBuilder::build | ( | ) | const |
Sam gamgee::SamBuilder::one_time_build | ( | ) |
build a Sam more efficiently by moving the builder's data out of it and invalidating future builds
build a Sam record more efficiently by moving the builder's data out to the caller and invalidating the builder's state
|
default |
|
delete |
|
inline |
simple setter for the alignment start.
SamBuilder & gamgee::SamBuilder::set_base_quals | ( | const BaseQuals & | new_base_quals | ) |
set the read's base qualities to the base qualities of an existing read
SamBuilder & gamgee::SamBuilder::set_base_quals | ( | const std::vector< uint8_t > & | new_base_quals | ) |
set the read's base qualities using a vector of quality scores
SamBuilder & gamgee::SamBuilder::set_base_quals | ( | const std::initializer_list< uint8_t > | new_base_quals | ) |
set the read's base qualities using an initializer_list of (uint8_t) quality scores
SamBuilder & gamgee::SamBuilder::set_base_quals | ( | const std::initializer_list< int > | new_base_quals | ) |
set the read's base qualities using an initializer_list of (int) quality scores
SamBuilder & gamgee::SamBuilder::set_bases | ( | const ReadBases & | new_bases | ) |
set the read's bases to the bases of an existing read
SamBuilder & gamgee::SamBuilder::set_bases | ( | const std::vector< Base > & | new_bases | ) |
set the read's bases using a vector of Bases
SamBuilder & gamgee::SamBuilder::set_bases | ( | const std::initializer_list< Base > | new_bases | ) |
set the read's bases using an initializer_list of Bases
SamBuilder & gamgee::SamBuilder::set_bases | ( | const std::string & | new_bases | ) |
set the read's bases using a string of base values (eg., "ACGT")
|
inline |
simple setter for the chromosome index. Index is 0-based.
SamBuilder & gamgee::SamBuilder::set_cigar | ( | const Cigar & | new_cigar | ) |
set the read's cigar to the cigar of an existing read
SamBuilder & gamgee::SamBuilder::set_cigar | ( | const std::vector< CigarElement > & | new_cigar | ) |
set the read's cigar using a vector of CigarElements
SamBuilder & gamgee::SamBuilder::set_cigar | ( | const std::initializer_list< CigarElement > | new_cigar | ) |
set the read's cigar using an initializer_list of CigarElements
SamBuilder & gamgee::SamBuilder::set_cigar | ( | const std::string & | new_cigar | ) |
set the read's cigar using a string representation of a cigar (eg., "3M1I3M")
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
simple setter for the mate's alignment start.
|
inline |
simple setter for the mate's chromosome index. Index is 0-based.
|
inline |
|
inline |
SamBuilder & gamgee::SamBuilder::set_name | ( | const std::string & | new_name | ) |
set the read's QNAME to the specified value
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |