schrodinger.application.ligprep.ionizer module¶
Ionizer module. Ported from ionizer.pl on February 2014.
Copyright (c) Schrodinger, LLC. All rights reserved.
-
class
schrodinger.application.ligprep.ionizer.
Fragment
(st, connect_to, chargef)¶ Bases:
object
Class representing a fragment from the ionizer library.
-
class
schrodinger.application.ligprep.ionizer.
Ionizer
(loglevel=0, specfile=None, ph=None, ph_thresh=None, pk_thresh=None)¶ Bases:
object
Class for ionizing structures (part of LigPrep).
To ionize a structure, do:
i = Ionizer() out_sts = i.ionizeStructure(st)
These options can be adjusted after instantiating the class:
Variables: - max_ions – Maximum number of ionizations.
- max_abstotq – Maximum absolute value of total charge.
- max_groups – Maximum ionizational groups to handle (up to MAX_GROUPS_MAX).
- max_outcts – Maximum output CTs per input CT.
- retain – Whether to retain the input structure in the output.
- retain_lab – Retain the input structure that has “i_lp_orig_ion_str” property set.
- show_match_atoms – Whether to report substructure pattern matches to the logger (log file).
- show_skips – Whether to show skipped state generations. Applies only to log levels 1 and up.
- keep_props – Whether to keep any structure-based properties from the input CT in the output CTs.
- retitle_with – Prefix for adding ion state numbers to output CT titles.
- logger – Logger instance. When processing CTs, any info, warning, and error messages will be redirected here.
- show_final_list – Report final ionization candidate list to logger.
-
addCostProperties
(st, ycost_total, zcost_total)¶ For use in pH mode only, this function adds CT-level properties recording the free energy costs associated with this particular ionization state.
-
addIonProperties
(st, state_num, total_charge, center_atoms_string, center_types_string, center_atoms_orig_string)¶ This function writes CT-level properties recording several details of a particular ionization state; it’s intended to be used on CTs generated for output; the values expressed in the properties must be calculated beforehand; all of these properties get marked as dependent on CONNECTIVITY.
-
collectIonCandidates
(st)¶ Check CT for matches to Acid/Base/Exclude patterns, in same order as supplied in control spec file; for non-Excluded, final Acid/Base matches, store specs in hash indexed on ion center atom number; also get ordered list of candidate atom numbers.
-
excludeCommandParser
(linenum, subs_patt)¶ Validate an “exclude” mmsubs pattern spec.
Parameters: - linenum (int) – Line number that is being parsed
- subs_patt (str) – Substructure pattern for this specification.
-
fuseIonFragment
(output_st, fuse_atom_orig, pre_fuse_center, renumbered_fuse_atoms, cand)¶ This function coordinates the ionization of one ionizable group, via mmbuild_fuse() of the appropriate ionizing fragment onto the group’s ionization center atom (same method as Maestro builder uses for Place onto non-terminal atom); function also takes care of various property adjustments in the modified CT.
-
generateStateCT
(st, total_charge, state_num, state_fuse_atoms, ion_candidates, ycost_total, zcost_total)¶ Generate the CT for the specificed ionization state.
Parameters: - st (
structure.Structure
) – Input structure. - total_charge (int) – Total charge of this ionization state.
- state_num (int) – The number of this state (0-indexed)
- state_fuse_atoms (list of ints) – List of atoms to which the new fragment will be attached to.
- ion_candidates (dict; key: atom index; value:
Spec
) – Specifications for this state change. - ycost_total (float) – Charging ionization penalty for this state
- zcost_total (float) – Neutral ionization penalty for this state
- st (
-
initializeMmlibs
()¶ Initialize the mmlibs libraries.
-
ionizeCommandParser
(linenum, cmd, subs_patt, frag_name, pka)¶ Validate mmsubs pattern spec; if all goes well, will store compiled pattern matcher below
Parses both Acid and Base specs.
Parameters: - linenum (int) – Line number that is being parsed
- cmd (str) – Spec command that is being parsed. Either “acid” or “base”.
- subs_patt (str) – Substructure pattern for this specification.
- frag_name (str) – Name of the fragment to use (from the “ionized” fragment library).
- pka (str) – String representation of the pKa for this ionizable group.
Return type: Returns: The Spec instance representing this ionizable group.
-
ionizeStructure
(st)¶ This is the public interface method. The specified CT will be ionized, and the output structures will be returned as a list.
Parameters: st (
structure.Structure
object) – Structure to ionize.Return type: List of structures.
Returns: Returns a list of ionized output structures.
Raises: - TooManyGroupsError – if the CT had too many ionizable groups.
- TolerableError – if there was a non-fatal error
- RuntimeError – on unexpected error
-
readFragmentLibrary
(flib_name)¶ Read the ionized frag library and populate self.frags dictionary.
The ionized frag lib contains a fairly small number of fragments, all or most of which will be fused in a typical run; therefore we just collect information on all of them now.
-
readSpecFile
()¶ Put cwd and $HOME/.schrodinger/mmshare at the front of the mmfile search path, to allow user “ionizer.ini” in either of those dirs to override installed data file in the mmshare data dir.
Note: We wait as late as possible to do this, to prevent any similar override of the mmfrag data files, which we currently consider to be inviolate, that is, the user must not be allowed to override them, even accidentally.
-
restoreIonCenterProps
(st, iatom)¶ Restores the atom properties saved by the method above. Also sets the default display color property based on the atom’s new (i.e., post-fuse) atom type. Pass in post-fuse atom number (new ionized group center or bonded H).
-
reviseIonizedGroup
(st, center_atom)¶ Function to apply above reset function to all atoms of newly ionized group. Pass in post-fuse ionized group center atom number Collect list of newly ionized group’s atoms (new ionized center + all Hydrogens bonded to it); revise certain atom properties to match original ion center
-
saveIonCenterProps
(st, center_anum)¶ Save certain properties of an ion center atom before the ionizing fuse.
-
class
schrodinger.application.ligprep.ionizer.
Spec
(cmd, linenum, mmsubs_pattern, mmsubs_handle)¶ Bases:
object
This class represents a specification line in the ionizer data file.
-
getMatches
(st)¶ Run a substracture search for this pattern in the specified structure.
Return type: list of int lists. Returns: A list of matches, where each list is a list of atom indices.
-
-
exception
schrodinger.application.ligprep.ionizer.
TolerableError
¶ Bases:
exceptions.Exception
Raised when the structure could not be processed due to a non-fatal error.
-
exception
schrodinger.application.ligprep.ionizer.
TooManyGroupsError
¶ Bases:
exceptions.Exception
Raised when the structure could not be processed because it has too many ionizable groups.
-
schrodinger.application.ligprep.ionizer.
format_charge
(charge)¶ Return a string representation of the charge. “-” will be prepended for negative numbers, “+” for positive, and nothing for zero.
-
schrodinger.application.ligprep.ionizer.
free_energy_costs
(x)¶ For a given pKa - pH difference X, this function calculates and returns RT.ln(10^X + 1) and RT.ln(10^(-X) + 1)
-
schrodinger.application.ligprep.ionizer.
get_bonded_hydrogens
(atom)¶ Return a list of atom numbers of all Hydrogens bonded to given atom.
-
schrodinger.application.ligprep.ionizer.
prepend_mmfile_path
(pdir)¶ Add the given path to the mmfile search path. This makes it possible to search for the mmfrag.ini file in custom locations.