Skip to content

config

Classes:

  • Config

    The configuration with parameters that can be used to define the entire protocol.

Config

Config(**kwargs)

The configuration with parameters that can be used to define the entire protocol. The settings can be overridden later in the actual classes.

The settings are stored as properties in the object and can be overwritten.

Methods:

Attributes:

Source code in ties/config.py
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
def __init__(self, **kwargs):
    # set the path to the scripts
    self.code_root = pathlib.Path(os.path.dirname(__file__))

    # scripts/input files,
    # these are specific to the host
    self.script_dir = self.code_root / 'scripts'
    self.namd_script_dir = self.script_dir / 'namd'
    self.ambertools_script_dir = self.script_dir / 'ambertools'
    self.tleap_check_protein = self.ambertools_script_dir / 'check_prot.in'
    self.vmd_vis_script = self.script_dir / 'vmd' / 'vis_morph.vmd'
    self.vmd_vis_script_sh = self.script_dir / 'vmd' / 'vis_morph.sh'

    self._workdir = None
    self._antechamber_dr = False
    self._ambertools_home = None

    self._protein = None

    self._ligand_net_charge = None
    self._atom_pair_q_atol = 0.1
    self._net_charge_threshold = 0.1
    self._redistribute_q_over_unmatched = True
    self._allow_disjoint_components = False
    # use only the element in the superimposition rather than the specific atom type
    self._use_element = False
    self._use_element_in_superimposition = True
    self.starting_pairs_heuristics = True
    # weights in choosing the best MCS, the weighted sum of "(1 - MCS fraction) and RMSD".
    self.weights = [1, 0.5]

    # coordinates
    self._align_molecules_using_mcs = False
    self._use_original_coor = False
    self._coordinates_file = None

    self._ligand_files = set()
    self._manually_matched_atom_pairs = None
    self._manually_mismatched_pairs = None
    self._ligands_contain_q = None

    self._ligand_tleap_in = None
    self._complex_tleap_in = None

    self._superimposition_starting_pair = None

    self._protein_ff = None
    self._ligand_ff = 'leaprc.gaff'
    self._ligand_ff_name = 'gaff'

    # MD/NAMD production input file
    self._md_engine = 'namd'
    #default to modern CPU version
    self.namd_version = '2.14'
    self._lambda_rep_dir_tree = False

    # experimental
    self._use_hybrid_single_dual_top = False
    self._ignore_charges_completely = False

    self.ligands = None

    # if True, do not allow ligands with the same ligand name
    self.uses_cmd = False

    # assign all the initial configuration values
    self.set_configs(**kwargs)

    # logging
    self.logging_breakdown = False
    self.logging_formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
    self.logging_level = logging.INFO

workdir property writable

workdir

Working directory for antechamber calls. If None, a temporary directory in /tmp/ will be used.

:return: Work dir :rtype: str

protein property writable

protein

Path to the protein

:return: Protein filename :rtype: str

ligand_files property writable

ligand_files

A list of ligand filenames. :return:

ambertools_home property writable

ambertools_home

Ambertools HOME path. If not configured, the env variable AMBERHOME as AMBER_PREFIX will be checked.

:return: ambertools path

ambertools_antechamber property

ambertools_antechamber

Antechamber path based on the .ambertools_home

:return:

ambertools_parmchk2 property

ambertools_parmchk2

Parmchk2 path based on the .ambertools_home :return:

ambertools_tleap property

ambertools_tleap

Tleap path based on the .ambertools_home :return:

antechamber_dr property writable

antechamber_dr

Whether to use -dr setting when calling antechamber.

:return:

ligand_net_charge property writable

ligand_net_charge

The ligand charge. If not provided, neutral charge is assumed. The charge is necessary for calling antechamber (-nc).

:return:

coordinates_file property writable

coordinates_file

A file from which coordinate can be taken.

:return:

atom_pair_q_atol property writable

atom_pair_q_atol

It defines the maximum difference in charge between any two superimposed atoms a1 and a2. If the two atoms differ in charge more than this value, they will be unmatched and added to the alchemical regions.

:return: default (0.1e) :rtype: float

net_charge_threshold property writable

net_charge_threshold

Defines how much the superimposed regions can, in total, differ in charge. If the total exceeds the thresholds, atom pairs will be unmatched until the threshold is met.

:return: default (0.1e) :rtype: float

ignore_charges_completely property writable

ignore_charges_completely

Ignore the charges during the superimposition. Useful for debugging. :return: default (False) :rtype: bool

allow_disjoint_components property writable

allow_disjoint_components

Defines whether there might be multiple superimposed areas that are separated by alchemical region.

:return: default (False) :rtype: bool

use_element_in_superimposition property writable

use_element_in_superimposition

Use element rather than the actual atom type for the superimposition during the joint-traversal of the two molecules.

:return: default (False) :rtype: bool

align_molecules_using_mcs property writable

align_molecules_using_mcs

After determining the maximum common substructure (MCS), use it to align the coordinates of the second molecule to the first.

:return: default (False) :rtype: bool

use_original_coor property writable

use_original_coor

Antechamber when assigning charges can modify the charges slightly. If that's the case, use the original charges in order to correct this slight divergence in coordinates.

:return: default (?) :rtype: bool

