# This file defines a family of coarse-grained protein models used in:
# G. Bellesia, AI Jewett, and J-E Shea, Protein Science, Vol19 141-154 (2010)
#
# Strategy:
#
#1) First I'll define some building blocks (A16, B16, T3)
#   which are helices, sheets and turns of a predetermined length)
#
#2)  Then I'll copy and paste them together to build
#    a 4-helix bundle or a 4-strand beta-barrel.
#    This approach is optional.  If your protein has helices which are not
#    identical, you should probably just include all 4 helices in a single
#    "Data Atoms" section and don't try to subdivide the protein into pieces.)


1beadProtSci2010 {  # <-- enclose definitions in a namespace for portability

  write_once("In Init") {
    units           lj
    atom_style      full
    bond_style      hybrid harmonic
    angle_style     hybrid harmonic
    dihedral_style  hybrid fourier
    pair_style hybrid lj/charmm/coul/charmm/inter es4k4l maxmax 3.5 4.0
    pair_modify     mix arithmetic
    special_bonds   lj 0.0 0.0 1.0   #(turn on "1-4" interactions)
  }


  # A16 is a coarse-grained alpha-helix containing 16 residues (one "atom" each)

  A16 {

    #  AtomID   MoleculeID AtomType  Charge       X        Y         Z

    write('Data Atoms') {
      $atom:a1  $mol:... @atom:../L  0.0      -0.4      -0.4       0.0
      $atom:a2  $mol:... @atom:../L  0.0       0.4      -0.4       0.6
      $atom:a3  $mol:... @atom:../H  0.0       0.4       0.4       1.2
      $atom:a4  $mol:... @atom:../H  0.0      -0.4       0.4       1.8
      $atom:a5  $mol:... @atom:../L  0.0      -0.4      -0.4       2.4
      $atom:a6  $mol:... @atom:../L  0.0       0.4      -0.4       3.0
      $atom:a7  $mol:... @atom:../H  0.0       0.4       0.4       3.6
      $atom:a8  $mol:... @atom:../H  0.0      -0.4       0.4       4.2
      $atom:a9  $mol:... @atom:../L  0.0      -0.4      -0.4       4.8
      $atom:a10 $mol:... @atom:../L  0.0       0.4      -0.4       5.4
      $atom:a11 $mol:... @atom:../H  0.0       0.4       0.4       6.0
      $atom:a12 $mol:... @atom:../H  0.0      -0.4       0.4       6.6
      $atom:a13 $mol:... @atom:../L  0.0      -0.4      -0.4       7.2
      $atom:a14 $mol:... @atom:../L  0.0       0.4      -0.4       7.8
      $atom:a15 $mol:... @atom:../H  0.0       0.4       0.4       8.4
      $atom:a16 $mol:... @atom:../H  0.0      -0.4       0.4       9.0
    }

    write('Data Bonds') {
      $bond:b1 @bond:../backbone $atom:a1 $atom:a2
      $bond:b2 @bond:../backbone $atom:a2 $atom:a3
      $bond:b3 @bond:../backbone $atom:a3 $atom:a4
      $bond:b4 @bond:../backbone $atom:a4 $atom:a5
      $bond:b5 @bond:../backbone $atom:a5 $atom:a6
      $bond:b6 @bond:../backbone $atom:a6 $atom:a7
      $bond:b7 @bond:../backbone $atom:a7 $atom:a8
      $bond:b8 @bond:../backbone $atom:a8 $atom:a9
      $bond:b9 @bond:../backbone $atom:a9 $atom:a10
      $bond:b10 @bond:../backbone $atom:a10 $atom:a11
      $bond:b11 @bond:../backbone $atom:a11 $atom:a12
      $bond:b12 @bond:../backbone $atom:a12 $atom:a13
      $bond:b13 @bond:../backbone $atom:a13 $atom:a14
      $bond:b14 @bond:../backbone $atom:a14 $atom:a15
      $bond:b15 @bond:../backbone $atom:a15 $atom:a16
    }

  } # A16


  # B16 is a coarse-grained beta-strand containing 16 residues (one "atom" each)

  B16 {

    #  AtomID   MoleculeID AtomType  Charge      X         Y         Z

    write('Data Atoms') {
      $atom:a1  $mol:... @atom:../L  0.0      -0.3       0.0       0.0
      $atom:a2  $mol:... @atom:../H  0.0       0.3       0.0       0.8
      $atom:a3  $mol:... @atom:../L  0.0      -0.3       0.0       1.6
      $atom:a4  $mol:... @atom:../H  0.0       0.3       0.0       2.4
      $atom:a5  $mol:... @atom:../L  0.0      -0.3       0.0       3.2
      $atom:a6  $mol:... @atom:../H  0.0       0.3       0.0       4.0
      $atom:a7  $mol:... @atom:../L  0.0      -0.3       0.0       4.8
      $atom:a8  $mol:... @atom:../H  0.0       0.3       0.0       5.6
      $atom:a9  $mol:... @atom:../L  0.0      -0.3       0.0       6.4
      $atom:a10 $mol:... @atom:../H  0.0       0.3       0.0       7.2
      $atom:a11 $mol:... @atom:../L  0.0      -0.3       0.0       8.0
      $atom:a12 $mol:... @atom:../H  0.0       0.3       0.0       8.8
      $atom:a13 $mol:... @atom:../L  0.0      -0.3       0.0       9.6
      $atom:a14 $mol:... @atom:../H  0.0       0.3       0.0       10.4
      $atom:a15 $mol:... @atom:../L  0.0      -0.3       0.0       11.2
      $atom:a16 $mol:... @atom:../H  0.0       0.3       0.0       12.0
    }

    write('Data Bonds') {
      $bond:b1 @bond:../backbone $atom:a1 $atom:a2
      $bond:b2 @bond:../backbone $atom:a2 $atom:a3
      $bond:b3 @bond:../backbone $atom:a3 $atom:a4
      $bond:b4 @bond:../backbone $atom:a4 $atom:a5
      $bond:b5 @bond:../backbone $atom:a5 $atom:a6
      $bond:b6 @bond:../backbone $atom:a6 $atom:a7
      $bond:b7 @bond:../backbone $atom:a7 $atom:a8
      $bond:b8 @bond:../backbone $atom:a8 $atom:a9
      $bond:b9 @bond:../backbone $atom:a9 $atom:a10
      $bond:b10 @bond:../backbone $atom:a10 $atom:a11
      $bond:b11 @bond:../backbone $atom:a11 $atom:a12
      $bond:b12 @bond:../backbone $atom:a12 $atom:a13
      $bond:b13 @bond:../backbone $atom:a13 $atom:a14
      $bond:b14 @bond:../backbone $atom:a14 $atom:a15
      $bond:b15 @bond:../backbone $atom:a15 $atom:a16
    }

  } # B16

  T3 { # T3 is a "turn" region consisting of 3 beads

    #  AtomID   MoleculeID AtomType  Charge       X        Y         Z

    write('Data Atoms') {
      $atom:a1  $mol:... @atom:../N  0.0      -0.8       0.0       0.0
      $atom:a2  $mol:... @atom:../N  0.0       0.0       0.55     -0.24
      $atom:a3  $mol:... @atom:../N  0.0       0.8       0.0       0.0
    }

    write('Data Bonds') {
      $bond:b1 @bond:../backbone $atom:a1 $atom:a2
      $bond:b2 @bond:../backbone $atom:a2 $atom:a3
    }

  } # T3

  # ----- Now build larger molecules using A16, B16 and T3 -------

  4SheetBarrel {

    sheet1 = new B16.rot(  45, 0,0,1).move(-0.793700526,-0.793700526, -6)
    sheet2 = new B16.rot( 135, 0,0,1).move( 0.793700526,-0.793700526, -6)
    sheet3 = new B16.rot( 225, 0,0,1).move( 0.793700526, 0.793700526, -6)
    sheet4 = new B16.rot( 315, 0,0,1).move(-0.793700526, 0.793700526, -6)

    turn1  = new T3.rot(180,1,0,0).rot(0,0,0,1).move(0,-1.3,6.6)
    turn2  = new T3.rot(  0,1,0,0).rot(-90,0,0,1).move(0.7,-0.0,-6.9)
    turn3  = new T3.rot(180,1,0,0).rot(-180,0,0,1).move(0,1.3,6.6)

    write('Data Bonds') {
      $bond:turn1a  @bond:../backbone  $atom:turn1/a1    $atom:sheet1/a16
      $bond:turn1b  @bond:../backbone  $atom:turn1/a3    $atom:sheet2/a16
      $bond:turn2a  @bond:../backbone  $atom:turn2/a1    $atom:sheet3/a1
      $bond:turn2b  @bond:../backbone  $atom:turn2/a3    $atom:sheet2/a1
      $bond:turn3a  @bond:../backbone  $atom:turn3/a1    $atom:sheet3/a16
      $bond:turn3b  @bond:../backbone  $atom:turn3/a3    $atom:sheet4/a16
    }
    create_var { $mol } # molecule ID number shared by all atoms in this protein
  }


  4HelixBundle {

    helix1 = new A16.rot( -45, 0,0,1).move(-1.12691645,-1.12691645, -4.5)
    helix2 = new A16.rot(  45, 0,0,1).move( 1.12691645,-1.12691645, -4.5)
    helix3 = new A16.rot( 135, 0,0,1).move( 1.12691645, 1.12691645, -4.5)
    helix4 = new A16.rot( 225, 0,0,1).move(-1.12691645, 1.12691645, -4.5)

    turn1  = new T3.rot(180,1,0,0).rot(-17,0,0,1).move(-0.2,-0.7,5.4)
    turn2  = new T3.rot(  0,1,0,0).rot(-100,0,0,1).move(0.7,-0.15,-4.8)
    turn3  = new T3.rot(180,1,0,0).rot(163,0,0,1).move(0.2,0.7,5.4)

    write('Data Bonds') {
      $bond:turn1a  @bond:../backbone  $atom:turn1/a1    $atom:helix1/a16
      $bond:turn1b  @bond:../backbone  $atom:turn1/a3    $atom:helix2/a16
      $bond:turn2a  @bond:../backbone  $atom:turn2/a1    $atom:helix3/a1
      $bond:turn2b  @bond:../backbone  $atom:turn2/a3    $atom:helix2/a1
      $bond:turn3a  @bond:../backbone  $atom:turn3/a1    $atom:helix3/a16
      $bond:turn3b  @bond:../backbone  $atom:turn3/a3    $atom:helix4/a16
    }
    create_var { $mol } # molecule ID number shared by all atoms in this protein
  }



  # 2-body (non-bonded) interactions:
  #
  #   Uij(r) = 4*eps_ij * (K*(sig_ij/r)^12 + L*(sig_ij/r)^6)
  #
  #              i       j            pairstylename          eps sig K L
  #
  write_once("In Settings") {
    pair_coeff @atom:H @atom:H  lj/charmm/coul/charmm/inter  1.0 1.0 1 -1
    pair_coeff @atom:L @atom:L  lj/charmm/coul/charmm/inter  1.0 1.0 1 0
    pair_coeff @atom:N @atom:N  lj/charmm/coul/charmm/inter  1.0 1.0 1 0
  }
  # Interactions between different atoms use "repulsive wins" mixing rules


  #   bond_coeff     bondType    bondstylename   k     r0

  write_once("In Settings") {
    bond_coeff     @bond:backbone   harmonic    66.6   1.0
  }


  #   angle_coeff  angleType  anglestylename   k   theta0

  write_once("In Settings") {
    angle_coeff @angle:backbone   harmonic    66.6  105.0
  }

  # We use the same bond-angle forces whenever 
  # there are 3 consecutively-bonded atoms:
  #
  # angleType       atomtypes1 2 3   bondtypes1 2

  write_once("Data Angles By Type") {
    @angle:backbone    @atom:*  @atom:*  @atom:*   @bond:*  @bond:*
  }



  # From the Bellesia et al 2010 paper:
  #             for helices: U_{dih}(\phi) = 1.2*(cos(3\phi) + cos(\phi+\delta))
  #               for turns: U_{dih}(\phi) = 0.2*cos(3\phi)
  #
  # General formula used for "dihedral_style fourier":
  # U_{dih}(\phi) = \Sum_{i=1}^m  K_i [ 1.0 + cos(n_i \phi - d_i) ]
  #
  # Syntax:
  #                dihedralType dihedralstyle m  K_1 n_1 d_1  K2 n_2 d_2 ...

  write_once("In Settings") {
    dihedral_coeff @dihedral:delta60_0 fourier 2 2.167862 3 0 2.167862 1 -60.0
    dihedral_coeff @dihedral:delta62_5 fourier 2 2.167862 3 0 2.167862 1 -62.5
    dihedral_coeff @dihedral:delta65_0 fourier 2 2.167862 3 0 2.167862 1 -65.0
    dihedral_coeff @dihedral:turn      fourier 1 0.361310 3 0
    # Note: 2.167862=1.2*epsilon and 0.361310=0.2*epsilon.
  }


  #   dihedralType         atomtypes1 2 3 4               bondtypes1 2 3

  write_once("Data Dihedrals By Type") {
    @dihedral:delta60_0  @atom:H  @atom:L  @atom:H  @atom:L    *  *  *
    @dihedral:delta60_0  @atom:H  @atom:H  @atom:L  @atom:L    *  *  *
    @dihedral:delta60_0  @atom:H  @atom:L  @atom:L  @atom:H    *  *  *
    @dihedral:delta60_0  @atom:L  @atom:H  @atom:H  @atom:L    *  *  *
    @dihedral:turn       @atom:N  @atom:*  @atom:*  @atom:*    *  *  *
  }
  # Note: This next rule is not needed:
  # @dihedral:turn       @atom:*  @atom:*  @atom:*  @atom:N    *  *  *
  #       (By reflection symmetry, it's equivalent to the rule above.)
  #
  # Note: The example in ../../membrane+protein/moltemplate_files/
  #       demonstrates how to define dihedral angles for this model
  #       in an alternate way which might be easier to understand.


  #  --- Mass Units ---
  # There are 3 atom types (referred to above as ../H, ../L, and ../N)
  # Define their masses (in reduced units):

  write_once("Data Masses") {
    @atom:H   1.0
    @atom:L   1.0
    @atom:N   1.0
  }


} # 1beadProtSci2010 (namespace)

