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
|
||||
|
||||
Reference in New Issue
Block a user