<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wikis.ch.cam.ac.uk/ro-walesdocs/wiki/index.php?action=history&amp;feed=atom&amp;title=Calculating_order_parameters</id>
	<title>Calculating order parameters - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wikis.ch.cam.ac.uk/ro-walesdocs/wiki/index.php?action=history&amp;feed=atom&amp;title=Calculating_order_parameters"/>
	<link rel="alternate" type="text/html" href="https://wikis.ch.cam.ac.uk/ro-walesdocs/wiki/index.php?title=Calculating_order_parameters&amp;action=history"/>
	<updated>2026-06-16T04:50:22Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.7</generator>
	<entry>
		<id>https://wikis.ch.cam.ac.uk/ro-walesdocs/wiki/index.php?title=Calculating_order_parameters&amp;diff=1242&amp;oldid=prev</id>
		<title>Adk44: Created page with &quot;When constructing a potential/free energy surface, or trying to understand the landscape topology by colouring a disconnectivity graph, you need to calculate order parameters...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wikis.ch.cam.ac.uk/ro-walesdocs/wiki/index.php?title=Calculating_order_parameters&amp;diff=1242&amp;oldid=prev"/>
		<updated>2019-05-13T10:33:35Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;When constructing a potential/free energy surface, or trying to understand the landscape topology by colouring a disconnectivity graph, you need to calculate order parameters...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;When constructing a potential/free energy surface, or trying to understand the landscape topology by colouring a disconnectivity graph, you need to calculate order parameters for your system. These are structural quantities, such as the radius of gyration, or the number of native contacts (Q).&lt;br /&gt;
