diff --git a/doc/tests/scripts/sidechain_steps.py b/doc/tests/scripts/sidechain_steps.py index be9f5c7558e9e14d9f90c0507a0766933ed5daaa..bf1a3866356d84db21819df5fa63218a41575b58 100644 --- a/doc/tests/scripts/sidechain_steps.py +++ b/doc/tests/scripts/sidechain_steps.py @@ -5,7 +5,8 @@ from promod3 import sidechain prot = io.LoadPDB('data/1CRN.pdb') # load rotamer library library = sidechain.LoadDunbrackLib() -# we need a rotamer constructor to create any rotamers or frame residues +# we need a rotamer constructor to create any rotamers or +# frame residues rot_constructor = sidechain.SCWRLRotamerConstructor() # create new entity from protein only containing the amino acids diff --git a/sidechain/doc/CMakeLists.txt b/sidechain/doc/CMakeLists.txt index 451e23076d3dd70b2ac3c895636bccc053da930f..b38d2f0a696ad677f23cc4361c77cf83ce9cfe90 100644 --- a/sidechain/doc/CMakeLists.txt +++ b/sidechain/doc/CMakeLists.txt @@ -5,7 +5,7 @@ rotamer.rst rotamer_id.rst frame.rst rotamer_lib.rst -sidechain_settings.rst +rotamer_constructor.rst graph.rst disulfid.rst loading.rst diff --git a/sidechain/doc/frame.rst b/sidechain/doc/frame.rst index d392553cd4cba2ef8dda3e9620cc2f9c0d1be59b..f72d44585d5d0add22d404eae05dcce924eb33aa 100644 --- a/sidechain/doc/frame.rst +++ b/sidechain/doc/frame.rst @@ -17,9 +17,6 @@ The Frame Objects -------------------------------------------------------------------------------- .. class:: FrameResidue(particles, residue_index) - - The most simple way of constructing a frame residue is the usage - of the convenient functions provided by PROMOD3. :param particles: particles building frame residue :param residue_index: Interaction energies between the constructed frame @@ -47,30 +44,12 @@ The Frame Objects .. class:: Frame(frame_residues) - The :class:`Frame` object allows to calculate frame energies for rotamers. - Due to technical reasons, this is only possible if the rotamers are - part of rotamer groups. + The :class:`Frame` object is used as a container for rigid particles, that + can be passed to rotamer groups for calculating frame energies. :param frame_residues: residues building the frame. :type frame_residues: :class:`list` of :class:`FrameResidue` - .. method:: SetFrameEnergy(rotamer_group) - - Calculates and sets frame energies for all rotamers in the rotamer group. - - :param rotamer_group: group of rotamers for energy calculation - - :type rotamer_group: :class:`RRMRotamerGroup` / :class:`FRMRotamerGroup` - - .. method:: AddFrameEnergy(rotamer_group) - - Calculates and adds frame energies to the already existing frame - energy values for all rotamers in the rotamer group. - This is useful if you have several :class:`Frame` objects. - - :param rotamer_group: group of rotamers for energy calculation - - :type rotamer_group: :class:`RRMRotamerGroup` / :class:`FRMRotamerGroup` Convenient functions for constructing frame residues diff --git a/sidechain/doc/graph.rst b/sidechain/doc/graph.rst index 965355b4f58358d015dd9b69389ba74de391643b..7e8ae2ef0e7cb029aacc991127a52dccdd0f07c5 100644 --- a/sidechain/doc/graph.rst +++ b/sidechain/doc/graph.rst @@ -19,20 +19,13 @@ and finally comes back with a solution. .. staticmethod:: CreateFromRRMList(rotamer_groups) - :param rotamer_groups: :class:`RRMRotamerGroup` objects representing the - possible sidechain conformations for every amino - acid position. - - :type rotamer_groups: :class:`list` - - .. staticmethod:: CreateFromFRMList(rotamer_groups) - :param rotamer_groups: :class:`FRMRotamerGroup` objects representing the - possible sidechain conformations for every amino - acid position. + :param rotamer_groups: :class:`RRMRotamerGroup` or :class:`FRMRotamerGroup` + objects representing the possible sidechain + conformations for every amino acid position. - :type rotamer_groups: :class:`list` + :type rotamer_groups: :class:`list` .. method:: Prune(epsilon, [e_cut=0.0, consider_all_nodes=False]) diff --git a/sidechain/doc/index.rst b/sidechain/doc/index.rst index 62cc9b2d688bafb84e01706bf0ea767cea6bf5a6..a1ba3806d3fff16687944b8a4067be5401680f96 100644 --- a/sidechain/doc/index.rst +++ b/sidechain/doc/index.rst @@ -40,7 +40,10 @@ Contents: rotamer frame rotamer_lib + rotamer_constructor graph - sidechain_settings disulfid loading + + +.. [krivov2009] Krivov GG, Shapovalov MV and Dunbrack RL Jr. (2009). Improved prediction of protein side-chain conformations with SCWRL4. Proteins. diff --git a/sidechain/doc/loading.rst b/sidechain/doc/loading.rst index 8f1471906600a90cf1c9fc94bc268c40ee5a600b..b795abc601ad9c617895d86a63316a14623727bf 100644 --- a/sidechain/doc/loading.rst +++ b/sidechain/doc/loading.rst @@ -25,8 +25,8 @@ the backbone independent Penultimate library [lovell2000]_ . Loads the backbone independent Penultimate library. The values for the dihedral angles are directly extracted from the publication without considering the - probabilities specifically for helices/sheets. Due to no assigned standard - deviations, the flexible rotamer model won't work. + probabilities specific for helices/sheets. Due to no assigned standard + deviations, the flexible rotamer model won't produce meaningful results. :returns: The requested library :rtype: :class:`RotamerLib` @@ -36,7 +36,7 @@ the backbone independent Penultimate library [lovell2000]_ . Reads a file as it is provided when you get a licence for the 2010 library of the Dunbrack lab. It can only read the classic version, where all rotamers - are in a single file. Specific distributions of nonrotameric sidechains also + are in a single file. Specific distributions of nonrotameric sidechains cannot be read. :param filename: Name of the file @@ -51,8 +51,6 @@ the backbone independent Penultimate library [lovell2000]_ . :rtype: :class:`BBDepRotamerLib` -.. [krivov2009] Krivov GG, Shapovalov MV and Dunbrack RL Jr. (2009). Improved prediction of protein side-chain conformations with SCWRL4. Proteins. - .. [shapovalov2011] Shapovalov MV and Dunbrack RL Jr. (2011). A smoothed backbone-dependent rotamer library for proteins derived from adaptive kernel density estimates and regressions. Structure. .. [lovell2000] Lovell SC, Word JM, Richardson JS, Richardson DC (2000). The penultimate rotamer library. Proteins. diff --git a/sidechain/doc/rotamer.rst b/sidechain/doc/rotamer.rst index 3d21bcc74fc1ff859fddbe0110d05c756e904079..2a10c66f1d570c17a7441d0fe891ff26dd279884 100644 --- a/sidechain/doc/rotamer.rst +++ b/sidechain/doc/rotamer.rst @@ -3,15 +3,17 @@ Rotamers .. currentmodule:: promod3.sidechain -The rotamers in PROMOD3 are heavily based on the definitions from SCWRL4. -A rotamer is basically a set of :class:`Particle` and exists in two types. -The :class:`RRMRotamer` and :class:`FRMRotamer`. Pairwise energies between -rotamer instances get calculated according to the definitions from SCWRL4. +A rotamer represents an amino acid sidechain and is basically a set of +:class:`Particle` objects. There exist two types. The :class:`RRMRotamer` and +:class:`FRMRotamer`. To gather all possible rotamers for one particular sidechain position, -PROMOD3 has the :class:`RRMRotamerGroup` and :class:`FRMRotamerGroup`. -Rotamers are not intended to be built from scratch. -PROMOD3 offers a built-in construction function, directly accessing a -:class:`BBDepRotamerLib`. +PROMOD3 offers the :class:`RRMRotamerGroup` and :class:`FRMRotamerGroup`. +Pairwise interactions between particles give raise to pairwise energies between +rotamers. Nevertheless, the energy calculation itself happens on the level +of RotamerGroups and is mostly hidden away in the construction of the +the :class:`RotamerGraph`. If you're too lazy to build up your rotamers +by hand, you might be interested in the :class:`SCWRLRotamerConstructor`. + The Smallest Building Block - The Particle @@ -114,11 +116,24 @@ Rotamers -------------------------------------------------------------------------------- -.. class:: RRMRotamer +.. class:: RRMRotamer(particles, probability, internal_e_prefactor) The RRMRotamer represents a rotamer of the so called rigid rotamer model. - The class has no constructor exported to python, the rotamer is expected to - be constructed with the convenient functions provided by PROMOD3. + + :param particles: List of :class:`Particle` objects + :param probability: Probability of rotamers. In case of the SCWRL4 + energy calculation, this directly controls the + internal energy of that rotamer. + :param internal_e_prefactor: Factor applied to the internal energy calculated + as -log(**probability**/max_probability), + where max_probability is the maximum + rotamer probability of any rotamer in a + particular :class:`RRMRotamerGroup`. + + :type particles: :class:`list` + :type probability: :class:`float` + :type internal_e_prefactor: :class:`float` + .. method:: __getitem__(index) @@ -139,13 +154,14 @@ Rotamers .. method:: ApplyOnResidue(res, consider_hydrogens=False, new_res_name="") - Strips all sidechain atom positions of given residue and reconstructs the - full sidechain given the positions of the particles in the rotamer. + Iterates over every particle and searches for the according atom in + **res**. If it's present, the position gets reset to the particle position. + If not, a new atom gets added to **res**. :param res: Residue to be reconstructed :param consider_hydrogens: Flag, whether polar hydrogens should be added to - the sidechain - :param new_res_name: New name of residue. Nothing happens in case of the + **res** + :param new_res_name: New name of **res**. Nothing happens in case of the default value ("") :type res: :class:`ost.mol.ResidueHandle` @@ -168,26 +184,10 @@ Rotamers :raises: :exc:`~exceptions.RuntimeError` if *res_idx* is invalid - .. method:: GetTransformedCopy(transform) - - Transforms all particle positions including their lone pair and polar - directions. - - :param transform: Transformation to be applied - - :type transform: :class:`ost.geom.Transform` - :returns: :class:`RRMRotamer` with all particles transformed - - - .. method:: CalculateInternalEnergy(normalization_factor) - - Calculates and sets the rotamer internal energy of the form: - -prefactor*log(probability/normalization_factor) - - :param normalization_factor: Normalization factor for internal probability + .. method:: GetInternalEnergyPrefactor() - :type normalization_factor: :class:`float` + :returns: Prefactor used in internal energy calculation .. method:: GetInternalEnergy() @@ -195,15 +195,11 @@ Rotamers :returns: Internal Energy if calculated, 0.0 otherwise - .. method:: GetInternalEnergyPrefactor() - - :returns: Prefactor used in internal energy calculation - - .. method:: GetFrameEnergy() - Returns previously calculated frame energy, this energy has to be calculated - using a :class:`Frame`. + Returns frame energy. This energy can either be manually set or calculated + using a :class:`Frame` and the :class:`RRMRotamerGroup` this rotamer + belongs to. :returns: Frame energy if calculated, 0.0 otherwise @@ -218,16 +214,16 @@ Rotamers :returns: probability of this rotamer - .. method:: SetInternalEnergy(energy) + .. method:: SetInternalEnergyPrefactor(prefactor) - :param energy: Internal energy to be set + :param energy: Internal energy prefactor to be set :type energy: :class:`float` - .. method:: SetInternalEnergyPrefactor(prefactor) + .. method:: SetInternalEnergy(energy) - :param energy: Internal energy prefactor to be set + :param energy: Internal energy to be set :type energy: :class:`float` @@ -239,6 +235,13 @@ Rotamers :type energy: :class:`float` + .. method:: AddFrameEnergy(energy) + + :param energy: Frame energy to be added + + :type energy: :class:`float` + + .. method:: SetProbability(probability) :param energy: Internal probability to be set @@ -247,14 +250,31 @@ Rotamers -.. class:: FRMRotamer +.. class:: FRMRotamer(particles, T, probability, internal_e_prefactor) - The FRMRotamer represents a rotamer of the so called flexible rotamer model. - The class has no constructor exported to python, the rotamer is expected to - be constructed with the convenient functions provided by PROMOD3. - The flexible rotamer contains several so called subrotamers. The internal data - layout is a list of particles and a list of subrotamer definitions in form - of particle indices. + The FRMRotamer represents a rotamer of the so called flexible rotamer model, + where one rotamer gets represented by several subrotamers. + The idea is, that all particles of all subrotamers are given at + initialization. Subrotamers are then defined by providing lists of indices. + One particle can be part of several subrotamers. + + :param particles: List of :class:`Particle` objects + :param probability: Probability of rotamers. In case of the SCWRL4 + energy calculation, this directly controls the + internal energy of that rotamer. + :param T: Temperature factor, that is used to generate a final + energy given the subrotamers according to the formalism + described in the SCWRL4 paper. + :param internal_e_prefactor: Factor applied to the internal energy calculated + as -log(**probability**/max_probability), + where max_probability is the maximum + rotamer probability of any rotamer in a + particular :class:`FRMRotamerGroup`. + + :type particles: :class:`list` + :type probability: :class:`float` + :type T: :class:`float` + :type internal_e_prefactor: :class:`float` .. method:: __getitem__(index) @@ -279,35 +299,11 @@ Rotamers :returns: Number of subrotamers - - .. method:: GetSubrotamerDefinition(index) - - :param index: Index of subrotamer - - :type index: :class:`int` - - :returns: :class:`list` of particle indices belonging to this - particular subrotamer - - :raises: :exc:`~exceptions.RuntimeError` if index is invalid - - - .. method:: GetSubrotamerAssociations(index) - - :param index: Index of particle - - :type index: :class:`int` - - :returns: :class:`list` of subrotamer indices this particle is - associated with - - :raises: :exc:`~exceptions.RuntimeError` if index is invalid - - .. method:: ApplyOnResidue(res, consider_hydrogens=False, new_res_name="") - Strips all sidechain atom positions of given residue and reconstructs the - full sidechain given the positions of the particles in the rotamer. + Iterates over every particle of the first subrotamer and searches for the + according atom in **res**. If it's present, the position gets reset to the + particle position. If not, a new atom gets added to **res**. :param res: Residue to be reconstructed :param consider_hydrogens: Flag, whether polar hydrogens should be added to @@ -335,51 +331,37 @@ Rotamers :raises: :exc:`~exceptions.RuntimeError` if *res_idx* is invalid + .. method:: GetSubrotamerDefinition(index) - .. method:: GetTransformedCopy(transform) - - Transforms all particle positions including their lone pair and polar - directions. - - :param transform: Transformation to be applied - - :type transform: :class:`ost.geom.Transform` + :param index: Index of subrotamer - :returns: :class:`FRMRotamer` with all particles transformed + :type index: :class:`int` + :returns: :class:`list` of particle indices belonging to this + particular subrotamer - .. method:: CalculateInternalEnergy(normalization_factor) - - Calculates and sets the rotamer internal energy of the form: - -prefactor*log(probability/normalization_factor) + :raises: :exc:`~exceptions.RuntimeError` if index is invalid - :param normalization_factor: Normalization factor for internal probability - :type normalization_factor: :class:`float` + .. method:: GetInternalEnergyPrefactor() + :returns: Prefactor used in internal energy calculation .. method:: GetInternalEnergy() :returns: Internal Energy if calculated, 0.0 otherwise - - .. method:: GetInternalEnergyPrefactor() - - :returns: Prefactor used in internal energy calculation - - .. method:: GetFrameEnergy() - Returns previously calculated frame energy of the full FRMRotamer, this - energy has to be calculated using a :class:`Frame`. + Returns frame energy. This energy can either be manually set or calculated + using a :class:`Frame` and the :class:`FRMRotamerGroup` this rotamer + belongs to. :returns: Frame energy if calculated, 0.0 otherwise - .. method:: GetFrameEnergy(index) - Returns previously calculated frame energy of the subrotamer specified by - *index*, this energy has to be calculated using a :class:`Frame`. + Returns frame energy of specified **index**. :param index: Index of subrotamer you want the frame energy from @@ -405,35 +387,56 @@ Rotamers :returns: Probability of this rotamer - .. method:: SetInternalEnergy(energy) + .. method:: SetInternalEnergyPrefactor(prefactor) - :param energy: Internal energy to be set + :param energy: Internal energy prefactor to be set :type energy: :class:`float` - .. method:: SetInternalEnergyPrefactor(prefactor) + .. method:: SetInternalEnergy(energy) - :param energy: Internal energy prefactor to be set + :param energy: Internal energy to be set :type energy: :class:`float` .. method:: SetFrameEnergy(energy) - :param energy: Frame energy for full rotamer to be set to be set + :param energy: Frame energy for full rotamer to be set :type energy: :class:`float` .. method:: SetFrameEnergy(energy, index) - :param energy: Frame energy for single subrotamer to be set to be set + :param energy: Frame energy for single subrotamer to be set + :param index: Index of subrotamer + + :type energy: :class:`float` + :type index: :class: + + .. method:: AddFrameEnergy(energy) + + :param energy: Frame energy for full rotamer to be added + + :type energy: :class:`float` + + + .. method:: AddFrameEnergy(energy, index) + + :param energy: Frame energy for single subrotamer to be added :param index: Index of subrotamer :type energy: :class:`float` :type index: :class: + .. method:: AddSubrotamerDefinition(indices) + + :param indices: List of indices defining a subrotamer + + :type indices: :class:`list` + .. method:: SetTemperature(temperature) @@ -453,15 +456,19 @@ Rotamer Groups -------------------------------------------------------------------------------- -.. class:: RRMRotamerGroup(rotamers) +.. class:: RRMRotamerGroup(rotamers, residue_index) The RRMRotamerGroup groups several :class:`RRMRotamer` objects for the same - residue position. It can either be constructed by providing a list of - :class:`RRMRotamer` objects or by convenience functions provided by PROMOD3. + residue position. :param rotamers: A list of :class:`RRMRotamer` objects + :param residue_index: Location of residue this :class:`FRMRotamerGroup` + represents. This index is important when calculating + frame energies to neglect the interactions to frame + particles of the same residue. :type rotamers: :class:`list` + :type residue_index: :class:`int` :raises: :exc:`~exceptions.RuntimeError` if provided *rotamers* is empty @@ -512,10 +519,21 @@ Rotamer Groups :type other: :class:`RRMRotamerGroup` + .. method:: SetFrameEnergy(frame) + + Calculates sets the energy of all rotamers in the group towards the + given **frame**. + + :param frame: Frame containing rigid particles + :type frame: :class:`Frame` - .. method:: CalculateInternalEnergies() + .. method:: AddFrameEnergy(frame) - Calculates internal energies of all rotamers in group + Calculates adds the energy of all rotamers in the group towards the + given **frame**. + + :param frame: Frame containing rigid particles + :type frame: :class:`Frame` .. method:: ApplySelfEnergyThresh(thresh=30) @@ -523,15 +541,19 @@ Rotamer Groups rotamers with *self_energy* > *l_e* + *thresh* -.. class:: FRMRotamerGroup(rotamers) +.. class:: FRMRotamerGroup(rotamers, residue_index) The FRMRotamerGroup groups several :class:`FRMRotamer` objects for the same - residue position. It can either be constructed by providing a list of - :class:`FRMRotamer` objects or by convenience functions provided by PROMOD3. + residue position. :param rotamers: A list of :class:`FRMRotamer` objects + :param residue_index: Location of residue this :class:`FRMRotamerGroup` + represents. This index is important when calculating + frame energies to neglect the interactions to frame + particles of the same residue. :type rotamers: :class:`list` + :type residue_index: :class:`int` :raises: :exc:`~exceptions.RuntimeError` if provided *rotamers* is empty @@ -582,238 +604,23 @@ Rotamer Groups :type other: :class:`FRMRotamerGroup` + .. method:: SetFrameEnergy(frame) - .. method:: CalculateInternalEnergies() - - Calculates internal energies of all rotamers in group - - .. method:: ApplySelfEnergyThresh(thresh=30) - - Searches rotamer with lowest self energy *l_e* and deletes all - rotamers with *self_energy* > *l_e* + *thresh* + Calculates sets the energy of all rotamers in the group towards the + given **frame**. + :param frame: Frame containing rigid particles + :type frame: :class:`Frame` + .. method:: AddFrameEnergy(frame) + Calculates adds the energy of all rotamers in the group towards the + given **frame**. + :param frame: Frame containing rigid particles + :type frame: :class:`Frame` + .. method:: ApplySelfEnergyThresh(thresh=30) - - -Convenient functions for constructing rotamers --------------------------------------------------------------------------------- - -For convenience, |project| offers some functionality to directly build single -rotamers or groups (see :ref:`below <rotamer_group_construction_label>`). - -.. method:: ConstructRRMRotamer(n_pos, ca_pos, cb_pos, rotamer_id, settings, \ - probability, chi1=NaN, chi2=NaN, chi3=NaN, \ - chi4=NaN) - ConstructRRMRotamer(residue, rotamer_id, settings, probability, \ - chi1=NaN, chi2=NaN, chi3=NaN, chi4=NaN) - - :param n_pos: Position of nitrogen used as anchor for the rotamer - :param ca_pos: Position of alpha carbon used as anchor for the rotamer - :param cb_pos: Position of beta carbon used as anchor for the rotamer - :param residue: Residue from which the anchor positions will be - extracted - :param rotamer_id: Type of :class:`RRMRotamer` - :param settings: Settings to control parametrization of the single - particles. - :param probability: Probability of occurence of this particular rotamer. - :param chi1: First sidechain dihedral angle - :param chi2: Second sidechain dihedral angle - :param chi3: Third sidechain dihedral angle - :param chi4: Fourth sidechain dihedral angle - - :type n_pos: :class:`ost.geom.Vec3` - :type ca_pos: :class:`ost.geom.Vec3` - :type cb_pos: :class:`ost.geom.Vec3` - :type residue: :class:`ost.mol.ResideHandle` - :type rotamer_id: :class:`RotamerID` - :type settings: :class:`RotamerSettings` - :type probability: :class:`float` - :type chi1: :class:`float` - :type chi2: :class:`float` - :type chi3: :class:`float` - :type chi4: :class:`float` - - :returns: :class:`RRMRotamer` - - :raises: :exc:`~exceptions.RuntimeError` if not all required chi angles - for this particular *id* are given or when not all required - anchor atoms are present in *residue*. - - -.. method:: ConstructFRMRotamer(n_pos, ca_pos, cb_pos, rotamer_id, settings, \ - probability, chi1=NaN, sig1=NaN, chi2=NaN, \ - sig2=NaN, chi3=NaN, sig3=NaN, chi4=NaN, \ - sig4=NaN) - ConstructFRMRotamer(residue, rotamer_id, settings, probability, \ - chi1=NaN, sig1=NaN, chi2=NaN, sig2=NaN, \ - chi3=NaN, sig3=NaN, chi4=NaN, sig4=NaN) - - :param n_pos: Position of nitrogen used as anchor for the rotamer - :param ca_pos: Position of alpha carbon used as anchor for the rotamer - :param cb_pos: Position of beta carbon used as anchor for the rotamer - :param residue: Residue from which the anchor positions will be - extracted - :param rotamer_id: Type of :class:`FRMRotamer` - :param settings: Settings to control parametrization of the single - particles. - :param probability: Probability of occurence of this particular rotamer. - :param chi1: First sidechain dihedral angle - :param sig1: Standard deviation of first dihedral angle - :param chi2: Second sidechain dihedral angle - :param sig2: Standard deviation of second dihedral angle - :param chi3: Third sidechain dihedral angle - :param sig3: Standard deviation of third dihedral angle - :param chi4: Fourth sidechain dihedral angle - :param sig4: Standard deviation of fourth dihedral angle - - :type n_pos: :class:`ost.geom.Vec3` - :type ca_pos: :class:`ost.geom.Vec3` - :type cb_pos: :class:`ost.geom.Vec3` - :type residue: :class:`ost.mol.ResideHandle` - :type rotamer_id: :class:`RotamerID` - :type settings: :class:`RotamerSettings` - :type probability: :class:`float` - :type chi1: :class:`float` - :type sig1: :class:`float` - :type chi2: :class:`float` - :type sig2: :class:`float` - :type chi3: :class:`float` - :type sig3: :class:`float` - :type chi4: :class:`float` - :type sig4: :class:`float` - - :returns: :class:`FRMRotamer` - - :raises: :exc:`~exceptions.RuntimeError` if not all required chi angles - or standard deviations for this particular *id* are given or when - not all required anchor atoms are present in *residue*. - - -Convenient functions for constructing rotamer groups --------------------------------------------------------------------------------- - -Instead of building single rotamers, following convenient functions query a -rotamer library and build all possible rotamers for a particular residue -position. If hbond scoring is enabled and *sample_polar_hydrogens* is true (in -*settings*), several rotamers might be constructed and added to the group per -library instance: - -#. SER construct three rotamers with hydrogen chi angles 180, -60 and 60 -#. THR construct three rotamers with hydrogen chi angles 180, -60 and 60 -#. TYR construct two rotamers with hydrogen chi angles 180 and 0 -#. HIS construct both possible protonation states (HSE,HSD) - -.. _rotamer_group_construction_label: - -.. method:: ConstructRRMRotamerGroup(n_pos, ca_pos, cb_pos, rotamer_id, \ - residue_index, bbdep_rot_lib, settings, \ - phi=-1.0472, psi=-0.7854) - ConstructRRMRotamerGroup(residue, rotamer_id, residue_index, \ - bbdep_rot_lib, settings, phi=-1.0472, \ - psi=-0.7854) - ConstructRRMRotamerGroup(n_pos, ca_pos, cb_pos, rotamer_id, \ - residue_index, rot_lib, settings) - ConstructRRMRotamerGroup(residue, rotamer_id, residue_index, \ - rot_lib, settings) - - Constructs a full group of :class:`RRMRotamer` objects. It extracts rotamers - from a rotamer library and adds them to the group until the summed probability - reaches the probability cutoff defined in *settings*. - - :param n_pos: Position of nitrogen used as anchor for the rotamers - :param ca_pos: Position of alpha carbon used as anchor for the rotamers - :param cb_pos: Position of beta carbon used as anchor for the rotamers - :param residue: Residue from which the anchor positions will be - extracted - :param rotamer_id: Type of of the constructed rotamers - :param residue_index: Index of rotamer in constructed rotamer group. This - matters for calculating the frame energy. Interactions - to frame residues with same index get neglected. - :param bbdep_rot_lib: Backbone dependent rotamer library from which the data - is taken to construct the rotamers. - :param rot_lib: Non-backbone-dependent rotamer library from which the - data is taken to construct the rotamers. - :param settings: Settings to control parametrization of the single - particles. - :param phi: Phi backbone dihedral angle used as input for backbone - dependent rotamer library. Default value is a typical - alpha helical value. - :param psi: Psi backbone dihedral angle used as input for backbone - dependent rotamer library. Default value is a typical - alpha helical value. - - :type n_pos: :class:`ost.geom.Vec3` - :type ca_pos: :class:`ost.geom.Vec3` - :type cb_pos: :class:`ost.geom.Vec3` - :type residue: :class:`ost.mol.ResideHandle` - :type rotamer_id: :class:`RotamerID` - :type residue_index: :class:`int` - :type bbdep_rot_lib: :class:`BBDepRotamerLib` - :type rot_lib: :class:`RotamerLib` - :type settings: :class:`RotamerSettings` - :type phi: :class:`float` - :type psi: :class:`float` - - :returns: :class:`RRMRotamerGroup` - - :raises: :exc:`~exceptions.RuntimeError` if not all required anchor atoms - are present in *residue*. - - -.. method:: ConstructFRMRotamerGroup(n_pos, ca_pos, cb_pos, rotamer_id, \ - residue_index, bbdep_rot_lib, settings, \ - phi=-1.0472, psi=-0.7854) - ConstructFRMRotamerGroup(residue, rotamer_id, residue_index, \ - bbdep_rot_lib, settings, phi=-1.0472, \ - psi=-0.7854) - ConstructFRMRotamerGroup(n_pos, ca_pos, cb_pos, rotamer_id, \ - residue_index, rot_lib, settings) - ConstructFRMRotamerGroup(residue, rotamer_id, residue_index, \ - rot_lib, settings) - - Constructs a full group of :class:`RRMRotamer` objects. It extracts rotamers - from a rotamer library and adds them to the group until the summed probability - reaches the probability cutoff defined in *settings*. - - :param n_pos: Position of nitrogen used as anchor for the rotamers - :param ca_pos: Position of alpha carbon used as anchor for the rotamers - :param cb_pos: Position of beta carbon used as anchor for the rotamers - :param residue: Residue from which the anchor positions will be - extracted - :param rotamer_id: Type of of the constructed rotamers - :param residue_index: Index of rotamer in constructed rotamer group. This - matters for calculating the frame energy. Interactions - to frame residues with same index get neglected. - :param bbdep_rot_lib: Backbone dependent rotamer library from which the data - is taken to construct the rotamers. - :param rot_lib: Non-backbone-dependent rotamer library from which the - data is taken to construct the rotamers. - :param settings: Settings to control parametrization of the single - particles. - :param phi: Phi backbone dihedral angle used as input for backbone - dependent rotamer library. Default value is a typical - alpha helical value. - :param psi: Psi backbone dihedral angle used as input for backbone - dependent rotamer library. Default value is a typical - alpha helical value. - - :type n_pos: :class:`ost.geom.Vec3` - :type ca_pos: :class:`ost.geom.Vec3` - :type cb_pos: :class:`ost.geom.Vec3` - :type residue: :class:`ost.mol.ResideHandle` - :type rotamer_id: :class:`RotamerID` - :type residue_index: :class:`int` - :type bbdep_rot_lib: :class:`BBDepRotamerLib` - :type rot_lib: :class:`RotamerLib` - :type settings: :class:`RotamerSettings` - :type phi: :class:`float` - :type psi: :class:`float` - - :returns: :class:`FRMRotamerGroup` - - :raises: :exc:`~exceptions.RuntimeError` if not all required anchor atoms - are present in *residue*. \ No newline at end of file + Searches rotamer with lowest self energy *l_e* and deletes all + rotamers with *self_energy* > *l_e* + *thresh* diff --git a/sidechain/doc/rotamer_constructor.rst b/sidechain/doc/rotamer_constructor.rst new file mode 100644 index 0000000000000000000000000000000000000000..08032435ae0bf530c1f4695ffb919f6b027c9d19 --- /dev/null +++ b/sidechain/doc/rotamer_constructor.rst @@ -0,0 +1,203 @@ +Rotamer Constructor +================================================================================ + +.. currentmodule:: promod3.sidechain + +Instead of creating rotamers by yourself, you can simply use the convenient +functionality provided by PROMOD3 + + +Constructing Rotamers and Frame Residues +-------------------------------------------------------------------------------- + + +.. class:: SCWRLRotamerConstructor() + + Constructing rotamers and frame residues that are parametrized according to + the SCWRL4 method. They contain all heavy atoms, but also the + polar hydrogens. The rotamers start after the CB atom (typically CG). + In case of the :class:`FrameResidue` construction, the + constructor distinguishes between backbone and sidechain frame residues. + + .. method:: ConstructRRMRotamerGroup(res, id, residue_index, rot_lib,\ + [probability_cutoff = 0.98]) + .. method:: ConstructRRMRotamerGroup(all_atom_pos, aa_res_idx, id,\ + residue_index, rot_lib,\ + [probability_cutoff = 0.98]) + .. method:: ConstructRRMRotamerGroup(n_pos, ca_pos, cb_pos, id,\ + residue_index, rot_lib,\ + [probability_cutoff = 0.98]) + .. method:: ConstructRRMRotamerGroup(res, id, residue_index, rot_lib,\ + [phi = -1.0472, psi = -0.7854,\ + probability_cutoff = 0.98]) + .. method:: ConstructRRMRotamerGroup(all_atom_pos, aa_res_idx, id,\ + residue_index, rot_lib,\ + [phi = -1.0472, psi = -0.7854,\ + probability_cutoff = 0.98]) + .. method:: ConstructRRMRotamerGroup(n_pos, ca_pos, cb_pos, id,\ + residue_index, rot_lib,\ + [phi = -1.0472, psi = -0.7854,\ + probability_cutoff = 0.98]) + + All functions are also avaible for their flexible rotamer model counterpart. + =>ConstructFRMRotamerGroup(...) with exactly the same parameters. + + :param res: To extract the N, CA, CB backbone anchor + :param all_atom_pos: To extract the N, CA, CB backbone anchor + :param aa_res_idx: Index of residue in **all_atom_pos** from which to + extract the backbone anchor + :param n_pos: To directly feed in the backbone anchor positions + :param ca_pos: To directly feed in the backbone anchor positions + :param cb_pos: To directly feed in the backbone anchor positions + :param id: Identifies the sidechain. + :param residue_index: Important for the energy calculations towards the + :class:`Frame` you don't want to calculate a pairwise + energy of the sidechain particles towards particles + representing the own backbone... + :param rot_lib: To search for rotamers + :param phi: Phi dihedral angle used to search for rotamers if a + :class:`BBDepRotamerLib` is given as input + :param psi: Psi dihedral angle used to search for rotamers if a + :class:`BBDepRotamerLib` is given as input + :param probability_cutoff: For some rotamers, there might be many low + probability entries in the library. + The function adds single rotamers to the group until + the cumulative probability of the added rotamers is + larger or equal **probability_cutoff**. + + :returns: The rotamer group containing all constructed rotamers + with internal energies assigned based on the + probabilities extracted from the rotamer library. + + :type res: :class:`ost.mol.ResidueHandle` + :type all_atom_pos: :class:`promod3.loop.AllAtomPositions` + :type aa_res_idx: :class:`int` + :type n_pos: :class:`ost.geom.Vec3` + :type ca_pos: :class:`ost.geom.Vec3` + :type cb_pos: :class:`ost.geom.Vec3` + :type id: :class:`RotamerID` + :type residue_index: :class:`int` + :type rot_lib: :class:`RotamerLib` / :class:`BBDepRotamerLib` + :type probability_cutoff: :class:`float` + :rtype: :class:`RRMRotamerGroup` + + :raises: :exc:`~exceptions.RuntimeError` when not all required backbone + atoms are present in **residue**, not all required atom + positions are set in **all_atom_pos** or when the rotamer library + does not contain any entries for **id** + + + .. method:: ConstructBackboneFrameResidue(res, id, residue_index, Real phi,\ + [n_ter = False, c_ter = False]) + + .. method:: ConstructBackboneFrameResidue(all_atom_pos, aa_res_idx, id,\ + residue_index, Real phi,\ + [n_ter = False, c_ter = False]) + + .. method:: ConstructBackboneFrameResidue(n_pos, ca_pos, c_pos, o_pos, cb_pos,\ + id, residue_index, Real phi,\ + [n_ter = False, c_ter = False]) + + Constructs backbone frame residues for amino acid residues. It extracts + the n, ca, c, o and cb positions and constructs a frame residue based on + the parametrizations of SCWRL4. In case of **n_ter**, there are additional + hydrogens added at the nitrogen to represent a proper n-terminus. The same + is true for **c_ter**, an additional oxygen is built instead. In any case, + a single hydrogen is added to the nitrogen (except proline), this is + why the phi angle of the residue is required as an input. + + :param res: Residue from which to extract the backbone positions + :param all_atom_pos: To extract the backbone positions + :param aa_res_idx: Index of residue in **all_atom_pos** from which to + extract the backbone positions + :param n_pos: To directly feed in the backbone positions + :param ca_pos: To directly feed in the backbone positions + :param c_pos: To directly feed in the backbone positions + :param o_pos: To directly feed in the backbone positions + :param cb_pos: To directly feed in the backbone positions + :param id: Identifies the sidechain + :param residue_index: Important for the energy calculations towards the + :class:`Frame` you don't want to calculate a pairwise + energy of the sidechain particles towards particles + representing the own backbone... + :param phi: The dihedral angle of the current residue, required to + construct the polar nitrogen hydrogen + :param n_ter: Whether to add additional hydrogens at the nitrogen + to represent a proper n-terminus + :param c_ter: Whether to add an additional oxygen at the carbon to + represent a proper c-terminus + + :type res: :class:`ost.mol.ResidueHandle` + :type all_atom_pos: :class:`promod3.loop.AllAtomPositions` + :type aa_res_idx: :class:`int` + :type n_pos: :class:`ost.geom.Vec3` + :type ca_pos: :class:`ost.geom.Vec3` + :type c_pos: :class:`ost.geom.Vec3` + :type o_pos: :class:`ost.geom.Vec3` + :type cb_pos: :class:`ost.geom.Vec3` + :type id: :class:`RotamerID` + :type residue_index: :class:`int` + :type phi: :class:`float` + :type n_ter: :class:`bool` + :type c_ter: :class:`bool` + + :rtype: :class:`FrameResidue` + + + :raises: :exc:`~exceptions.RuntimeError` when not all required backbone + atoms are present in **residue**, not all required atom + positions are set in **all_atom_pos**. + + + .. method:: ConstructSidechainFrameResidue(res, id, residue_index) + + .. method:: ConstructSidechainFrameResidue(all_atom, aa_res_idx, id,\ + residue_index) + + Extracts all required positions from the input and generates a sidechain + frame residue. Additionally to the heavy atoms, the function also produces + particles for all polar hydrogens. + + :param res: Residue from which to extract the sidechain positions + :param all_atom_pos: To extract the sidechain positions + :param aa_res_idx: Index of residue in **all_atom_pos** from which to + extract the sidechain positions + :param id: Identifies the sidechain + :param residue_index: idenfifies residue in frame + + :type res: :class:`ost.mol.ResidueHandle` + :type all_atom_pos: :class:`promod3.loop.AllAtomPositions` + :type aa_res_idx: :class:`int` + :type id: :class:`RotamerID` + :type residue_index: :class:`int` + + :rtype: :class:`FrameResidue` + + + :raises: :exc:`~exceptions.RuntimeError` when not all required sidechain + atoms are present in **residue** or not all required sidechain + atom positions are set in **all_atom_pos**. + + + .. method:: AssignInternalEnergies(rot_group) + + Takes the rotamer group and assigns every single rotamer its internal + energy based on the probabilistic approach used by SCWRL4. + => -internal_e_prefac*log(p/max_p), where internal_e_prefac and p are + rotamer specific and max_p is the maximum probablity of any of the rotamers + in **rot_group**. If you construct a rotamer group by the + ConstructRRMRotamerGroup/ConstructFRMRotamerGroup functions, this function + is already called at construction and the energies are properly assigned. + + + + + + + + + + + + + diff --git a/sidechain/doc/sidechain_settings.rst b/sidechain/doc/sidechain_settings.rst deleted file mode 100644 index 5652f945b9b321b969605f019e29bfd94bd8159d..0000000000000000000000000000000000000000 --- a/sidechain/doc/sidechain_settings.rst +++ /dev/null @@ -1,193 +0,0 @@ -Rotamer Settings -================================================================================ - -.. currentmodule:: promod3.sidechain - -The rotamer settings control the sidechain modelling algorithms at different -stages. Most of the parameters that can be set are related to the flexible -rotamer model (temperature factor and delta factors to control the -variability of the subrotamers in the flexible rotamer model) -or the internal energy prefactor used for the different amino -acids. Other parameters include the radius influencing the pseudo Lennard -Jones term for the different atom types and the max interaction radius. -The max interaction radius is more a technical thing and is used by a -collision detection algorithm to define the collision distance, i.e. -two particles with max radii a,b collide/interact if the distance between -them is smaller than a+b. The last three parameters control the buildup of the -rotamers. It is possible to deactivate the hbond term, resulting in -no hydrogens being constructed. The sampling of polar hydrogens can also -be controlled resulting in several rotamers per rotamer lib entry for -Ser,Thr and Tyr when using the convenient functions for constructing full -rotamer groups of them (see :ref:`here <rotamer_group_construction_label>`). -Constructing the rotamer groups can further be controlled by assigning a max -summed probability resulting in less very unlikely rotamers added to the -rotamer group (see :ref:`here <rotamer_group_construction_label>`). - -.. class:: RotamerSettings - - .. attribute:: FRM_T_ARG default: 1.23 - - .. attribute:: FRM_T_ASN default: 1.41 - - .. attribute:: FRM_T_ASP default: 1.48 - - .. attribute:: FRM_T_GLN default: 1.32 - - .. attribute:: FRM_T_GLU default: 0.94 - - .. attribute:: FRM_T_LYS default: 1.27 - - .. attribute:: FRM_T_SER default: 3.53 - - .. attribute:: FRM_T_CYS default: 1.69 - - .. attribute:: FRM_T_MET default: 1.77 - - .. attribute:: FRM_T_TRP default: 0.99 - - .. attribute:: FRM_T_TYR default: 1.96 - - .. attribute:: FRM_T_THR default: 1.11 - - .. attribute:: FRM_T_VAL default: 2.20 - - .. attribute:: FRM_T_ILE default: 2.03 - - .. attribute:: FRM_T_LEU default: 2.55 - - .. attribute:: FRM_T_PRO default: 2.62 - - .. attribute:: FRM_T_HIS default: 1.35 - - .. attribute:: FRM_T_PHE default: 1.07 - - .. attribute:: FRM_delta1_ARG default: 0.87 - - .. attribute:: FRM_delta2_ARG default: 1.62 - - .. attribute:: FRM_delta3_ARG default: 1.67 - - .. attribute:: FRM_delta4_ARG default: 0.78 - - .. attribute:: FRM_delta1_ASN default: 0.62 - - .. attribute:: FRM_delta2_ASN default: 1.93 - - .. attribute:: FRM_delta1_ASP default: 1.59 - - .. attribute:: FRM_delta2_ASP default: 0.63 - - .. attribute:: FRM_delta1_GLN default: 1.55 - - .. attribute:: FRM_delta2_GLN default: 0.68 - - .. attribute:: FRM_delta3_GLN default: 1.88 - - .. attribute:: FRM_delta1_GLU default: 0.82 - - .. attribute:: FRM_delta2_GLU default: 1.57 - - .. attribute:: FRM_delta3_GLU default: 0.78 - - .. attribute:: FRM_delta1_LYS default: 1.62 - - .. attribute:: FRM_delta2_LYS default: 0.99 - - .. attribute:: FRM_delta3_LYS default: 0.96 - - .. attribute:: FRM_delta4_LYS default: 1.48 - - .. attribute:: FRM_delta1_SER default: 0.65 - - .. attribute:: FRM_delta2_SER default: 2.98 - - .. attribute:: FRM_delta1_CYS default: 1.69 - - .. attribute:: FRM_delta1_MET default: 0.97 - - .. attribute:: FRM_delta2_MET default: 1.54 - - .. attribute:: FRM_delta3_MET default: 1.21 - - .. attribute:: FRM_delta1_TRP default: 1.28 - - .. attribute:: FRM_delta2_TRP default: 1.48 - - .. attribute:: FRM_delta1_TYR default: 1.48 - - .. attribute:: FRM_delta2_TYR default: 0.73 - - .. attribute:: FRM_delta3_TYR default: 0.96 - - .. attribute:: FRM_delta1_THR default: 0.88 - - .. attribute:: FRM_delta2_THR default: 0.88 - - .. attribute:: FRM_delta1_VAL default: 2.08 - - .. attribute:: FRM_delta1_ILE default: 1.23 - - .. attribute:: FRM_delta2_ILE default: 0.98 - - .. attribute:: FRM_delta1_LEU default: 1.15 - - .. attribute:: FRM_delta2_LEU default: 1.48 - - .. attribute:: FRM_delta1_PRO default: 0.78 - - .. attribute:: FRM_delta2_PRO default: 1.27 - - .. attribute:: FRM_delta1_HIS default: 1.84 - - .. attribute:: FRM_delta2_HIS default: 0.85 - - .. attribute:: FRM_delta1_PHE default: 1.45 - - .. attribute:: FRM_delta2_PHE default: 1.35 - - .. attribute:: internal_e_prefactor_ARG default: 2.27 - - .. attribute:: internal_e_prefactor_ASN default: 1.80 - - .. attribute:: internal_e_prefactor_ASP default: 2.44 - - .. attribute:: internal_e_prefactor_GLN default: 1.61 - - .. attribute:: internal_e_prefactor_GLU default: 1.85 - - .. attribute:: internal_e_prefactor_LYS default: 2.13 - - .. attribute:: internal_e_prefactor_SER default: 2.78 - - .. attribute:: internal_e_prefactor_CYS default: 4.07 - - .. attribute:: internal_e_prefactor_MET default: 1.95 - - .. attribute:: internal_e_prefactor_TRP default: 3.24 - - .. attribute:: internal_e_prefactor_TYR default: 2.00 - - .. attribute:: internal_e_prefactor_THR default: 2.96 - - .. attribute:: internal_e_prefactor_VAL default: 1.62 - - .. attribute:: internal_e_prefactor_ILE default: 2.18 - - .. attribute:: internal_e_prefactor_LEU default: 2.25 - - .. attribute:: internal_e_prefactor_PRO default: 0.76 - - .. attribute:: internal_e_prefactor_HIS default: 2.01 - - .. attribute:: internal_e_prefactor_PHE default: 1.71 - - .. attribute:: probability_cutoff default: 0.98 - - .. attribute:: consider_hbonds default: True - - .. attribute:: sample_polar_hydrogens default: True - - - - - diff --git a/sidechain/pymod/_reconstruct_sidechains.py b/sidechain/pymod/_reconstruct_sidechains.py index d402500c1f650893e0c4ce4ed8345a335b7cead4..3afeada1ee3cb3f4b0a3561aee875379cbc66718 100644 --- a/sidechain/pymod/_reconstruct_sidechains.py +++ b/sidechain/pymod/_reconstruct_sidechains.py @@ -377,7 +377,7 @@ def _GetDisulfidBridges(frame_residues, cystein_indices, res_list, rotamer_libra def Reconstruct(ent, keep_sidechains=False, build_disulfids=True, rotamer_model="frm", consider_ligands=True, - rotamer_library=None, rotamer_constructor=None): + rotamer_library=None): '''Reconstruct sidechains for the given structure. :param ent: Structure for sidechain reconstruction. Note, that the @@ -431,8 +431,8 @@ def Reconstruct(ent, keep_sidechains=False, build_disulfids=True, bbdep = False if type(rotamer_library) is sidechain.BBDepRotamerLib: bbdep = True - if rotamer_constructor == None: - rotamer_constructor = sidechain.SCWRLRotamerConstructor() + + rotamer_constructor = sidechain.SCWRLRotamerConstructor() # take out ligand chain and any non-peptides prot = ent.Select("peptide=true and cname!='_'")