Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add cycle_break attribute to molsetup Bond #254

Open
wants to merge 58 commits into
base: release
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
14ec360
minor fix to meeko.molsetup.Atom
rwxayheee Nov 12, 2024
a917592
Merge remote-tracking branch 'origin/develop' into molsetup_python_usage
rwxayheee Nov 16, 2024
36168d5
Merge remote-tracking branch 'origin/release' into molsetup_python_usage
rwxayheee Nov 26, 2024
8780dd0
add cycle_break attribute to molsetup Bond
diogomart Nov 27, 2024
07bc6f7
add option rename_atoms in prepare
rwxayheee Nov 27, 2024
1b52b64
add rename_atoms to MoleculePreparation and CLI ligprep script
rwxayheee Nov 27, 2024
64ef134
correct help message
rwxayheee Nov 27, 2024
e8cc1f5
correct help msg; minor fix
rwxayheee Nov 27, 2024
8a3a710
remove rename_atoms from MoleculePreparation
rwxayheee Nov 27, 2024
e27ca1c
update templates -> 7924c7f
rwxayheee Nov 30, 2024
e549a58
edit ambiguous dict for CHARMM27 resnames
rwxayheee Nov 30, 2024
5874160
use utility functions in jsonutils: string_to_tuple
rwxayheee Nov 30, 2024
638c4f4
remove unnecessary print
rwxayheee Nov 30, 2024
726ae0b
add args to read charges from atom prop
rwxayheee Nov 30, 2024
63b0fff
edit init_atom to support read charges from atom prop
rwxayheee Nov 30, 2024
bedbdb7
finish draft charges from mol2
rwxayheee Nov 30, 2024
2d9492e
change default read_charge_from_propname to _TriposPartialCharge
rwxayheee Nov 30, 2024
31c0d4b
fixup! change default read_charge_from_propname to _TriposPartialCharge
rwxayheee Nov 30, 2024
f6699e7
fixup! change default read_charge_from_propname to _TriposPartialCharge
rwxayheee Dec 1, 2024
4b08a31
add test for dihedral JSON (de)serialization
diogomart Dec 4, 2024
1cd72eb
Merge pull request #257 from rwxayheee/dihedrals_to_JSON
diogomart Dec 4, 2024
cad0e5e
warn rename_atoms with warnings
diogomart Dec 4, 2024
f14ba18
Merge pull request #256 from rwxayheee/template_mod
rwxayheee Dec 4, 2024
b41338c
Merge pull request #255 from rwxayheee/molsetup_python_usage
rwxayheee Dec 4, 2024
e0f7c53
set default atom property name to PartialCharge; revise error handlin…
rwxayheee Dec 5, 2024
6741616
rename charge_propname to charge_atom_prop
rwxayheee Dec 5, 2024
2bfa6a2
add option charge_from_prop to mk_prepare_ligand.py
rwxayheee Dec 5, 2024
c7f0fb4
use arguments from cli to override config, before
rwxayheee Dec 5, 2024
7f1380f
fixup! use arguments from cli to override config, before preparator =…
rwxayheee Dec 5, 2024
0568941
fix mistakes in handling args charge_from_prop and config;
rwxayheee Dec 5, 2024
772c8d9
Only explicitly provided command line arguments override config
rwxayheee Dec 6, 2024
3c4422c
remove special & redundant handling of explicitly prvided args;
rwxayheee Dec 6, 2024
5995773
clean up unused backend options; redirect error msg to file=sys.stderr
rwxayheee Dec 6, 2024
d0fd018
clearify error msg; make them all begin with Error:
rwxayheee Dec 6, 2024
86b0eb2
clean up lines added in testing
rwxayheee Dec 6, 2024
36c3af4
revert unecessary changes to make diffs prettier
rwxayheee Dec 6, 2024
eb82a91
docs: cli args override config file params
diogomart Dec 6, 2024
d9a2b82
docs: cli arg add_atom_types extends config (no override)
diogomart Dec 6, 2024
81151af
clean up changes; move --charge_atom_prop to config_group
rwxayheee Dec 6, 2024
a2a7984
clarify argparse overriding config file
diogomart Dec 6, 2024
efc78f5
Merge pull request #258 from rwxayheee/charges_from_mol2
rwxayheee Dec 6, 2024
02524c6
use plain \n as eol
rwxayheee Dec 7, 2024
71c1fbd
Merge pull request #265 from diogomart/minor_docs_edit
rwxayheee Dec 7, 2024
06f61eb
Merge pull request #266 from rwxayheee/cross_platform_newline
rwxayheee Dec 7, 2024
6314793
don't max out substructure matches at 1000
diogomart Dec 8, 2024
4554056
Merge pull request #270 from diogomart/develop
rwxayheee Dec 9, 2024
41ef572
catch prepare error without interrupting batch processing
rwxayheee Dec 9, 2024
a4e45d7
Merge pull request #272 from rwxayheee/catch_prepare_err_in_cli
rwxayheee Dec 9, 2024
cc7f0da
remove dependencies from setup.py
diogomart Dec 10, 2024
dc8b263
remove from class Ring the unused attributes:
rwxayheee Dec 10, 2024
485ead1
Merge pull request #274 from diogomart/pip_freedom
nbruciaferri Dec 10, 2024
b7ced6c
remove call to get_symmetries_for_rmsd from RDKitMoleculeSetup.from_m…
rwxayheee Dec 10, 2024
573a366
remove is_aromatic from ring's attributes
rwxayheee Dec 10, 2024
cd40ef1
test aromatic rings unbreakable with macrocycle code
diogomart Dec 11, 2024
5727d7f
Merge pull request #276 from rwxayheee/reduce_prepare_overhead
rwxayheee Dec 11, 2024
2a756b0
minor fixes and minor clean up
diogomart Dec 17, 2024
c5e38dc
Merge pull request #289 from diogomart/minor_cleanup
diogomart Dec 17, 2024
542e23d
Merge remote-tracking branch 'origin/develop' into bond_break_attribute
diogomart Dec 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions docs/source/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,25 @@ From conda-forge

