BamTools::Algorithms::Sort Struct Reference

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

#include <Sort.h>

List of all members.

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< BamAlignmentSortAlignments (const std::vector< BamAlignment > &input, const Compare &comp=Compare())
template<typename Compare >
static std::vector< BamAlignmentGetSortedRegion (BamReader &reader, const BamRegion &region, const Compare &comp=Compare())
template<typename Compare >
static std::vector< BamAlignmentGetSortedRegion (BamMultiReader &reader, const BamRegion &region, const Compare &comp=Compare())

Detailed Description

Provides classes & methods related to sorting BamAlignments.


Member Enumeration Documentation

Provides explicit values for specifying desired sort ordering.

Enumerator:
AscendingOrder 
DescendingOrder 

Member Function Documentation

template<typename Compare >
static 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"));
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
template<typename Compare >
static 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"));
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
template<typename Compare >
static 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));
Parameters:
[in] input vector of alignments to be sorted
[in] comp comparison function object
Returns:
sorted copy of the input data
template<typename Compare >
static 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:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Generated on Wed Aug 29 17:43:46 2012 for BamTools by  doxygen 1.6.3