-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScript
More file actions
31 lines (24 loc) · 1020 Bytes
/
Copy pathScript
File metadata and controls
31 lines (24 loc) · 1020 Bytes
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
#formatador de pdb
def add_chain_ids(input_pdb, output_pdb, chain_ids=('A', 'B')):
with open(input_pdb, 'r') as infile:
lines = infile.readlines()
current_chain = 0
atom_count = 0
with open(output_pdb, 'w') as outfile:
for line in lines:
if line.startswith("ATOM"):
if "TP3M" not in line:
atom_count += 1
if atom_count > 9951: #Mude conforme o arquivo
current_chain = (current_chain + 1) % len(chain_ids)
atom_count = 1
modified_line = line[:21] + chain_ids[current_chain] + line[22:]
outfile.write(modified_line)
else:
outfile.write(line)
else:
outfile.write(line)
print("Arquivo formatado!! :D")
input_pdb = 'structure.pdb'
output_pdb = 'structure_chains.pdb'
add_chain_ids(input_pdb, output_pdb, chain_ids=('A', 'B'))