Loading...
Searching...
No Matches
BamTools::Algorithms::Sort Struct Reference

Provides classes & methods related to sorting BamAlignments. More...

`#include <Sort.h>`

## Classes

struct | ByName
| Function object for comparing alignments by name. More...
struct | ByPosition
| Function object for comparing alignments by position. More...
struct | ByTag
| Function object for comparing alignments by tag value. More...
struct | Unsorted
| Placeholder function object. More...

## Public Types

enum | Order { AscendingOrder = 0 , DescendingOrder }
| Provides explicit values for specifying desired sort ordering. More...

## Static Public Member Functions

template<typename Compare>
static void | SortAlignments (std::vector< BamAlignment > &data, const Compare &comp=Compare())
template<typename Compare>
static std::vector< BamAlignment > | SortAlignments (const std::vector< BamAlignment > &input, const Compare &comp=Compare())
template<typename Compare>
static std::vector< BamAlignment > | GetSortedRegion (BamReader &reader, const BamRegion &region, const Compare &comp=Compare())
template<typename Compare>
static std::vector< BamAlignment > | GetSortedRegion (BamMultiReader &reader, const BamRegion &region, const Compare &comp=Compare())

## Detailed Description

Provides classes & methods related to sorting BamAlignments.

## Member Enumeration Documentation

## Order

enum BamTools::Algorithms::Sort::Order

Provides explicit values for specifying desired sort ordering.

Enumerator
AscendingOrder |
DescendingOrder |

## Member Function Documentation

## GetSortedRegion() [1/2]

template<typename Compare>

std::vector< BamAlignment > BamTools::Algorithms::Sort::GetSortedRegion | ( | BamMultiReader & | reader,
|  | const BamRegion & | region,
|  | const Compare & | comp = Compare() )

inline static

Reads a region of alignments from position-sorted BAM files, then sorts by the provided compare function

BamMultiReader reader;
// open BAM files & index files
BamRegion region;
// define a region of interest (i.e. a exon or some other feature)
// get all alignments covering that region, sorted by read group name
std::vector<BamAlignments> a;
a = Sort::GetSortedRegion(reader, region, Sort::ByTag<std::string>("RG"));
BamTools::BamMultiReader
Convenience class for reading multiple BAM files.
Definition BamMultiReader.h:27
BamTools::Algorithms::Sort::ByTag
Function object for comparing alignments by tag value.
Definition Sort.h:178
BamTools::Algorithms::Sort::GetSortedRegion
static std::vector< BamAlignment > GetSortedRegion(BamReader &reader, const BamRegion &region, const Compare &comp=Compare())
Definition Sort.h:307
BamTools::BamRegion
Represents a sequential genomic region.
Definition BamAux.h:90

Parameters

  [in] | reader | BamMultiReader opened on desired BAM files
  [in] | region | desired region-of-interest
  [in] | comp | comparison function object

Returns
  sorted vector of the region's alignments

## GetSortedRegion() [2/2]

template<typename Compare>

std::vector< BamAlignment > BamTools::Algorithms::Sort::GetSortedRegion | ( | BamReader & | reader,
|  | const BamRegion & | region,
|  | const Compare & | comp = Compare() )

inline static

Reads a region of alignments from a position-sorted BAM file, then sorts by the provided compare function

BamReader reader;
// open BAM file & index file
BamRegion region;
// define a region of interest (i.e. a exon or some other feature)
// get all alignments covering that region, sorted by read group name
std::vector<BamAlignments> a;
a = Sort::GetSortedRegion(reader, region, Sort::ByTag<std::string>("RG"));
BamTools::BamReader
Provides read access to BAM files.
Definition BamReader.h:26

Parameters

  [in] | reader | BamReader opened on desired BAM file
  [in] | region | desired region-of-interest
  [in] | comp | comparison function object

Returns
  sorted vector of the region's alignments

## SortAlignments() [1/2]

template<typename Compare>

std::vector< BamAlignment > BamTools::Algorithms::Sort::SortAlignments | ( | const std::vector< BamAlignment > & | input,
|  | const Compare & | comp = Compare() )

inline static

Returns a sorted copy of the input alignments, using the provided compare function.

std::vector<BamAlignemnt> a;
// populate data
// get a copy of our original data, sorted by edit distance (descending order)
std::vector<BamAligment> sortedData;
sortedData = Sort::SortAlignments(a, Sort::ByTag<int>("NM", Sort::DescendingOrder));
BamTools::Algorithms::Sort::SortAlignments
static void SortAlignments(std::vector< BamAlignment > &data, const Compare &comp=Compare())
Definition Sort.h:257
BamTools::Algorithms::Sort::DescendingOrder
@ DescendingOrder
Definition Sort.h:37

Parameters

  [in] | input | vector of alignments to be sorted
  [in] | comp | comparison function object

Returns
  sorted copy of the input data

## SortAlignments() [2/2]

template<typename Compare>

void BamTools::Algorithms::Sort::SortAlignments | ( | std::vector< BamAlignment > & | data,
|  | const Compare & | comp = Compare() )

inline static

Sorts a std::vector of alignments (in-place), using the provided compare function.

std::vector<BamAlignemnt> a;
// populate data
// sort our alignment list by edit distance
Sort::SortAlignments(a, Sort::ByTag<int>("NM"));

Parameters

  [in,out] | data | vector of alignments to be sorted
  [in] | comp | comparison function object

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

- Sort.h