micromamba install meeko

Other tools like ``mamba`` or ``conda`` can also be used. Note that ``conda``
is significantly slower.


From PyPI
------------------------
---------

.. code-block:: bash

pip install meeko

If using micromamba or a similar package manager, ``pip`` installs the package
in the active environment.
If using ``micromamba`` or a similar package manager, ``pip`` installs the
package in the active environment. The following dependencies required:
``python``, ``numpy``, ``scipy``, ``gemmi``, and ``rdkit``.

Installing with ``pip`` does not check for missing dependencies or attempt to
resolve conflicts between versions. That information is included on the
conda-forge recipe and used by a package manager like
``mamba`` or ``micromamba``.


From source
Expand Down
3 changes: 3 additions & 0 deletions docs/source/lig_prep_advanced.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ Alternatively, each parameter can be passed directly:

mk_prepare_ligand.py -i mol.sdf --charge_model gasteiger --merge_these_atom_types H

Parameters passed directly as command line arguments override those in the
configuration file. Exceptionally, option `add_atom_types` extends the
parameters in the configuration file.


Merging hydrogens (or not)
Expand Down
2 changes: 1 addition & 1 deletion meeko/cli/mk_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import gzip
import pathlib
import sys
from os import linesep as eol
eol="\n"
import warnings
import copy
import numpy as np
Expand Down
107 changes: 71 additions & 36 deletions meeko/cli/mk_prepare_ligand.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from datetime import datetime
import io
import os
from os import linesep as eol
eol="\n"
import sys
import json
import tarfile
Expand All @@ -33,7 +33,6 @@


def cmd_lineparser():
backend = "rdkit"

conf_parser = argparse.ArgumentParser(
description=__doc__,
Expand All @@ -47,13 +46,6 @@ def cmd_lineparser():
)
confargs, remaining_argv = conf_parser.parse_known_args()

config = MoleculePreparation.get_defaults_dict()

if confargs.config_file is not None:
with open(confargs.config_file) as f:
c = json.load(f)
config.update(c)