&lt;br /&gt;
Often, these are calculated after the fact i.e. a system is studied with [[OPTIM]]/[[PATHSAMPLE]] and then for each identified minimum, the coordinates are extracted, and the quantities of interest are calculated. &lt;br /&gt;
&lt;br /&gt;
In this article, you can find examples of some useful order parameters - and how to use [[CHARMM]] to calculate them. I have also included example script segments which you can use to extract the values from the [[CHARMM]] output. &lt;br /&gt;
&lt;br /&gt;
==Setting up CHARMM==&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;NOTE: some of these only work with newer versions of [[CHARMM]], so please compile the source in ~/svn/CHARMM35, and use the executable produced.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
===Reading in the structure of interest===&lt;br /&gt;
&lt;br /&gt;
Before asking for order parameters, we need to set [[CHARMM]] up, and load in the coordinates for the structure of interest, in this case &amp;#039;&amp;#039;test.crd&amp;#039;&amp;#039;. Here is the top of a [[CHARMM]] input file which does this for TZ2:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
! Example CHARMM input file to calculate three order parameters for TZ2&lt;br /&gt;
! Chris Whittleston 25/01/12&lt;br /&gt;
&lt;br /&gt;
! Set paths for topology and parameter files&lt;br /&gt;
set pardir &amp;quot;/home/csw34/svn/CHARMM31/toppar&amp;quot;&lt;br /&gt;
set top &amp;quot;toph19_eef1_perm.inp&amp;quot;&lt;br /&gt;
set par &amp;quot;param19_eef1_perm.inp&amp;quot;&lt;br /&gt;
&lt;br /&gt;
! BOMLev sets the level of warnings what do not cause the program to exit. -5 = very lax&lt;br /&gt;
BOMLev -5&lt;br /&gt;
&lt;br /&gt;
! PRNLEV sets the ammount of output you get from CHARMM. 0 = small&lt;br /&gt;
PRNLEV 3&lt;br /&gt;
&lt;br /&gt;
! Read standard topology and parameter files&lt;br /&gt;
OPEN READ CARD UNIT 1 NAME @pardir/@top&lt;br /&gt;
READ RTF CARD UNIT 1&lt;br /&gt;
CLOSE UNIT 1&lt;br /&gt;
&lt;br /&gt;
OPEN READ CARD UNIT 2 NAME @pardir/@par&lt;br /&gt;
READ PARAMETER CARD UNIT 2&lt;br /&gt;
CLOSE UNIT 2&lt;br /&gt;
&lt;br /&gt;
! Generate the PSF for TZ2&lt;br /&gt;
READ SEQUence CARD&lt;br /&gt;
*&lt;br /&gt;
12&lt;br /&gt;
SER TRP THR TRP GLU GLY ASN LYS TRP THR TRP LYS&lt;br /&gt;
GENErate FIRS NTER LAST CT2 SETUp&lt;br /&gt;
&lt;br /&gt;
OPEN UNIT 20 NAME test.crd READ CARD&lt;br /&gt;
READ COOR UNIT 20 CARD FREE&lt;br /&gt;
CLOSE UNIT 20&lt;br /&gt;
&lt;br /&gt;
! Build the internal coordinate tables&lt;br /&gt;
IC FILL PRESERVE&lt;br /&gt;
IC PARAMETERS&lt;br /&gt;
IC PURGE&lt;br /&gt;
IC BUILD&lt;br /&gt;
&lt;br /&gt;
! Set up the EEF1 solvent model&lt;br /&gt;
eef1 setup temp 298.15 unit 93 name &amp;quot;/home/csw34/svn/CHARMM31/toppar/solvpar.inp&amp;quot;&lt;br /&gt;
update ctonnb 7. ctofnb 9. cutnb 15. group rdie&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This file is read into [[CHARMM]] by piping it in like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
charmm &amp;lt; order_parameters.inp &amp;gt; charmm.out&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If you do this for the above, the &amp;#039;&amp;#039;charmm.out&amp;#039;&amp;#039; file will show that the coordinates were read, but not much else. &lt;br /&gt;
&lt;br /&gt;
===Making selections for groups of interest to save time===&lt;br /&gt;
In TZ2, we are interested in the TRP sidechains, as it is the interaction of these rings which give the small hairpin its remarkable stability. Because we are likely to want to consider them multiple times, it saves time to pre-define a [[CHARMM]] atom selection for each - like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
! Set up selections for each TRP ring in TZ2 (saves typing later!)&lt;br /&gt;
define TRP2 sele resid 2 .and. .not. ( type n .or. type ca .or. type c .or. -&lt;br /&gt;
       type o .or. type oct* .or. type ha* .or. type hn .or. type ht* ) end&lt;br /&gt;
define TRP4 sele resid 4 .and. .not. ( type n .or. type ca .or. type c .or. -&lt;br /&gt;
       type o .or. type oct* .or. type ha* .or. type hn .or. type ht* ) end&lt;br /&gt;
define TRP9 sele resid 9 .and. .not. ( type n .or. type ca .or. type c .or. -&lt;br /&gt;
       type o .or. type oct* .or. type ha* .or. type hn .or. type ht* ) end&lt;br /&gt;
