11#ifndef ALGORITHMS_SORT_H
12#define ALGORITHMS_SORT_H
45 template <
typename ElemType>
46 static bool sort_helper(
const Sort::Order& order,
const ElemType& lhs,
const ElemType& rhs)
49 case (Sort::AscendingOrder): {
50 std::less<ElemType> comp;
51 return comp(lhs, rhs);
53 case (Sort::DescendingOrder): {
54 std::greater<ElemType> comp;
55 return comp(lhs, rhs);
58 BT_ASSERT_UNREACHABLE;
90 return sort_helper(m_order, lhs.
Name, rhs.
Name);
94 static bool UsesCharData()
133 if (lhs.
RefID == -1) {
136 if (rhs.
RefID == -1) {
146 return sort_helper(m_order, lhs.
RefID, rhs.
RefID);
150 static bool UsesCharData()
176 template <
typename T>
193 if (!lhs.
GetTag(m_tag, lhsTagValue)) {
196 if (!rhs.
GetTag(m_tag, rhsTagValue)) {
201 return sort_helper(m_order, lhsTagValue, rhsTagValue);
205 static bool UsesCharData()
212 const std::string m_tag;
237 static bool UsesCharData()
256 template <
typename Compare>
257 static void SortAlignments(std::vector<BamAlignment>& data,
const Compare& comp = Compare())
259 std::sort(data.begin(), data.end(), comp);
277 template <
typename Compare>
278 static std::vector<BamAlignment>
SortAlignments(
const std::vector<BamAlignment>& input,
279 const Compare& comp = Compare())
281 std::vector<BamAlignment> output(input);
282 SortAlignments(output, comp);
306 template <
typename Compare>
308 const Compare& comp = Compare())
312 return std::vector<BamAlignment>();
315 return std::vector<BamAlignment>();
320 std::vector<BamAlignment> results;
322 results.push_back(al);
326 SortAlignments(results, comp);
350 template <
typename Compare>
353 const Compare& comp = Compare())
357 return std::vector<BamAlignment>();
360 return std::vector<BamAlignment>();
365 std::vector<BamAlignment> results;
367 results.push_back(al);
371 SortAlignments(results, comp);