ligands_contain_q property writable

ligands_contain_q

If not provided, it tries to deduce whether charges are provided. If all charges are set to 0, then it assumes that charges are not provided.

If set to False explicitly, charges are ignored and computed again.

:return: default (None) :rtype: bool

superimposition_starting_pair property writable

superimposition_starting_pair

Set a starting pair for the superimposition to narrow down the MCS search. E.g. "C2-C12"

:rtype: str

manually_matched_atom_pairs property writable

manually_matched_atom_pairs

Either a list of pairs or a file with a list of pairs of atoms that should be superimposed/matched.

:return:

manually_mismatched_pairs property writable

manually_mismatched_pairs

A path to a file with a list of a pairs that should be mismatched.

protein_ff property writable

protein_ff

The protein forcefield to be used by ambertools for the protein parameterisation.

:return: default (leaprc.ff19SB) :rtype: string

md_engine property writable

md_engine

The MD engine, with the supported values NAMD2.13, NAMD2.14, NAMD3 and OpenMM

:return: NAMD2.13, NAMD2.14, NAMD3 and OpenMM :rtype: string

ligand_ff property

ligand_ff

The forcefield for the ligand.

ligand_ff_name property writable

ligand_ff_name

Either GAFF or GAFF2

:return:

redistribute_q_over_unmatched property writable

redistribute_q_over_unmatched

The superimposed and matched atoms have every slightly different charges. Taking an average charge between any two atoms introduces imbalances in the net charge of the alchemical regions, due to the different charge distribution.

:return: default(True)

use_hybrid_single_dual_top property writable

use_hybrid_single_dual_top

Hybrid single dual topology (experimental). Currently not implemented.

:return: default(False).

ligand_tleap_in property

ligand_tleap_in

The name of the tleap input file for ambertools for the ligand.

:return: Default ('leap_ligand.in') :rtype: string

complex_tleap_in property

complex_tleap_in

The tleap input file for the complex.

:return: Default 'leap_complex.in' :type: string

prep_dir property

prep_dir

Path to the prep directory. Currently in the workdir

:return: Default (workdir/prep)

pair_morphfrcmods_dir property

pair_morphfrcmods_dir

Path to the .frcmod files for the morph.

:return: Default (workdir/prep/morph_frcmods)

pair_morphfrmocs_tests_dir property

pair_morphfrmocs_tests_dir

Path to the location where a test is carried out with .frcmod

:return: Default (workdir/prep/morph_frcmods/tests)

pair_unique_atom_names_dir property

pair_unique_atom_names_dir

Location of the morph files with unique filenames.

:return: Default (workdir/prep/morph_unique_atom_names)

lig_unique_atom_names_dir property

lig_unique_atom_names_dir

Directory location for files with unique atom names.

:return: Default (workdir/prep/unique_atom_names)

lig_frcmod_dir property

lig_frcmod_dir

Directory location with the .frcmod created for each ligand.

:return: Default (workdir/prep/ligand_frcmods)

lig_acprep_dir property

lig_acprep_dir

Directory location where the .ac charges are converted into the .mol2 format.

:return: Default (workdir/prep/acprep_to_mol2)

lig_dir property

lig_dir

Directory location with the .mol2 files.

:return: Default (workdir/mol2)

get_element_map staticmethod

get_element_map()

:return:

Source code in ties/config.py
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
@staticmethod
def get_element_map():
    """


    :return:
    """
    # Get the mapping of atom types to elements
    element_map_filename = pathlib.Path(os.path.dirname(__file__)) / 'data' / 'element_atom_type_map.txt'
    # remove the comments lines with #
    lines = filter(lambda l: not l.strip().startswith('#') and not l.strip() == '', open(element_map_filename).readlines())
    # convert into a dictionary

    element_map = {}
    for line in lines:
        element, atom_types = line.split('=')

        for atom_type in atom_types.split():
            element_map[atom_type.strip()] = element.strip()

    return element_map

get_serializable

get_serializable()

Get a JSON serializable structure of the config.

pathlib.Path is not JSON serializable, so replace it with str

todo - consider capturing all information about the system here, including each suptop.get_serializable() so that you can record specific information such as the charge changes etc.

:return: Dictionary {key:value} with the settings :rtype: Dictionary

Source code in ties/config.py
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
def get_serializable(self):
    """
    Get a JSON serializable structure of the config.

    pathlib.Path is not JSON serializable, so replace it with str

    todo - consider capturing all information about the system here,
    including each suptop.get_serializable() so that you can record
    specific information such as the charge changes etc.

    :return: Dictionary {key:value} with the settings
    :rtype: Dictionary
    """

    host_specific = ['code_root', 'script_dir0', 'namd_script_dir',
                     'ambertools_script_dir', 'tleap_check_protein', 'vmd_vis_script']

    ser = {}
    for k, v in self.__dict__.items():
        if k in host_specific:
            continue

        if type(v) is logging.Formatter:
            continue

        if type(v) is pathlib.PosixPath:
            v = str(v)

        # account for the ligands being pathlib objects
        if k == 'ligands' and v is not None:
            # a list of ligands, convert to strings
            v = [str(l) for l in v]
        if k == '_ligand_files':
            continue

        ser[k] = v

    return ser