Skip to content
This repository has been archived by the owner on Jun 1, 2021. It is now read-only.

Commit

Permalink
freeze before clean tools/view
Browse files Browse the repository at this point in the history
  • Loading branch information
Crazy-Jack committed Dec 16, 2019
1 parent 8976249 commit 767d553
Show file tree
Hide file tree
Showing 11 changed files with 83 additions and 54 deletions.
2 changes: 1 addition & 1 deletion cirDraw/media/example/example_results

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions cirDraw/static/tools/js/denChrPlot.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ $("#previous").click(function () {
index = getIndex();
if (index > 0) {
blockRecord[densityFilter[index - 1].chr+densityFilter[index - 1].start].click();
currentClickBlock = $chr.text() + $('#js-input-from').text();
/* preDen = densityFilter[index - 1];
$('#geneNameSelect').val(preDen.name);
$("#js-input-from").text(preDen.start);
Expand All @@ -450,6 +451,7 @@ $("#next").click(function () {
// console.log('Next index:', index);
if (index < densityFilter.length - 1) {
blockRecord[densityFilter[index + 1].chr+densityFilter[index + 1].start].click();
currentClickBlock = $chr.text() + $('#js-input-from').text();
/*
$('#geneNameSelect').val(nextDen.name);
$("#js-input-from").text(nextDen.start);
Expand Down
9 changes: 5 additions & 4 deletions cirDraw/static/tools/js/drawCirc.js
Original file line number Diff line number Diff line change
Expand Up @@ -973,8 +973,8 @@ function ring(opt) {
}).click(function () {
if (links !== undefined & links !== null) {
elink = links.split(',')
for (var i = 0, up = links.length; i < up; i++) {
openNewTab(links[i]);
for (var i = 0, up = elink.length; i < up; i++) {
openNewTab(elink[i]);
}
}
});
Expand Down Expand Up @@ -1004,8 +1004,9 @@ function ring(opt) {
}
}).click(function () {
if (links !== undefined & links !== null) {
for (var i = 0, up = links.length; i < up; i++) {
openNewTab(links[i]);
elink = links.split(',')
for (var i = 0, up = elink.length; i < up; i++) {
openNewTab(elink[i]);
}
}
});
Expand Down
5 changes: 3 additions & 2 deletions cirDraw/static/tools/js/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ $(document).ready(function () {
$('#uploadlabel').hide();
document.querySelector('.textarea').innerText = example_content;
$('#submit').prop('disabled', true);
finishProcess('8bd10a77cbda74ed2513d2643a39b0bb');
finishProcess('4672896d383d34c10a4561dddece79aa');
});

function finishProcess(md5, display_time) {
Expand Down Expand Up @@ -144,6 +144,7 @@ $(document).ready(function () {
data: formdata,
processData: false,
contentType: false,
timeout: 5000000000,
};

/* else {
Expand Down Expand Up @@ -248,7 +249,7 @@ $(document).ready(function () {
function () {
$('.lds-roller').remove();
$('#upload-text').remove();
$('#processtip').html('<p>Failed to upload, please check your connection and <a id="refresher" onclick="location.reload()"><i>refresh</i><i class="fas fa-redo-alt ml-1"></i></a></p>');
$('#processtip').html('<p>Server timeout, please <a id="refresher" onclick="location.reload()"><i>refresh</i><i class="fas fa-redo-alt ml-1"></i></a></p>');
$('#refresher').hover(function(){
$('#refresher').css({'cursor':'pointer', 'color': '#fed136'});
},
Expand Down
4 changes: 2 additions & 2 deletions cirDraw/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<!-- CSS -->
<link rel="stylesheet" href="https://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.13.2/css/bootstrap-select.min.css">
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css">
<!--<link rel="stylesheet" href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css">-->
<link href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.7.0/animate.min.css" rel="stylesheet">
<link href="{% static 'base/css/agency.css' %}" rel="stylesheet">
<link href="{% static 'base/css/circCirc.css' %}" rel="stylesheet">
Expand All @@ -46,7 +46,7 @@
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav text-uppercase ml-auto">
<li class="nav-item">
<a class="nav-link js-scroll-trigger" href="/tools/display/8bd10a77cbda74ed2513d2643a39b0bb">Example</a>
<a class="nav-link js-scroll-trigger" href="/tools/display/4672896d383d34c10a4561dddece79aa">Example</a>
</li>
<li class="nav-item">
<a class="nav-link js-scroll-trigger" href="{% url 'tools' %}">Upload</a>
Expand Down
66 changes: 43 additions & 23 deletions cirDraw/tools/handle_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,24 +118,36 @@ def find_exon_combo(chr_num: str, circStart: int, circEnd: int, assembly: str, b
engine.dispose()
connection = engine.raw_connection()
try:
get_gene_script = f'select id from {assembly}_genome_genes where chr_num="{chr_num}" and start<={circStart+bias} and end>={circEnd-bias};'
get_gene_script_1 = f'select id from {assembly}_genome_genes where chr_num="{chr_num}" and start<={circStart+bias} and end>={circStart-bias};'
get_gene_script_2 = f'select id from {assembly}_genome_genes where chr_num="{chr_num}" and start<={circEnd+bias} and end>={circEnd-bias};'
with connection.cursor() as cur:
cur.execute(get_gene_script)
get_gene = cur.fetchall()
except:
cur.execute(get_gene_script_1)
get_gene_1 = cur.fetchall()
cur.execute(get_gene_script_2)
get_gene_2 = cur.fetchall()
get_gene = get_gene_1 + get_gene_2
except Exception as e:
print('When get gene', e)
return None, None, None

transcripts_pool = []
if len(get_gene) == 0:
#print(f'circRNA: {chr_num}|{circStart}-{circEnd}: \033[33mGene Not Found\033[0m')
return None, None, None
elif len(get_gene) > 0:

for i in get_gene:
get_transcripts_script = f'select id from {assembly}_genome_transcripts where gene="{i[0]}" and start<={circStart+bias} and end>={circEnd-bias};'
with connection.cursor() as cur:
cur.execute(get_transcripts_script)
get_transcripts = cur.fetchall()
get_transcripts_script_1 = f'select id from {assembly}_genome_transcripts where gene="{i[0]}" and start<={circStart+bias} and end>={circStart-bias};'
get_transcripts_script_2 = f'select id from {assembly}_genome_transcripts where gene="{i[0]}" and start<={circEnd+bias} and end>={circEnd-bias};'
try:
with connection.cursor() as cur:
cur.execute(get_transcripts_script_1)
get_transcripts_1 = cur.fetchall()
cur.execute(get_transcripts_script_2)
get_transcripts_2 = cur.fetchall()
get_transcripts = get_transcripts_1 + get_transcripts_2
#print(get_transcripts)
except Exception as e:
print('When get transcripts', e)
if len(get_transcripts) == 0:
pass
else:
Expand Down Expand Up @@ -219,7 +231,7 @@ def process_file(file, assembly: str, file_type, task_id, bias=2):
with connection.cursor() as cur:
cur.execute(f'select disease from circ_disease where assembly="{assembly}" and chr_num="{chr_num}" and start>={start-bias} and start<={start+bias} and end<={end+bias} and end>={end-bias};')
disease = cur.fetchall()
print(disease)
#print(disease)
if len(disease) == 0:
disease = 'Unknown'
else:
Expand Down Expand Up @@ -261,8 +273,11 @@ def process_file(file, assembly: str, file_type, task_id, bias=2):

for circ in unmap_circ:
try:
combo, gene, transcript = find_exon_combo(circ[0], int(circ[1]), int(circ[2]), assembly)
#print(gene, transcript)
try:
combo, gene, transcript = find_exon_combo(circ[0], int(circ[1]), int(circ[2]), assembly)
#print(gene, transcript)
except Exception as e:
print('When calculating exon combo', e)
if combo != None:
#print('before components')
try:
Expand All @@ -274,16 +289,20 @@ def process_file(file, assembly: str, file_type, task_id, bias=2):
except Exception as e:
print(e)
#print('After components')
for i in components:
i['mods'] = ujson.loads(i['mods'])
#print('alter components')
with connection.cursor() as cur:
cur.execute(f'select disease from circ_disease where assembly="{assembly}" and chr_num="{chr_num}" and start>={start-bias} and start<={start+bias} and end<={end+bias} and end>={end-bias};')
disease = cur.fetchall()
if len(disease) == 0:
try:
disease = 'Unknown'
else:
disease = disease[0]
for i in components:
if type(i['mods']) == str:
i['mods'] = ujson.loads(i['mods'])
#print('alter components')
with connection.cursor() as cur:
cur.execute(f'select disease from circ_disease where assembly="{assembly}" and chr_num="{chr_num}" and start>={start-bias} and start<={start+bias} and end<={end+bias} and end>={end-bias};')
find_disease = cur.fetchall()
#print(find_disease)
if len(find_disease) > 0:
disease = find_disease[0]
except Exception as e:
print('When mapping disease',e)

try:
circ_on_gene[gene][1].append({"start": int(circ[1]),
Expand Down Expand Up @@ -311,7 +330,7 @@ def process_file(file, assembly: str, file_type, task_id, bias=2):
except Exception as e:
print("Add circ error:", e)
except Exception as e:
print(mp.current_process().name, "Failed to process one unmapped circ:", e)
print(mp.current_process().name, "Failed to process one unmapped circ:", circ[0], int(circ[1]), int(circ[2]), e)

print('Mapped circ:', len(circ_on_gene))
return circ_on_gene
Expand Down Expand Up @@ -363,7 +382,7 @@ def handle(config):
result[k][1] += v[1]
except:
result[k] = v

#print('raw result:', circ_on_gene_all)
print('Create result file:', path + config['NEW_FILE'])
with open(path + config['NEW_FILE'], 'w+') as f:
for _,v in result.items():
Expand Down Expand Up @@ -432,6 +451,7 @@ def count_dist(array, step):
cord[s[i]] += 1
return cord
try:
tmp_circ_len = {}
if len(circRNA_length) > 16:
tmp_circ_len = count_dist(np.array(circRNA_length,dtype=np.float64),16)
else:
Expand Down
2 changes: 1 addition & 1 deletion cirDraw/tools/templates/tools/tools.html
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ <h2 id="BaTable" class="d-inline-block mr-3">Possible modifications on circRNA</
<!-- Outside js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/intro.js/2.9.3/intro.min.js" type="text/javascript"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tabulator/4.2.3/js/tabulator.js"></script>
<script src="https://cdn.bootcss.com/echarts/4.1.0.rc2/echarts-en.common.js" type="text/javascript"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/echarts/4.2.1/echarts-en.common.js" integrity="sha256-4omDrvG5ELofoBmmZnfzGAe2hzSzjiG2qHBXIZwuDXA=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/snap.svg/0.5.1/snap.svg-min.js" type="text/javascript"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.5.3/jspdf.debug.js"
integrity="sha384-NaWTHo/8YCBYJ59830LTz/P4aQZK1sS0SneOgAvhsIl3zBu8r9RevNg5lHCHAuQ/" crossorigin="anonymous">
Expand Down
2 changes: 1 addition & 1 deletion cirDraw/tools/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
urlpatterns = [

# Render pages
url(r'^$', views.render_upload_page, name='tools'),
url(r'^$', views.render_upload_page, name='tools'),
url(r'^display/(?P<md5>[0-9a-f-]+)$', views.render_display_page, name="render_display"),

# Upload
Expand Down
24 changes: 24 additions & 0 deletions load.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import pymysql
import ujson

connection = pymysql.connect(host='127.0.0.1',
port=6603,
user='root',
db='circDraw',
password='mypassword',
charset='utf8',
local_infile=True)

with connection.cursor() as cur:
counter = 0
with open('/home/circ/map_circ/server/hg19_circRNA_annotated.txt','r') as f1:
for line in f1:
i = line.strip().split('\t')
cur.execute(f'''INSERT INTO hg19_circRNAs_new (gene,transcript,chr_num,start,end,components) VALUES ("{i[0]}","{i[1]}","{i[2]}","{i[3]}","{i[4]}",{ujson.dumps(i[-1])})''')
connection.commit()
with open('/home/circ/map_circ/server/hg38_circRNA_annotated.txt','r') as f2:
for line in f2:
i = line.strip().split('\t')
cur.execute(f'''INSERT INTO hg38_circRNAs_new (gene,transcript,chr_num,start,end,components) VALUES ("{i[0]}","{i[1]}","{i[2]}","{i[3]}","{i[4]}",{ujson.dumps(i[-1])})''')
connection.commit()

19 changes: 0 additions & 19 deletions process_watchdog/auto-clean.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,4 @@
#!/usr/bin/python3
#import datetime
#import time
#
#path = "/home/circ/circDraw/process_watchdog/auto-clean.log"
## reset
#with open(path, 'w') as f:
# f.write(str(datetime.datetime.now()) + ": Restart")
# f.write('\n')
#
#while True:
# time.sleep(2)
# a = datetime.datetime.now()
# with open(path, 'a') as f:
# f.write(str(a))
# print(a)
# f.write('\n')
#

import mysqlconnect as mc
import datetime, time
Expand Down Expand Up @@ -61,8 +44,6 @@ def cleanup_once(login_file_name, logfile):





def main():
check_duration = 1800 # as in seconds
login_file_name = '/home/circ/circDraw/process_watchdog/admin_login.json'
Expand Down
2 changes: 1 addition & 1 deletion process_watchdog/resetdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def main(login_file_name, inp):

elif inp == "clean":
clean_box = ['tools_species_circrnas', 'tools_species_genome_exons_introns', 'tools_species_genome_genes', 'tools_species_genome_transcripts']
example_md5 = ''#'8bd10a77cbda74ed2513d2643a39b0bb'
example_md5 = '4672896d383d34c10a4561dddece79aa'#'8bd10a77cbda74ed2513d2643a39b0bb'
path_box = ["../cirDraw/media/md5_data/"]
empty_db(connector, clean_box)
empty_dir(path_box)
Expand Down

0 comments on commit 767d553

Please sign in to comment.