tools
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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),
|
||||
]
|
||||
|
||||
@@ -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})
|
||||
Reference in New Issue
Block a user