forked from psudmant/ssf_DTS_caller
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GC_data.py
29 lines (20 loc) · 909 Bytes
/
GC_data.py
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
from wssd_pw_common import *
class GC_data(object):
def __init__(self, fn_GC_DTS, contig, fn_contigs):
self.contig = contig
self.wnd_GC = DenseTrackSet(fn_contigs,
fn_GC_DTS,
overwrite=False,
openMode='r')
self.wnd_starts = self.wnd_GC["starts"][contig][:]
self.wnd_ends = self.wnd_GC["ends"][contig][:]
self.GC = self.wnd_GC["GC"][contig][:]
def get_GC(self, contig, start, end):
assert contig == self.contig
start_idx = np.searchsorted(self.wnd_starts, start)
end_idx = np.searchsorted(self.wnd_ends, end)
if end_idx<=start_idx:
end_idx = start_idx+1
elif end_idx-start_idx>1:
start_idx+=1
return np.mean(self.GC[start_idx:end_idx])