-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathprepare4scan.py
32 lines (24 loc) · 896 Bytes
/
prepare4scan.py
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
import argparse
parser = argparse.ArgumentParser(description='prepare for PositionScan in FoldX')
parser.add_argument("-i", help="input a fasta file")
parser.add_argument("-p", help="the a pdb file corresponding to the fasta file, a repaired pdbfile mostly")
args = parser.parse_args()
inf = open(args.i)
pdbid = args.p
def readseq(fasta):
seq = ''
for line in fasta:
line = line.strip('\n')
if not line.startswith('>'):
seq += line
return seq
ofile = open('config_scan.cfg', "w")
print('command=PositionScan' + '\n' + 'pdb=' + pdbid + '\n' + 'positions=', end='', file=ofile)
seq = readseq(inf)
for i in range(len(seq)):
if i < len(seq) - 1:
new_word = seq[i] + 'A' + str(i + 1) + 'a,'
print(new_word, end='', file=ofile)
else:
new_word = seq[i] + 'A' + str(i + 1) + 'a'
print(new_word, end='', file=ofile)