parser = (
argparse.ArgumentParser()
) # parents=[conf_parser]) # parents shows --config_file in help msg
Expand Down Expand Up @@ -214,10 +206,14 @@ def cmd_lineparser():
)
config_group.add_argument(
"--charge_model",
choices=("gasteiger", "espaloma", "zero"),
choices=("gasteiger", "espaloma", "zero", "read"),
help="default is 'gasteiger', 'zero' sets all zeros",
default="gasteiger",
)
config_group.add_argument(
"--charge_atom_prop",
help="set atom partial charges from an RDKit atom property based on the input file. The default is 'PartialCharge' for SDF and '_TriposPartialCharge' for MOL2 unless overriden by a user defined property name. ",
)
config_group.add_argument(
"--bad_charge_ok",
help="NaN and Inf charges allowed in PDBQT",
Expand All @@ -235,6 +231,12 @@ def cmd_lineparser():
action="store_true",
help="do not write smiles as remark to pdbqt",
)
config_group.add_argument(
"--rename_atoms",
dest="rename_atoms",
action="store_true",
help="rename atoms: the new name will be the original name and its (1-based) index in MoleculeSetup",
)
reactive_group = parser.add_argument_group("Reactive docking")
reactive_group.add_argument(
"--reactive_smarts", help="SMARTS pattern for reactive group"
Expand Down Expand Up @@ -273,6 +275,18 @@ def cmd_lineparser():
help="indices (1-based) of the SMARTS atoms that will be attached (default: 1 2)",
)

config = MoleculePreparation.get_defaults_dict()

if confargs.config_file is not None:
with open(confargs.config_file) as f:
c = json.load(f)
config.update(c)

# Command line arguments should override the config file only for options
# set explicitly by the user. The config file still has priority over the
# defaults set in argparse. To achieve this, we reset the argparse
# defaults to the values from the config file. Then, we can just update
# variable `config` with the values parsed with argparse
parser.set_defaults(**config)
args = parser.parse_args(remaining_argv)

Expand All @@ -293,13 +307,14 @@ def cmd_lineparser():
sys.exit(2)
args.reactive_smarts_idx -= 1 # convert from 1- to 0-index

# command line arguments override config
# This is where command line arguments override config file.
# Relies on key/parameter names being equal.
# Deliberate mismatch for add_atom_types/add_atom_types_json, as these
# are extended below instead of being replaced
for key in config:
if key in args.__dict__:
config[key] = args.__dict__[key]

config["load_atom_params"] = args.load_atom_params

if args.add_atom_types_json is not None:
additional_ats = []
for at in args.add_atom_types_json:
Expand All @@ -308,7 +323,7 @@ def cmd_lineparser():
additional_ats.append(at)
elif type(at) == list:
additional_ats.extend(at)
config["add_atom_types"] = additional_ats
config["add_atom_types"] += additional_ats

if args.multimol_output_dir is not None or args.multimol_prefix is not None:
if args.output_pdbqt_filename is not None:
Expand All @@ -329,7 +344,8 @@ def cmd_lineparser():
num_required_covalent_args += int(args.tether_smarts is not None)
if num_required_covalent_args not in [0, 3]:
print(
"Error: --receptor, --rec_residue, and --tether_smarts are all required for covalent docking."
"Error: --receptor, --rec_residue, and --tether_smarts are all required for covalent docking.",
file=sys.stderr,
)
sys.exit(2)
is_covalent = num_required_covalent_args == 3
Expand Down Expand Up @@ -364,7 +380,7 @@ def cmd_lineparser():
indices[0] = indices[0] - 1 # convert from 1- to 0-index
indices[1] = indices[1] - 1

return args, config, backend, is_covalent
return args, config, is_covalent


class Output:
Expand Down Expand Up @@ -495,27 +511,27 @@ def get_suffixes(molsetups):
return tuple("mk%d" % (i + 1) for i in range(len(molsetups)))

def main():
args, config, backend, is_covalent = cmd_lineparser()
args, config, is_covalent = cmd_lineparser()
input_molecule_filename = args.input_molecule_filename

