File: WeightedInterval.hpp

package info (click to toggle)
pbseqlib 0~20161219-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 5,924 kB
  • ctags: 5,123
  • sloc: cpp: 82,727; makefile: 305; python: 239; sh: 8
file content (85 lines) | stat: -rw-r--r-- 2,574 bytes parent folder | download | duplicates (2)
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
73
74
75
76
77
78
79
80
81
82
83
84
85
#ifndef _BLASR_WEIGHTED_INTERVAL_HPP_
#define _BLASR_WEIGHTED_INTERVAL_HPP_

#include <vector>
#include <set>
#include "../../../pbdata/DNASequence.hpp"
#include "MatchPos.hpp"

class WeightedInterval {
public:
    DNALength size; // not necessarily end - start + 1
    DNALength start;
    DNALength end;
    DNALength qStart, qEnd;
    int readIndex;
    float pValue;
    std::vector<int> positions;
    std::vector<ChainedMatchPos> matches;
    float pValueVariance, pValueNStdDev;
    float sizeVariance, sizeNStdDev;
    int nAnchors;
    int totalAnchorSize;
    bool isOverlapping;

    WeightedInterval();

    WeightedInterval(int _size, int _start, int _end, 
        int _readIndex, float _pValue =0.0);

    WeightedInterval(int _size, int _start, int _end, 
        int _readIndex, float _pValue, int _qStart, int _qEnd);

    WeightedInterval(int _size, unsigned int _nAnchors, 
        unsigned int _totalAnchorSize, int _start, int _end, 
        int _readIndex, float _pValue, int _qStart, int _qEnd, 
        std::vector<ChainedMatchPos> &_matches);

    void Init(int _size, int _start, int _end, 
        int _readIndex, float _pValue);

    int GetStrandIndex() const;
    void SetPValueVariance(float v);
    void SetPValueNStdDev(float v);
    void SetSizeVariance(float v);
    void SetSizeNStdDev(float v);
    int operator<(const WeightedInterval &intv) const;
    int operator==(const WeightedInterval &intv) const;

    friend std::ostream & operator << (std::ostream & out, WeightedInterval & wi) {
        out << wi.size << " " << wi.start << " " << wi.end
            << " " << wi.qStart << " " << wi.qEnd << " " << wi.readIndex
            << " " << wi.pValue ;
        return out;
    }

    float PValue() const;
    int Size() const;
};

class CompareWeightedIntervalByPValue {
public:
    int operator()(const WeightedInterval& a, const WeightedInterval& b) const;
};

typedef std::vector<WeightedInterval> WeightedIntervalVector;

typedef std::multiset<WeightedInterval, CompareWeightedIntervalByPValue> 
T_WeightedIntervalMultiSet;

class WeightedIntervalSet: public T_WeightedIntervalMultiSet {
public:
    size_t maxSize;
    WeightedIntervalSet();
    WeightedIntervalSet(const size_t maxSizeP);
    bool insert(WeightedInterval &intv);
    friend std::ostream & operator << (std::ostream & out, WeightedIntervalSet & wis) {
        WeightedIntervalSet::iterator it;
        for (it = wis.begin(); it != wis.end(); it++) {
            out << *((WeightedInterval*)&(*it)) << std::endl;
        }
        return out;
    }
};

#endif