Rosetta
Namespaces | Functions
Patch.cc File Reference

Implementation class for abstract class Residue. More...

#include <core/chemical/Patch.hh>
#include <core/chemical/PatchOperationFactory.hh>
#include <core/chemical/PatchOperation.hh>
#include <core/chemical/ChemicalManager.hh>
#include <core/chemical/ResidueType.hh>
#include <core/chemical/MutableResidueType.hh>
#include <basic/Tracer.hh>
#include <utility/vector1.hh>
#include <utility/io/izstream.hh>
#include <basic/options/keys/chemical.OptionKeys.gen.hh>
#include <basic/options/option.hh>
#include <core/chemical/ResidueProperties.hh>

Namespaces

 core
 A class for reading in the atom type properties.
 
 core::chemical
 

Functions

static basic::Tracer core::chemical::tr ("core.chemical.Patch")
 
std::string core::chemical::tag_from_line (std::string const &line)
 handy function, return the first word from a line More...
 
std::string core::chemical::residue_type_base_name (ResidueTypeBase const &rsd_type)
 helper function, returns the base residue name prior to any patching More...
 
std::string core::chemical::residue_type_all_patches_name (ResidueType const &rsd_type)
 helper function, returns the name of all added patches More...
 
utility::vector1< std::string > core::chemical::get_patch_names (ResidueType const &rsd_type)
 
void core::chemical::setup_patch_atomic_charge_reassignments_from_commandline (std::string const &patch_name, TypeSetMode rsd_type_set_mode, ResidueTypeSelector const &rsd_selector, std::map< std::string, Real > &atomic_charge_reassignments)
 override patch partial charges with values from commandline More...
 
PatchCaseOP core::chemical::case_from_lines (utility::vector1< std::string > const &lines, TypeSetMode res_type_set_mode, std::string const &patch_name)
 create a PatchCase from input lines More...
 

Detailed Description

Implementation class for abstract class Residue.

My understanding of this piece of code comes from various conversations with Oliver Lang, Summer Thyme, and Andrew Leaver-Fay. If the ideas are incorrect, feel free to correct.

General Overview

What are patches? Patches are modifications to the original amino acid residue types. These modifications include capping the N and C terminus, adding phosphorylation to residues, etc, etc. The actual files that are read and used are found in: database/chemical/residue_type_sets/fa_standard/patches

All of these patches are read when ResidueTypeSet is instantiated and are applied to all residues that are identified as needing to be patched. (Identification of residues is explained later.) Identification of residues that need to be patched varies by what is in the actual patch file. For example, peptide residues that are C and/or N termini are patched with the N and/or C terminus patches, which are defined in the files NtermProteinFull.txt and CtermProteinFull.txt.

Overview of a Patch File

Let's look at a patch file to see what goes on. The file we are looking at is NtermProteinFull.txt. The file is shortened to make it easier to read. Important parts are shown:

NAME NtermProteinFull # actual name of the patch TYPES LOWER_TERMINUS # the type that this patch belongs to. Types are defined in VariantType.cc/.hh

This section is for general selection rules to apply the patch.

BEGIN_SELECTOR # Here is where we define how to select amino acids for the patch.

Properties/variant types needed for the patch are found between the BEGIN_SELECTOR and

END_SELECTOR "titles"

PROPERTY PROTEIN # For this patch to apply, the residue must be a protein, as defined in the paramaters file. NOT VARIANT_TYPE LOWER_TERMINUS # We do not want to patch the variant type LOWER_TERMINUS. This is because, we do

not want to double patch a residue (if the residue is already variant type

lower_terminus).

END_SELECTOR # ending the selection process for the patch

This section is to modify specific residues that the patch encounters.

BEGIN_CASE ## PROLINE # Within the BEGIN_CASE and END_CASE section is where the residue is modified.

These are the operations that occur to apply the patch.

BEGIN_SELECTOR # Once again, we are defining what to do in this specific BEGIN_CASE/END_CASE block by using the

selector.

AA PRO # We only want to modify aa PRO in the following way between the BEGIN_CASE and END_CASE block. END_SELECTOR # End selection requirements

ADD_ATOM 1H Hpol HC 0.24 # straight forward; add atom 1H ADD_ATOM 2H Hpol HC 0.24 ADD_BOND N 1H # Atoms need bonds; add those bonds. ADD_BOND N 2H SET_POLYMER_CONNECT LOWER NONE # setting a property

totally making these up:

SET_ICOOR 1H 120 60 1 N CA C ## like to use CD but CD's parent is CG # Once new atoms are placed, SET_ICOOR 2H 120 60 1 N CA 1H # new internal cooridantes need to be made.

modify properties of existing atoms

SET_ATOM_TYPE N Nlys SET_MM_ATOM_TYPE N NP SET_ATOMIC_CHARGE N -0.07 SET_ATOMIC_CHARGE CA 0.16 SET_ATOMIC_CHARGE HA 0.09 SET_ATOMIC_CHARGE CD 0.16 SET_ATOMIC_CHARGE 1HD 0.09 SET_ATOMIC_CHARGE 2HD 0.09 ADD_PROPERTY LOWER_TERMINUS ## implies terminus END_CASE

