-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathIntronQueue.H
88 lines (78 loc) · 3.22 KB
/
IntronQueue.H
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
88
/****************************************************************
IntronQueue.H
Copyright (C)2013 William H. Majoros ([email protected]).
This is OPEN SOURCE SOFTWARE governed by the Gnu General Public
License (GPL) version 3, as described at www.opensource.org.
****************************************************************/
#ifndef INCL_IntronQueue_H
#define INCL_IntronQueue_H
#include "BOOM/Map.H"
#include "BOOM/Set.H"
#include "SignalQueue.H"
class IntronQueueIterator : public BOOM::Iterator<SignalPtr>
{
FixedSizePriorityList<SignalPtr >::iterator iterators[3];
FixedSizePriorityList<SignalPtr >::iterator ends[3];
int index;
void increment();
public:
IntronQueueIterator() {}
IntronQueueIterator(FixedSizePriorityList<SignalPtr > *lists[3],
bool pastTheEnd=false);
virtual void operator++();
virtual void operator++(int);
virtual SignalPtr &operator*();
virtual bool operator==(const BOOM::Iterator<SignalPtr > &) const;
virtual BOOM::Iterator<SignalPtr > &clone();
FixedSizePriorityList<SignalPtr >::iterator getNativeIterator() const;
int getIndex() const;
};
/*************************************************************************
This is a special type of SignalQueue in which there can be multiple
(overlapping) signals in the holding queue, but there can be at most
three signals in the main queue -- a best signal for each phase. When
a signal is ready to graduate from the holding queue to the main queue
we see (in each phase) if it is better than one in the main queue (i.e.,
has a better inductive score in that phase), and if so, move it there;
otherwise we discard it.
**************************************************************************/
class IntronQueue : public SignalQueue
{
class MembershipCounter // counts # "main" queues a signal is in (0-3)
{
BOOM::Map<SignalPtr ,int> counter;
public:
void increment(SignalPtr s)
{if(counter.isDefined(s)) ++counter[s]; else counter[s]=1;}
void decrement(SignalPtr s)
{--counter[s];if(!counter[s]) counter.undefine(s);}
BOOM::Map<SignalPtr ,int>::iterator begin() {return counter.begin();}
BOOM::Map<SignalPtr ,int>::iterator end() {return counter.end();}
void clear() {counter.clear();}
} membershipCounter;
// These 3 lists replace the functionality of the "mainQueue" in the
// SignalQueue ancestor class:
FixedSizePriorityList<SignalPtr> *lists[3];
IntronQueueIterator iter, iterEnd;
public:
IntronQueue(ContentType,
int capacity,
BOOM::Array1D<SinglePhaseComparator*> &);
virtual ~IntronQueue();
void switchComparator(BOOM::Array1D<SinglePhaseComparator*> &);
virtual void switchToIsochore(Isochore *);
virtual void resetQueue(Isochore *);
virtual void addSignal(SignalPtr);
virtual void updateHoldingQueue(int position);
virtual BOOM::Iterator<SignalPtr> &begin();
virtual BOOM::Iterator<SignalPtr> &end();
BOOM::Map<SignalPtr ,int>::iterator beginUniq()
{return membershipCounter.begin();}
BOOM::Map<SignalPtr,int>::iterator endUniq()
{return membershipCounter.end();}
virtual int numElements();
virtual void drop(BOOM::Iterator<SignalPtr>&);
// ^-- removes a signal from the queue
virtual void flushAccumulator();
};
#endif