Gamgee
You miserable little maggot. I'll stove your head in!
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
Public Member Functions | Friends | List of all members
gamgee::Sam Class Reference

Utility class to manipulate a Sam record. More...

#include <sam.h>

Public Member Functions

 Sam ()=default
 initializes a null Sam More...
 
 Sam (const std::shared_ptr< bam_hdr_t > &header, const std::shared_ptr< bam1_t > &body) noexcept
 creates a Sam given htslib objects. More...
 
 Sam (const Sam &other)
 makes a deep copy of a Sam and it's header. Shared pointers maintain state to all other associated objects correctly. More...
 
 Sam (Sam &&other) noexcept
 moves Sam and it's header accordingly. Shared pointers maintain state to all other associated objects correctly. More...
 
Samoperator= (const Sam &other)
 deep copy assignment of a Sam and it's header. Shared pointers maintain state to all other associated objects correctly. More...
 
Samoperator= (Sam &&other) noexcept
 move assignment of a Sam and it's header. Shared pointers maintain state to all other associated objects correctly. More...
 
SamHeader header ()
 
uint32_t chromosome () const
 returns the integer representation of the chromosome. Notice that chromosomes are listed in index order with regards to the header (so a 0-based number). Similar to Picards getReferenceIndex() More...
 
uint32_t alignment_start () const
 returns a (1-based and inclusive) alignment start position (as you would see in a Sam file). More...
 
uint32_t alignment_stop () const
 returns a (1-based and inclusive) alignment stop position (as you would see in a Sam file). More...
 
uint32_t unclipped_start () const
 calculates the theoretical alignment start of a read that has soft/hard-clips preceding the alignment More...
 
uint32_t unclipped_stop () const
 calculates the theoretical alignment stop of a read that has soft/hard-clips preceding the alignment More...
 
uint32_t mate_chromosome () const
 returns the integer representation of the mate's chromosome. Notice that chromosomes are listed in index order with regards to the header (so a 0-based number). Similar to Picards getMateReferenceIndex() More...
 
uint32_t mate_alignment_start () const
 returns a (1-based and inclusive) mate's alignment start position (as you would see in a Sam file). More...
 
uint32_t mate_alignment_stop () const
 returns a (1-based and inclusive) mate'salignment stop position (as you would see in a Sam file). More...
 
uint32_t mate_unclipped_start () const
 
uint32_t mate_unclipped_stop () const
 
void set_chromosome (const uint32_t chr)
 simple setter for the chromosome index. Index is 0-based. More...
 
void set_alignment_start (const uint32_t start)
 simple setter for the alignment start. More...
 
void set_mate_chromosome (const uint32_t mchr)
 simple setter for the mate's chromosome index. Index is 0-based. More...
 
void set_mate_alignment_start (const uint32_t mstart)
 simple setter for the mate's alignment start. More...
 
std::string name () const
 returns the read name More...
 
ReadBases bases () const
 returns the read bases More...
 
BaseQuals base_quals () const
 returns the base qualities More...
 
Cigar cigar () const
 returns the cigar More...
 
bool paired () const
 whether or not this read is paired More...
 
bool properly_paired () const
 whether or not this read is properly paired (see definition in BAM spec) More...
 
bool unmapped () const
 whether or not this read is unmapped More...
 
bool next_unmapped () const
 whether or not the next read is unmapped More...
 
bool reverse () const
 whether or not this read is from the reverse strand More...
 
bool next_reverse () const
 whether or not the next read is from the reverse strand More...
 
bool first () const
 whether or not this read is the first read in a pair (or multiple pairs) More...
 
bool last () const
 whether or not this read is the last read in a pair (or multiple pairs) More...
 
bool secondary () const
 whether or not this read is a secondary alignment (see definition in BAM spec) More...
 
bool fail () const
 whether or not this read is marked as failing vendor (sequencer) quality control More...
 
bool duplicate () const
 whether or not this read is a duplicate More...
 
bool supplementary () const
 whether or not this read is a supplementary alignment (see definition in the BAM spec) More...
 
void set_paired ()
 
void set_not_paired ()
 
void set_unmapped ()
 
void set_not_unmapped ()
 
void set_next_unmapped ()
 
void set_not_next_unmapped ()
 
void set_reverse ()
 
void set_not_reverse ()
 
void set_next_reverse ()
 
void set_not_next_reverse ()
 
void set_first ()
 
void set_not_first ()
 
void set_last ()
 
void set_not_last ()
 
void set_secondary ()
 
void set_not_secondary ()
 
void set_fail ()
 
void set_not_fail ()
 
void set_duplicate ()
 
