-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathseq_parser.py
More file actions
63 lines (50 loc) · 1.6 KB
/
seq_parser.py
File metadata and controls
63 lines (50 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import sys
import shutil
import subprocess
import os
from lasso_extension.lasso_peptide_gen import *
path = os.getcwd()
def get_cwd(directory):
"""get directory
"""
real_dir_path = f"{path}/{directory}"
if not os.path.isdir(real_dir_path):
os.mkdir(real_dir_path)
cwd = os.path.abspath(real_dir_path)
return cwd
def seq_parse(seq:str, ring_len: int, upper_plug: int):
sequence = seq
seq_len = len(sequence)
ring = ring_len
loop = upper_plug
isopeptide = ''
tail_length = seq_len - ( ring + loop )
for idx , char in enumerate(seq):
idx += 1
if idx == ring:
isopeptide = 'e' if char in 'E' else 'd'
return sequence, ring, loop, tail_length, isopeptide
def seq_flags(seq: str, ring_num: int):
"""generates flags from sequence
"""
lis = []
for idx, char in enumerate(seq):
idx +=1
if idx == ring_num: #acidic residue
continue
lis.append('A' + str(idx) + char)
return lis
def construct_scaffold(seq:str, ring_len: int, upper_plug:int, wk_dir):
"""constructs scaffold from given sequence
"""
cwd = get_cwd(wk_dir)
seq, ring, loop, tail_length, isopeptide = seq_parse(seq, ring_len, upper_plug)
outfile = f"{ring}{isopeptide}_{loop}_{tail_length}.pdb"
lasso_peptide_gen(ring, loop, tail_length, isopeptide, outfile)
out_path = "lasso_extension/output_structures/" + outfile
outfile_mover(out_path, cwd)
return out_path
def outfile_mover(lasso,wk_dir):
"""moves outfile to working directory.
"""
filePath = shutil.copy(lasso, wk_dir)