define TRP11 sele resid 11 .and. .not. ( type n .or. type ca .or. type c .or. -&lt;br /&gt;
       type o .or. type oct* .or. type ha* .or. type hn .or. type ht* ) end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This selection is quite simple. For the second residue, TRP2, we select all atoms in residue 2 (&amp;#039;&amp;#039;resid 2&amp;#039;&amp;#039;), and then exclude those in the backbone, including in any terminal residues. A full explaination of CHARMM selection logic can be found on [http://www.charmmtutorial.org/index.php/Essential_CHARMM_Features#Atom_Selection this] really useful page.&lt;br /&gt;
&lt;br /&gt;
==Calculating and extracting order parameters==&lt;br /&gt;
Once we can read in the coordinates, we can add to the bottom of the [[CHARMM]] input file commands to calculate the order parameters for us. Sometimes we cannot get the exact result we want right away, but with some post-processing in a bash script, anything is possible! :) For each example, the [[CHARMM]] input file segment is accompanied by a bash script block demonstrating how to get the single value of interest out of the [[CHARMM]] output file.&lt;br /&gt;
&lt;br /&gt;
===Number of native backbone hydrogen-bonds===&lt;br /&gt;
For TZ2, there are four hydrogen-bonds between backbone atoms in the native state. As we know these will not be formed when the peptide is extended, monitoring how many are present should give us a rough idea of how folded the hairpin is:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
! First BB H-bond&lt;br /&gt;
COOR HBOND sele resid 5 .and. type O end sele resid 8 .and. type H end&lt;br /&gt;
&lt;br /&gt;
! Second BB H-bond&lt;br /&gt;
COOR HBOND sele resid 3 .and. type O end sele resid 10 .and. type H end&lt;br /&gt;
&lt;br /&gt;
! Third BB H-bond&lt;br /&gt;
COOR HBOND sele resid 10 .and. type O end sele resid 3 .and. type H end&lt;br /&gt;
&lt;br /&gt;
! Fourth BB H-bond&lt;br /&gt;
COOR HBOND sele resid 12 .and. type O end sele resid 1 .and. type HT1 end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Here, for each hydrogen bond, we specify the atoms involved exactly. For example, one bond is between O in residue 5, and H in residue 8. This produces the following [[CHARMM]] output:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 CHARMM&amp;gt;    ! First BB H-bond&lt;br /&gt;
 CHARMM&amp;gt;    COOR HBOND sele resid 5 .and. type O end sele resid 8 .and. type H end&lt;br /&gt;
 SELRPN&amp;gt;      1 atoms have been selected out of    147&lt;br /&gt;
 SELRPN&amp;gt;      1 atoms have been selected out of    147&lt;br /&gt;
&lt;br /&gt;
 NONBOND OPTION FLAGS:&lt;br /&gt;
     ELEC     VDW      GROUps   RDIElec  SWITch   VGROup   VSWItch&lt;br /&gt;
     BYGRoup  NOEXtnd  NOEWald&lt;br /&gt;
 CUTNB  = 15.000 CTEXNB =999.000 CTONNB =  7.000 CTOFNB =  9.000&lt;br /&gt;
 WMIN   =  1.500 WRNMXD =  0.500 E14FAC =  0.400 EPS    =  1.000&lt;br /&gt;
 NBXMOD =      5&lt;br /&gt;
 There are        0 atom  pairs and      658 atom  exclusions.&lt;br /&gt;
 There are     1502 group pairs and      139 group exclusions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 Analysing hydrogen bond patterns for:&lt;br /&gt;
              #donors  #acceptors&lt;br /&gt;
 1st sel:           0           1&lt;br /&gt;
 2nd sel:           1           0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   hydrogen bonds. Total time=      0.0ps. Resolution=  0.000ps.&lt;br /&gt;
 Cutoff distance=   2.40 time=    0.0 occupancy= 0.00&lt;br /&gt;
          ATOM            &amp;lt;occupancy&amp;gt;      &amp;lt;lifetime&amp;gt; (ps)&lt;br /&gt;
 1    GLU  5    O              1.0000&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
We are only interested in the presence of the &amp;#039;&amp;#039;&amp;lt;occupancy&amp;gt;&amp;#039;&amp;#039; field in the last couple of lines. A value of 1.0000 here shows this bond is present, so if we have four of these commands in the [[CHARMM]] input file, we will get four of these output blocks. This bash script fragment can be used to extract the number of occupied bonds:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# NUMBER OF NATIVE BACKBONE H-BONDS&lt;br /&gt;
   bbhbond=`grep -3 &amp;quot;hydrogen bonds. Total&amp;quot; charmm.out | grep 1.0000 | wc | awk &amp;#039;{print $1}&amp;#039;`&lt;br /&gt;
   echo &amp;quot;There are ${bbhbond} native backbone hydrogen bonds present&amp;quot;&lt;br /&gt;
   echo $bbhbond &amp;gt;&amp;gt; bbhbond.dat&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===TRP sidechain COM/COM distances===&lt;br /&gt;