# read input
input_fname, ext = os.path.splitext(input_molecule_filename)
ext = ext[1:].lower()
if backend == "rdkit":
parsers = {
"sdf": Chem.SDMolSupplier,
"mol2": rdkitutils.Mol2MolSupplier,
"mol": Chem.SDMolSupplier,
}
if not ext in parsers:
print(
"*ERROR* Format [%s] not in supported formats [%s]"
% (ext, "/".join(list(parsers.keys())))
)
sys.exit(1)
mol_supplier = parsers[ext](
input_molecule_filename, removeHs=False
) # input must have explicit H

parsers = {
"sdf": Chem.SDMolSupplier,
"mol2": rdkitutils.Mol2MolSupplier,
"mol": Chem.SDMolSupplier,
}
if not ext in parsers:
print(
"Error: Format [%s] not in supported formats [%s]"
% (ext, "/".join(list(parsers.keys())))
)
sys.exit(1)
mol_supplier = parsers[ext](
input_molecule_filename, removeHs=False
) # input must have explicit H

# configure output writer
if args.output_pdbqt_filename is None:
Expand Down Expand Up @@ -543,13 +559,24 @@ def main():
rec_prody_mol = prody_parser(rec_filename)
covalent_builder = CovalentBuilder(rec_prody_mol, args.rec_residue)

input_mol_counter = 0
input_mol_skipped = 0
input_mol_with_failure = (
0 # if reactive or covalent, each mol can yield multiple PDBQT
)
nr_failures = 0
is_after_first = False

if config["charge_atom_prop"] is not None:
if config["charge_model"] != "read":
print(f'Error: --charge_atom_prop must be used with --charge_model "read", but the current charge_model is "{config["charge_model"]}". ',
file=sys.stderr,)
sys.exit(1)
elif config["charge_model"] == "read":
if ext=="sdf":
config["charge_atom_prop"] = "PartialCharge"
elif ext=="mol2":
config["charge_atom_prop"] = "_TriposPartialCharge"

preparator = MoleculePreparation.from_config(config)
for mol in mol_supplier:
if is_after_first and output.is_multimol == False:
Expand All @@ -561,8 +588,7 @@ def main():
break

# check that molecule was successfully loaded
if backend == "rdkit":
is_valid = mol is not None
is_valid = mol is not None
input_mol_skipped += int(is_valid == False)
if not is_valid:
continue
Expand All @@ -587,6 +613,7 @@ def main():
cov_lig.mol,
root_atom_index=root_atom_index,
not_terminal_atoms=[root_atom_index],
rename_atoms=args.rename_atoms,
)
chain, res, num = cov_lig.res_id
suffixes = output.get_suffixes(molsetups)
Expand All @@ -610,7 +637,15 @@ def main():
print(error_msg, file=sys.stderr)

else:
molsetups = preparator.prepare(mol)
try:
molsetups = preparator.prepare(mol, rename_atoms=args.rename_atoms)
except Exception as error_msg:
nr_failures += 1
this_mol_had_failure = True
print(error_msg, file=sys.stderr)
input_mol_with_failure += int(this_mol_had_failure)
continue

if len(molsetups) > 1:
output.is_multimol = True
suffixes = output.get_suffixes(molsetups)
Expand Down
2 changes: 1 addition & 1 deletion meeko/cli/mk_prepare_receptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import argparse
import json
import math
from os import linesep as eol
eol="\n"
import pathlib
import sys

Expand Down
1 change: 1 addition & 0 deletions meeko/data/params/ad4_hb.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{"ad4_hb": [
{ "ad4_hb_hydrogen": false, "smarts": "[*]"},
{ "ad4_hb_hydrogen": true, "smarts": "[#1][#7,#8,#9,#15,#16]"},
{"ad4_hb_rij": 1.9, "ad4_hb_epsij": 5.0, "smarts": "[#8]"},
{"ad4_hb_rij": 1.9, "ad4_hb_epsij": 5.0, "smarts": "[#7;!+1;!+2;!$([#7X3v3][a]);!$([#7X3v3][#6X3v4])]"},
Expand Down
Loading