Giter Club home page Giter Club logo

moltemplate's Introduction

CircleCI CodeQL GitHub PyPI - Downloads PyPI - Version Website GitHub repo size

Moltemplate

Description

Moltemplate is a general cross-platform text-based molecule builder for LAMMPS and (the TCL version of) ESPResSo. Moltemplate was intended for building custom coarse-grained molecular models, but it can be used to prepare realistic all-atom simulations as well. It currently supports the OPLSAA(2008), OPLSUA, LOPLS(2015), AMBER(GAFF,GAFF2), DREIDING, COMPASS, TraPPE(1998) force fields, the ATB molecule database, and the MOLC, mW, ELBA(water), oxDNA2, and EFF molecular models (and others). (New force fields and examples are added continually by users.) Moltemplate is inter-operable with ATB, VMD/topotools, PACKMOL, RED-server, LigParGen, AmberTools, Open Babel, EMC, CellPACK, Vipster, struc2lammpsdf, and any other program that generates LAMMPS DATA (.lmpdat) files or MOL2 files.

This repository contains 3 folders:

  • moltemplate: source code and force fields
  • doc: documentation for moltemplate.sh, ltemplify.py, genpoly_lt.py, etc..
  • examples: examples built with moltemplate

Documentation

The best way to learn how to use moltemplate is to find an example which is similar to the system that you wish to simulate and modify it. This repository includes approximately 50 examples. Some of the moltemplate examples are also demonstrated (with pictures) here.