If you want to get an idea for how many of the TRP rings are forming hydrophobic contacts with each other, you can check the distance between the centres of mass of each pair of rings. If this distance is less than a certain cutoff, you consider that a &amp;#039;contact&amp;#039;, and count it. In this section of &lt;br /&gt;
[[CHARMM]] input, we consider each possible pairing of the 4 TRP rings:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
! COM/COM distance TRP2/TRP4 sidechains&lt;br /&gt;
quick sele TRP2 end sele TRP4 end mass&lt;br /&gt;
&lt;br /&gt;
! COM/COM distance TRP2/TRP9 sidechains&lt;br /&gt;
quick sele TRP2 end sele TRP9 end mass&lt;br /&gt;
&lt;br /&gt;
! COM/COM distance TRP2/TRP11 sidechains&lt;br /&gt;
quick sele TRP2 end sele TRP11 end mass&lt;br /&gt;
&lt;br /&gt;
! COM/COM distance TRP9/TRP11 sidechains&lt;br /&gt;
quick sele TRP9 end sele TRP11 end mass&lt;br /&gt;
&lt;br /&gt;
! COM/COM distance TRP4/TRP11 sidechains&lt;br /&gt;
quick sele TRP4 end sele TRP11 end mass&lt;br /&gt;
&lt;br /&gt;
! COM/COM distance TRP4/TRP9 sidechains&lt;br /&gt;
quick sele TRP4 end sele TRP9 end mass&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Because we specify two selections (using the ring groups we defined above), the &amp;#039;&amp;#039;quick&amp;#039;&amp;#039; function knows to calculate a distance. The &amp;#039;&amp;#039;mass&amp;#039;&amp;#039; keyword on the end of each line specifies that the distance should be between the centres of mass of each group. Each call to &amp;#039;&amp;#039;quick&amp;#039;&amp;#039; results in the following output:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CHARMM&amp;gt;    ! COM/COM distance TRP2/TRP4 sidechains&lt;br /&gt;
 CHARMM&amp;gt;    quick sele TRP2 end sele TRP4 end mass&lt;br /&gt;
 SELRPN&amp;gt;     12 atoms have been selected out of    147&lt;br /&gt;
 SELRPN&amp;gt;     12 atoms have been selected out of    147&lt;br /&gt;
 QUICKA: The distance is:     5.41712&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
There will be six blocks like this in this case, as there are six possible pairs. The following bash script fragment is an example of how the number of contacts can be extracted in the case where we use a cutoff of 6.0A:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# TRP-TRP HYDROPHOBIC CONTACTS (COM/COM DISTANCE &amp;lt;6A)&lt;br /&gt;
   comcutoff=6.0&lt;br /&gt;
   nhydro=0&lt;br /&gt;
# Extract distances to file&lt;br /&gt;
   grep -4 &amp;#039;COM/COM distance&amp;#039; charmm.out | grep QUICKA | awk &amp;#039;{print $5}&amp;#039; &amp;gt; comcom.tmp&lt;br /&gt;
# Check each distance in the file to see if it is less than the cutoff ($comcutoff)&lt;br /&gt;
   for dist in `cat comcom.tmp`&lt;br /&gt;
   do&lt;br /&gt;
   compare=`echo &amp;quot;${dist} &amp;lt;= ${comcutoff}&amp;quot; | bc`&lt;br /&gt;
      if [ $compare -eq 1 ]; then&lt;br /&gt;
# If the distance is less than the cutoff, increment the number of contacts&lt;br /&gt;
         nhydro=$((nhydro + 1))&lt;br /&gt;
      fi&lt;br /&gt;
   done&lt;br /&gt;
   echo &amp;quot;There are ${nhydro} hydrophobic contacts between TRP rings (COM/COM)&amp;quot;&lt;br /&gt;
   echo $nhydro &amp;gt;&amp;gt; nhydro.dat&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Because bash can&amp;#039;t handle floating point numbers like these distances, we resort to a trick here to compare each to the cutoff by piping it to &amp;#039;&amp;#039;bc&amp;#039;&amp;#039; which returns &amp;#039;&amp;#039;1&amp;#039;&amp;#039; (true) if the equality is satisfied.&lt;br /&gt;
