Skip to content

Commit 450b665

Browse files
author
Remco van den Broek
committed
Added: protein-complex PPM alignment
1 parent ff5f7ae commit 450b665

File tree

4 files changed

+93
-17
lines changed

4 files changed

+93
-17
lines changed

Diff for: README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ You can download any version of **PyModSim** by cloning the repository to your
1313
local machine using git.
1414

1515
You will need to create a free personal account at github and send
16-
and e-mail to: [r.l.van.den.broek@umail.leidenuniv.nl](r.l.van.den.broek@umail.leidenuniv.nl)
16+
and e-mail to: [r.l.van.den.broek@lacdr.leidenuniv.nl](r.l.van.den.broek@lacdr.leidenuniv.nl)
1717
requesting access to the code. After request processing from us you will be
1818
given access to the free repository.
1919

@@ -24,12 +24,13 @@ To install **PyModSim** follow these steps:
2424
Python 3.X (extensively tested on Python 3.10)
2525
Python modules:
2626
- modeller 10.2 (https://salilab.org/modeller/release.html)
27+
- biopython 1.81 (https://biopython.org/wiki/Download)
2728
AlphaFold 2.0 - (https://github.com/deepmind/alphafold)
2829
PPM 3.0 - (https://console.cloud.google.com/storage/browser/opm-assets/ppm3_code)
2930

3031
1. Clone **PyModSim** for Python 3.X with the *modeller* module:
3132

32-
git clone https://username@github.com/rlvandenbroek/pymodsim.git
33+
git clone https://username@github.com/GPCR-ModSim/pymodsim.git
3334

3435
Make sure to change *username* to the one you have created at
3536
github.

Diff for: commands.py

+59
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from Bio.PDB import PDBParser, Superimposer, PDBIO
12
import functools
23
import logging
34
import math
@@ -45,6 +46,36 @@ def __init__(self, *args, **kwargs):
4546
datefmt='%m/%d/%Y %I:%M:%S',
4647
level=logging.DEBUG)
4748

49+
def superimpose(self, **kwargs):
50+
"""
51+
superimpose: superimpose the initial protein complex (.pdb) file with the PPM-aligned protein
52+
"""
53+
parser = PDBParser()
54+
fixed = parser.get_structure("fixed", os.path.join(self.work_dir, kwargs["src"]))
55+
moving = parser.get_structure("moving", os.path.join(self.work_dir, kwargs["pdb"]))
56+
57+
# Select the first models in each structure for superimposing
58+
model1 = fixed[0]
59+
model2 = moving[0]
60+
61+
chain1 = list(model1.get_chains())[0]
62+
chain2 = list(model2.get_chains())[0]
63+
64+
atoms1 = [atom for atom in chain1.get_atoms() if atom.name == "CA"]
65+
atoms2 = [atom for atom in chain2.get_atoms() if atom.name == "CA"]
66+
67+
# Superimposer objects
68+
super_imposer = Superimposer()
69+
super_imposer.set_atoms(atoms1, atoms2)
70+
super_imposer.apply(model2.get_atoms())
71+
logging.debug("RMSD: " + str(super_imposer.rms))
72+
73+
# Save superimposed objects
74+
io = PDBIO()
75+
io.set_structure(moving)
76+
io.save(os.path.join(self.work_dir, kwargs["tgt"]))
77+
78+
4879
def clean_pdb(self, **kwargs):
4980
"""
5081
clean_pdb: Remove membrane from pdb
@@ -61,6 +92,34 @@ def clean_pdb(self, **kwargs):
6192

6293
tgt.close()
6394

95+
def get_protein(self, **kwargs):
96+
"""
97+
get_protein: Get protein structure (.pdb) from a protein complex file (.pdb)
98+
"""
99+
protein_res_names = ["ALA", "ARG", "ASN", "ASP", "CYS", "CYX", "GLN", "GLU", "GLY", "HIS",
100+
"HIE", "HID", "HIP", "HISE", "HISD", "HISH", "ILE", "LEU", "LYS",
101+
"MET", "PHE", "PRO", "SER", "THR", "TRP", "TYR", "VAL", ]
102+
103+
tgt = open(os.path.join(self.work_dir, kwargs["tgt"]), "w")
104+
105+
with open(os.path.join(self.work_dir, kwargs["pdb"]), "r") as src:
106+
chain = 0
107+
for line in src:
108+
if line.startswith("TER"):
109+
tgt.write(line)
110+
chain += 1
111+
112+
if line.startswith("ATOM") or line.startswith("HETATM"):
113+
# add protein chain IDs
114+
if line[21] == ' ':
115+
line = line[:21] + (chr(ord('A') + chain) + line[22:])
116+
117+
# only save protein residues
118+
res_name = line[17:21].strip()
119+
if res_name in protein_res_names:
120+
tgt.write(line)
121+
tgt.close()
122+
64123
def make_inp(self, **kwargs):
65124
"""
66125
make_inp: Create a PPM input file (.inp)

Diff for: pymodsim

100644100755
File mode changed.

Diff for: recipes.py

+31-15
Original file line numberDiff line numberDiff line change
@@ -80,50 +80,66 @@ def __init__(self, **kwargs):
8080

8181
class Orientation(object):
8282
def __init__(self, **kwargs):
83-
self.steps = ["set_stage_init", "make_inp", "ppm", "clean_pdb",
84-
"set_end1", "set_end2"]
83+
self.steps = ["set_stage_init", "get_protein", "make_inp", "ppm", "clean_pdb",
84+
"superimpose", "set_end1", "set_end2"]
8585

8686
self.recipe = \
8787
{"set_stage_init": {"command": "set_stage_init", # 1
8888
"options": {"repo_files": ["res.lib"],
8989
"tgt_dir": "."}},
9090

91-
"make_inp": {"command": "make_inp", # 2
91+
"get_protein": {"command": "get_protein", # 2
9292
"options": {"pdb": "",
93+
"tgt": "protein_stripped.pdb"}},
94+
95+
"make_inp": {"command": "make_inp", # 3
96+
"options": {"pdb": "protein_stripped.pdb",
9397
"tgt": "2membranes.inp"}},
9498

95-
"ppm": {"ppm": "ppm", # 3
99+
"ppm": {"ppm": "ppm", # 4
96100
"options": {"inp": "2membranes.inp"}},
97101

98-
"clean_pdb": {"command": "clean_pdb", # 4
99-
"options": {"src": "",
100-
"tgt": "homology.pdb"}},
102+
"clean_pdb": {"command": "clean_pdb", # 5
103+
"options": {"src": "protein_strippedout.pdb",
104+
"tgt": "protein_aligned.pdb"}},
101105

102-
"set_end1": {"command": "set_stage_init", # 5
106+
"superimpose": {"command": "superimpose", # 6
107+
"options": {"pdb": "",
108+
"src": "protein_aligned.pdb",
109+
"tgt": "homology.pdb"}},
110+
111+
"set_end1": {"command": "set_stage_init", # 7
103112
"options": {"src_dir": "",
104113
"src_files": "",
105114
"tgt_dir": "finalOutput"}},
106115

107-
"set_end2": {"command": "set_stage_init", # 6
116+
"set_end2": {"command": "set_stage_init", # 8
108117
"options": {"src_dir": "",
109-
"src_files": ["homology.pdb"],
118+
"src_files": ["protein_stripped.pdb",
119+
"protein_aligned.pdb",
120+
"homology.pdb"],
110121
"tgt_dir": "finalOutput"}}}
111122

112123
self.breaks = \
113-
{"make_inp": {"pdb": "pdb_3"},
114-
"clean_pdb": {"src": "pdb_3out"},
115-
"set_end1": {"src_files": "pdb_3out"}}
124+
{"get_protein": {"pdb": "pdb_3"},
125+
"superimpose": {"pdb": "pdb_3"},
126+
"set_end1": {"src_files": "pdb_3"}}
116127

117128

118129
##########################################################################
119130
# Collect All Results & Output #
120131
##########################################################################
121132
class CollectResults(object):
122133
def __init__(self, **kwargs):
123-
self.steps = ["tar_out"]
134+
self.steps = ["set_end", "tar_out"]
124135

125136
self.recipe = \
126-
{"tar_out": {"command": "tar_out", # 1
137+
{"set_end": {"command": "set_stage_init", # 1
138+
"options": {"src_dir": "",
139+
"src_files": ["pymodsim.log"],
140+
"tgt_dir": "finalOutput"}},
141+
142+
"tar_out": {"command": "tar_out", # 2
127143
"options": {"src_dir": "finalOutput",
128144
"tgt": "Model_output.tgz"}}}
129145

0 commit comments

Comments
 (0)