#!/usr/bin/env python3 """ Create a test generator and files to copy for an EquilibriumCrystalStructure_Unconstrained_TypeLabels test from a CHARMM-GUI Nanomaterial Modeler .tgz file containing LAMMPS inputs. Args: Path to .tgz file. The name of the file should be the English name of nanomaterial according to CHARMM-GUI spaced with dashes (i.e. "Calcium-Hydroxide") Printed to STDOUT: Test generator line """ from lmp_typelabel_dat_from_charmm_gui.convert import convert import sys, os, pathlib from bonded_util import get_labelmap_from_lammps_data, get_type_to_element_mapping import random import json MODELTYPE = "CHARMM-GUI INTERFACE" KIM_USER_ID = "4ad03136-ed7f-4316-b586-1e94ccceb311" MATCHING_MODELS= "[\"charmm-gui/\"]" # relative to script file location, will be converted to absolute TEST_DIR_PATH = "../Tests/CHARMM-GUI" SYM_FILE_PATH="symfiles/charmm-gui/sym.txt" def get_random_kim_id() -> str: """ Returns random 12-digit numerical string Returns: Random 12-digit numerical string """ return "".join(["{}".format(random.randint(0, 9)) for num in range(12)]) if __name__ == "__main__": numargs = len(sys.argv) assert numargs==2 path_to_tgz=sys.argv[1] # path to tgz file created by CHARMM-GUI material = path_to_tgz.split(".")[-2].split("/")[-1] # create data file with labelmap test_absdir = os.path.join(pathlib.Path(__file__).parent.resolve(),TEST_DIR_PATH,material) data_path = os.path.join(test_absdir,"input0.dat") convert(path_to_tgz,data_path) symbol_abspath = os.path.join(pathlib.Path(__file__).parent.resolve(),SYM_FILE_PATH) # determine species for test generator labelmap = get_labelmap_from_lammps_data(data_path) mapping = get_type_to_element_mapping(SYM_FILE_PATH) species = sorted(list(set([mapping[label] for label in labelmap.values()]))) if ("IGNORE" in species): species.remove("IGNORE") print(json.dumps( {"species": species, "material": material, "modeltype": MODELTYPE, "matching_models": MATCHING_MODELS, "version": "000", "kimnum": get_random_kim_id(), "kim_user_id": KIM_USER_ID, "FILES_TO_COPY": [symbol_abspath,data_path], "comment": "Initial geometry and bonding topology obtained from CHARMM-GUI.", "source_citations":[" \"abstract\" \"CHARMM is an academic research program used widely for macromolecular mechanics and dynamics with versatile analysis and manipulation tools of atomic coordinates and dynamics trajectories. CHARMM-GUI, http://www.charmm-gui.org, has been developed to provide a web-based graphical user interface to generate various input files and molecular systems to facilitate and standardize the usage of common and advanced simulation techniques in CHARMM. The web environment provides an ideal platform to build and validate a molecular model system in an interactive fashion such that, if a problem is found through visual inspection, one can go back to the previous setup and regenerate the whole system again. In this article, we describe the currently available functional modules of CHARMM-GUI Input Generator that form a basis for the advanced simulation techniques. Future directions of the CHARMM-GUI development project are also discussed briefly together with other features in the CHARMM-GUI website, such as Archive and Movie Gallery. © 2008 Wiley Periodicals, Inc. J Comput Chem, 2008\"\n \"author\" \"Jo, Sunhwan and Kim, Taehoon and Iyer, Vidyashankara G. and Im, Wonpil\"\n \"doi\" \"https://doi.org/10.1002/jcc.20945\"\n \"eprint\" \"https://onlinelibrary.wiley.com/doi/pdf/10.1002/jcc.20945\"\n \"journal\" \"Journal of Computational Chemistry\"\n \"keywords\" \"molecular dynamics, Poisson-Boltzmann, electrostatic potential, membrane, visualization, explicit solvent, implicit solvent, MarvinSpace\"\n \"number\" \"11\"\n \"pages\" \"1859-1865\"\n \"recordtype\" \"article\"\n \"title\" \"CHARMM-GUI: A web-based graphical user interface for CHARMM\"\n \"url\" \"https://onlinelibrary.wiley.com/doi/abs/10.1002/jcc.20945\"\n \"volume\" \"29\"\n \"year\" \"2008\""," \"author\" \"Choi, Yeol Kyo and Kern, Nathan R. and Kim, Seonghan and Kanhaiya, Krishan and Afshar, Yaser and Jeon, Sun Hee and Jo, Sunhwan and Brooks, Bernard R. and Lee, Jumin and Tadmor, Ellad B. and Heinz, Hendrik and Im, Wonpil\"\n \"doi\" \"10.1021/acs.jctc.1c00996\"\n \"eprint\" \" https://doi.org/10.1021/acs.jctc.1c00996 \"\n \"journal\" \"Journal of Chemical Theory and Computation\"\n \"note\" \"PMID: 34871001\"\n \"number\" \"1\"\n \"pages\" \"479-493\"\n \"recordtype\" \"article\"\n \"title\" \"CHARMM-GUI Nanomaterial Modeler for Modeling and Simulation of Nanomaterial Systems\"\n \"url\" \"https://doi.org/10.1021/acs.jctc.1c00996\"\n \"volume\" \"18\"\n \"year\" \"2022\""],"atom_type_labels":" ".join(labelmap.values())} ))