Go to the documentation of this file.
11 #ifndef ALGORITHMS_SORT_H
12 #define ALGORITHMS_SORT_H
25 namespace Algorithms {
45 template <
typename ElemType>
46 static inline bool sort_helper(
const Sort::Order& order,
const ElemType& lhs,
51 std::less<ElemType> comp;
52 return comp(lhs, rhs);
55 std::greater<ElemType> comp;
56 return comp(lhs, rhs);
59 BT_ASSERT_UNREACHABLE;
65 typedef std::binary_function<BamAlignment, BamAlignment, bool> AlignmentSortBase;
83 struct ByName :
public AlignmentSortBase
94 return sort_helper(m_order, lhs.
Name, rhs.
Name);
98 static inline bool UsesCharData()
137 if (lhs.
RefID == -1)
return false;
138 if (rhs.
RefID == -1)
return true;
144 return sort_helper(m_order, lhs.
RefID, rhs.
RefID);
148 static inline bool UsesCharData()
174 template <
typename T>
175 struct ByTag :
public AlignmentSortBase
191 if (!lhs.
GetTag(m_tag, lhsTagValue))
return false;
192 if (!rhs.
GetTag(m_tag, rhsTagValue))
return true;
195 return sort_helper(m_order, lhsTagValue, rhsTagValue);
199 static inline bool UsesCharData()
206 const std::string m_tag;
231 static inline bool UsesCharData()
250 template <
typename Compare>
252 const Compare& comp = Compare())
254 std::sort(data.begin(), data.end(), comp);
272 template <
typename Compare>
273 static inline std::vector<BamAlignment>
SortAlignments(
const std::vector<BamAlignment>& input,
274 const Compare& comp = Compare())
276 std::vector<BamAlignment> output(input);
277 SortAlignments(output, comp);
301 template <
typename Compare>
303 const Compare& comp = Compare())
306 if (!reader.
IsOpen())
return std::vector<BamAlignment>();
307 if (!reader.
SetRegion(region))
return std::vector<BamAlignment>();
311 std::vector<BamAlignment> results;
313 results.push_back(al);
316 SortAlignments(results, comp);
340 template <
typename Compare>
343 const Compare& comp = Compare())
347 if (!reader.
SetRegion(region))
return std::vector<BamAlignment>();
351 std::vector<BamAlignment> results;
353 results.push_back(al);
356 SortAlignments(results, comp);
364 #endif // ALGORITHMS_SORT_H
#define API_EXPORT
Definition: api_global.h:18