File: OrderedBAMWriter.h

package info (click to toggle)
tvc 5.0.3%2Bgit20151221.80e144e%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 3,548 kB
  • sloc: cpp: 24,088; ansic: 3,933; python: 260; makefile: 16
file content (40 lines) | stat: -rw-r--r-- 1,110 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* Copyright (C) 2013 Ion Torrent Systems, Inc. All Rights Reserved */

/* Author: Alex Artyomenko <aartyomenko@cs.gsu.edu> */

#ifndef ION_ANALYSIS_ORDEREDBAMWRITER_H
#define ION_ANALYSIS_ORDEREDBAMWRITER_H

#include <deque>
#include <queue>
#include <algorithm>
#include "BAMWalkerEngine.h"

using namespace std;

class Alignment;

template<typename T>
int cmp(T p1, T p2) { return p1 < p2 ? 1 : (p1 > p2 ? -1 : 0); }

template<typename T1, typename T2>
int cmp_pairs(T1 p11, T2 p12, T1 p21, T2 p22) { int lvl1 = cmp(p11, p21); if (lvl1) return lvl1; return cmp(p12, p22); }

struct AlignmentComporator {
  bool operator()(Alignment* lhs, Alignment* rhs);
};

typedef priority_queue<Alignment*, deque<Alignment*>, AlignmentComporator> alignment_queue;

class OrderedBAMWriter : protected alignment_queue {
  AlignmentComporator cmp;
public:
  OrderedBAMWriter() : alignment_queue(cmp) { }
  Alignment* process_new_etries(Alignment* list);
  Alignment* flush();
private:
  Alignment* wrap_items_in_linkedlist(Alignment * current);
  bool cond(Alignment* current);
};

#endif //ION_ANALYSIS_ORDEREDBAMWRITER_H