File: doc_amber2lt.md

package info (click to toggle)
moltemplate 2.22.4-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 26,084 kB
  • sloc: python: 25,770; sh: 3,746; tcl: 170; makefile: 14; awk: 4
file content (168 lines) | stat: -rw-r--r-- 5,043 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
amber2lt.py
===========

*amber2lt.py* is a program for converting AMBER FRCMOD and DAT files
into moltemplate (LT) file format.

## *WARNING: ALPHA SOFTWARE. THIS SOFTWARE IS EXPERIMENTAL AS OF 2022-8-24*


## Usage:

```
amber2lt.py \
  --in AMBER_FILE \
  --name FORCE_FIELD_NAME \
  [--out MOLTEMPLATE_FILE.lt]
```


## Examples

### Example 1

Convert the GAFF force field from a file named "gaff.dat"
into moltemplate format ("gaff.lt")

```
amber2lt.py --in gaff.dat --name GAFF --out gaff.lt
```
Later on, you can create molecule definition files (eg "benzene.lt")
which refer to the force field you have just converted.  For example:
```
#---- "benzene.lt" file -----
import "gaff.lt"
Benzene inherits GAFF {
  write('Data Atoms') {
    $atom:c1  $mol  @atom:ca  -0.115   -0.739   1.189  -0.00733
    $atom:c2  $mol  @atom:ca  -0.115    0.614   1.208   0.35167
       :        :        :
  }
  write("Data Bond List") {
    $bond:b1 $atom:C1 $atom:C2
       :
  }
}
```


### Example 2:

Suppose when you run AmberTools, it creates a file named "benzene.mol2" and "benzene.frcmod".  You can use *amber2lt.py* and *mol22lt.py* to create all of the moltemplate files you need this way:

```
amber2lt.py --in benzene.frcmod --name MyForceField \
  >> my_force_field.lt

mol22lt.py --in benzene.mol2 \
           --out benzene.lt \
           --name Benzene \
           --ff MyForceField \
           --ff-file my_force_field.lt
```
In this case, the "benzene.lt" file generated by *mol22lt.py*
would resemble this file:
```
import "my_force_field.lt"
Benzene inherits MyForceField {
  write('Data Atoms') {
    $atom:c1  $mol  @atom:ca  -0.112739   -0.739   1.189  -0.00733
    $atom:c2  $mol  @atom:ca  -0.112739    0.614   1.208   0.35167
       :        :        :
  }
  write("Data Bond List") {
    $bond:b1 $atom:C1 $atom:C2
       :
  }
}

```
If you have multiple molecules, you can repeat this process for each of them.
(Each time, you do, your "my_force_field.lt" file will grow larger and larger
 as *amber2lt.py* appends more and more atom types and interaction types
 to the existing file.
 *If you need to make changes to the original FRCMOD file, remember to
 delete the "my_force_field.lt" file before you start over again.*)





## Arguments


### --in AMBER_FILE

Specify the name of the AMBER force-field file you want to convert
(eg. "gaff.dat" or "benzene.frcmod").
*If omitted, the terminal (stdin) is used by default.*


### --out MOLTEMPLATE_FILE.lt

Specify the name of the moltemplate file (LT file) you want to create.
(eg. "gaff.lt").
*If omitted, the terminal (stdout) is used by default.*


### --name FORCE_FIELD_NAME

The name of force field you want to create.
(This is not necessarily the same as the file name containing the force field.)
Suppose the name of the force field is "GAFF".  Later on, when you define
molecules that use this force field, you will refer to it this way
"MoleculeName inherits GAFF {..."

## Optional Arguments

AMBER .DAT and FRCMOD files are divided into multiple sections containing
mass, bond, angle, dihedral, improper, and nonbonded (pair) interactions.
Unfortunately, available documentation describing the file format
is somewhat ambiguous about where these sections begin and end.
The "amber2lt.py" attempts to guess where each section is,
however it sometimes fails.  When this happens, the conversion will fail.
You can get around this problem by manually dividing the original file
into seperate files containing only the lines of text that are relevant
for that section.  Then you can pass these files individually to
the *amber2lt.py* program using the following arguments:

### --mass mass.txt
### --bond bond.txt
### --angle angle.txt
### --dihedral dihedral.txt
### --improper improper.txt
### --pair pair.txt

Once you have specified the text in these files, the "amber2lt.py"
usually succeeds in the conversion.
Each file must not contain any blank lines or irrelevant text.

*Note that if you supply one of these arguments, you must supply all of them.*


## Python API

It is possible to access the functionality of *amber2lt.py* from 
within python.  Example:

```python
import moltemplate
# Open the file you want to convert
with open('gaff.dat', 'r') as file_in:
    lines_in = file_in.readlines()
# Now create a new moltemplate file
lines_out = ConvertAmber2Lt(object_name, lines_in)
# Write the contents of the new file
with open('gaff.lt', 'w') as file_out:
    file_out.write(''.join(output_lines))
# Alternatively, if you have loaded each section of the the AMBER file into
# different lists of lines (eg "lines_mass", "lines_bond", ...)
# then you can do the conversion this way:
# lines_out = ConvertAmberSections2Lt(object_name,
#                                     lines_mass,
#                                     lines_bond,
#                                     lines_angle,
#                                     lines_dihedral,
#                                     lines_improper,
#                                     lines_pair)
```