# -*- coding: utf-8 -*-
from setuptools import setup

packages = \
['molecules',
 'molgri',
 'molgri.molecules',
 'molgri.plotting',
 'molgri.scripts',
 'molgri.space',
 'plotting',
 'scripts',
 'space']

package_data = \
{'': ['*'], 'molgri': ['examples/*']}

install_requires = \
['MDAnalysis>=2.3.0,<2.4.0',
 'matplotlib>=3.6.2,<3.7.0',
 'networkx>=2.8.8,<2.9.0',
 'numpy>=1.23.5,<1.24.0',
 'pandas>=1.5.2,<1.6.0',
 'scipy>=1.9.3,<1.10.0',
 'seaborn>=0.12.1,<0.13.0',
 'setuptools>=65.6.3,<65.7.0']

entry_points = \
{'console_scripts': ['molgri-energy = '
                     'molgri.scripts.generate_energy:run_generate_energy',
                     'molgri-grid = '
                     'molgri.scripts.generate_grid:run_generate_grid',
                     'molgri-io = molgri.scripts.set_up_io:parse_and_create',
                     'molgri-pt = molgri.scripts.generate_pt:run_generate_pt']}

setup_kwargs = {
    'name': 'molgri',
    'version': '1.3.1',
    'description': 'Generate molecular pseudotrajectories based on rotational grids.',
    'long_description': '![Coverage Status](https://img.shields.io/coverallsCoverage/github/bkellerlab/molecularRotationalGrids)\n![issues](https://img.shields.io/github/issues/bkellerlab/molecularRotationalGrids)\n![license](https://img.shields.io/github/license/bkellerlab/molecularRotationalGrids)\n![activity](https://img.shields.io/github/last-commit/bkellerlab/molecularRotationalGrids)\n[![Documentation Status](https://readthedocs.org/projects/molgri/badge/?version=main)](https://molgri.readthedocs.io/en/main/?badge=main)\n![release](https://img.shields.io/github/v/release/bkellerlab/molecularRotationalGrids)\n\nThis repository is connected to the publication:\nHana Zupan, Frederick Heinz, Bettina G. Keller: "Grid-based state space exploration for molecular binding",\narXiv preprint: [https://arxiv.org/abs/2211.00566](https://arxiv.org/abs/2211.00566)\n\n# molecularRotationalGrids\n\nThe python package ```molgri``` has three main purposes: 1) generation of rotation grids, 2) analysis of\nsaid grids and 3) generation of pseudotrajectories (PTs). PTs are files in .xtc or similar format \nconsisting of several timesteps in\nwhich the interaction space of two molecules is systematically explored. We provide user-friendly,\none-line scripts for rotation grid generation and analysis as well as pseudotrajectory generation and \nintutive visual inspection.\nIn this short tutorial, we also give instructions how to use PTS with external tools like \nVMD and GROMACS for further analysis.\n\nIn the figures below, we show examples of rotation grids and pseudotrajectories as well as some analysis plots. All plots and animations are created\ndirectly with the ```molgri``` package, except the PT plot in the middle where the output of ```molgri``` is drawn\nusing VMD.\n\n\n<p float="left">\n    <img src="/readme_images/ico_630_grid.gif" width="48%">\n    <img src="/readme_images/H2O_H2O_o_ico_500_b_ico_5_t_3830884671_trajectory_energies.gif" width="48%">\n</p>\n\n<p float="left">\n    <img src="/readme_images/systemE_1000_uniformity.png" width="30%">\n    <img src="/readme_images/set_up_30_full_color.png" width="30%">\n    <img src="/readme_images/systemE_1000_convergence.png" width="30%">\n</p>\n\n\n\n## Installation\n\nThis is a python library that can be easily installed using:\n\n```\npip install molgri\n```\n\n\n\n## Running examples\n\nTo explore the capabilities of the package, the user is encouraged to run\nthe following example commands (the commands should all be executed in the\nsame directory, we recommend an initially empty directory).\n\n```\nmolgri-io --examples\nmolgri-grid -N 250 -algo ico --draw --animate --animate_ordering --statistics\nmolgri-pt -m1 H2O -m2 NH3 -o cube3D_15 -b ico_10 -t "range(1, 5, 2)"\nmolgri-energy -xvg H2O_H2O_o_ico_500_b_ico_5_t_3830884671 --p1d --p2d --p3d --animate --convergence --Ns_o "(50, 100, 500)"\n```\n\nThe first-line command ```molgri-io``` creates the 📂 input/ and\n📂 output/ folder structure. This command should be run in each new\ndirectory before running other commands. The optional\nflag ```--examples``` provides some sample input files that are used by the rest of the commands.\n\nThe second command ```molgri-grid``` is used to generate rotation grids. It is\nnecessary to specify the number of grid points ```-N``` and the algorithm \n```-algo``` (select from: systemE, randomE, randomQ, cube4D, cube3D, ico; we\nrecommend ico). Other flags describe optional figures and animations to save. All\ngenerated files can be found in ```output/grid_files/```, statistics in the \n```output/statistics_files/``` and visualisations in ```output/figures/``` and ```output/animations/```. \nNote: you do not need to use this function if you are only interested in pseudotrajectories. All required\ngrids will be automatically generated when running the ```molgri-pt``` command.\n\nThe third command ```molgri-pt``` creates a pseudotrajectory. By default, this is a single \ntrajectory-like file containing\nall frames. Alternatively, with an optional command ```--as_dir``` a directory of single-frame files is\ncreated. In addition, the first frame of the pseudo-trajectory is also written out as a structure file.\nDefault trajectory format is .xtc and default structure format .gro, user can change this behaviour with\noptional commands ```--extension_trajectory``` and ```--extension_structure```.\n\nThis scripts needs\ntwo file inputs that should be provided in input/, each containing a single molecule. Standard formats\nlike .gro, .xyz, .pdb and others are accepted. In this example, due to the flag\n```-m1 H2O``` the program will look for a file input/H2O with any standard extension\nand use it as the fixed molecule in the pseudotrajectory. The flag ```-m2```\ngives the name of the file with the other molecule, which will be mobile\nin the simulation. Finally, the user needs to specify the two rotational grids\nin form ```-o algorithm_N``` (for rotations around the origin) and \n```-b algorithm_N``` , see algorithm names above. If you want to use the default algorithms (currently\nicosahedron algorithm),\nspecify only the number of points, e.g. ```-o 15 -b 10```. Finally, the translational grid after the\nflag ```-t``` should be supplied in one of the\nfollowing formats: a list of distances (in nm), linspace(start, stop, num) \nor range(start, stop, step). The argument should be surrounded by quotation\nmarks. Some acceptable translation grid arguments would be:\n\n```-t "(1, 3, 5)"``` -> use distances 1nm, 3nm and 5nm\n\n```-t "linspace(1, 3, 5)"``` -> use 5 equally spaced points\nbetween 1nm and 3nm\n\n```-t "range(1, 3, 0.5)"``` -> use distances between 1nm and 3nm\nin 0.5nm increments\n\nAll flags starting with ```--``` are optional and can be omitted for faster\ncalculations. Remember that you can always add the flag ```--help``` to get\nfurther instructions.\n\nThe last command ```molgri-energy``` is discussed further in section "Visualising energy distribution and convergence".\n\n## Using outputs\n\nThe pseudotrajectory .xtc and .gro files can be used as regularly generated trajectory files. We show how they can be\ndisplayed with VMD or used for GROMACS calculations, but the user is free to use them as inputs to any other\ntool.\n\n#### Displaying pseudotrajectory\n\nTo display the example pseudotrajectory we created in the previous section with VMD, change to\ndirectory ```output/pt_files``` and run\n\n```\nvmd H2O_NH3_o_cube3D_15_b_ico_10_t_3203903466.gro H2O_NH3_o_cube3D_15_b_ico_10_t_3203903466.xtc\n```\n\nor on a windows computer\n\n```\nstart vmd H2O_NH3_o_cube3D_15_b_ico_10_t_3203903466.gro H2O_NH3_o_cube3D_15_b_ico_10_t_3203903466.xtc\n```\n\nThen, to fully display a pseudotrajectory, it is often helpful to change the display style and to display\nseveral or all frames at once. We suggest using the following commands within the VMD command line:\n\n```\nmol modstyle 0 0 VDW\nmol drawframes 0 0 0:1:300\n```\n\nThe first one displays the molecules as spheres with van der Waals radii and the second draws frames of\nthe pseudotrajectory in a form &lt;start>:&lt;step>:&lt;stop>.\nA useful trick is to use the number of rotations as &lt;step> (in this case that would be 15) - this displays one structure per mass point\nwithout considering internal rotations. This number is also written in the name of the .gro file.\nIf you want to display all frames, you can use any large number\nfor &lt;num_frames>, it does not need to correspond exactly to the number of frames.\n\n#### Calculating energy along a pseudotrajectory\nOften, a pseudotrajectory is used to explore where regions of high and low energies lie when molecules\napproach each other. Since a range of timesteps sampling important rotations and translations\nis already provided in a PT, there is no need to run a real\nsimulation. Therefore, the flag ```-rerun``` is always used while dealing with PTs in GROMACS. This\nsetting saves time that would else be used for running an integrator and propagating positions.\n\n\nTo use GROMACS with PTs, the user must also provide a topology file which includes both molecules used in a pseudotrajectory.\nWe will assume that this file is named topol.top. Lastly, we need a GROMACS run file that we will name\nmdrun.mdp. This file records GROMACS parameters and can be used as in normal simulations, but note that\nsome parameters (e.g. integrator, dt) are meaningless for a pseudotrajectory without actual dynamics.\nThen, the energy along a pseudotrajectory can be calculated as follows, using the molgri-generated\n<structure_file> (eg. H2O_NH3_o_cube3D_15_b_ico_10_t_3203903466.gro) and \n<trajectory_file> (eg. H2O_NH3_o_cube3D_15_b_ico_10_t_3203903466.xtc):\n\n```\ngmx22 grompp -f mdrun.mdp -c <structure_file> -p topol.top -o result.tpr   \ngmx22 mdrun -s result.tpr -rerun <trajectory_file>\ngmx22 energy -f ener.edr -o full_energy.xvg\n```\n\n## Visualising energy distribution and convergence\n\nAfter calculating energy for each point along the pseudotrajectory (see a GROMACS example above), the\n.xvg file can be copied to the ```input/``` folder and used to visualise the distribution of energies.\nVisualisation can be performed with the command ```molgri-energy``` and flags\n - ```--p1d``` in 1D (violin plot), \n - ```--p2d``` in 2D (color-coded Hammer projection) and/or \n - ```--p3d``` in 3D (color-coded 3D plot).\nIn the last case we also recommend using the ```--animate``` flag so that the plot can be observed from all sides.\n\nA XVG file is required for the visualisation and must be supplied after the ```-xvg``` flag.\nIt is recommended that the .xvg file has the same name as the pseudotrajectory for the full functionality.\nAn example provided with the package can be run like:\n```\nmolgri-energy -xvg H2O_H2O_o_ico_500_b_ico_5_t_3830884671 --p1d --p2d --p3d --animate\n``` \n\nAdditionaly, energy visualisation can be used to check for convergence / determine how many rotational \npoints are truly necessary. For this purpose, it is useful to visualise energy distributions using only a fraction \nof points and visually inspecting for sufficient convergence of energy surface (see example pictured).\n\n<p float="left">\n<img src="/readme_images/hammer_energies_hammer.png">\n</p>\n\nTo perform convergence tests, add the flag ```--convergence```. You can also select specific number of\npoints tested with a flag ```--Ns_o```, for example\n\n```\nmolgri-energy -xvg H2O_H2O_o_ico_500_b_ico_5_t_3830884671 --p1d --p2d --p3d --animate --convergence --Ns_o "(50, 100, 500)"\n``` \n\n\n## Complex applications: using python package\n\nUsers who would like to build custom grids, pseudotrajectories or sets of rotations and enjoy more\nflexibility with visualisation tools can import ```molgri```\nas a python package (following installation described above) and work with all provided modules. Documentation\nof all modules is available online\n[via ReadTheDocs](https://molgri.readthedocs.io/en/main/).',
    'author': 'Hana Zupan',
    'author_email': 'hana.zupan@fu-berlin.de',
    'maintainer': 'None',
    'maintainer_email': 'None',
    'url': 'https://www.bcp.fu-berlin.de/en/chemie/chemie/forschung/PhysTheoChem/agkeller/index.html',
    'packages': packages,
    'package_data': package_data,
    'install_requires': install_requires,
    'entry_points': entry_points,
    'python_requires': '>=3.8',
}


setup(**setup_kwargs)
