<commit_before>{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "import os\n",
    "import warnings\n",
    "warnings.filterwarnings('ignore')\n",
    "with warnings.catch_warnings():\n",
    "    warnings.simplefilter(\"ignore\")\n",
    "    import matplotlib.pyplot as plt\n",
    "    import seaborn as sns\n",
    "\n",
    "    import mbuild as mb\n",
    "    import metamds as mds\n",
    "    import mdtraj as md\n",
    "    from mdtraj.html import TrajectorySliderView\n",
    "\n",
    "%matplotlib inline\n",
    "!rm -rf output/ *.top *.gro"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def build_ethane_box(box, n_molecules, **kwargs):\n",
    "    from mbuild.examples import Ethane\n",
    "    ethane = Ethane()\n",
    "    full_box = mb.fill_box(ethane, n_molecules, box)\n",
    "    full_box.name = '{}_ethanes'.format(n_molecules)\n",
    "    return full_box"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# Input parameters\n",
    "parameters = {'n_molecules': 200,\n",
    "              'box': [3, 3, 3],\n",
    "              'forcefield': 'OPLS-aa'}\n",
    "\n",
    "# Build the initial configuration\n",
    "compound = build_ethane_box(**parameters)\n",
    "#compound.visualize()\n",
    "\n",
    "parameters['compound'] = compound"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def create_run_script(compound, forcefield, input_dir, **kwargs):\n",
    "    name = compound.name\n",
    "    em = os.path.join(input_dir, 'em.mdp')\n",
    "    nvt = os.path.join(input_dir, 'nvt.mdp')\n",
    "    gro = '{name}.gro'.format(name=name)\n",
    "    top = '{name}.top'.format(name=name)\n",
    "\n",
    "    compound.save(top, forcefield=forcefield, overwrite=True)\n",
    "\n",
    "    em_grompp = 'gmx grompp -f {mdp} -c {gro} -p {top} -o em.tpr'.format(mdp=em, gro=gro, top=top)\n",
    "    em_mdrun = 'gmx mdrun -v -deffnm em'\n",
    "\n",
    "    nvt_grompp = 'gmx grompp -f {mdp} -c em.gro -p {top} -o nvt.tpr'.format(mdp=nvt, top=top)\n",
    "    nvt_mdrun = 'gmx mdrun -v -deffnm nvt'\n",
    "\n",
    "    script = (em_grompp, em_mdrun, nvt_grompp, nvt_mdrun)\n",
    "    return script"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# Initialize a simulation instance with a template and some metadata\n",
    "sim = mds.Simulation(name='ethane', template=create_run_script, output_dir='output')\n",
    "\n",
    "# Parameterize our simulation template\n",
    "task = sim.parametrize(**parameters)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },<commit_msg>set static input dir in ethane_box.ipynb<commit_after>{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "import os\n",
    "import warnings\n",
    "warnings.filterwarnings('ignore')\n",
    "with warnings.catch_warnings():\n",
    "    warnings.simplefilter(\"ignore\")\n",
    "    import matplotlib.pyplot as plt\n",
    "    import seaborn as sns\n",
    "\n",
    "    import mbuild as mb\n",
    "    import metamds as mds\n",
    "    import mdtraj as md\n",
    "    from mdtraj.html import TrajectorySliderView\n",
    "\n",
    "%matplotlib inline\n",
    "!rm -rf output/ *.top *.gro"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def build_ethane_box(box, n_molecules, **kwargs):\n",
    "    from mbuild.examples import Ethane\n",
    "    ethane = Ethane()\n",
    "    full_box = mb.fill_box(ethane, n_molecules, box)\n",
    "    full_box.name = '{}_ethanes'.format(n_molecules)\n",
    "    return full_box"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# Input parameters\n",
    "parameters = {'n_molecules': 200,\n",
    "              'box': [3, 3, 3],\n",
    "              'forcefield': 'OPLS-aa'}\n",
    "\n",
    "# Build the initial configuration\n",
    "compound = build_ethane_box(**parameters)\n",
    "#compound.visualize()\n",
    "\n",
    "parameters['compound'] = compound"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def create_run_script(compound, forcefield, input_dir, **kwargs):\n",
    "    name = compound.name\n",
    "    em = os.path.join(input_dir, 'em.mdp')\n",
    "    nvt = os.path.join(input_dir, 'nvt.mdp')\n",
    "    gro = '{name}.gro'.format(name=name)\n",
    "    top = '{name}.top'.format(name=name)\n",
    "\n",
    "    compound.save(top, forcefield=forcefield, overwrite=True)\n",
    "\n",
    "    em_grompp = 'gmx grompp -f {mdp} -c {gro} -p {top} -o em.tpr'.format(mdp=em, gro=gro, top=top)\n",
    "    em_mdrun = 'gmx mdrun -v -deffnm em'\n",
    "\n",
    "    nvt_grompp = 'gmx grompp -f {mdp} -c em.gro -p {top} -o nvt.tpr'.format(mdp=nvt, top=top)\n",
    "    nvt_mdrun = 'gmx mdrun -v -deffnm nvt'\n",
    "\n",
    "    script = (em_grompp, em_mdrun, nvt_grompp, nvt_mdrun)\n",
    "    return script"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# Initialize a simulation instance with a template and some metadata\n",
    "sim = mds.Simulation(name='ethane', template=create_run_script, input_dir='static_input_files', output_dir='output')\n",
    "\n",
    "# Parameterize our simulation template\n",
    "task = sim.parametrize(**parameters)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
{'fraction_non_alphanumeric': 0.19820828667413215, 'fraction_numerical': 0.001919692849144137, 'mean_word_length': 2.5361990950226243, 'pattern_counts': {'":': 70, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '648271', 'n_tokens_mistral': 2457, 'n_tokens_neox': 2414, 'n_words': 454}