diff --git a/chart/tools.py b/chart/tools.py index e570d84..6540fe0 100644 --- a/chart/tools.py +++ b/chart/tools.py @@ -3,6 +3,8 @@ import random import time import pandas as pd +from Bio import SeqIO +from Bio.SeqUtils import GC from Simple_Drawing.settings import BASE_DIR @@ -338,7 +340,7 @@ class="layui-input" style="height: 25px; width:80px;margin-top: 6px"> for d in self.Basics[title]: parameter = ChartParameter(d) - if parameter.input_type in ["rgb","hex",'color_name']: + if parameter.input_type in ["rgb", "hex", 'color_name']: code += f"""{parameter.name}:{parameter.name}, """ else: @@ -349,7 +351,7 @@ class="layui-input" style="height: 25px; width:80px;margin-top: 6px"> for d in self.Senior[title]: parameter = ChartParameter(d) print(parameter.input_type) - if parameter.input_type in ["rgb", "hex",'color_name']: + if parameter.input_type in ["rgb", "hex", 'color_name']: code += f"""{parameter.name}:{parameter.name}, """ else: @@ -381,7 +383,7 @@ class="layui-input" style="height: 25px; width:80px;margin-top: 6px"> } }); }) - """ % (i, random_color(), fl,i) + """ % (i, random_color(), fl, i) return code @@ -404,4 +406,68 @@ Treemap = { } +class Basics(object): + def __init__(self, file_path, args): + self.args = args + self.file_path = file_path + self.out_file = [] + self.f = SeqIO.parse(file_path, "fasta") # 读取多条序列 + def Sequence_cleaning(self): + f = self.f + temp = [] + for i in f: + temp.append(f">{i.id}\n{str(i.seq)}") + self.out_file.append(["Sequence_cleaning", temp]) + + def Sequence_length(self): + f = self.f + temp = [] + for i in f: + temp.append(f"{i.id}\t{len(i)}") + self.out_file.append(["Sequence_length", temp]) + + def GC_content(self): + f = self.f + temp = [] + for i in f: + CONTENT = GC(str(i.seq)) + temp.append(f"{i.id}\t{CONTENT}") + self.out_file.append(["GC_content", temp]) + + def Sequence_flip(self): + f = self.f + temp = [] + for i in f: + temp.append(f">{i.id}\n{str(i.reverse_complement().seq)}") + self.out_file.append(["Sequence_flip", temp]) + + def Reverse_complementarity(self): + f = self.f + temp = [] + for i in f: + temp.append(f">{i.id}\n{str(i.complement().seq)}") + self.out_file.append(["Reverse_complementarity", temp]) + + # def Codon_preference(self): + # f = self.f + # temp = [] + # for i in f: + # temp.append(f">{i.id}\n{str(i.complement().seq)}") + # self.out_file.append({"Reverse_complementarity": temp}) + + def run(self): + for i in self.args.keys(): + if self.args[i] == "YES": + eval(f"self.{self.args[i]}")() + + data = "" + for i in self.out_file: + for j in i: + data += f"\n{'-' * 15}\n{j[0]}\n" + data += "\n".join(i[1]) + + with open(self.file_path, "w") as f: + f.write(data) + + return data diff --git a/chart/urls.py b/chart/urls.py index 59f4f5f..d22801a 100644 --- a/chart/urls.py +++ b/chart/urls.py @@ -7,7 +7,5 @@ urlpatterns = [ path('down', views.download), url("(.*\.html$)", views.out_page), url('up_file', views.up_file), - url('tools$', views.tools), - url('tools$', views.tools), url('(.*)_run', views.chart_run), ] diff --git a/chart/views.py b/chart/views.py index 70a7742..d8812bc 100644 --- a/chart/views.py +++ b/chart/views.py @@ -122,19 +122,3 @@ def chart_run(request, get_chart_sort): return JsonResponse({"img": f"/static/img_eg/show_chart/{file_id}_{k}.png"}) -def tools(request): - file = request.FILES.get("file", None) # 标题 - mg = request.POST.get('mg', None) - data = "" - if file is None and mg is None: - return JsonResponse({"http": "内容为空"}) - if file is None: - data = 反向互补序列(mg) - else: - p = file.read() - p.decode(encoding='utf-8') - data = 反向互补序列(p.decode(encoding='utf-8')) - - file_path, file_id = path_out("tools") - keep_file(data, file_path, ui=1) - return JsonResponse({"work_id": file_id}) \ No newline at end of file diff --git a/templates/page/tools.html b/templates/page/tools.html index cbbd317..7b9e573 100644 --- a/templates/page/tools.html +++ b/templates/page/tools.html @@ -123,6 +123,7 @@ var form = layui.form; var url_up = "{{ url }}" var upload = layui.upload + var element = layui.element // 页面跳转加载函数 @@ -164,6 +165,7 @@ temp = $('#main_show') temp.empty() temp.append(String.raw`{% include 'tools/Basics.html' %}`) + basics_run() form.render(); } @@ -172,6 +174,7 @@ temp = $('#main_show') temp.empty() temp.append(String.raw`{% include 'tools/pfam.html' %}`) + pfam_run() form.render(); @@ -183,6 +186,7 @@ temp = $('#main_show') temp.empty() temp.append(String.raw`{% include 'tools/Differential_expression_analysis.html' %}`) + Differential_expression_analysis_run() form.render(); } @@ -338,6 +342,124 @@ ; }) } + + + function pfam_run() { + layui.use(['upload'], function () { + var $ = layui.jquery + , layer = layui.layer; + upload.render({ + elem: '#select_pfam' + , url: url_up + '/tools/' + "pfam" + , auto: false + , accept: 'file' + , data: { + csrfmiddlewaretoken: '{{ csrf_token }}', + b_dom: document.getElementById("b_dom").value, + b_seq: document.getElementById("b_seq").value, + e_dom: document.getElementById("e_dom").value, + e_seq: document.getElementById("e_seq").value, + align: document.getElementById("align").value, + clan_overlap: document.getElementById("clan_overlap").value, + } + , before: function (obj) { //obj参数包含的信息,跟 choose回调完全一致,可参见上文。 + layer.load(1); //上传loading + } + , bindAction: '#pfam_run' + , done: function (res, index) { + layer.closeAll('loading'); //关闭loading + ab = '' + ' ' + $("#down").append(ab) + } + , error: function (index, upload) { + layer.closeAll('loading'); //关闭loading + } + }) + ; + }) + } + + + function Differential_expression_analysis_run() { + + var uploadListIns = upload.render({ + elem: '#testList' + , elemList: $('#demoList') //列表元素对象 + , url: url_up + '/tools/' + "Differential_expression_analysis" //此处用的是第三方的 http 请求演示,实际使用时改成您自己的上传接口即可。 + , accept: 'file' + , multiple: true + , number: 10 + , auto: false + , bindAction: '#testListAction' + , choose: function (obj) { + var that = this; + var files = this.files = obj.pushFile(); //将每次选择的文件追加到文件队列 + //读取本地文件 + obj.preview(function (index, file, result) { + var tr = $(['
+
+ Group file suffix is group
+ The suffix of the statistics file is con
+ The suffix of the comparison file is TXT
+
+
+
Convert standard gff format files to standard gtf + format
+Convert standard gff format files to standard gtf + format
+