&lt;br /&gt;
===End-to-end distance (CA-CA)===&lt;br /&gt;
Another measure of how folded the hairpin is, could be the distance between the ends, the termini of the peptide. when it is folded, we know this distance is short (&amp;lt;6A), but it can be very large when it is unfolded (&amp;gt;30A). This distance is very easy to calculate, using the &amp;#039;&amp;#039;quick&amp;#039;&amp;#039; function in the [[CHARMM]] input:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
quick sele resid 1 .and. type CA end sele resid 12 .and. type CA end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As before, because we specify two selections (the CA atoms in the first and last residues), quick knows to calculate the distance between them. This results in the following CHARMM output:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 CHARMM&amp;gt;    ! 4) END-TO-END DISTANCE (CA-CA)&lt;br /&gt;
 CHARMM&amp;gt;    quick sele resid 1 .and. type CA end sele resid 12 .and. type CA end&lt;br /&gt;
 SELRPN&amp;gt;      1 atoms have been selected out of    147&lt;br /&gt;
 SELRPN&amp;gt;      1 atoms have been selected out of    147&lt;br /&gt;
 QUICKA: The distance is:     5.15931&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
All we want here is the distance itself, which is easily extracted using a simple bash script:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# END-TO-END DISTANCE&lt;br /&gt;
   endtoend=`grep -4 &amp;quot;END-TO-END DISTANCE&amp;quot; charmm.out | tail -n1 | awk &amp;#039;{print $5}&amp;#039;`&lt;br /&gt;
   echo &amp;quot;End-to-end distance (A) is ${endtoend}&amp;quot;&lt;br /&gt;
   echo $endtoend &amp;gt;&amp;gt; endtoend.dat&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Calculating order parameters for a whole PATHSAMPLE database==&lt;br /&gt;
Most often, you&amp;#039;ll want to calculate such order parameters for a whole database of minima, not just a single structure. This can be done by simply looping over each minimum in a bash script, extracting it using PATHSAMPLE with the EXTRACTMIN keyword, and then running your [[CHARMM]] input on the resulting structure, and extracting the values from the output. &lt;br /&gt;
&lt;br /&gt;
Here is the top of such a bash script for interest:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Script to extract order parameters from CHARMM output&lt;br /&gt;
nmin=`wc min.data | awk &amp;#039;{print $1}&amp;#039;`&lt;br /&gt;
&lt;br /&gt;
# Loop over minima&lt;br /&gt;
for ((min=1; min &amp;lt;= $nmin ; min++))&lt;br /&gt;
do&lt;br /&gt;
   echo &amp;quot;Working on minimum ${min}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Run PATHSAMPLE to extract crd file&lt;br /&gt;
   cp pathdata pathdata.tmp&lt;br /&gt;
   sed &amp;#039;s/.*EXTRACTMIN.*/EXTRACTMIN &amp;#039;$min&amp;#039;/&amp;#039; pathdata.tmp &amp;gt; pathdata&lt;br /&gt;
   PATHSAMPLE &amp;gt; output.extract&lt;br /&gt;
# Rename the extracted structure&lt;br /&gt;
   mv extractedmin.crd test.crd&lt;br /&gt;
# Run CHARMM to calculate the order parameters&lt;br /&gt;
   charmm_new &amp;lt; order_parameters.inp &amp;gt; charmm.out&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;NOTE: This script assumes that you have EXTRACTMIN already in your pathdata file before you start. It can be commented - but it must be present!&amp;#039;&amp;#039;&amp;#039;&lt;/div&gt;</summary>
		<author><name>Adk44</name></author>
	</entry>
</feed>