Skip to content

Commit 7a34285

Browse files
Ligandfit update (#329)
* Add scaling_id param to ligandfit * Make pipeline_final directory * Update conda requirements
1 parent 679a141 commit 7a34285

3 files changed

Lines changed: 24 additions & 11 deletions

File tree

requirements.conda.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ ispyb>=11.0.3
44
junit-xml>=1.9
55
marshmallow-sqlalchemy
66
minio>=7.1.0
7+
molviewspec
78
msgpack-python
89
networkx
910
nxmx
11+
openbabel
1012
pandas
1113
pika
1214
pint
@@ -19,7 +21,6 @@ python-jose
1921
python-relion
2022
pyyaml
2123
pyzmq
22-
rdkit
2324
seaborn
2425
sqlalchemy>=2.0.39,<3
2526
stomp.py>=7,<9

src/dlstbx/services/trigger.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2699,6 +2699,7 @@ def trigger_ligand_fit(
26992699
"smiles": parameters.smiles,
27002700
"pipeline": parameters.pipeline,
27012701
"acronym": acronym,
2702+
"scaling_id": scaling_id,
27022703
}
27032704

27042705
jp = self.ispyb.mx_processing.get_job_params()

src/dlstbx/wrapper/ligand_fit.py

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
import subprocess
99
from shutil import ignore_patterns
1010

11-
# import molviewspec as mvs
1211
from iotbx import pdb
13-
from rdkit import Chem
14-
from rdkit.Chem import Draw
12+
13+
# import molviewspec as mvs
14+
from openbabel import pybel
1515

1616
import dlstbx.util.symlink
1717
from dlstbx.wrapper import Wrapper
@@ -34,7 +34,7 @@ def pull_CC_from_log(self, pipeline_directory):
3434
CC = float(match.group(1))
3535
return CC
3636

37-
def send_attachments_to_ispyb(self, pipeline_directory):
37+
def send_attachments_to_ispyb(self, pipeline_directory, final_directory):
3838
for f in pipeline_directory.iterdir():
3939
if f.stem.endswith("final"):
4040
file_type = "Result"
@@ -54,6 +54,7 @@ def send_attachments_to_ispyb(self, pipeline_directory):
5454
else:
5555
continue
5656
try:
57+
shutil.copy(pipeline_directory / f.name, final_directory)
5758
result_dict = {
5859
"file_path": str(pipeline_directory),
5960
"file_name": f.name,
@@ -62,6 +63,7 @@ def send_attachments_to_ispyb(self, pipeline_directory):
6263
}
6364
self.record_result_individual_file(result_dict)
6465
self.log.info(f"Uploaded {f.name} as an attachment")
66+
6567
except Exception:
6668
self.log.warning(f"Could not attach {f.name} to ISPyB", exc_info=True)
6769

@@ -102,6 +104,15 @@ def run(self):
102104
working_directory.mkdir(parents=True, exist_ok=True)
103105
results_directory = pathlib.Path(params["results_directory"])
104106
results_directory.mkdir(parents=True, exist_ok=True)
107+
108+
if pipeline_final_params := params.get("pipeline-final", []):
109+
final_directory = pathlib.Path(pipeline_final_params["path"])
110+
final_directory.mkdir(parents=True, exist_ok=True)
111+
if params.get("create_symlink"):
112+
dlstbx.util.symlink.create_parent_symlink(
113+
final_directory, params.get("create_symlink")
114+
)
115+
105116
with open(working_directory / "LIG.smi", "w") as smi_file:
106117
smi_file.write(smiles)
107118

@@ -110,7 +121,7 @@ def run(self):
110121
# if pipeline == "phenix":
111122
# phenix_command = f"phenix.ligandfit data={mtz} model={pdb} ligand=LIG.smi min_ligand_cc_keep={min_cc_keep} nproc=8" # ligand={ligand_code}
112123
if pipeline == "phenix_pipeline":
113-
phenix_command = f"phenix.ligand_pipeline {pdb} {mtz} LIG.smi min_ligand_cc_keep={min_cc_keep} nproc=8"
124+
phenix_command = f"phenix.ligand_pipeline {pdb} {mtz} LIG.smi min_ligand_cc_keep={min_cc_keep} nproc=8" # build=False
114125

115126
try:
116127
result = subprocess.run(
@@ -145,7 +156,7 @@ def run(self):
145156
acr = params.get("acronym", "Protein")
146157

147158
os.system(
148-
f"module load molviewspec; gen_html.py --pdb_file {out_pdb} --map_file {out_map} --cc {CC} --outdir {pipeline_directory} --smiles '{smiles}' --acr {acr}"
159+
f"module load molviewspec; gen_html_ligandfit.py --pdb_file {out_pdb} --map_file {out_map} --cc {CC} --outdir {pipeline_directory} --smiles '{smiles}' --acr {acr}"
149160
)
150161

151162
self.generate_smiles_png(smiles, pipeline_directory)
@@ -175,7 +186,7 @@ def run(self):
175186
)
176187

177188
self.log.info("Sending results to ISPyB")
178-
self.send_attachments_to_ispyb(pipeline_directory)
189+
self.send_attachments_to_ispyb(pipeline_directory, final_directory)
179190

180191
if CC >= min_cc_keep:
181192
self.log.info("Ligand_fitting pipeline finished successfully")
@@ -187,9 +198,9 @@ def run(self):
187198
return False
188199

189200
def generate_smiles_png(self, smiles, outdir):
190-
mol = Chem.MolFromSmiles(smiles)
191-
img = Draw.MolToImage(mol, size=(450, 450))
192-
img.save(f"{outdir}/SMILES.png")
201+
mol = pybel.readstring("smi", smiles)
202+
mol.make2D()
203+
mol.draw(show=False, filename=(f"{outdir}/SMILES.png"))
193204

194205

195206
# def generate_html_visualisation(pdb_file, map_file, outdir, acr, smiles, cc):

0 commit comments

Comments
 (0)