1
1
import sys
2
- import os
3
2
import numpy as np
4
3
from flask import Flask , render_template , request , send_file
5
4
6
5
import os
7
- from os .path import basename , exists
6
+ from os .path import exists
8
7
9
8
import json
10
9
18
17
hicexplorer .trackPlot .DEFAULT_WIDTH_RATIOS = (0.89 , 0.11 )
19
18
hicexplorer .trackPlot .DEFAULT_MARGINS = {'left' : 0.02 , 'right' : 0.98 , 'bottom' : 0 , 'top' : 1 }
20
19
20
+
21
21
def get_TAD_for_gene (gene_name ):
22
22
"""
23
23
Returs the TAD position of a given gene name
@@ -34,8 +34,7 @@ def get_TAD_for_gene(gene_name):
34
34
chrom_ = chrom_ [3 :]
35
35
else :
36
36
chrom_ = 'chr' + chrom_
37
- tad_pos = tads_intval_tree [chrom_ ].find (start_ , end_ )[0 ]
38
-
37
+ tad_pos = sorted (tads_intval_tree [chrom_ ][start_ , end_ ])[0 ]
39
38
return chrom_ , tad_pos .start , tad_pos .end
40
39
else :
41
40
return None
@@ -148,9 +147,9 @@ def main(config_file, port, numProc, template_folder=None, debug=False):
148
147
149
148
# register an static path for images using Blueprint
150
149
images_static = Blueprint ('site' , __name__ ,
151
- static_url_path = '/images' ,
152
- template_folder = template_folder ,
153
- static_folder = img_path )
150
+ static_url_path = '/images' ,
151
+ template_folder = template_folder ,
152
+ static_folder = img_path )
154
153
app .register_blueprint (images_static )
155
154
156
155
# setup up the tracks. It works as follows
@@ -190,8 +189,6 @@ def main(config_file, port, numProc, template_folder=None, debug=False):
190
189
track_file = config .get ('general' , 'tracks' )
191
190
tads = hicbrowser .tracks2json .SetTracks (track_file , fig_width = 40 )
192
191
193
- #tads = hicexplorer.trackPlot.PlotTracks(track_file, fig_width=40, dpi=70)
194
-
195
192
from hicexplorer .trackPlot import opener
196
193
with opener (genes ) as fh :
197
194
for line in fh .readlines ():
@@ -223,9 +220,9 @@ def get_tad(gene_name):
223
220
224
221
# plot
225
222
outfile = "{}/{}_{}_{}.json" .format (tad_img_root ,
226
- chromosome ,
227
- start ,
228
- end )
223
+ chromosome ,
224
+ start ,
225
+ end )
229
226
if not exists (outfile ):
230
227
with open (outfile , 'w' ) as fh :
231
228
sys .stderr .write ("Saving json file: {}\n " .format (outfile ))
0 commit comments