BEGIN_CASE ### THE GENERAL CASE # Here is the general case, specified at the very beginning of the patch file.

these are the operations involved

DELETE_ATOM H ## deletes all bonds to this atom ADD_ATOM 1H Hpol HC 0.33 ADD_ATOM 2H Hpol HC 0.33 ADD_ATOM 3H Hpol HC 0.33 ADD_BOND N 1H ADD_BOND N 2H ADD_BOND N 3H SET_POLYMER_CONNECT LOWER NONE

totally making these up:

SET_ICOOR 1H 120 60 1 N CA C SET_ICOOR 2H 120 60 1 N CA 1H SET_ICOOR 3H 120 60 1 N CA 2H

modify properties of existing atoms

SET_ATOM_TYPE N Nlys SET_MM_ATOM_TYPE N NH3 SET_ATOMIC_CHARGE N -0.3 SET_ATOMIC_CHARGE CA 0.21 SET_ATOMIC_CHARGE HA 0.10 ADD_PROPERTY LOWER_TERMINUS ## implies terminus END_CASE

So, let's go through what was put up there. In general, you name your patch and assign it a type. Then, you tell the patch system in the BEGIN_SELECTOR / END_SELECTOR block what type of properties that you are looking for to apply the patch. You then, in the BEGIN_CASE / END_CASE block, add operations to the residue. You can specify specific selectors within the BEGIN_CASE / END_CASE by having another BEGIN_SELECTOR / END_SELECTOR block. People generally specify specific amino acids within the BEGIN_SELECTOR / END_SELECTOR blocks within the BEGIN_CASE / END_CASE blocks. At the end, there is one last BEGIN_CASE / END_CASE with no BEGIN_SELECTOR / END_SELECTOR block. This block is used to specify what to do with the general case, which was defined at the very beginning of the file. A few more details follow below.

First, you must name your patch. Then you have to give it a "type". This type is defined in VariantType.cc/.hh. All the type does is adds a name that can be used later on in different protocols. It also helps the patch system keep track of what residues are patched with what type. The type has no magical meaning; it's a name that you give it that is "defined" in the variantType.cc. In short, it's a name handler. Once the name and type have been assigned, you must define a general case in which your patch applies. Generally, this means that you want it to apply to a specific type of aa, or all residues of a specific type or property. After this block comes the BEGIN_CASE / END_CASE statements. In these statements, you specify what modifications you want to apply to the residues. If you have different requirements for different amino acids, you must specify this in a BEGIN_SELECTOR / END_SELECTOR block within the BEGIN_CASE / END_CASE block. You must specify specific amino acids first, then in a new BEGIN_CASE / END_CASE block, you specify the general modifications defined by the first selector. Confusing, huh? The reason for having specific selectors defined before the general case is because..., I don't know. I suspect it's because of how the file is read in and applied. Regardless, if you want to do something to a specific amino acid/residue before you get to the general case, you need to have a BEGIN_CASE / END_CASE block with a selector in there before you get to the general BEGIN_CASE / END_CASE block.

Using Patch Selector to Specify Application of a Patch to Specific Residues

Woah there! Now that you know how to use patches, you don't need to go all gun-ho crazy and create a ton of patches. This is because all patches are read when ResidueTypeSet is created and applied. This creates overhead if you have a ton of patch files. To circumvent this, someone wrote an option called -chemical:patch_selectors. I don't know who wrote it, or where it's located, sorry. This option allows you to create patches that are only loaded when you use the option -chemical:patch_selectors. To get this to work, you create a patch like normal. Then, in the BEGIN_SELECTOR / END_SELECTOR line, you add a line CMDLINE_SELECTOR <name of command line>. This means, if you use the CMDLINE_SELECTOR sc_orbitals, your patch will only be loaded if you use the option -chemical:patch_selectors sc_orbitals. Cool, huh?

Trouble Shooting!!! So, you added a new patch and used the command line selector and nothing happens. Did you modify VariantTypes.cc to have your new type? Did you name things correctly? Did you edit the patches.txt to include your patch? Are you trying to use a command that does not exist? Look at patchoperations.cc for commands that exist. These are all things to check for.

So, you have added a new patch, and you get segmentation faults. Most common seg fault for me is in the stub atom. This is because your patch might add atoms/delete atoms that are used in other patches. In order to fix this, you must modify other patches to include your modifications. Remember patches are all loaded whenever ResidueTypeSet is instantiated, which is usually near the beginning of a Rosetta protocol when a pose is 1st loaded! If you have conflicts with other patches in your patch, even if you are using the command line selector, you must resolve those problems. Write an integration test so that people won't screw up your patches.

Author
Phil Bradely Steven Combs only added comments