-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathConnGO_check_smiles.py
More file actions
33 lines (28 loc) · 972 Bytes
/
ConnGO_check_smiles.py
File metadata and controls
33 lines (28 loc) · 972 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
32
import os, sys
import linecache
import numpy as np
file_name = sys.argv[1]
dir_path = sys.argv[3]
or_smi = sys.argv[2]
new_fname = dir_path + "/modified_smiles.smi"
or_path = dir_path + "/" + or_smi
for line in open(or_path,"r"):
if file_name in line:
with open("temp_file","w") as tf:
tf.write(line.strip())
for line in open("temp_file", "r"):
if "[NH3+]" in line:
rp1 = line.replace("[NH3+]","N")
rp1 = rp1.replace("[O-]", "O")
with open(new_fname, "a") as nf:
nf.write(rp1 + "\n")
if "[NH2+]" in line:
rp1 = line.replace("[NH2+]","N")
rp1 = rp1.replace("[O-]", "O")
with open(new_fname, "a") as nf:
nf.write(rp1 + "\n")
if "[NH+]" in line:
rp1 = line.replace("[NH+]","N")
rp1 = rp1.replace("[O-]", "O")
with open(new_fname, "a") as nf:
nf.write(rp1 + "\n")