void set_not_duplicate ()
 
void set_supplementary ()
 
void set_not_supplementary ()
 
bool empty () const
 whether or not this Sam object is empty, meaning that the internal memory has not been initialized (i.e. a Sam object initialized with Sam()). More...
 

Friends

class SamWriter
 allows the writer to access the guts of the object More...
 

Detailed Description

Utility class to manipulate a Sam record.

Constructor & Destructor Documentation

gamgee::Sam::Sam ( )
default

initializes a null Sam

Note
this is only used internally by the iterators
Warning
if you need to create a Variant from scratch, use the builder instead
gamgee::Sam::Sam ( const std::shared_ptr< bam_hdr_t > &  header,
const std::shared_ptr< bam1_t > &  body 
)
explicitnoexcept

creates a Sam given htslib objects.

creates a sam record that points to htslib memory already allocated

Note
used by all iterators
the resulting Sam shares ownership of the pre-allocated memory via shared_ptr reference counting
gamgee::Sam::Sam ( const Sam other)

makes a deep copy of a Sam and it's header. Shared pointers maintain state to all other associated objects correctly.

creates a deep copy of a sam record

Note
the copy will have exclusive ownership over the newly-allocated htslib memory until a data field (cigar, bases, etc.) is accessed, after which it will be shared via reference counting with the Cigar, etc. objects
gamgee::Sam::Sam ( Sam &&  other)
noexcept

moves Sam and it's header accordingly. Shared pointers maintain state to all other associated objects correctly.

moves a sam record, transferring ownership of the underlying htslib memory

Member Function Documentation

uint32_t gamgee::Sam::alignment_start ( ) const
inline

returns a (1-based and inclusive) alignment start position (as you would see in a Sam file).

Note
the internal encoding is 0-based to mimic that of the BAM files.
uint32_t gamgee::Sam::alignment_stop ( ) const
inline

returns a (1-based and inclusive) alignment stop position (as you would see in a Sam file).

Note
the internal encoding is 0-based to mimic that of the BAM files.
BaseQuals gamgee::Sam::base_quals ( ) const
inline

returns the base qualities

Warning
the objects returned by this member function will share underlying htslib memory with this object
ReadBases gamgee::Sam::bases ( ) const
inline

returns the read bases

Warning
the objects returned by this member function will share underlying htslib memory with this object
uint32_t gamgee::Sam::chromosome ( ) const
inline

returns the integer representation of the chromosome. Notice that chromosomes are listed in index order with regards to the header (so a 0-based number). Similar to Picards getReferenceIndex()

Cigar gamgee::Sam::cigar ( ) const
inline

returns the cigar

Warning
the objects returned by this member function will share underlying htslib memory with this object
bool gamgee::Sam::duplicate ( ) const
inline

whether or not this read is a duplicate

bool gamgee::Sam::empty ( ) const
inline

whether or not this Sam object is empty, meaning that the internal memory has not been initialized (i.e. a Sam object initialized with Sam()).

bool gamgee::Sam::fail ( ) const
inline

whether or not this read is marked as failing vendor (sequencer) quality control

bool gamgee::Sam::first ( ) const
inline

whether or not this read is the first read in a pair (or multiple pairs)

SamHeader gamgee::Sam::header ( )
inline
bool gamgee::Sam::last ( ) const
inline

whether or not this read is the last read in a pair (or multiple pairs)

uint32_t gamgee::Sam::mate_alignment_start ( ) const
inline

returns a (1-based and inclusive) mate's alignment start position (as you would see in a Sam file).

Note
the internal encoding is 0-based to mimic that of the BAM files.
uint32_t gamgee::Sam::mate_alignment_stop ( ) const

returns a (1-based and inclusive) mate'salignment stop position (as you would see in a Sam file).

Note
the internal encoding is 0-based to mimic that of the BAM files.
Warning
not implemented – requires new mate cigar tag!
uint32_t gamgee::Sam::mate_chromosome ( ) const
inline

returns the integer representation of the mate's chromosome. Notice that chromosomes are listed in index order with regards to the header (so a 0-based number). Similar to Picards getMateReferenceIndex()

uint32_t gamgee::Sam::mate_unclipped_start ( ) const
inline
Warning
dummy implementation – requires new mate cigar tag!
uint32_t gamgee::Sam::mate_unclipped_stop ( ) const
Warning
not implemented – requires new mate cigar tag!
std::string gamgee::Sam::name ( ) const
inline

returns the read name

bool gamgee::Sam::next_reverse ( ) const
inline

whether or not the next read is from the reverse strand

bool gamgee::Sam::next_unmapped ( ) const
inline

