File: WeightedInterval.hpp

package info (click to toggle)
pbseqlib 5.3.1%2Bdfsg-2.1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 7,136 kB
  • sloc: cpp: 77,246; python: 570; makefile: 312; sh: 111; ansic: 9
file content (87 lines) | stat: -rw-r--r-- 2,692 bytes parent folder | download | duplicates (4)
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
86
87
#ifndef _BLASR_WEIGHTED_INTERVAL_HPP_
#define _BLASR_WEIGHTED_INTERVAL_HPP_

#include <set>
#include <vector>

#include <alignment/datastructures/anchoring/MatchPos.hpp>
#include <pbdata/DNASequence.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, const WeightedInterval &wi)
    {
        out << "[WeightedInterval size=" << wi.size << " start=" << wi.start << " end=" << wi.end
            << " qstart=" << wi.qStart << " qend=" << wi.qEnd << " strand=" << wi.readIndex
            << " pval=" << 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, const WeightedIntervalSet &wis)
    {
        WeightedIntervalSet::iterator it;
        for (it = wis.begin(); it != wis.end(); it++) {
            out << *((WeightedInterval *)&(*it)) << std::endl;
        }
        return out;
    }
};

#endif