File: multireads.h

package info (click to toggle)
cufflinks 1.3.0-2
  • links: PTS, VCS
  • area: non-free
  • in suites: wheezy
  • size: 3,864 kB
  • sloc: cpp: 48,999; ansic: 12,297; sh: 3,381; python: 432; makefile: 209
file content (72 lines) | stat: -rw-r--r-- 1,518 bytes parent folder | download | duplicates (5)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#ifndef MULTIREADS_H
#define MULTIREADS_H

#include <boost/thread.hpp>

typedef uint64_t RefID;
typedef uint64_t InsertID;

struct MultiHit
{
    MultiHit(RefID id, int l, int r)
    :   r_id(id),
        left(l),
        right(r),
        expr(0) {}
    RefID r_id;
    int left;
    int right;
    double expr;
};

class MultiRead
{
	size_t _curr_index;
	std::vector<MultiHit> _hits;
	double _tot_expr;
	InsertID _id;
    
    MultiHit* get_hit(RefID r_id, int left, int right);
	
public:
	
	MultiRead(InsertID id, int exp_num_hits)
	:	_curr_index(0),
		_tot_expr(0.0),
		_id(id)
	{
		_hits.reserve(exp_num_hits);
	}
	
	size_t num_hits() { return (int)_hits.size(); }
	void add_hit(RefID r_id, int left, int right);
	void add_expr(RefID r_id, int left, int right, double expr);
	double get_mass(RefID r_id, int left, int right, bool valid_mass);
};

class MateHit;

class MultiReadTable
{
	typedef std::map<InsertID, MultiRead> MultiReadMap;
	MultiReadMap _read_map;
	bool _valid_mass;
	MultiRead* get_read(InsertID mr_id);
#if ENABLE_THREADS
	boost::mutex _lock;
#endif
public:
	MultiReadTable(): _valid_mass(false) {}
	
	void valid_mass(bool vm) { _valid_mass = vm; }
	void add_hit(const MateHit& hit);
	void add_hit(RefID r_id, int left, int right, InsertID mr_id, int exp_num_hits);
	void add_expr(const MateHit& hit, double expr);
	void add_expr(RefID r_id, int left, int right, InsertID mr_id, double expr);
	double get_mass(const MateHit& hit);
	size_t num_multireads();
	size_t num_multihits();
	
};

#endif