whether or not the next read is unmapped

Sam & gamgee::Sam::operator= ( const Sam other)

deep copy assignment of a Sam and it's header. Shared pointers maintain state to all other associated objects correctly.

creates a deep copy of a sam record

Note
the copy will have exclusive ownership over the newly-allocated htslib memory until a data field (cigar, bases, etc.) is accessed, after which it will be shared via reference counting with the Cigar, etc. objects

< shared_ptr assignment will take care of deallocating old sam record if necessary

< shared_ptr assignment will take care of deallocating old sam record if necessary

Sam & gamgee::Sam::operator= ( Sam &&  other)
noexcept

move assignment of a Sam and it's header. Shared pointers maintain state to all other associated objects correctly.

moves a sam record, transferring ownership of the underlying htslib memory

< shared_ptr assignment will take care of decrementing the reference count for the old managed object (and destroying it if necessary)

< shared_ptr assignment will take care of decrementing the reference count for the old managed object (and destroying it if necessary)

bool gamgee::Sam::paired ( ) const
inline

whether or not this read is paired

bool gamgee::Sam::properly_paired ( ) const
inline

whether or not this read is properly paired (see definition in BAM spec)

bool gamgee::Sam::reverse ( ) const
inline

whether or not this read is from the reverse strand

bool gamgee::Sam::secondary ( ) const
inline

whether or not this read is a secondary alignment (see definition in BAM spec)

void gamgee::Sam::set_alignment_start ( const uint32_t  start)
inline

simple setter for the alignment start.

Warning
You should use (1-based and inclusive) alignment but internally this is stored 0-based to simplify BAM conversion.
void gamgee::Sam::set_chromosome ( const uint32_t  chr)
inline

simple setter for the chromosome index. Index is 0-based.

void gamgee::Sam::set_duplicate ( )
inline
void gamgee::Sam::set_fail ( )
inline
void gamgee::Sam::set_first ( )
inline
void gamgee::Sam::set_last ( )
inline
void gamgee::Sam::set_mate_alignment_start ( const uint32_t  mstart)
inline

simple setter for the mate's alignment start.

Warning
You should use (1-based and inclusive) alignment but internally this is stored 0-based to simplify BAM conversion.
void gamgee::Sam::set_mate_chromosome ( const uint32_t  mchr)
inline

simple setter for the mate's chromosome index. Index is 0-based.

void gamgee::Sam::set_next_reverse ( )
inline
void gamgee::Sam::set_next_unmapped ( )
inline
void gamgee::Sam::set_not_duplicate ( )
inline
void gamgee::Sam::set_not_fail ( )
inline
void gamgee::Sam::set_not_first ( )
inline
void gamgee::Sam::set_not_last ( )
inline
void gamgee::Sam::set_not_next_reverse ( )
inline
void gamgee::Sam::set_not_next_unmapped ( )
inline
void gamgee::Sam::set_not_paired ( )
inline
void gamgee::Sam::set_not_reverse ( )
inline
void gamgee::Sam::set_not_secondary ( )
inline
void gamgee::Sam::set_not_supplementary ( )
inline
void gamgee::Sam::set_not_unmapped ( )
inline
void gamgee::Sam::set_paired ( )
inline
void gamgee::Sam::set_reverse ( )
inline
void gamgee::Sam::set_secondary ( )
inline
void gamgee::Sam::set_supplementary ( )
inline
void gamgee::Sam::set_unmapped ( )
inline
bool gamgee::Sam::supplementary ( ) const
inline

whether or not this read is a supplementary alignment (see definition in the BAM spec)

uint32_t gamgee::Sam::unclipped_start ( ) const

calculates the theoretical alignment start of a read that has soft/hard-clips preceding the alignment

Returns
the alignment start (1-based, inclusive) adjusted for clipped bases. For example if the read has an alignment start of 100 but the first 4 bases were clipped (hard or soft clipped) then this method will return 96.

Invalid to call on an unmapped read. Invalid to call with cigar = null

uint32_t gamgee::Sam::unclipped_stop ( ) const

calculates the theoretical alignment stop of a read that has soft/hard-clips preceding the alignment

Returns
the alignment stop (1-based, inclusive) adjusted for clipped bases. For example if the read has an alignment stop of 100 but the last 4 bases were clipped (hard or soft clipped) then this method will return 104.

Invalid to call on an unmapped read. Invalid to call with cigar = null

bool gamgee::Sam::unmapped ( ) const
inline

whether or not this read is unmapped

Friends And Related Function Documentation

friend class SamWriter
friend

allows the writer to access the guts of the object


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