All moltemplate users should read chapter 4 of the reference manual (It's only 6 pages long. The first 3 chapters can be skipped.) Chapters 6, 7, and 5.1-5.3 also also recommended. (13 pages.)

In addition, there are also several talks/tutorials online.

Strategies for preparing all-atom simulations

Moltemplate was originally designed for preparing coarse-grained simulations. Fully atomistic simulations usually require choosing force-field specific atom types ("atom typing"), and the calculation of atomic charge. Moltemplate does not do this. Moltemplate also does not repair incomplete PDB files. To get around these limitations:

  • Users can use use 3rd-party molecule-builder tools such as: the ATB database (LT format), AmberTools (MOL2 format), EMC (DATA format), LigParGen (DATA format), and OpenBabel. These tools can generate MOL2 or LAMMPS-DATA files which can be converted into moltemplate format (LT format) using mol22lt.py or ltemplify.py. (If you want to try and select the atom types manually instead of using 3rd-party tools, read these suggestions.) Alternatively, users can use the DREIDING force field which has relatively simple atom type rules.
  • For atomic partial charges the RED-server is useful (which can generate a MOL2 file), in addition to the tools listed above. Alternatively, users can try using LAMMPS' built-in fix qeq feature.

Typical usage

    moltemplate.sh [-atomstyle style] [-pdb/-xyz coord_file] [-vmd] system.lt

Installation Instructions

Moltemplate depends on other software to work (such as BASH, python, pip, or python3, and pip3). Once these dependencies have been met, installing moltemplate is relatively easy. However many users find it difficult to install these prerequisites correctly. A detailed installation guide is located here.

Quick installation overview

Once you have installed the prerequesites mentioned above, download moltemplate using:

git clone https://github.com/jewettaij/moltemplate DESTINATION_DIRECTORY

(See below if you don't have git installed.) Then enter the directory where this README file is located:

cd DESTINATION_DIRECTORY

...and run the following command:

pip3 install .              # (or "pip", if that fails)

(Note: In some environments, "pip3" is called "pip" instead.)

If the command above fails (with both "pip" and "pip3"), then try this instead:

pip3 install . --user       # (or "pip", if that fails)

This will install moltemplate for a single user. If you are on a shared computer and you want to install moltemplate system-wide, then use:

sudo pip3 install .         # (or "pip", if that fails)

Later, you can uninstall moltemplate using:

pip3 uninstall moltemplate
# (use "pip" and/or prepend "sudo" if you did that earlier)

If this fails then read the installation troubleshooting guide. This guide will offer several different installation methods and explain how to install the prerequisites needed.

Note: Alternatively, you can download and install moltemplate using a single command:

pip3 install git+https://github.com/jewettaij/moltemplate.git   # (or "pip", if that fails)

...however this will omit all of the examples and documentation.

Web page

Additional suggestions and supporting code can be found at:

http://www.moltemplate.org

Requirements

Moltemplate requires BASH and a recent version of Python (>3.5), NumPy, and can run on MacOS, linux, or windows.

(Note: On MacOS, it may eventually become necessary to use 3rd-party tools like "brew" to install BASH if apple removes BASH support in future updates. Python 2.7 may also work, but you must edit your PATH to install moltemplate instead of using pip/pip3. Pip no longer works with old versions of python.)

To use LAMMPS and moltemplate, you will also need to install (and learn how to use) a (unix-style) text editor. (Word, Wordpad, and Notepad will not work.) Popular graphical text editors include Atom, Sublime, Notepad++, and VSCode. Older, non-graphical programs include vim, emacs, nano, ne, and jove. (Apple's TextEdit can be used if you save the file as plain text.)

License

With the exception of one file (ttree_lex.py), moltemplate is available under the terms of the MIT license.

The remaining file, (ttree_lex.py), is a modified version of the shlex.py module, which was released using the PSF license. Hence ttree_lex.py must also use this license. (The PSF is not a copyleft license. It is similar to the BSD and MIT licenses and is compatible with the the GPL license.)

Citation

If you find this program useful, please cite:

"Moltemplate: A Tool for Coarse-Grained Modeling of Complex Biological Matter and Soft Condensed Matter Physics", J. Mol. Biol., 2021, 433(11):166841, Jewett AI, Stelter D, Lambert J, Saladi SM, Roscioni OM, Ricci M, Autin L, Maritan M, Bashusqeh SM, Keyes T, Dame RT, Shea J-E, Jensen GJ, Goodsell DS https://doi.org/10.1016/j.jmb.2021.166841

moltemplate's People

Contributors

andersle avatar bhargavchava97 avatar cpossel avatar dstelter92 avatar hothello avatar jewettaij avatar jsbtic avatar ll8848 avatar mnink275 avatar profleao avatar schoyen avatar sebastianecheverrir avatar sgsaenger avatar smerz1989 avatar smsaladi avatar zouguijin1990 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

moltemplate's Issues

A possible error in the oplsaa force field file

Dear jewettaij:
We can open “oplsaa.lt” file in moltemplate/force_fields.In line 8217,it is "@improper:055_055_X_055 @atom:_b_a*_d*_i55 @atom:_b_a*_d*_i55 @atom:* @atom:_b_a*_d*_i55". I think we should use “i055” rather than “i55” in the second half of the sentence .I don’t know if my judgment is correct, but I hope this helps to ensure the correctness of the force field file.
Best wishes.
ALEX

force fields ("oplsaa.lt") and water molecules ("spce.lt") not found when downloaded using pypi ("pip install moltemplate")

I seem to have a pypi specific bug which occasionally occurs when people install using "pip install moltemplate" (ie using pypi to download moltemplate instead of github).

If you installed it that way, then ".lt" files that contain force fields, and some random stuff like popular water molecules were not getting copied to the correct place. That means if you use any of these force fields or water molecules in your simulations, moltemplate will complain that it can't find the .lt file for that force field. (eg "oplsaa.lt").

If you run into this problem, there are two easy work-arounds:

  1. Just download the file you need from: https://github.com/jewettaij/moltemplate/tree/master/moltemplate/force_fields/
    ...and then move it to the directory where you are running moltemplate, and try again.

  2. Alternatively, try downloading moltemplate from git instead (bypassing pypi), and install it by changing to the "moltemplate" directory and entering:
    pip install .
    (instead of "pip install moltemplate")
    This problem only occurred when python 3, not python 2.7, in conjunction with pypi. And, again, this problem never occurred when downloading moltemplate directly from git (or from the moltemplate.org web page, regardless of whether you were using python 3 or 2.7).

Details

I must be screwing up the format of the "package_data" entry in the "setup.py" file,

package_data={'moltemplate': ['force_fields/*.lt']}

...because the various .LT files which are stored (in the "force_fields" directory) there are not getting copied to where they need to go. But this only occurs when downloading from pypi ("pip install moltemplate") using python 3 or later. If anyone has any suggestions, please issue a pull request (or send me an email if that's easier)
http://moltemplate.org/images/author_email.png

Bug in cleanup_moltemplate.sh

This is line 226 of the script:
if ! "${PY_SCR_DIR}/scripts/moltemplate.sh" "${BASE_NAME}.lt" \

The correct line should have been:
if ! "${PY_SCR_DIR}/moltemplate.sh" "${BASE_NAME}.lt" \

Force field in the GROMACS topology format to LAMMPS format

Dear Andrew,

How do I convert this Ethylene glycol topology and parameter set in GROMACS format to LAMMPS format?

So, I have this OPLS-AA file and the ethlyene glycol molecule file from ATB.

The set was obtained from this paper https://doi.org/10.1021/jp109914s

#define _FF_OPLS
#define _FF_OPLSAA

[ defaults ]
; nbfunc    comb-rule   gen-pairs   fudgeLJ fudgeQQ
       1            3         yes       0.5     0.5

[ atomtypes ]
; name  bond_type      mass    charge   ptype          sigma      epsilon
    CG      CG  6  12.01100    0.1650       A    3.50000e-01  2.76144e-01
    HG      HG  1   1.00800    0.0600       A    2.50000e-01  1.25520e-01
    OG      OG  8  15.99940   -0.7200       A    3.00000e-01  7.11280e-01
    HO      HO  1   1.00800    0.4350       A    0.00000e+00  0.00000e+00

[ bondtypes ]
;  i     j   func         b0         kb
  CG    CG      1    0.15290   224262.0
  CG    HG      1    0.10900   284512.0
  CG    OG      1    0.14300   267776.0
  OG    HO      1    0.09450   462750.4

[ angletypes ]
;  i     j     k   func      th0      cth
  CG    CG    OG      1   108.00   418.40
  CG    CG    HG      1   110.70   313.80
  HG    CG    HG      1   107.80   276.14
  HG    CG    OG      1   109.50   292.88
  CG    OG    HO      1   108.50   460.24

[ dihedraltypes ]
;   i    j     k     l   func  coefficients
   OG    CG    CG    OG  3    9.852  11.989   4.987 -26.828   0.000   0.000
   CG    CG    OG    HO  3   -0.141   5.591   3.156  -8.606   0.000   0.000

; Fourier coefficients
; angle    F1      F2      F3
; OCCO   16.264  -4.987  13.414
; CCOH    1.727  -3.156   4.303

Thank you for your time and support.

Best regards,
Yunes Salman

Error in membrane example

Dear Andrew Jewett,

I tried to run the example Coarse-grained lipid bilayer using the MARTINI force field and PACKMOL. When I run " moltemplate.sh -xyz system.xyz system.lt" comment there was an error like this.

Error: Number of atoms in coordinate file provided by user (9600)
does not match the number of atoms generated in ttree file (9216)

Could you please show me how to fix this error.
Ps: I didn't change any thing in your input files

Thank you in advance for your help.

Best regards

SPC/E in force_fields/spce_oplsaa.lt

The spc_oplsaa.lt file and the one in the example are inconsistent.

diff moltemplate/moltemplate/force_fields/spc_oplsaa.lt moltemplate/examples/all_atom/force_field_OPLSAA/waterSPC_using_OPLSAA/moltemplate_files/spc.lt

Notably, the constraint is missing in the latter.

1c1
< # file "spc_oplsaa.lt" 
---
> # file "spce.lt" 
6,8d5
< #
< # This is the version of the SPC water model suitable for use in a simulation
< # using the OPLSAA force field (as implemented in the "oplsaa.lt" file).
10d6
< import "oplsaa.lt"  # <-- defines OPLSAA, @atom:76 and @atom:77
12c8,10
< SPC_oplsaa inherits OPLSAA {
---
> import "oplsaa.lt"
> 
> SPC inherits OPLSAA {
14,16c12,14
<   # Atom types from "oplsa.lt"
<   # @atom:76 <--> "SPC Water O"
<   # @atom:77 <--> "SPC Water H"
---
>   # Atom types from "oplsaa_lt_generator/oplsaa_subset.prm"
>   # @atom:76  <-->  OW  "SPC Water O"
>   # @atom:77  <-->  HW  "SPC Water H"
19,21c17,19
<     $atom:O  $mol:. @atom:76 -0.82   0.0000000 0.00000 0.000000
<     $atom:H1 $mol:. @atom:77  0.41   0.8164904 0.00000 0.5773590
<     $atom:H2 $mol:. @atom:77  0.41  -0.8164904 0.00000 0.5773590
---
>     $atom:O  $mol:. @atom:76 -0.8200 0.0000000 0.0000 0.000000
>     $atom:H1 $mol:. @atom:77 0.4100 0.8164904 0.0000 0.577359
>     $atom:H2 $mol:. @atom:77 0.4100 -0.8164904 0.0000 0.577359
25,26c23,24
<     $bond:OH1  $atom:O $atom:H1
<     $bond:OH2  $atom:O $atom:H2
---
>     $bond:OH1 $atom:O $atom:H1
>     $bond:OH2 $atom:O $atom:H2
29,39c27,35
<   write_once("In Constraints") {
<     # Define a group for the spc water molecules:
<     group spc type  @atom:76  @atom:77
< 
<     # Constrain the angles and distances in spc water:
<     fix fRattleSPCE spc rattle 0.0001 10 100 b @bond:OH a @angle:HOH
< 
<     # Remember to put this command in your LAMMPS input script:
<     #  include system.in.constraints
<     # ...AFTER minimization and after all integration fixes.
<   }
---
> } # end of definition of "SPC" water molecule type
> 
> 
> 
> 
> 
> 
> 
> 
41d36
< } # end of definition of "SPCE" water molecule type
42a38,95
> 
> ###################### old version (SPCE) ######################
> #
> #SPCE {
> #
> #  write("Data Atoms") {
> #    $atom:O  $mol:. @atom:O -0.8476 0.0000000 0.0000 0.000000
> #    $atom:H1 $mol:. @atom:H 0.4238 0.8164904 0.0000 0.577359
> #    $atom:H2 $mol:. @atom:H 0.4238 -0.8164904 0.0000 0.577359
> #  }
> #
> #  write_once("Data Masses") {
> #    @atom:O 15.9994
> #    @atom:H 1.008
> #  }
> #
> #  write("Data Bonds") {
> #    $bond:OH1 @bond:OH $atom:O $atom:H1
> #    $bond:OH2 @bond:OH $atom:O $atom:H2
> #  }
> #
> #  write("Data Angles") {
> #    $angle:HOH @angle:HOH $atom:H1 $atom:O $atom:H2
> #  }
> #
> #  write_once("In Settings") {
> #    bond_coeff   @bond:OH     harmonic               1000.0  1.0 
> #    angle_coeff  @angle:HOH   harmonic               1000.0  109.47
> #    pair_coeff   @atom:O @atom:O  lj/cut/coul/long   0.1553  3.166 
> #    pair_coeff   @atom:H @atom:H  lj/cut/coul/long   0.0     2.058
> #    # Note: Since we are using RATTLE constraints, the bond and angle strength
> #    # parameters ("600.0", "75.0") do not matter. But the equilibrium bond
> #    # length ("1.0") and equilibrium angle ("109.47") does matter. LAMMPS
> #    # obtains these numbers from the bond_coeff and angle_coeff commands above.
> #  }
> #
> #  write_once("In Constraints") {
> #    group spce type  @atom:O  @atom:H
> #    fix fRattleSPCE spce rattle 0.0001 10 100 b @bond:OH a @angle:HOH
> #    # Remember to put this command in your LAMMPS input script:
> #    #  include system.in.constraints
> #    # ...AFTER minimization and after all integration fixes.
> #  }
> #
> #  write_once("In Init") {
> #    # -- Default styles (for solo "SPCE" water) --
> #    units        real
> #    atom_style   full
> #    # (Hybrid force fields were not necessary but are used for portability.)
> #    pair_style   hybrid lj/cut/coul/long 10.0
> #    bond_style   hybrid harmonic
> #    angle_style  hybrid harmonic
> #    kspace_style pppm 0.0001
> #    pair_modify  shift yes
> #  }
> #
> #} SPCE
> ###################################################################

Doubts with bonds_type

Hi Andrew. I've been looking at scripts (sh) but I'm not very good with this programming language, I didn't understand it very well. I'm in doubt about the bonds_type property of the GPSettings class, in genpoly. I know that genpoly_lt does not check the bond and atom type, but moltemplate.sh does. I'm trying to use types present in force field, like "084_084" from oplsaa, but moltemplate says the type doesn't have the necessary parameters. Where can I learn more about the valid types of bonds_type and bonds_atoms?

ltemplify.py Not recognising pair_coeffs when names inferred from comments

When being built, self.l_data_pair_coeffs and self.l_data_pairij_coeffs (I'm not sure if others do this too) are identified by a name given by using self.atomtypes_int2name on their atom types
e.g. line 1996 i_str = '@atom:' + self.atomtypes_int2name[i]

However later in the postprocess3 function when checking whether to delete a line or not the, name is converted by the Intify function (line 2992:3005)

atomtype = Intify(split_colon[1])
            if ((not (atomtype in self.needed_atomtypes)) and
                (not ((len(self.atomtype_selection) > 0) and
                      BelongsToSel(atomtype, self.atomtype_selection)))):
                del self.l_data_pair_coeffs[i_line]

and the Intify function fails to recognise the names of the atoms if they were read from comments, causing all pair_coeffs lines to be deleted.

Suggestion:

Replace the Intify functions in these sections with the self.atomtypes_name2int. Since the names are built originally by self.atomtypes_int2name this simply reverts them back to ints.
Example for self.l_data_pair_coeffs (line 2992:3005):

atomtype = self.atomtypes_name2int[split_colon[1]]
            if ((not (atomtype in self.needed_atomtypes)) and
                (not ((len(self.atomtype_selection) > 0) and
                      BelongsToSel(atomtype, self.atomtype_selection)))):
                del self.l_data_pair_coeffs[i_line]

One test fails

Hello,

The FreeBSD port runs this script as a testsuite:

        @cd ${WRKSRC} && \
                ([ -e shunit2 ] || (${MKDIR} tests/shunit2 && ${RM} tests/shunit2/shunit2 && ${LN} -s ${LOCALBASE}/bin/shunit2 tests/shunit2/shunit2)) && \
                ${SETENV} ${TEST_ENV} bash tests/test_read_coords_pdb.sh && \
                ${SETENV} ${TEST_ENV} bash tests/test_ltemplify.sh && \
                ${SETENV} ${TEST_ENV} bash tests/test_oplsaa.sh && \
                ${SETENV} ${TEST_ENV} bash tests/test_compass.sh && \
                ${SETENV} ${TEST_ENV} python3 tests/test_genpoly_lt.py

In version 2.20.17 it fails like this in the middle:

/disk-samsung/freebsd-ports/science/py-moltemplate/work-py39/stage/usr/local/bin/cleanup_moltemplate.sh: line 227: /disk-samsung/freebsd-ports/science/py-moltemplate/work-py39/stage/usr/local/bin/scripts/moltemplate.sh: No such file or directory
ERROR: cleanup_moltemplate.sh: unable to convert the simplified LT file to LAMMPS files
ASSERT:cleanup_moltemplate.sh failed: system.data missing impropers

Ran 1 test.

FAILED (failures=2)

A question about how to build graphene/ polymer interfaces or hexagonal boron nitride /polymer interfaces

Hello!
Recently, I am building a polymer interface model. The polymer uses polyvinyl alcohol . The interface plans to use graphene sheet or hexagonal boron nitride sheet . Later, I will consider grafting other polymers on the interface. It is not difficult to build a polymer model using moltemplate,but it seems difficult to build a graphene sheet or hexagonal boron nitride sheet and polymer interface model.
I checked the establishment of the graphene sheet in the example, and I found that the atom types were set by ourselves, such as “@atom:C",rather than gotten from oplsaa force field. The force field parameters of the polymer interface model can be divided into three parts, the polymer itself;graphene or hexagonal boron nitride;between the polymer and the interface.The first one can be obtained by moltemplate, the second is also simple , such as AIREBO or Tersoff.But the third one seems difficult, because I did not find the appropriate C, B, and N atomic types in oplsaa to build graphene and hexagonal boron nitride sheet, So it is hard for me to get correct pair_coeff parameters between polymer and boron nitride sheets or graphene sheets .
I want to know whether it is possible to bulild a graphene or hexagonal boron nitride sheet in the oplsaa force field through molteplate, and obtain a reasonable pair_coeff parameter between the polymer and the interface?
Thank you!

wrong masses in LAMMPS data file using OPLSAA force field

Hi Andrew.

I'm trying to build a LAMMPS data file through Moltemplate. My system is formed by a carboxylic acid adduct solvated by water. For that, I'm using spce_oplsaa.lt and oplsaa.lt for water and adduct, respectively. I solved several of my issues by means your excellent answers in the LAMMPS forum. However, I have one methodological issues that I can't solve. In particular, it seems to me that Moltemplate generates wrong masses in LAMMPS data file using OPLSAA force field. All masses are being copied from oplsaa.lt to LAMMPS data file. I though that it was a problem in my LT files, but I found the same error using the system.it available example waterSPCE+methane. Do I need to do anything else with oplsaa.lt?

Thanks in advance.
Sincerely,
Raphael

Help for reading coordinates from pdb files.

Dear Professor,

I want to use moltemplate to add information such as key corners from the pdb file created by packmol, but when I run:
moltemplate.sh -pdb start.pdb -atomstyle "full" system
lt it reports an error stating:
Error: Number of atoms in coordinate file provided by user (23238) does not match the number of atoms generated in ttree file (9798).

My system is graphene electrode with ionic liquid system,When I was troubleshooting the error, I found that when I read just the graphene or water or Li ions individually, I could read their pdb file coordinates, but when I read them together I had a problem with not being able to match the pdb coordinates.

This problem has been bothering me for a long time, and my lt files are written strictly according to the syntax.Here, I sincerely ask for your help!

Thanks a lot!

Here, I attach my lt files.
case.zip

dump2data.py fails when box size changes (NPT)

The dump2data.py utility seems to fail when reading trajectories from simulations that were not run at constant volume (such as NPT simulations). I noticed this when interrupting a constant-pressure simulation and using the dump2data.py program to convert the last frame from the incomplete trajectory to start a new simulation.

I don't need this feature in my own work, so it might be a little while before I get around to fixing this problem.

-Andrew

Tests fail to run: no tests ran in 0.09 seconds

setup.py says that pytest is required for tests, but it fails to run them:

==================================================================================== test session starts ====================================================================================
platform freebsd13 -- Python 3.8.12, pytest-4.6.11, py-1.9.0, pluggy-0.13.1
rootdir: /disk-samsung/freebsd-ports/science/py-moltemplate/work-py38/moltemplate-2.20.1
plugins: forked-1.0.2, hypothesis-6.32.1, cov-2.9.0, xdist-1.32.0, rerunfailures-10.1, timeout-1.4.2, mock-1.10.4
collected 0 items                                                                                                                                                                           

=============================================================================== no tests ran in 0.09 seconds ================================================================================
*** Error code 5

Version: 2.20.1
Python-3.8
pytest-4.6.11
FreeBSD 13

cnt capillary example error

I'm new to moltemplate, i just installed it and tried to run the carbon nanotube capillary example,
when i try to run the 'moltemplate.sh system.lt'
it shows this error
Error(ttree.StaticObj.Parse()):
Duplicate class/array "unitcells"
This occurs near:
"graphene_walls.lt", line 14
and also near:
"nanotube.lt", line 14
Could you help please?

drymartini and martini file issues

Hello!

I've been playing around with the dry martini model incldued with moltemplate - I had an error that certain atom masses and atom types were undefined. It seems like this issue cropped up especially surrounding the small bead naming schemes. In particular, throughout the lt file there were references to SP4_bSP4_aSP4_dSP4_iSP4, but the replace command read replace{ @atom:SP4 @atom:SP4_SP4_aP4_dP4_iP4} missing S's before the P's in the longer name causing moltemplate to think there weren't masses defined for these atoms.

There was also one bond coeff not defined - P1-C1, I wasn't sure whether that should be defined or not - I added a coeff for it and marked the location (line 828). The coeff I chose was 1.49375 4.8 (which I think is correct).

I've gone through and corrected (I think) all of these issues - I don't make any promises that anything else in the file is correct. (I marked things I changed with comments). Moltemplate runs with dry martini now at least with these changes.

I've attached the new lt file to this issue report (I had to swap the extension to get github to accept it). Let me know if you have any questions, I hope this helps!

Best,
Zeke

drymartini.txt

python2 assumed when python is in path, fails with miniconda3

In moltemplate.sh:

if which python > /dev/null; then
    PYTHON_COMMAND='python2'
elif which python3 > /dev/null; then
    PYTHON_COMMAND='python3'
else
    echo "Error:  $G_PROGRAM_NAME requires python or python3" >&2
    exit 1
fi

This fails when conda is activated and 'python' leads to python 3+.
If I knew bash well enough I would fix this to check the version with 'python -v'

question about choosing OPLSAA @atom types (atomic charge)

Hello!
I created a chain of polyvinyl alcohol for all-atoms MD simulation. I choosed the atom 96 and 97 as oxygen and hydrogen atoms of hydroxyl in OPLSAA.
Their charges are -0.683 and 0.418.This is not electrically neutral .Is this because I chose the wrong atom type? Or I need to use another tool to calculate atomic charges?

Thank you!

Error: There are no atoms in the system (with write("Data Atoms") command)

Dear Moltemplate users,

I have an issue about " There are no atoms in the system".

I build a force-field of PDMS. The force field include atoms I need inside. (The partial code is shown below:)
PForceField {
write_once("In Init") {
units real
atom_style full
bond_style class2
angle_style quartic
dihedral_style opls
pair_style buck
}
#There are 4 atom types: "C" "H" "Si" "O"
write_once("Data Masses") {
@atom:Si 28.085
@atom:C 12.01
@atom:H 1.007
@atom:O 15.999

And I import the force field to my monomer.lt script. (as shown below:)

_import "PForcefield.lt" # contains force-field parameters

monomer inherits PForceField {

write("Data Atoms") {
#atomId molId atomType charge x y z
$atom:Si $mol:... @atom:Si 0.0 -0.637886 0.553288 -0.183695
$atom:O $mol:... @atom:O 0.0 0.248119 -0.271508 -1.283296
$atom:C1 $mol:... @atom:C 0.0 -0.600714 2.369272 -0.648393
$atom:H1 $mol:... @atom:H 0.0 0.439526 2.758433 -0.590174
$atom:H2 $mol:... @atom:H 0.0 -0.977302 2.505258 -1.68573
$atom:H3 $mol:... @atom:H 0.0 -1.241965 2.958313 0.0432318461
$atom:C2 $mol:... @atom:C 0.0 -2.392134 -0.107249 -0.223331
$atom:H4 $mol:... @atom:H 0.0 -2.823555 0.014571 -1.241173
$atom:H5 $mol:... @atom:H 0.0 -2.40159 -1.186807 0.0434449812
$atom:H6 $mol:... @atom:H 0.0 -3.0274 0.446758 0.502263
}
write("Data Bonds") {
#bond-id bond-type atom-id1 atom-id2
$bond:CH31 @bond:Sidechain1 $atom:C1 $atom:H1
$bond:CH32 @bond:Sidechain1 $atom:C1 $atom:H2
$bond:CH33 @bond:Sidechain1 $atom:C1 $atom:H3
$bond:CH34 @bond:Sidechain1 $atom:C2 $atom:H4
$bond:CH35 @bond:Sidechain1 $atom:C2 $atom:H5
$bond:CH36 @bond:Sidechain1 $atom:C2 $atom:H6
$bond:SiC1 @bond:Sidechain2 $atom:Si $atom:C1
$bond:SiC2 @bond:Sidechain2 $atom:Si $atom:C2
$bond:SiO @bond:Backbone $atom:Si $atom:O
}
}_

However, the Error shows:
_Error: There are no atoms in your system. Suggestions:

   Your files must contain at least one
       write("Data Atoms")
   command.  These commands are typically located somewhere in
   one of the molecule object(s) you have defined._

I also try using "new" in my monomer.lt script:

_import "PForcefield.lt" # contains force-field parameters

mon1 = new Si
mon2 = new C
mon3 = new O
mon4 = new H
monomer inherits PForceField {_

It shows:
Error(ttree.PtknsToNode()):
Class or variable "Si" not found
in this context: ".../Si"

Did I do something wrong with creating atoms?

Thank you so much for help and any suggestions in advance

monomer.txt
PForcefield.txt
.

[Doc] Add direct pip installation command in README.md

Thanks for such a great library.

Since pip allows direct installation from remote git repository by running following command,

user@host:~$ pip install git+https://github.com/jewettaij/moltemplate.git

it will be very helpful for new users to add this in README.md, especially who's not familiar with python.

906 atom types in system.data using the OPLSAA force field


moltemplate_2020-4-04/examples/all_atom/force_field_OPLSAA/
ethylene+benzene
ethylene+benzene_PACKMOL/

For the above examples, the system.data gives 906 atom types as in the following.
I wonder why there are 906 atom types, as the actual atom types in the Atoms section
are few. Just the same as in oplsaa.tt ? Thank you very much.

LAMMPS Description

 2592  atoms
 2376  bonds
 3240  angles
 3456  dihedrals
 3240  impropers

 906  atom types
 379  bond types
 1017  angle types
 800  dihedral types
 6  improper types

Undefined variable 'needed_improperids'

Hi, I got the following error message while running ltemplify.py on a system with improper dihedrals:

File "ltemplify.py", line 3901, in PostProcess3
    for improperid in needed_improperids:
NameError: name 'needed_improperids' is not defined

Presumably a self.needed_improperids is needed on line 3901?

About the output the mass information of all atoms of the force field in system.data for "all atoms"

Hello!
I found a small problem.I successfully installed moltemplate on my computer which is windows 10 a few days ago.After that,I run a example on it .Its name is "alkane_chain_single" and the file path is “examples\all_atom\force_field_OPLSAA\alkane_chain_single”.

I got the system.data after running the moltemplate. Then I used the VMD to open this file. There was no problem in molecular configuration with VMD. But I found the mass information of all atoms that own to the force field in the system.data . It seems that this wouldn't affect the consequence of simulation.

I think it will be better if the data file just contains the mass information of the atoms of given system. Unfortunately I haven't learned python and how to use python yet. So I don't know how to deal with this small problem.I will start to to learn python and try to address this issue after I finish my current course.And when I'm done, I'll come back and give an answer.

Thank you!

ALEXysd.

failure to read coordinates from XYZ files (and PDB files?)

Here is a message posted on the LAMMPS mailing list from Daoud El Kadiri.
I am posting it here because I was unable to reproduce the problem on my end, and I am hoping that Daoud or someone else can follow up.:

"I changed my ubuntu from 18.04 to 20.04, and downloaded the last version of moltemplate (before i was using 2020-12-02) and since then i have a problem running moltemplate

When i try to generate lammps input files through "moltemplate.sh -xyz system.xyz -vmd system.lt", the data file generated has all molecules placed on the same coordinates (which is not the case on the .xyz file).

I tried with the files already available in the moltemplate example directory (for example ethylene+benzene_PACKMOL) to be sure the problem wasn't in my own lt files and it still the same

I attached the .xyz file and the data file generated when i run the example "ethylene+benzene_PACKMOL" from the moltemplate examples

Thanks in advance for your help"

ltemplify.py typo in line 4823

        if len(self.l_data_improper_coeffs) > 0:
            l_data_improper_coeffs.insert(
                0, (' ' * self.cindent) + 'write_once(\"' + data_improper_coeffs + '\") {')

should be

        if len(self.l_data_improper_coeffs) > 0:
            self.l_data_improper_coeffs.insert(
                0, (' ' * self.cindent) + 'write_once(\"' + data_improper_coeffs + '\") {')

Dihedrals in ethene?

Hi Andrew,

Attached are the chemical.lt for a simple ethene molecule and the corresponding system.lt. When I followed the guideline and used path/moltemplate.sh system.lt, I found 4 dihedrals in system.data, which doesn't seem make sense as all the atoms in ethene lie in one plane. Please let me know what you think about this. Thanks!

chemical.lt

import "oplsaa.lt"

chemical inherits OPLSAA {
    write('Data Atoms') {
        $atom:0 $mol @atom:88 -0.39937 0.666  -0.000   0.000
        $atom:1 $mol @atom:88 -0.39937 -0.666   0.000  -0.000
        $atom:2 $mol @atom:89 0.199685 1.241  -0.924  -0.000
        $atom:3 $mol @atom:89 0.199685 1.240   0.924  -0.000
        $atom:4 $mol @atom:89 0.199685 -1.240  -0.924   0.000
        $atom:5 $mol @atom:89 0.199685 -1.241   0.925   0.000
    }

    write('Data Bond List') {
        $bond:0 $atom:0 $atom:1
        $bond:1 $atom:0 $atom:2
        $bond:2 $atom:0 $atom:3
        $bond:3 $atom:1 $atom:4
        $bond:4 $atom:1 $atom:5
    }
}

system.lt

import "chemical.lt"

# Periodic boundary conditions
write_once("Data Boundary") {
    0.0  32.0  xlo xhi
    0.0  32.0  ylo yhi
    0.0  64.0  zlo zhi
}

Chemical = new chemical
Chemical.move(0.0, 0.0, 0.0)

system.data

LAMMPS Description

     6  atoms
     5  bonds
     6  angles
     4  dihedrals
     6  impropers

     906  atom types
     379  bond types
     1017  angle types
     800  dihedral types
     6  improper types

  0.0 32.0 xlo xhi
  0.0 32.0 ylo yhi
  0.0 64.0 zlo zhi
...

lttree_postprocess.py error: reference to undefined $angle

Hi Andrew.

I was trying to modified a .lt file generated by ATB to fit OPLSAA force field. However, an error occurred as below:

lttree_postprocess.py v0.6.1 2020-10-15

Error(lttree_postprocess.py): near "D7JH_allatom_optimized_geometry.lt", line 272

      Reference to undefined $angle:

            $/angle:bcb/a2     (<--full name)

      (If that angle belongs to a molecule (or other subunit), make sure that
       you specified the correct path which leads to it (using / and ..))

I don't think this error result from mistakes in the .lt file because the assignment for that angle can be found in "ttree_assignments.txt" file.
$/angle:bcb/a2 2 #"D7JH_allatom_optimized_geometry.lt", line 272

This error was omitted when running the script with "-nocheck" flag. However, there will be extra sections of "Angle List", "Dihedral List" and "Improper List" in the .data file.

Could you tell me what's the problem?
Thanks

a bug to cleanmoltemplate.sh

OK, after about a whole day i finally figure out how to use TIP4P model by using moltemplate and oplsaa.lt
There is a bug to cleanmoltemplate.sh.

After I generate simulation system by moltemplate.sh, it all works well. But after using cleanmoltemplate.sh, those irrelevant information is removed, but add set type charge to system.in.settings. That means we use set charge two times: one in system.in.settings, after pair_coeff etc; another is system.in.charges.

If i want to use TIP4P model, i should not explicitly add a dummy atom M to water.lt, but just assign the charge of M to O, thus LAMMPS would implicitly introduce the dummy atom M to system just if your H2O has the right order. (It is a little bit imcompatible for moltemplate to LAMMPS.) Here is point. I forget that there is a system.in.charges file exists and i just rectify .settings, so .charges override my previous charge assign, so my system always blow up due to no attraction.

Anyway, I think you should do remove the function that cleanmoltemplate.sh copy set charge command to .settings. Or due to simplicity, totally remove the system.in.charges and write set charge to .settings file. Because the meaning of .settings is that settings the parameters of system.

I would pull request a example of how to build TIP4P water system and write a tutorial about how to use oplsaa force field(I think after one week study and try and try and try i can say i understand it). But today it is too late...

running moltemplate on large systems is slow and needs a lot of memory

Hi andrew,

I have a martini based coursegrain simulation in which the size of the box is large. There are 3 species of atoms totaling around 12million atoms. Moltemplate always crashes through the run and it takes forever, is it possible it on multiple cores with mpi/mpiexec.

Hassan

How to use LAMMPS' "variable" command in an .LT file

Hi,

I am new to moltemplate, so I am sorry if I asking a (trivial) question here. I wanna create forcefield.lt. Can I use LAMMPS variable command in my script? I would like then use this forcefield.lt as a template and produce a collection of LAMMPS input files by bash scripts.

For instance I want to have the following command in my LAMMPS script

variable cutoff11 equal ${sig1}*1.12246205

where sig1 is then given to LAMMPS as an argument with the command-line option lmp_serial -var sig1 VALUE.

Please see the part of the input file that I want to use variable command in.

example.txt

Thanks

Amir

name_sequence_multi not properly initialized when genpoly API is used.

When GenPoly ParseArgs is used referencing the "-sequence" file, name_sequence_multi is not initialized. This is probably due to the fact that ReadSequence is only executed in main() which is not used in API mode. I think it's something simple to fix, but I believe you have a proposal for a better solution.

ImportError: cannot import name OrderedDict

Hi,

I am using an Bash environment to run moltemplate on my windows 10 machine. After getting it to recognise moltemplate (v 2.19.12) as an command and making sure it recognises my python installation (v 3.9), I end up with an error message: ValueError: Attempted relative import in non-package, it enters the exception after which Bash presents me with: ImportError: cannot import name OrderedDict.

This happens both on v2.19.12 and v2.19.11 of moltemplate. The ValueError was solved by removing the "." in the moltemplate script. I struggle to find a solution for the import error.

If I write "lttree_check.py" in bash, I get the exact same error message.

I understand that this isn't a bug as per say, but I was hoping I could receive some help in getting it to work.

Thanks for your time!
H2O2

The number of columns in your data file does not match the LAMMPS atom_style you selected.

Dear Andrew

When I generated the system. data file for the newest version, I got the error " The number of columns in your data file does not match the LAMMPS atom_style you selected. Use the -atomstyle <style> command line argument." However, if I used the version from July 26, 2020, there is no error. Besides, I tested the example files in the old and the newest version, there is also no error. I tried to space between the columns or arrange columns in align but I cannot pass the error. Can you check it? Thank you very much.
Tue Le

No module named moltemplate.lttree_check

Dear All,

This issue was raised a few months ago but it is closed now and I can't really figure out the solution.

So, I installed moltemplate using
sudo pip3.8 install .
command. I got this message in response:

WARNING: The directory '/home/dawid/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Processing /home/dawid/qsar/moltemplate/moltemplate
Requirement already satisfied: numpy in /usr/local/lib/python3.8/dist-packages (from moltemplate==2.19.4) (1.19.3)
Building wheels for collected packages: moltemplate
  Building wheel for moltemplate (setup.py) ... done
  Created wheel for moltemplate: filename=moltemplate-2.19.4-py3-none-any.whl size=947603 sha256=636b2825e6147f767754caf7f16cb1cf018a0eb5cadc160428c2ab31546e2073
  Stored in directory: /tmp/pip-ephem-wheel-cache-12keh4te/wheels/49/fb/77/543625cb3ecfa30c8a7d9be81a554a2159052b2ef9bffcf78e
Successfully built moltemplate
Installing collected packages: moltemplate
Successfully installed moltemplate-2.19.4

So apart from the WARNING, everything seems fine. However, if I run
moltemplate.sh system.lt
I keep on getting this message

  File "/usr/local/bin/lttree_check.py", line 5, in <module>
    from moltemplate.lttree_check import main
ImportError: No module named moltemplate.lttree_check

I can find the lttree_check.py script in my /usr/local/bin directory but there is no moltemplate module.
However in the directory where moltemplate was downloaded I found the moltemlpate.sh script:
/home/dawid/qsar/moltemplate/moltemplate/moltemplate/scripts/moltemplate.sh
When I run it, it seems to work. So I just want to let you know that the reason behind this error is that
moltemplate.sh does not know about the directory where it should look for the *.py modules.

menger_cubes example

I can't seem to run the menger_cubes example:

moltemplate.sh v2.0.2 2016-12-04

lttree_check.py v0.76 2014-12-19

    "Data Atoms" column format:
    atom-ID molecule-ID atom-type q x y z

lttree_check.py:    parsing the class definitions...
Error(ttree.StaticObj.Parse()):
       Syntax error at or before "menger_cubes.lt", line 48:
       "cells_xz= new".

I looked at the syntax in menger_cubes.lt but can't seem to spot the error. Could you assist please?

trouble importing modules in the "nbody_alternate_symmetry" subdirectory

After installing my branch of moltemplate with pip, and trying to
run this example

examples/force_field_OPLSAA/alkane_chain_single/moltemplate_files

(The example works when moltemplate is not installed through pip.)

nbody_by_type.pyc v0.18 2014-12-19 (python version < 3)
Error: Unable to locate file "opls_imp"
(Did you mispell the file name?
Check the "nbody_alternate_symmetry/" directory.)

The file it is looking for is
moltemplate/nbody_alternate_symmetry/opls_imp.py

Error message from genpoly.

I have been getting this error message.

Traceback (most recent call last):
  File "genpoly_lt.py", line 1084, in <module>
    main()
  File "genpoly_lt.py", line 1071, in main
    genpoly.WriteLTFile(outfile)
  File "genpoly_lt.py", line 663, in WriteLTFile
    self.WritePolymer(outfile,
  File "genpoly_lt.py", line 703, in WritePolymer
    self.ChooseDirections(coords)
  File "genpoly_lt.py", line 605, in ChooseDirections
    self.direction_vects[0][d] = coords[1][d] - coords[0][d]
IndexError: list index out of range

My workflow is following the logic below.
a) Run: python3 moltemplate_files/sequence_generator.py CH3 CH2 8405 41 41 40

import sys

def sequence(mon_lst, pol_deg, dims_lattice, random= False):
    """
        Função para a geração das sequências de monômeros que serão adicionadas
        ao polímero simulado. Esta função deve receber uma lista com os 
        monômeros declarados na forma de strings na lista, o grau de 
        polimerização, e as dimensões X, Y e Z da rede onde serão realizadas as 
        simulações. 

        Parâmetros:
        ·mon_lst: Lista com monômeros para a geração da sequência, cada monômero
            deve possuir o formato "CH2" ou "CH3" por exemplo. O primeiro valor
            da lista será tratado como "cap"; primeiro e último monômero de 
            cada polímero. O segundo será entendido como composto intermediário
            para a cadeia. Nesta versão, se monômeros adicionais forem 
            adicionados então serão ignorados, em versões futuras desse código, 
            será implementada uma regra para a geração de listas de
            heteropolímeros.
        
        ·pol_deg: Inteiro com o grau de polimerização da cadeia. 
        ·dims_lattice: Lista com três elementos inteiros informando o número de 
            sítions respectivamente nas direções 'X', 'Y' e 'Z' do volume 
            simulado. 
        ·radom: Variável booleana que em versões futuras será utilizada para 
            determinar se a colocação de monômeros alienígenas em 
            heteropolímeros será randômica (True) ou padronizada (False).

    """
    try:
        num_sitios = dims_lattice[0] * dims_lattice[1] * dims_lattice[2]
        num_cadeias = num_sitios // pol_deg
        pol_cap, pol_body = mon_lst[0], mon_lst[1]
    except:
        return ValueError

    with open("cuts.txt", 'w') as f:
        line = 0
        with open("sequence.txt", 'w') as file:
            for i in range(num_cadeias):
                file.write(pol_cap + "\n")
                line+=1
                for j in range(pol_deg-2):
                    file.write(pol_body + "\n")
                    line+=1
                file.write(pol_cap + ".rot(180,0,0,1)" + "\n")
                line+=1
                f.write(f"{line}\n")
def main():
    mon_lst = sys.argv[1:3]
    sys.argv[3:7] = [int(i) for i in sys.argv[3:7]]
    pol_deg, dims_lattice =  sys.argv[3], sys.argv[4:7]
    try:
        sequence(mon_lst, pol_deg, dims_lattice)
    except ValueError:
        print("**** ERRO ****\n", "Parâmetros inválidos!")
        exit()
    print("Sequencias de monômeros e de cortes geradas com sucesso!")
if __name__ == "__main__":
    main()

and
b) Run: ./lattice_generatos.sh

#!/bin/bash
cwd=$(pwd)		  # salva o diretório atual

POL_CAP='CH3';       	# Extremidade dos polímeros
POL_BODY='CH2';       # Corpo do polímero, heteropolímeros serão implementados
						# em outras versões do sequence_generator.py

#						
NMONOMERS=8405;         # O número de monômeros HDPE2911 8553 no entanto, 
						# para a modelagem e organização da rede em formato 
						# paralelepípedico, este valor não é factível, optou-se
						# por reduzir o GD para 8405 e adcioná-lo a uma rede de
						# 40 41 41
						# Para essa definição foi utilizada a seguinte 
						# metodologia:
						# 8553 * 8 (numero cúbico) = 68424
						# raiz(68424,3) = 40,901 -> 40
						# 68424 / 40 = 1710,6 -> 1710
						# raiz(1710,2) = 41,352 -> 41 
						# Logo a rede possui 41x41x40 = 67240 sítios que 
						# segmentados em oito unidades poliméricas resulta em
						# um gd de 67240/8 = 8405  



B=1.5350                # comprimento de cada monômero
DENSITY=0.96;		  	# densidade do polímero
MOL_WEIGHT=120000	

Nx=41; Ny=41; Nz=40;    # numero de sites (locais para a existência de uma 
						# partícula) da rede .

sites=$Nx*$Ny*$Nz;

# Gera a rede
cd ndmansfield/src/
./ndmansfield -box $Nx $Ny $Nz -seed 0 -tstart 1 -tsave 2000 -tstop $sites > curve_lattice.raw
mv curve_lattice.raw $cwd
cd $cwd


# Interpolação e reescalonamento da rede
SCALE=`echo "($NMONOMERS*$B)/($Nx*$Ny*$Nz-1)" | bc -l`   #comprimento da cadeia / #número de sites
python3 interpolate_curve.py $NMONOMERS $SCALE < curve_lattice.raw > curve_smooth.raw

# Transferência de arquivos
mv curve_smooth.raw curve_lattice.raw cuts.txt sequence.txt moltemplate_files/
cd moltemplate_files/

# Criação das sequências de monômeros e cortes
#/sequence_generator.py $POL_CAP $POL_BODY $NMONOMERS $Nx $Ny $Nz

# Criação do inputs LAMMPS 
python3 genpoly_lt.py	-polymer-name 'HDPE2911'\
						-monomer-name 'alcano'  \
						-sequence 'sequence.txt'\
						-bond Backbone C C  \
						-header 'import "compass_published.lt"'\
        				        -header 'import "ch2group.lt"' \
						-header 'import "ch3group.lt"' \
						-cuts 'cuts.txt' \
						< curve_lattice.raw > hdpe2911.lt

rm curve_smooth.raw curve_lattice.raw cuts.txt sequence.txt
#moltemplate.sh ...
cd $cwd

All files can be found here:
files.zip

How to use moltemplate to construct crystals, such as SiC

Hello, Andrew.
I'm a student who just started using moltemplate. I found that the examples in official website of moltemplate do not include crystal construction, such as hexagonal crystal of SiC. This confuses me, and I can't build it after looking for many methods. Can you give me a simple example for me to learn? Please reply me, thank you very much.

Generating redundant impropers when using gaff.lt

Hello there,

When trying to generate data file using gaff.lt, I see a lot of redundant impropers being generated. This seems to be a problem with sorting atoms as I have been able to sort the output and see that the distinct atom sets equal the number of sp2 atoms.

pkg_resources.DistributionNotFound:

Dear Author:

An error occured. I used "pip3 install moltemplate" to install latest version, then I typed "moltemplate.sh system.lt" and it told me that :

moltemplate.sh v2.17.10 2020-6-12

Traceback (most recent call last):
File "/home/roy/.local/bin/lttree_check.py", line 6, in
from pkg_resources import load_entry_point
File "/usr/lib/python2.7/dist-packages/pkg_resources/init.py", line 3088, in
@_call_aside
File "/usr/lib/python2.7/dist-packages/pkg_resources/init.py", line 3072, in _call_aside
f(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/pkg_resources/init.py", line 3101, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "/usr/lib/python2.7/dist-packages/pkg_resources/init.py", line 574, in _build_master
ws.require(requires)
File "/usr/lib/python2.7/dist-packages/pkg_resources/init.py", line 892, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/lib/python2.7/dist-packages/pkg_resources/init.py", line 778, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'moltemplate==2.17.10' distribution was not found and is required by the application.

And i tried sudo pip3 but also failed.

When i git clone the source code from github, and use both "pip3 install . " and "pip3 install --user .", but:

moltemplate.sh v2.17.10 2020-6-12

Traceback (most recent call last):
File "/home/roy/.local/bin/lttree_check.py", line 5, in
from moltemplate.lttree_check import main
ImportError: No module named moltemplate.lttree_check

So i dont know what's wrong. I will try old version to check if those mistakes is owe to my fault.

`ltemplify.py` usability improvements

We've discussed this already in sgsaenger/vipster#35,
but here are some ideas i have about the architecture of your scripts.
I've mostly looked at ltemplify.py, so this is centered around this file.

It seems like the different workloads of ltemplify.main() are separated into logical blocks already.
These could easily be encapsulated in functions to increase interoperability/readability, e.g. like

def main():
    parse_pass1()
    parse_pass2()
    eval_atoms()
    eval_masses()

This usually decreases statefulness and makes it easier to export an API.

More importantly, i'd recommend using something like argparse to handle cmdline-arguments.
I've stumbled over this because ltemplify.py itself does not tell you about the (semi-mandatory?) use of the -atom_style argument.
argparse would add a -h option for free, which greatly improves discoverability.

Semi-related to this (just don't want to spam issues), would it be possible to parse the atom_style comment from the Atoms section? At least, comments like in moltemplate.sh about the guessed/default atom_style should be printed.

Atom type not found in the oplsaa.lt

Thank you very much for the great work! I am trying to build an lt file for the Sodium dodecyl sulfate (SDS) molecule. When I checked the lt file, there is no atom type that corresponds to the elements (C, O, S) in the charged head group of SDS system. After a deep online search, I found some useful papers (see link below) with relevant information about its LJ parameters (and others). Is it possible for you to help add them to the oplsaa.lt or guide me on how to go about it? Thanks.

https://pubs.acs.org/doi/10.1021/acs.jctc.7b00181

https://pubs.acs.org/doi/full/10.1021/acs.jctc.9b00947

DREIDING hbond interactions undefined for atoms which are both donors and acceptors

EDIT
When I originally posted this issue on 2021-4-08, I was worried that DREIDING-style hydrogen-bond interactions might not work in moltemplate due to the way atoms are ordered. Today, I attempted to address the root cause of the problem. I tried editing the code included with moltemplate (specifically the "postprocess_input_scripts.py" file) to make sure it can understand the syntax of "hbond/dreiding" pair_coeff commands. When I did that, I realized that the code already does this (and has done this since before 2019/11/11). But this was buried deep in the code, and I did not remember I had this working when I created this issue. So, assuming the code works, the original concern I had when I created this issue is largely moot. I'm sorry if I caused unnecessary concern.

However Matt Bone has since contacted me to bring up another possible problem that occurs when two different atom types can be both hydrogen-bond donors and acceptors. (See example below.) This is a different but closely related problem, so I included it here as well. To address this problem, we may need to add some additional atom types to the "dreiding.lt" file and do some testing.

Here is the original post. It is probably no longer relevant, but I will leave it up until we have confirmed that everything is working and all of these issues have been resolved. -A 2022-2-09*


The DREIDING force field occasionally makes use of pair_style hbond/dreiding/lj.

  • In the "dreiding.lt" file, in each corresponding pair_coeff command for these interactions, we are assuming that the first atom type is a hydrogen bond donor, because we invoke the pair_coeff command using the "i" argument. For details, see the documentation for pair_style hbond/dreiding/lj.
  • However all pair_coeff i j... commands requires that i≤j. (See the documentation for pair_coeff.)
  • To comply with this requirement, moltemplate.sh actually has a post-processing step where it looks inside all of the pair_coeff commands and swaps the order of the atom types whenever i>j. When it does this, it only considers the i and j numbers (after the @atom types have been converted into numbers). It does not know whether i or j correspond to donor or acceptor atom types.
  • In moltemplate, by default, @atom types are assigned to numbers according to the order in which they first appear in any of the user's LT files. Currently (as of 2021-4-08), the donor atom types (@atom types ending in "_hd") are interspersed with with the acceptor atom types (ending in "_ha").
  • This means that, approximately half of the time, LAMMPS will confuse the donor and acceptor atoms in each hbond/dreiding/lj interaction.

There are two solutions to this problem:

1) Edit the postprocess_input_script.py and postprocess_coeffs.py files and make them aware of the quirks of the hbond/dreiding/ pair_coeff syntax.

2) Modify the "dreiding.lt" file to make sure all of the donor atom types are mentioned before any of the acceptor atom types. This is the easiest solution, and it works nearly all of the time. But it will fail if the user decides to override the @atom number assignments (by invoking moltemplate.sh using either the "-a" or "-b" arguments on those atom types). It will also fail in the unlikely event that users decide to refer to an acceptor atom (eg "@atom:N_R_b1_d2_ha") somewhere at the very beginning of their LT file, before the import "dreiding.lt" command is issued (causing it to be assigned to 1).

For now (2021-4-08), I will try solution 2. Later, I will try solution 1 when I have more time.
Meanwhile, I will leave this issue on the tracker until it is resolved.

EDIT
I have implemented both solutions 1 and 2. We just need to make some changes to the "dreiding.lt" file and test to make sure everything works. -A 2022-2-09

Are charges in LT files always neglected in the case of OPLS-AA?

As atomic charges can be obtained from ab initio calculations, it might be desired sometimes to use charges explicitly given in the molecule LT file even in the case of OPLS-AA, for example, for some experimental purposes of testing. Could this be easily achieved in the present version?

Thank you very much for your great work.

Specifying Geometry in Moltemplate

Dear Andrew,

I'm wondering if there's an easy way to fill up the specified simulation box with particles.

I tried many ways of manipulating this matrix but I either get arrangments that are too small or outside the simulation box.

Thank you for your help.

Best regards,
Yunes Salman

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.