diff --git a/doc/source/index.rst b/doc/source/index.rst index bbac12bcb16cfd88ea77fc742ff44d48a3ce4834..94fd76232138995504434cc6119211b2db12250e 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -11,8 +11,6 @@ Contents: .. toctree:: :maxdepth: 2 - members - Features -------- PyCGTOOL provides a means to quickly and easily generate coarse-grained molecular dynamics models within the MARTINI framework from all-atom or united-atom simulation trajectories. @@ -29,6 +27,11 @@ PyCGTOOL requires: Optional: +- MDTraj for pseudo-CG XTC output (http://mdtraj.org/1.7.2/) with own dependencies: + + - Scipy (https://www.scipy.org/) + - Cython (http://cython.org/) + - Python testing framework (e.g. Nose2, py.test) - Numba for increased performance (http://numba.pydata.org/) - Sphinx to generate documentation yourself (http://www.sphinx-doc.org/en/stable/) @@ -42,9 +45,9 @@ PyCGTOOL requires four input files to generate a coarse-grained model: -m PyCGTOOL mapping definition file -b PyCGTOOL bond definition file -The program is called by: -:: - pycgtool.py -g <GRO file> -x <XTC file> -m <MAP file> -b <BND file> +The program is called by:: + + pycgtool.py -g <GRO file> -x <XTC file> -m <MAP file> -b <BND file> Example mapping and bond definition files are present in the ``test/data`` directory. Their format is explained below. @@ -58,8 +61,8 @@ Mapping Definition ~~~~~~~~~~~~~~~~~~ An example of mapping definition file for the monosaccharide allose taken from ``test/data/sugar.map`` is shown below. -Molecule names (as present in the gro coordinate file) are used as section headers inside square brackets. Each of the following lines describes a single coarse-grained bead mapping. The items on a line are: the name of the bead, its MARTINI bead type, a list of all the atom names it should contain. All items on a line are whitespace separated. Multiple molecules may be specified in their own sections. It is not recommended to provide a mapping for water since MARTINI water combines four molecules into a single bead which is not yet supported by PyCGTOOL. -:: +Molecule names (as present in the gro coordinate file) are used as section headers inside square brackets. Each of the following lines describes a single coarse-grained bead mapping. The items on a line are: the name of the bead, its MARTINI bead type, a list of all the atom names it should contain. All items on a line are whitespace separated. Multiple molecules may be specified in their own sections. It is not recommended to provide a mapping for water since MARTINI water combines four molecules into a single bead which is not yet supported by PyCGTOOL. :: + ; comments begin with a semicolon [ALLA] C1 P3 C1 O1 @@ -78,8 +81,8 @@ An example bond definition file for the monosaccharide allose taken from ``test/ As in the mapping definition file, molecule names are used as section headers inside square brackets. The following lines define bonds lengths, angles and dihedrals between coarse-grained beads. Each line is a list of bead names, using the names defined in the mapping file. Two bead names on a line defines a bond length, three defines an angle, and four defines a dihedral. -If no angles are defined for a molecule, PyCGTOOL will construct all angles from the list of bonds. This may also be enabled for dihedrals via the ``--interactive`` flag, but is not recommended as in most cases coarse-grained models do not require dihedrals. Additionally, any angles inside a triangle of bond lengths are excluded from the output as they often cause simulation stability issues when used in conjunction with LINCS. -:: +If no angles are defined for a molecule, PyCGTOOL will construct all angles from the list of bonds. This may also be enabled for dihedrals via the ``--interactive`` flag, but is not recommended as in most cases coarse-grained models do not require dihedrals. Additionally, any angles inside a triangle of bond lengths are excluded from the output as they often cause simulation stability issues when used in conjunction with LINCS. :: + ; comments begin with a semicolon [ALLA] C1 C2 @@ -111,12 +114,12 @@ Modes ~~~~~ PyCGTOOL performs several other functions which may be useful in the testing and use of coarse-grained models. -Mapping-only mode performs a coarse-grain mapping on a single frame and may be used to generate initial coordinates for a coarse-grain simulation, whether the model being used was created by PyCGTOOL or not. In this respect it functions similarly to the MARTINI tool MARTINIZE. This mode may be invoked by: -:: +Mapping-only mode performs a coarse-grain mapping on a single frame and may be used to generate initial coordinates for a coarse-grain simulation, whether the model being used was created by PyCGTOOL or not. In this respect it functions similarly to the MARTINI tool MARTINIZE. This mode may be invoked by:: + pycgtool.py -g <GRO file> -m <MAP file> -Measure-only mode may be used to aid in the testing of a coarse-grained model by making measurements of bonds from a true corase-grained simulation trajectory. These bond measurements are those collected from the pseudo-coarse-grained trajectory used to generate the model, so are a directly comparable measure of model accuracy. This mode may be invoked by: -:: +Measure-only mode may be used to aid in the testing of a coarse-grained model by making measurements of bonds from a true corase-grained simulation trajectory. These bond measurements are those collected from the pseudo-coarse-grained trajectory used to generate the model, so are a directly comparable measure of model accuracy. This mode may be invoked by:: + pycgtool.py -g <GRO file> -x <XTC file> -b <BND file> Options @@ -126,7 +129,9 @@ By passing the flag ``--interactive`` to PyCGTOOL several advanced options are a ================== ========================================== ======================= Option Description Values ================== ========================================== ======================= +output_name Base name of output files **out**, any string output Coordinate output format **gro** +output_xtc Should a pseudo-CG XTC be created **False**, True map_only Run in mapping-only mode **False**, True map_center Mapping method **geom**, mass constr_threshold Convert stiff bonds to constraints over **100000**, any number diff --git a/pycgtool.py b/pycgtool.py index 0bc112391d17040023a19afd2f55c29921629530..6eb7ca03169c8c0e437da63bf7ed7e7b2c8bc675 100755 --- a/pycgtool.py +++ b/pycgtool.py @@ -95,24 +95,21 @@ if __name__ == "__main__": args = parser.parse_args() config = Options([("output_name", "out"), ("output", "gro"), - ("map_only", False), + ("output_xtc", args.outputxtc), + ("map_only", bool(args.bnd)), ("map_center", "geom"), ("constr_threshold", 100000), - ("dump_measurements", False), + ("dump_measurements", bool(args.bnd) and not bool(args.map)), ("dump_n_values", 100000), ("output_forcefield", False), ("temperature", 310), ("angle_default_fc", True), ("generate_angles", True), - ("generate_dihedrals", False), - ("output_xtc", args.outputxtc)], + ("generate_dihedrals", False)], args) if not args.bnd: config.set("map_only", True) - if args.bnd and not args.map: - config.set("dump_measurements", True) - if not args.map and not args.bnd: parser.error("One or both of -m and -b is required.") diff --git a/pycgtool/mapping.py b/pycgtool/mapping.py index d0f3e78a7df5d0a490415bb6c3afd80a45bfa418..16828db316987aa2b3b3653d80d28b603939602e 100644 --- a/pycgtool/mapping.py +++ b/pycgtool/mapping.py @@ -126,12 +126,14 @@ class Mapping: """ if cgframe is None: cgframe = Frame() - cgframe.name = frame.name - cgframe.number = frame.number - cgframe.box = frame.box + cgframe.name = frame.name + cgframe.natoms = 0 cgframe.residues = [] + cgframe.number = frame.number + cgframe.box = frame.box + for aares in frame: if aares.name not in self._mappings: continue