├── .coveragerc ├── .gitattributes ├── .github ├── ISSUE_TEMPLATE.md ├── nglview-gha.yml └── workflows │ ├── build-extension.yml │ └── test.yml ├── .gitignore ├── .style.yapf ├── CHANGELOG.md ├── CONTRIBUTING.md ├── Dockerfile ├── Dockerfile-jupyterlab ├── LICENSE ├── MANIFEST.in ├── README.md ├── circle.yml ├── conda-requirements-test.sh ├── devtools ├── README.release ├── build_docker.sh ├── circleci │ └── install_miniconda.sh ├── conda-recipe │ ├── build.sh │ └── meta.yaml ├── create_labextension_symlink.py ├── gifipy.py ├── make_test_js.py ├── nb_runner │ ├── start_server.sh │ └── stop_server.sh ├── nglview-jupyterlab.sh ├── outdated │ └── nglview-jupyterlab.sh ├── recipe │ ├── build.sh │ ├── meta.yaml │ └── post-link.sh ├── release.py └── update_versions.py ├── docs ├── FAQ.md ├── Makefile ├── README.md ├── _api │ ├── modules.rst │ ├── nglview.adaptor.rst │ ├── nglview.contrib.movie.rst │ ├── nglview.datafiles.rst │ ├── nglview.jsutils.rst │ ├── nglview.layout.rst │ ├── nglview.player.rst │ ├── nglview.scripts.rst │ ├── nglview.shape.rst │ ├── nglview.static.rst │ ├── nglview.theme.rst │ ├── nglview.widget.rst │ └── nglview.widget_utils.rst ├── _static │ └── cindex.js ├── api.rst ├── big.pdb ├── changelog.rst ├── conf.py ├── contributing.rst ├── embed.md ├── images │ ├── embed.gif │ ├── membrane.gif │ └── nglview_2windows.png ├── index.md ├── index.rst ├── interface_classes.md ├── interface_classes.rst ├── make.bat ├── md_1u19.txt ├── ngl.js ├── ngl_player.html ├── nglview-jupyterlab │ ├── environment.yml │ └── index.md ├── nglview.png ├── scripts.rst ├── talks.rst ├── two_windows.rst └── view_demo.html ├── environment.yml ├── examples ├── README.md ├── customize_color.md ├── extra │ ├── README.md │ ├── bionano.ipynb │ ├── example_bokeh_residue_distance.ipynb │ └── images │ │ ├── README.md │ │ └── bokeh.png ├── images │ ├── bionano.png │ ├── dark_theme.md │ ├── dark_theme.png │ ├── display_ccp4_file.md │ ├── display_ccp4_file.png │ ├── display_gui.md │ ├── display_gui.png │ ├── jupyterlab_three_views.png │ ├── mdanalysis.gif │ ├── mdtraj.gif │ ├── membrane.gif │ ├── nanotube_dna_translocating.gif │ ├── nglview_gui.png │ ├── nglview_jupyterlab.png │ ├── parmed.gif │ ├── two_screens.png │ ├── viewer_pop_up.md │ └── viewer_pop_up.png ├── jupyterlab.md ├── mdanalysis.md ├── mdtraj.md ├── notebooks │ ├── export_image.ipynb │ ├── multiple_ligand_view.ipynb │ ├── representations_and_selection_language.ipynb │ ├── trpcage.pdb │ ├── view_trajectory.ipynb │ └── xray.ipynb ├── parmed.md ├── parmed_minimization.md ├── pytraj.md ├── sandbox │ └── ambermd │ │ ├── ambermd_view.ipynb │ │ ├── md.in │ │ ├── min.rst7 │ │ └── peptide.top ├── user_examples.md └── users │ └── ase.md ├── js ├── .gitignore ├── DEVELOPMENT.md ├── LICENSE ├── eslint.config.js ├── package.json ├── pyproject.toml ├── src │ ├── base.ts │ ├── color.ts │ ├── embed.js │ ├── extension.js │ ├── fullscreen.ts │ ├── gui.js │ ├── index.ts │ ├── jupyterlab-plugin.js │ ├── lib │ │ ├── colorpicker.min.js │ │ └── signals.min.js │ ├── molstarview │ │ ├── light.css │ │ ├── representation.ts │ │ ├── ui.ts │ │ └── widget.ts │ ├── theme.ts │ ├── ui │ │ ├── ui.extra.js │ │ ├── ui.js │ │ └── ui.ngl.js │ └── widget_ngl.ts ├── style │ ├── base.css │ ├── index.css │ └── index.js ├── test │ ├── mocha.opts │ └── test_widget.js ├── tsconfig.json ├── update_ngl.sh └── webpack.config.js ├── nglview-js-widgets.json ├── nglview.gif ├── nglview.png ├── nglview ├── __init__.py ├── __main__.py ├── _frontend.py ├── adaptor.py ├── base.py ├── base_adaptor.py ├── color.py ├── component.py ├── config.py ├── contrib │ ├── __init__.py │ └── movie.py ├── data_source.py ├── datafiles │ ├── .md_1u19.xtc_offsets.pkl │ ├── __init__.py │ ├── ala3.pdb │ ├── md_1u19.gro │ ├── md_1u19.pdb │ ├── md_1u19.traj │ ├── md_1u19.trr │ ├── md_1u19.xtc │ └── md_1u19.xtc.offsets ├── default.py ├── interpolate.py ├── layout.py ├── parameters.py ├── remote_thread.py ├── representation.py ├── sandbox │ ├── __init__.py │ ├── amber.py │ ├── base.py │ ├── grid_view.py │ ├── interpolate.py │ └── lab.py ├── shape.py ├── show.py ├── stage.py ├── theme │ ├── __init__.py │ ├── dark.css │ ├── light.css │ ├── main.css │ ├── oceans16.css │ └── theme.py ├── utils │ ├── __init__.py │ ├── js_utils.py │ ├── py_utils.py │ ├── test_utils.py │ └── widget_utils.py ├── viewer_control.py ├── widget.py ├── widget_base.py └── widget_molstar.py ├── nightwatch.json ├── notebooks ├── README ├── custom_color.ipynb ├── gui.ipynb ├── molstarview.ipynb ├── molstarview_sandbox.ipynb ├── molviewspec.ipynb ├── movie_making.ipynb ├── orientation.ipynb ├── rdkit_smiles_3d.ipynb ├── render_image.ipynb └── trajectory_player.ipynb ├── pip-requirements-test.txt ├── pyproject.toml ├── run_tests.sh ├── setup.py ├── talks.md └── tests ├── .coveragerc ├── data ├── rho.pdb ├── tc5b.parm ├── tc5b.ref.crd ├── tc5b.x ├── tz2.pdb ├── tz2.single.pdb ├── tz2_2.pdb.gz └── volmap.dx ├── js └── test.js ├── make_dummy_comm.py ├── notebooks ├── README.md ├── api │ ├── test_add_shape.ipynb │ ├── test_app_layout.ipynb │ ├── test_custom_color.ipynb │ ├── test_embed.ipynb │ ├── test_grid_view_sync_camera.ipynb │ ├── test_gui_theme.ipynb │ ├── test_movie_making.ipynb │ ├── test_render_image.ipynb │ ├── test_representations.ipynb │ ├── test_set_coordinates.ipynb │ ├── test_sync_view.ipynb │ └── test_view_trajectory.ipynb └── extra │ ├── README.md │ ├── component_viewer.ipynb │ ├── display_some_components.ipynb │ ├── example_mbuild.ipynb │ ├── movie_making.ipynb │ ├── test_component_names.ipynb │ ├── test_grid_box_3_views_with_gui.ipynb │ └── test_sync_camera.ipynb ├── test_color.py ├── test_component_viewer.py ├── test_molstarview.py ├── test_movie_maker.py ├── test_show.py ├── test_theme.py ├── test_utils.py ├── test_version.py ├── test_widget.py └── utils.py /.coveragerc: -------------------------------------------------------------------------------- 1 | [run] 2 | branch = True 3 | source = nglview 4 | 5 | [report] 6 | exclude_lines = 7 | pragma: no cover 8 | def __repr__ 9 | def __str__ 10 | if self.debug 11 | if __name__ == .__main__.: 12 | 13 | omit = 14 | *_version.py 15 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | nglview/_version.py export-subst 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | - Question about usage? Please search your issue here first: https://github.com/arose/nglview/issues/589 and https://github.com/arose/nglview/issues/785 3 | 4 | - Version report 5 | 6 | ```bash 7 | python -c 'import nglview; print(nglview.__version__)' 8 | python -c 'import ipywidgets; print(ipywidgets.__version__)' 9 | ``` 10 | -------------------------------------------------------------------------------- /.github/nglview-gha.yml: -------------------------------------------------------------------------------- 1 | name: nglview-gha 2 | 3 | channels: 4 | - conda-forge 5 | 6 | dependencies: 7 | - jupyter-packaging 8 | - qcelemental 9 | - traitlets 10 | - ipywidgets>=8.0.5 11 | - comm>=0.1.3 # see https://github.com/jupyter-widgets/ipywidgets/issues/3729 12 | - ipykernel 13 | - notebook 14 | - mock 15 | - coverage 16 | - pytest 17 | - pytest-cov 18 | - pandas 19 | - ase 20 | - biopython 21 | - pymatgen 22 | - matplotlib 23 | - moviepy 24 | - imageio 25 | - pillow 26 | - numpy 27 | - rdkit 28 | - mdanalysis 29 | - mdtraj 30 | - ambertools # have both pytraj and parmed 31 | - pip 32 | -------------------------------------------------------------------------------- /.github/workflows/build-extension.yml: -------------------------------------------------------------------------------- 1 | name: Build extension 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - '*' 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - name: Checkout 13 | uses: actions/checkout@v3 14 | 15 | - name: Set up Node.js 16 | uses: actions/setup-node@v3 17 | with: 18 | node-version: 'lts/*' 19 | 20 | - name: Install Yarn 21 | run: corepack enable 22 | 23 | - name: Install Python 24 | uses: actions/setup-python@v4 25 | with: 26 | python-version: '3.12' 27 | architecture: 'x64' 28 | 29 | - name: Setup pip cache 30 | uses: actions/cache@v3 31 | with: 32 | path: ~/.cache/pip 33 | key: pip-3.12-${{ hashFiles('package.json') }} 34 | restore-keys: | 35 | pip-3.12- 36 | pip- 37 | 38 | - name: Get yarn cache directory path 39 | id: yarn-cache-dir-path 40 | run: echo "::set-output name=dir::$(yarn cache dir)" 41 | 42 | - name: Setup yarn cache 43 | uses: actions/cache@v3 44 | id: yarn-cache 45 | with: 46 | path: ${{ steps.yarn-cache-dir-path.outputs.dir }} 47 | key: yarn-${{ hashFiles('**/yarn.lock') }} 48 | restore-keys: | 49 | yarn- 50 | 51 | - name: Install dependencies 52 | run: python -m pip install -U jupyterlab jupyter_packaging jupyterlab_widgets 53 | 54 | - name: Use existing lockfile 55 | run: yarn install --frozen-lockfile 56 | 57 | - name: Build the extension 58 | working-directory: js 59 | run: npm install 60 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Test 2 | 3 | on: 4 | pull_request: 5 | workflow_dispatch: 6 | 7 | jobs: 8 | test: 9 | runs-on: ${{ matrix.os }} 10 | 11 | defaults: 12 | run: 13 | shell: bash -l {0} 14 | 15 | strategy: 16 | matrix: 17 | os: [ubuntu-latest, macos-latest] 18 | python-version: ["3.10", "3.11", "3.12"] 19 | 20 | steps: 21 | - name: Checkout nglview repository 22 | uses: actions/checkout@v4 23 | 24 | - name: Cache conda 25 | uses: actions/cache@v4 26 | env: 27 | CACHE_NUMBER: 2 # Increase this value to reset cache if .github/nglview-gha.yml has not changed 28 | with: 29 | path: ~/conda_pkgs_dir 30 | key: 31 | ${{ matrix.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('.github/nglview-gha.yml') }} 32 | 33 | - name: Set up conda environment 34 | uses: conda-incubator/setup-miniconda@v3 35 | with: 36 | auto-update-conda: true 37 | auto-activate-base: false 38 | activate-environment: nglview-gha 39 | environment-file: .github/nglview-gha.yml 40 | mamba-version: "*" 41 | channels: conda-forge 42 | channel-priority: true 43 | python-version: ${{ matrix.python-version }} 44 | use-only-tar-bz2: false # https://github.com/conda-incubator/setup-miniconda/issues/264 45 | 46 | - name: Set up Node.js 47 | uses: actions/setup-node@v3 48 | with: 49 | node-version: 'lts/*' 50 | 51 | - name: Install Yarn 52 | run: corepack enable 53 | 54 | - name: Build labextension 55 | run: | 56 | cd js 57 | npm install 58 | cd .. 59 | 60 | - name: Run tests 61 | run: | 62 | python -m pytest -vs tests --cov=nglview --cov-report=html --disable-pytest-warnings 63 | 64 | - name: Check installation with pip 65 | run: | 66 | python setup.py sdist 67 | pip install dist/*gz 68 | python -c "import nglview as nv; print(nv.__version__)" -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | *.sublime-project 3 | *.sublime-workspace 4 | 5 | *.pyc 6 | 7 | dist/* 8 | build/* 9 | *.egg-info 10 | 11 | .ipynb_checkpoints/ 12 | *.npz 13 | selenium-debug.log 14 | nbtests/ 15 | 16 | js/node_modules/ 17 | 18 | .vscode/ 19 | js/yarn.lock 20 | js/dist/ 21 | js/lib/ 22 | -------------------------------------------------------------------------------- /.style.yapf: -------------------------------------------------------------------------------- 1 | [style] 2 | based_on_style = google 3 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # (optional) docker build . -f Dockerfile-jupyterlab -t hainm/juypterlab:0.25.2 2 | # docker build . -t hainm/nglview:1.0.a0 3 | 4 | # How to run? 5 | # docker run -it --rm -p 8888:8888 hainm/nglview:1.0.a0 6 | 7 | FROM hainm/jupyterlab:0.25.2 8 | ADD ./jslab /opt/jslab 9 | 10 | RUN pip install numpy==1.13.1 11 | RUN pip install pytraj==2.0.2 12 | RUN pip install matplotlib==2.0.2 13 | RUN pip install moviepy==0.2.2.11 14 | RUN pip install imageio==1.6 15 | RUN pip install pillow==4.2.1 16 | RUN pip install nglview==1.0.a0 17 | RUN nglview install 18 | RUN nglview enable 19 | RUN jupyter-labextension install /opt/jslab 20 | RUN mkdir -p /root/.imageio/ffmpeg/ 21 | RUN curl https://github.com/imageio/imageio-binaries/raw/master/ffmpeg/ffmpeg.linux64 --output /root/.imageio/ffmpeg/ffmpeg.linux64 22 | 23 | CMD jupyter lab --ip=* --port=8888 --no-browser --notebook-dir=/opt/app/data --allow-root --NotebookApp.iopub_data_rate_limit=100000000 24 | -------------------------------------------------------------------------------- /Dockerfile-jupyterlab: -------------------------------------------------------------------------------- 1 | # docker build . -f Dockerfile-jupyterlab -t hainm/juypterlab:0.25.2 2 | # 3 | FROM continuumio/miniconda3 4 | 5 | RUN conda install notebook -c conda-forge -y 6 | RUN pip install ipywidgets==7.0.0b0 7 | RUN jupyter nbextension enable --py --sys-prefix widgetsnbextension 8 | 9 | RUN conda install nodejs -c conda-forge -y 10 | RUN conda install jupyterlab==0.25.2 -c conda-forge -y 11 | RUN jupyter labextension install @jupyter-widgets/jupyterlab-manager # 0.24.7 12 | 13 | # Expose Jupyter port & cmd 14 | EXPOSE 8888 15 | RUN mkdir -p /opt/app/data 16 | CMD jupyter lab --ip=* --port=8888 --no-browser --notebook-dir=/opt/app/data --allow-root --NotebookApp.iopub_data_rate_limit=100000000 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | /////////////// 3 | // NGL Widget 4 | 5 | The MIT License, Copyright © 2015 Alexander S. Rose 6 | 7 | applies to all files unless otherwise noted 8 | 9 | 10 | The MIT License 11 | 12 | Copyright (c) , 13 | 14 | Permission is hereby granted, free of charge, to any person obtaining a copy 15 | of this software and associated documentation files (the "Software"), to deal 16 | in the Software without restriction, including without limitation the rights 17 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 18 | copies of the Software, and to permit persons to whom the Software is 19 | furnished to do so, subject to the following conditions: 20 | 21 | The above copyright notice and this permission notice shall be included in 22 | all copies or substantial portions of the Software. 23 | 24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 27 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 28 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 29 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 30 | THE SOFTWARE. 31 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include nglview/datafiles/* 2 | recursive-include nglview/nbextension *.* 3 | recursive-include nglview/labextension *.* 4 | include nglview/theme/* 5 | include LICENSE README.md DEVELOPMENT.md CHANGELOG.md 6 | include setup.py 7 | global-exclude *.pycinclude *.ipynb *.gif *tests/notebooks/* 8 | -------------------------------------------------------------------------------- /circle.yml: -------------------------------------------------------------------------------- 1 | machine: 2 | services: 3 | - docker 4 | 5 | dependencies: 6 | override: 7 | - docker pull continuumio/miniconda3 8 | 9 | test: 10 | override: 11 | - docker build . -f Dockerfile-jupyterlab -t hainm/juypterlab-dev 12 | - docker build . -t nglview:dev 13 | -------------------------------------------------------------------------------- /conda-requirements-test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # FIXME: Update to requirements.txt once those packages have binary 4 | # distribution on pypi. 5 | conda install mdanalysis=0.16.2 -c conda-forge --yes 6 | conda install mdtraj=1.8.0 -c conda-forge --yes 7 | conda install rdkit -c rdkit --yes 8 | # conda install simpletraj -c omnia --yes # install via pip since simpletraj is not available in py3.7 yet. 9 | 10 | # > 100 MB 11 | # conda install ambertools=17 -c http://ambermd.org/downloads/ambertools/conda/ --yes 12 | -------------------------------------------------------------------------------- /devtools/README.release: -------------------------------------------------------------------------------- 1 | - cd js: 2 | - Update version in package.json (via: python devtools/update_versions.py [version]) 3 | - npm install && npm publish # to publish nglview-js-widgets for html embeding. 4 | - npm copy:labextension # to copy labextension files to nglview/labextension 5 | - Update version in /nglview/_frontend.py 6 | - Commit the change and push to master 7 | - Create a release tag in github 8 | - git fetch origin && git checkout 9 | - PYTHONPATH=`pwd` ./devtools/release.py 10 | - twine upload ./dist/ 11 | -------------------------------------------------------------------------------- /devtools/build_docker.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | docker build . -t hainm/nglview 4 | -------------------------------------------------------------------------------- /devtools/circleci/install_miniconda.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | yum install -y \ 4 | wget \ 5 | unzip 6 | 7 | # miniconda=https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh 8 | # wget $miniconda -O miniconda.sh 9 | # bash miniconda.sh -b 10 | # export PATH=/root/miniconda3/bin:$PATH 11 | export PATH=/opt/conda/bin/:$PATH 12 | conda update --yes --all 13 | conda install --yes conda-build anaconda-client numpy matplotlib 14 | conda info 15 | conda install --yes jupyter notebook nose numpy mock coverage cython netcdf4 16 | # pytraj 17 | pip install pytraj 18 | # mdanalysis 19 | conda config --add channels MDAnalysis 20 | conda install mdanalysis -c kain88-de --yes 21 | # mdtraj 22 | conda install mdtraj -c omnia --yes 23 | # ParmEd 24 | conda install -c ambermd parmed --yes 25 | # ase 26 | pip install https://github.com/hainm/ase/archive/3.11.0.tar.gz 27 | # simpletraj 28 | # turn off for now since this package requires install from source code. 29 | # pip install git+https://github.com/arose/simpletraj 30 | # rdkit 31 | # conda install rdkit -c rdkit --yes 32 | 33 | # update a bunch of stuff 34 | conda install --yes -c conda-forge ipywidgets notebook pyzmq 35 | -------------------------------------------------------------------------------- /devtools/conda-recipe/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | cp -r $RECIPE_DIR/../../ $SRC_DIR 4 | $PYTHON setup.py clean 5 | $PYTHON setup.py install 6 | -------------------------------------------------------------------------------- /devtools/conda-recipe/meta.yaml: -------------------------------------------------------------------------------- 1 | package: 2 | name: nglview-dev 3 | version: !!str 0.6.dev 4 | 5 | requirements: 6 | build: 7 | - python 8 | - setuptools 9 | - jupyter 10 | - ipywidgets 11 | - notebook >4.1 12 | - traitlets 13 | run: 14 | - python 15 | - numpy 16 | - ipywidgets 17 | - notebook >4.1 18 | - jupyter 19 | - traitlets 20 | 21 | test: 22 | imports: 23 | - nglview 24 | 25 | about: 26 | home: https://github.com/arose/nglview 27 | license: MIT 28 | summary: An IPython widget to interactively view molecular structures and trajectories. Utilizes the embeddable NGL Viewer for rendering. 29 | -------------------------------------------------------------------------------- /devtools/create_labextension_symlink.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | import argparse 4 | from pathlib import Path 5 | 6 | 7 | def get_extension_paths(): 8 | base_dir = Path(sys.prefix) 9 | nglview_js_widgets = "nglview-js-widgets" 10 | nbextension_dest = base_dir / "share" / "jupyter" / "nbextensions" / nglview_js_widgets 11 | labextension_dest = base_dir / "share" / "jupyter" / "labextensions" / nglview_js_widgets 12 | return nbextension_dest, labextension_dest 13 | 14 | 15 | def create_symlink(source, destination): 16 | try: 17 | if os.path.islink(destination): 18 | os.remove(destination) 19 | os.symlink(source, destination) 20 | print(f"Created symlink: {destination} -> {source}") 21 | except OSError as e: 22 | print(f"Failed to create symlink: {e}", file=sys.stderr) 23 | 24 | 25 | def remove_symlink(destination): 26 | try: 27 | if os.path.islink(destination): 28 | os.remove(destination) 29 | print(f"Removed symlink: {destination}") 30 | else: 31 | print(f"No symlink to remove at: {destination}") 32 | except OSError as e: 33 | print(f"Failed to remove symlink: {e}", file=sys.stderr) 34 | 35 | 36 | def main(): 37 | parser = argparse.ArgumentParser(description="Create or remove symlinks for nbextension and labextension.") 38 | parser.add_argument('-d', '--delete', action='store_true', help="Remove the symlinks instead of creating them.") 39 | args = parser.parse_args() 40 | 41 | nbextension_dest, labextension_dest = get_extension_paths() 42 | 43 | base_dir = Path(__file__).resolve().parent.parent 44 | nbextension_source = base_dir / 'nglview' / 'nbextension' 45 | labextension_source = base_dir / 'nglview' / 'labextension' 46 | 47 | if args.delete: 48 | remove_symlink(nbextension_dest) 49 | remove_symlink(labextension_dest) 50 | else: 51 | create_symlink(nbextension_source, nbextension_dest) 52 | create_symlink(labextension_source, labextension_dest) 53 | 54 | 55 | if __name__ == "__main__": 56 | main() -------------------------------------------------------------------------------- /devtools/gifipy.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import subprocess 4 | # require: ffmpeg 5 | # e.g: conda install ffmpeg -c menpo 6 | # 7 | import sys 8 | 9 | mov_in = sys.argv[1] 10 | mov_out = sys.argv[2] 11 | 12 | command = f'ffmpeg -i {mov_in} -pix_fmt rgb24 -r 10 -f gif {mov_out}' 13 | subprocess.call(command, shell=True) 14 | -------------------------------------------------------------------------------- /devtools/make_test_js.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import argparse 4 | import os 5 | import subprocess 6 | from glob import glob 7 | from random import shuffle 8 | 9 | parser = argparse.ArgumentParser() 10 | parser.add_argument('--basic', action='store_true') 11 | parser.add_argument('--api', action='store_true') 12 | parser.add_argument('--single', action='store_true') 13 | parser.add_argument('--travis', action='store_true') 14 | parser.add_argument('-n', '--nb', nargs='?') 15 | args = parser.parse_args() 16 | 17 | api_root_dir = 'nglview/tests/notebooks/api/' 18 | 19 | notebook_names_for_travis = [ 20 | 'test_no_gui_demo.ipynb', 21 | 'test_add_structure_then_trajectory.ipynb', 22 | 'test_automatically_added_attributes_0.ipynb', 23 | ] 24 | 25 | if args.travis: 26 | notebook_names = notebook_names_for_travis 27 | notebooks = [api_root_dir + notebook_name for notebook_name in notebook_names] 28 | elif args.api: 29 | notebooks = glob(api_root_dir + '/test*.ipynb') 30 | elif args.single: 31 | notebooks = [args.nb] 32 | else: 33 | notebooks = ['nglview/tests/notebooks/dummy.ipynb',] 34 | 35 | notebooks += (glob('nglview/tests/notebooks/test*ipynb') + 36 | glob('nglview/tests/notebooks/api/test*ipynb')) 37 | 38 | # shuffle(notebooks) 39 | def get_cell_length(nb): 40 | n_cells = 0 41 | 42 | with open(nb) as fh: 43 | for line in fh.readlines(): 44 | if 'cell_type' in line: 45 | n_cells += 1 46 | return n_cells 47 | 48 | notebooks_with_cell_lengths = [(nb, 2*get_cell_length(nb)) for nb in notebooks] 49 | 50 | head = """ 51 | module.exports = { 52 | 53 | """ 54 | 55 | 56 | body_template = """ 57 | "%s": function (browser) { 58 | browser.openNotebook("%s"); 59 | browser.restartKernel(2000); 60 | for ( var i = 0; i < %s; i++) { 61 | browser.executeCell(i) 62 | .pause(3000) 63 | .cellHasError(i); 64 | } 65 | browser.end(); 66 | }, 67 | """ 68 | 69 | tail = """ 70 | } 71 | """ 72 | 73 | if __name__ == '__main__': 74 | 75 | all_notebooks = '\n'.join(body_template % (notebook, notebook, n_cells) 76 | for (notebook, n_cells) in notebooks_with_cell_lengths) 77 | 78 | fn = 'nglview/tests/js/test.js' 79 | with open(fn, 'w') as fh: 80 | fh.write(head + all_notebooks + tail) 81 | 82 | for nb_abspath, n_cells in notebooks_with_cell_lengths: 83 | basename = os.path.basename(nb_abspath) 84 | js_fn = os.path.join('nglview/tests/js', 85 | os.path.splitext(basename)[0] + '.js') 86 | with open(js_fn, 'w') as fh: 87 | body = body_template % (nb_abspath, nb_abspath, n_cells) 88 | fh.write(head + body + tail) 89 | -------------------------------------------------------------------------------- /devtools/nb_runner/start_server.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "Checking ./nbtests" 4 | 5 | if [ ! -d nbtests ]; then 6 | echo "Can not find nbtests folder" 7 | echo "Clone it" 8 | git clone https://github.com/hainm/nbtests 9 | fi 10 | 11 | echo "Running notebook in background" 12 | # jupyter notebook --port=8889 --NotebookApp.iopub_data_rate_limit 1000000000 > /dev/null & 13 | jupyter notebook --port=8889 2> /dev/null & 14 | sleep 2 15 | -------------------------------------------------------------------------------- /devtools/nb_runner/stop_server.sh: -------------------------------------------------------------------------------- 1 | for id in `ps -A | grep jupyter-notebook | grep python | awk '{print $1}'`; do 2 | kill $id 3 | done 4 | -------------------------------------------------------------------------------- /devtools/nglview-jupyterlab.sh: -------------------------------------------------------------------------------- 1 | conda create -n lab python=3.11 -y 2 | source activate lab 3 | # conda install jupyterlab=3 nglview -c conda-forge -y 4 | conda install jupyterlab=3 -c conda-forge -y 5 | -------------------------------------------------------------------------------- /devtools/outdated/nglview-jupyterlab.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | nglview_src=`pwd` 4 | env=jupyterlab_0_31 5 | jupyterlab_version=0.31 6 | lab_manager_version=${jupyterlab_version} # need to match to ./jslab/package.json too too. 7 | python_version=3.6 8 | notebook_version=5.0.0 9 | ipywidgets_version=7.1.2 10 | # widgetsnbextension_version=3.0.0 11 | 12 | echo "nglview root folder: $nglview_src" 13 | echo "Creating env $env" 14 | 15 | conda create -n $env python=${python_version} numpy nomkl -y 16 | source activate $env 17 | conda install setuptools -c conda-forge --force -y 18 | conda install notebook==${notebook_version} -c conda-forge -y 19 | pip install ipywidgets==${ipywidgets_version} 20 | # pip install widgetsnbextension==${widgetsnbextension_version} --upgrade 21 | pip install pytraj # comment if using windows 22 | jupyter nbextension install --py --sys-prefix widgetsnbextension 23 | jupyter nbextension enable --py --sys-prefix widgetsnbextension 24 | 25 | conda install jupyterlab==${jupyterlab_version} -c conda-forge -y 26 | jupyter labextension install @jupyter-widgets/jupyterlab-manager@${lab_manager_version} 27 | 28 | cd $nglview_src 29 | 30 | ## Developer should do this 31 | ## nglview-js-widgets 32 | # cd js 33 | # npm install && npm publish 34 | # cd ../ 35 | 36 | # nglview 37 | python setup.py install 38 | 39 | # nglview-jupyterlab 40 | jupyter-labextension install ./jslab 41 | -------------------------------------------------------------------------------- /devtools/recipe/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | $PYTHON setup.py install --conda 4 | -------------------------------------------------------------------------------- /devtools/recipe/meta.yaml: -------------------------------------------------------------------------------- 1 | package: 2 | name: nglview 3 | version: !!str 0.0.0 4 | 5 | source: 6 | path: ../../ 7 | 8 | requirements: 9 | build: 10 | - python 11 | - setuptools 12 | - ipywidgets 13 | - notebook 14 | 15 | run: 16 | - python 17 | - numpy 18 | - ipywidgets 19 | - notebook 20 | 21 | test: 22 | imports: 23 | - nglview 24 | 25 | about: 26 | home: https://github.com/arose/nglview 27 | license: MIT 28 | summary: An IPython widget to interactively view molecular structures and trajectories. Utilizes the embeddable NGL Viewer for rendering. 29 | -------------------------------------------------------------------------------- /devtools/recipe/post-link.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | jupyter nbextension install nglview --py --user 4 | jupyter nbextension enable nglview --py --user 5 | -------------------------------------------------------------------------------- /devtools/release.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import subprocess 4 | import sys 5 | from pathlib import Path 6 | import time 7 | 8 | HERE = Path(__file__).parents[1].resolve().absolute() 9 | sys.path.insert(0, str(HERE)) 10 | 11 | import nglview 12 | 13 | print(nglview) 14 | 15 | front_end_version = nglview.widget.__frontend_version__ 16 | latest_tag = sorted(subprocess.check_output('git tag', shell=True).decode().split('\n'))[-1] 17 | latest_tag = latest_tag.replace('v', '') 18 | print("latest_tag", latest_tag) 19 | print("front_end_version", front_end_version) 20 | 21 | if front_end_version != latest_tag: 22 | print(f"WARNING: Version mismatch between front_end_version {front_end_version} and latest_tag {latest_tag}") 23 | time.sleep(5) 24 | 25 | print("\nMake sure to publish npm package") 26 | output = subprocess.check_output(["npm", "search", "nglview-js-widgets"]).decode() 27 | print(output) 28 | 29 | subprocess.check_call('python setup.py sdist', shell=True) 30 | -------------------------------------------------------------------------------- /devtools/update_versions.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import json 4 | from pathlib import Path 5 | import sys 6 | from packaging.version import parse as parse_version 7 | 8 | version = sys.argv[1] 9 | HERE = Path(__file__).parents[1].resolve().absolute() 10 | pkg_file = HERE / "js/package.json" 11 | 12 | content = [] 13 | 14 | with open(pkg_file) as fh: 15 | for line in fh: 16 | if line.strip().startswith('"version"'): 17 | content.append(f' "version": "{version}",\n') 18 | else: 19 | content.append(line) 20 | 21 | with open(pkg_file, 'w') as fh: 22 | for line in content: 23 | fh.write(line) 24 | 25 | 26 | with open('nglview/_frontend.py', 'w') as fh: 27 | fh.write(f"__frontend_version__ = '{version}'") 28 | 29 | 30 | print("DONE updating version") 31 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | Please check [scripts/fix_readme_link.py](https://github.com/arose/nglview/blob/gh-pages/scripts/fix_readme_link.py) in `gh-pages` branch 2 | 3 | -------------------------------------------------------------------------------- /docs/_api/modules.rst: -------------------------------------------------------------------------------- 1 | nglview 2 | ======= 3 | 4 | .. toctree:: 5 | :maxdepth: 4 6 | 7 | nglview 8 | nglview.widget 9 | nglview.adaptor 10 | nglview.shape 11 | nglview.widget_utils 12 | nglview.player 13 | nglview.scripts 14 | -------------------------------------------------------------------------------- /docs/_api/nglview.adaptor.rst: -------------------------------------------------------------------------------- 1 | nglview.adaptor 2 | =============== 3 | 4 | Module contents 5 | --------------- 6 | 7 | .. automodule:: nglview.adaptor 8 | :members: 9 | :undoc-members: 10 | :show-inheritance: 11 | -------------------------------------------------------------------------------- /docs/_api/nglview.contrib.movie.rst: -------------------------------------------------------------------------------- 1 | nglview.contrib.movie 2 | ===================== 3 | 4 | Module contents 5 | --------------- 6 | 7 | .. automodule:: nglview.contrib.movie 8 | :members: 9 | :undoc-members: 10 | :show-inheritance: 11 | -------------------------------------------------------------------------------- /docs/_api/nglview.datafiles.rst: -------------------------------------------------------------------------------- 1 | nglview.datafiles package 2 | ========================= 3 | 4 | Module contents 5 | --------------- 6 | 7 | .. automodule:: nglview.datafiles 8 | :members: 9 | :undoc-members: 10 | :show-inheritance: 11 | -------------------------------------------------------------------------------- /docs/_api/nglview.jsutils.rst: -------------------------------------------------------------------------------- 1 | nglview.js_utils 2 | ================ 3 | 4 | Module contents 5 | --------------- 6 | 7 | .. automodule:: nglview.utils.js_utils 8 | :members: 9 | :undoc-members: 10 | :show-inheritance: 11 | -------------------------------------------------------------------------------- /docs/_api/nglview.layout.rst: -------------------------------------------------------------------------------- 1 | nglview.layout 2 | ============== 3 | 4 | Module contents 5 | --------------- 6 | 7 | .. automodule:: nglview.layout 8 | :members: 9 | :undoc-members: 10 | :show-inheritance: 11 | -------------------------------------------------------------------------------- /docs/_api/nglview.player.rst: -------------------------------------------------------------------------------- 1 | nglview.player 2 | ============== 3 | 4 | Module contents 5 | --------------- 6 | 7 | .. automodule:: nglview.player 8 | :members: 9 | :undoc-members: 10 | :show-inheritance: 11 | -------------------------------------------------------------------------------- /docs/_api/nglview.scripts.rst: -------------------------------------------------------------------------------- 1 | nglview.scripts package 2 | ======================= 3 | 4 | Submodules 5 | ---------- 6 | 7 | nglview.scripts.app module 8 | -------------------------- 9 | 10 | .. automodule:: nglview.scripts.app 11 | :members: 12 | :undoc-members: 13 | :show-inheritance: 14 | 15 | nglview.scripts.cmd_example module 16 | ---------------------------------- 17 | 18 | .. automodule:: nglview.scripts.cmd_example 19 | :members: 20 | :undoc-members: 21 | :show-inheritance: 22 | 23 | nglview.scripts.nglview module 24 | ------------------------------ 25 | 26 | .. automodule:: nglview.scripts.nglview 27 | :members: 28 | :undoc-members: 29 | :show-inheritance: 30 | 31 | 32 | Module contents 33 | --------------- 34 | 35 | .. automodule:: nglview.scripts 36 | :members: 37 | :undoc-members: 38 | :show-inheritance: 39 | -------------------------------------------------------------------------------- /docs/_api/nglview.shape.rst: -------------------------------------------------------------------------------- 1 | nglview.shape 2 | ============= 3 | 4 | Module contents 5 | --------------- 6 | 7 | .. automodule:: nglview.shape 8 | :members: 9 | :undoc-members: 10 | :show-inheritance: 11 | -------------------------------------------------------------------------------- /docs/_api/nglview.static.rst: -------------------------------------------------------------------------------- 1 | nglview.static package 2 | ====================== 3 | 4 | Module contents 5 | --------------- 6 | 7 | .. automodule:: nglview.static 8 | :members: 9 | :undoc-members: 10 | :show-inheritance: 11 | -------------------------------------------------------------------------------- /docs/_api/nglview.theme.rst: -------------------------------------------------------------------------------- 1 | nglview.theme package 2 | ===================== 3 | 4 | Submodules 5 | ---------- 6 | 7 | nglview.theme.theme module 8 | -------------------------- 9 | 10 | .. automodule:: nglview.theme.theme 11 | :members: 12 | :undoc-members: 13 | :show-inheritance: 14 | 15 | 16 | Module contents 17 | --------------- 18 | 19 | .. automodule:: nglview.theme 20 | :members: 21 | :undoc-members: 22 | :show-inheritance: 23 | -------------------------------------------------------------------------------- /docs/_api/nglview.widget.rst: -------------------------------------------------------------------------------- 1 | nglview.widget 2 | ============== 3 | 4 | Module contents 5 | --------------- 6 | 7 | .. automodule:: nglview.widget 8 | :members: 9 | :undoc-members: 10 | :show-inheritance: 11 | -------------------------------------------------------------------------------- /docs/_api/nglview.widget_utils.rst: -------------------------------------------------------------------------------- 1 | nglview.widget_utils 2 | ==================== 3 | 4 | Module contents 5 | --------------- 6 | 7 | .. automodule:: nglview.utils.widget_utils 8 | :members: 9 | :undoc-members: 10 | :show-inheritance: 11 | -------------------------------------------------------------------------------- /docs/_static/cindex.js: -------------------------------------------------------------------------------- 1 | // from pymunk: http://pymunk.readthedocs.org/en/latest/_static/pymunk.js 2 | 3 | $(function (){ 4 | var createList = function(selector){ 5 | 6 | var ul = $('