|
import re |
|
|
|
from tname import * |
|
from Rfile import * |
|
|
|
|
|
def Strip(seq_file): |
|
contents = j_reads(seq_file.name) |
|
ina = Name() |
|
ina = ina + r"input.tsv" |
|
|
|
|
|
for i in range(0, len(contents) - 1): |
|
if contents[i][0] != '>' and contents[i + 1][0] != '>': |
|
content = contents[i].split() |
|
content = content[0] |
|
else: |
|
content = contents[i] |
|
with open(ina, "a") as f: |
|
f.write(content) |
|
|
|
with open(ina, "a") as f: |
|
f.write(contents[len(contents) - 1]) |
|
return ina |
|
|
|
|
|
def Merge(smi_file, seq_file): |
|
smile = j_read(smi_file.name) |
|
smile = smile.strip("\n") |
|
|
|
|
|
contents = j_reads(seq_file.name) |
|
|
|
name = Name() |
|
name = name + r"kcat_input.tsv" |
|
|
|
with open(name, "a") as f3: |
|
f3.write("Substrate Name Substrate SMILES Protein Sequence") |
|
f3.write("\n") |
|
|
|
for i in range(0, len(contents)): |
|
if i % 2 == 1: |
|
with open(name, "a") as f3: |
|
|
|
f3.write(">seq" + str(int((i - 1) / 2))) |
|
f3.write("\t") |
|
|
|
f3.write(smile) |
|
f3.write("\t") |
|
|
|
f3.write(contents[i]) |
|
return name |
|
|
|
|
|
def Merge_All(smi_file, seq_file): |
|
smile = j_read(smi_file.name) |
|
smile = smile.strip("\n") |
|
|
|
|
|
contents = j_reads(seq_file.name) |
|
|
|
name = Name() |
|
name = name + r"kcat_input.tsv" |
|
|
|
with open(name, "a") as f3: |
|
f3.write("Substrate Name Substrate SMILES Protein Sequence") |
|
f3.write("\n") |
|
|
|
for i in range(0, len(contents)): |
|
if i % 2 == 1: |
|
with open(name, "a") as f3: |
|
|
|
|
|
info = re.sub(' ', '_', contents[i - 1]) |
|
info = re.sub('\n', '', info) |
|
f3.write(info) |
|
f3.write("\t") |
|
|
|
f3.write(smile) |
|
f3.write("\t") |
|
|
|
f3.write(contents[i]) |
|
return name |
|
|