-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathindividual_input.py
More file actions
54 lines (48 loc) · 1.93 KB
/
individual_input.py
File metadata and controls
54 lines (48 loc) · 1.93 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
import os
from pathlib import Path
import schrodinger.structure as structure
from schrodinger.application.desmond import constants
#from schrodinger.application.desmond.starter.generator.abfep import prepare_inputs, generate
from schrodinger.application.desmond.starter.generator.fep_absolute_binding import prepare_inputs, generate
KEEP_CT_TYPE = [
constants.CT_TYPE.VAL.MEMBRANE,
constants.CT_TYPE.VAL.SOLVENT
]
if __name__ == '__main__':
import argparse
parser = argparse.ArgumentParser(description="Extract individual pv files from one FEP pv file.")
parser.add_argument('mae_file', help="File with input structures for FEP")
parser.add_argument('dir_base', help="Name for the output directory")
args = parser.parse_args()
# Read the file with input structures
with structure.StructureReader(args.mae_file) as streader:
cms_components = [st for st in streader]
# Start the list of template structures.
# The first entry is supposed to be the receptor
template = [cms_components[0]]
# Start the list of ligands
ligands = []
# Add membrane and solvent to template.
# Everything else is interpreted as a ligand.
for st in cms_components[1:]:
prop = st.property.get(constants.CT_TYPE)
if prop in KEEP_CT_TYPE:
template.append(st)
else:
ligands.append(st)
# for each ligand
for lig_st in ligands:
# Get its name
name = lig_st.title.replace(' ','_')
# Create the job dir and go there
lig_path = Path(args.dir_base, name)
os.makedirs(lig_path, exist_ok=True)
os.chdir(lig_path)
# Write an input structure file
mae_path = Path(name+'.mae')
with structure.StructureWriter(mae_path) as stwriter:
for st in template:
stwriter.append(st)
stwriter.append(lig_st)
# Go back up in the dir hierarchy
os.chdir('../..')