-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIntronDepthProfile.C
More file actions
75 lines (58 loc) · 1.45 KB
/
IntronDepthProfile.C
File metadata and controls
75 lines (58 loc) · 1.45 KB
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
/****************************************************************
IntronDepthProfile.C
Copyright (C)2013 William H. Majoros (martiandna@gmail.com).
This is OPEN SOURCE SOFTWARE governed by the Gnu General Public
License (GPL) version 3, as described at www.opensource.org.
****************************************************************/
#include <iostream>
#include "IntronDepthProfile.H"
using namespace std;
using namespace BOOM;
IntronDepthProfile::IntronDepthProfile(RnaJunctions &junctions,int length)
: A(length)
{
construct(junctions);
//normalize();
}
float IntronDepthProfile::operator[](int i) const
{
return A[i];
}
void IntronDepthProfile::construct(RnaJunctions &junctions)
{
int L=A.size();
A.setAllTo(0);
int numJ=junctions.getNumJunctions();
for(int i=0 ; i<numJ ; ++i) {
const RnaJunction &junction=junctions[i];
int begin=junction.getBegin(), end=junction.getEnd();
float depth=junction.getDepth();
for(int j=begin ; j<end ; ++j) A[j]+=depth;
}
}
void IntronDepthProfile::normalize()
{
int L=A.size();
float max=0;
for(int i=0 ; i<L ; ++i) {
float depth=A[i];
if(depth>max) max=depth;
}
for(int i=0 ; i<L ; ++i) A[i]/=max;
}
void IntronDepthProfile::rescale(float factor)
{
int L=A.size();
for(int i=0 ; i<L ; ++i)
A[i]*=factor;
}
float IntronDepthProfile::getMax() const
{
float m=0;
int L=A.size();
for(int i=0 ; i<L ; ++i) {
float x=A[i];
if(x>m) m=x;
}
return m;
}