nglview-js-widgets

Jupyter widget to interactively view molecular structures and trajectories

https://github.com/nglviewer/nglview

Science Score: 36.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
    Found 2 DOI reference(s) in README
  • Academic publication links
  • Committers with academic emails
    3 of 40 committers (7.5%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (11.2%) to scientific vocabulary

Keywords from Contributors

molecular-dynamics computational-chemistry quantum-chemistry molecular-simulation closember distributed standards genomics units benchmarks
Last synced: 10 months ago · JSON representation

Repository

Jupyter widget to interactively view molecular structures and trajectories

Basic Info
Statistics
  • Stars: 889
  • Watchers: 20
  • Forks: 135
  • Open Issues: 38
  • Releases: 86
Created over 10 years ago · Last pushed about 1 year ago
Metadata Files
Readme Changelog Contributing License

README.md

Citation | Installation | Example | Usage | Command line | API doc | Interface classes | Website | Acknowledgment

Build Status Build Extension Status

An IPython/Jupyter widget to interactively view molecular structures and trajectories. Utilizes the embeddable NGL Viewer for rendering. Support for showing data from the file-system, RCSB PDB, simpletraj and from objects of analysis libraries mdtraj, pytraj, mdanalysis, ParmEd, rdkit, ase, HTMD, biopython, cctbx, pyrosetta, schrodinger's Structure

Should work with Python 3. If you experience problems, please file an issue.

Ask question about usage? Please post here

membrane

Table of contents

Installation

Released version

  • Available on conda-forge channel

    bash conda install nglview -c conda-forge

  • Available on PyPI

bash pip install nglview

Jupyterlab: nglview works best with jupyterlab >= 3.0 and no further steps needed. Known to work versions

|nglview|lab|notebook|ipywidgets|Known issue(s)|VSCode |--|--|--|--|--|--| |3.1.0|4.0.10|7.0.6|8.1.1|HTML embed doesn't work|No| |3.0.8|4.0.10|7.0.6|8.1.1|show_pdbid doesn't work|Yes|

Notes

If you are using notebook v5.0, you need to increase the iopub_data_rate_limit to visualize big structure (e.g: solvated system)

jupyter notebook --NotebookApp.iopub_data_rate_limit=10000000

Development version

Requirement: ipywidgets >= 7.0, notebook >= 4.2

The development version can be installed directly from github:

notebook user

```bash git clone https://github.com/arose/nglview cd nglview python setup.py install

# if you edit files in ./js folder, make sure to rebuild the code
cd js
npm install

# probably need to activate widgetsnbextension
# python -m ipykernel install --sys-prefix
# jupyter nbextension enable --py --sys-prefix widgetsnbextension
# jupyter nbextension enable --py --sys-prefix nglview

# tested with ipywidgets 5.2.2, notebook 4.2.1

```

Example

Showcase from users

Usage

Open a notebook

jupyter notebook

and issue

Python import nglview view = nglview.show_pdbid("3pqr") # load "3pqr" from RCSB PDB and display viewer widget view

A number of convenience functions are available to quickly display data from the file-system, RCSB PDB, simpletraj and from objects of analysis libraries mdtraj, pytraj, mdanalysis, ParmEd, rdkit, HTMD, biopython.

| Function | Description | |------------------------------------------|-------------------------------------------------------| | show_file(path) | Shows any NGL supported file formats (pdb, gro, mol2, sdf, dx, ..) in path | | show_pdbid(pdbid) | Shows pdbid fetched from RCSB PDB | | show_simpletraj(struc_path, traj_path) | Shows structure & trajectory loaded with simpletraj | | show_mdtraj(traj) | Shows MDTraj trajectory traj | | show_pytraj(traj) | Shows PyTraj trajectory traj | | show_parmed(structure) | Shows ParmEd structure | | show_mdanalysis(univ) | Shows MDAnalysis Universe or AtomGroup univ | | show_rdkit(mol) | Shows rdkit rdkit.Chem.rdchem.Mol | | show_ase(atoms) | Shows ase Atoms | | show_asetraj(traj) | Shows ase trajectory traj | | show_pymatgen(struct) | Shows pymatgen Structure | | show_htmd(mol) | Shows HTMD Molecules | | show_biopython(mol) | Shows Biopython structural entities | | show_iotbx(mol) | Shows cctbx's iotbx structure | | show_rosetta(pose) | Shows pyrosetta's Pose | | show_iodata(obj) | Shows iodata's IOData | | show_psi4(obj) | Shows psi4's Molecule | | show_qcelemental | Shows QCelementary's Molecule | | show_openbabel | Shows openbabel's OMol | | show_prody | Shows prody's Ensemble or AtomGroup |

API

Representations

```python view.add_representation('cartoon', selection='protein')

or shorter

view.addcartoon(selection="protein") view.addsurface(selection="protein", opacity=0.3)

specify color

view.add_cartoon(selection="protein", color='blue')

specify residue

view.add_licorice('ALA, GLU')

clear representations

view.clear_representations()

update parameters for ALL cartoons of component 0 (default)

view.update_cartoon(opacity=0.4, component=0)

remove ALL cartoons of component 0 (default)

view.remove_cartoon(opacity=0.4, component=0)

Not using default representation

view = nv.showfile('your.pdb', default=False) view.center() view.addrope() ```

Representations can also be changed by overwriting the representations property of the widget instance view. The available type and params are described in the NGL Viewer documentation.

Python view.representations = [ {"type": "cartoon", "params": { "sele": "protein", "color": "residueindex" }}, {"type": "ball+stick", "params": { "sele": "hetero" }} ]

The widget constructor also accepts a representation argument:

```Python initial_repr = [ {"type": "cartoon", "params": { "sele": "protein", "color": "sstruc" }} ]

view = nglview.NGLWidget(struc, representation=initial_repr) view ```

Properties

```Python

set the frame number

view.frame = 100 ```

```Python

parameters for the NGL stage object

view.stage.set_parameters(**{ # "percentages, "dist" is distance to camera in Angstrom "clipNear": 0, "clipFar": 100, "clipDist": 10, # percentages, start of fog and where on full effect "fogNear": 0, "fogFar": 100, # background color "backgroundColor": "black", })

note: NGLView accepts both origin camel NGL keywords (e.g. "clipNear")

and snake keywords (e.g "clip_near")

```

```python

parameters to control the delay between snapshots

change step to play forward (positive value) or backward (negative value)

note: experimental code

view.player.parameters = dict(delay=0.04, step=-1) ```

```python

update camera type

view.camera = 'orthographic' ```

```python

change background color

view.background = 'black' ```

Trajectory

```python

adding new trajectory

view.add_trajectory(traj)

traj could be a pytraj.Trajectory, mdtraj.Trajectory, MDAnalysis.Universe,

parmed.Structure, htmd.Molecule or derived class of nglview.Trajectory

change representation

view[0].addcartoon(...) # equal to view.addcartoon(component=0) view[1].addlicorice(...) # equal to view.addlicorice(component=1) ```

Add extra component

```python

Density volumes (MRC/MAP/CCP4, DX/DXBIN, CUBE)

Or adding derived class of nglview.Structure

view.add_component('my.ccp4')

add component from url

view.add_component('rcsb://1tsu.pdb')

NOTE: Trajectory is a special case of component.

```

Mouse

```python

coot mouse style (https://en.wikipedia.org/wiki/Coot_(software))

view.stage.setparameters(mousepreset='coot') ```

Interaction controls

Movie making

Require: moviepy (pip install moviepy)

python from nglview.contrib.movie import MovieMaker movie = MovieMaker(view, output='my.gif', in_memory=True) movie.make()

Embed widget

embed

API doc

Command line

```bash

open a notebook and import nglview

nglview

Require installing pytraj (PR for other backends is welcome)

open notebook, load my.pdb to pytraj's trajectory then display view

nglview my.pdb

load density data

nglview my.ccp4

open notebook, create trajectory with given topology my.parm7 and trajecotry file traj.nc,

then display view

nglview my.parm7 -c traj.nc

load all trajectories with filename ending with 'nc'

make sure to use quote " "

nglview my.parm7 -c "*.nc"

open notebook, copy content from myscript.py

nglview myscript.py

create a remote notebook

just follow its instruction

nglview my.pdb --remote nglview my.parm7 -c traj.nc --remote nglview mynotebook.ipynb --remote

demo (don't need pytraj)

nglview demo

specify web browser

nglview my.pdb --browser=google-chrome ```

FAQ

Q&A

Website

  • http://nglviewer.github.io/nglview/latest
  • http://nglviewer.github.io/nglview/dev

Talks

Talks about NGL and nglview

Contributing

Join us here

Projects integrating NGLView

(Feel free to make a PR to add/remove your project here. Thanks.)

  • AMBER - A package of programs for molecular dynamics simulations of proteins and nucleic acids
  • mbuild - A hierarchical, component based molecule builder
  • deepchem - Deep-learning models for Drug Discovery and Quantum Chemistry
  • htmd - High throughput molecular dynamics simulations
  • Moleidoscope - Molecular kaleidoscope
  • ssbio - Tools for enabling structural systems biology
  • hublib - hublib is a Python library for the HUBzero science gateway platform.
  • molPX: ipython API to visualize MD-trajectories along projected trajectories
  • nanoribbon
  • ase: Atomic Simulation Environment
  • pida: Software for analyzing multiple protein-protein interaction docking solutions,
  • pytim
  • MobleyLab/drug-computing Educational materials for, and related to, UC Irvine's Drug Discovery Computing Techniques course.
  • pyiron: an integrated development environment for implementing, testing, and running simulations in computational materials science.
  • BioSimSpace: An interoperable framework for biomolecular simulation
  • pyrod: PyRod - Tracing water molecules in molecular dynamics simulations
  • kugupu: kugupu - a molecular network generator to study charge transport pathways in amorphous materials
  • pnab: proto-Nucleic Acid Builder
  • opencadd: A Python library for structural cheminformatics
  • teachopencadd: TeachOpenCADD: a teaching platform for computer-aided drug design (CADD) using open source packages and data
  • query.libretexts.org: query.libretexts.org
  • datamol: A python library to work with molecules.
  • dynophores: Dynamic pharmacophore modeling of molecular interactions
  • pychemcurv: Discrete and local curvature applied to chemistry and chemical reactivity
  • AutoSolvate: Automated workflow for generating quantum chemistry calculation of explicitly solvated molecules
  • plipify: PLIPify: Protein-Ligand Interaction Frequencies across Multiple Structures
  • Melodia: Differential Geometry of Proteins Backbones
  • pyrosetta_viewer3d: Display PackedPose objects, Pose objects, or PDB files within a Jupyter notebook and Google Colab
  • py4vasp: Python interface for VASP
  • eminus: A plane wave density functional theory code.
  • MolSysMT: Molecular Systems Multi-Tool

Acknowledgment

  • Funding: Hai Nguyen is supported by NIH Grant GM103297, "The Center for HIV RNA Studies" (2015 to 02-2017).
  • Many thanks to nglview contributors

Cite

If you would like to acknowledge our work, feel free to cite:

Hai Nguyen, David A Case, Alexander S Rose; NGLview - Interactive molecular graphics for Jupyter notebooks, Bioinformatics, , btx789, https://doi.org/10.1093/bioinformatics/btx789

License

Generally MIT, see the LICENSE file for details.

Owner

  • Name: nglviewer
  • Login: nglviewer
  • Kind: organization

GitHub Events

Total
  • Create event: 26
  • Release event: 1
  • Issues event: 21
  • Watch event: 63
  • Delete event: 31
  • Issue comment event: 58
  • Push event: 116
  • Pull request event: 50
  • Fork event: 4
Last Year
  • Create event: 26
  • Release event: 1
  • Issues event: 21
  • Watch event: 63
  • Delete event: 31
  • Issue comment event: 58
  • Push event: 116
  • Pull request event: 50
  • Fork event: 4

Committers

Last synced: about 1 year ago

All Time
  • Total Commits: 1,362
  • Total Committers: 40
  • Avg Commits per committer: 34.05
  • Development Distribution Score (DDS): 0.146
Past Year
  • Commits: 32
  • Committers: 3
  • Avg Commits per committer: 10.667
  • Development Distribution Score (DDS): 0.094
Top Committers
Name Email Commits
Hai Nguyen h****m 1,163
arose a****e@w****e 102
Roberto Di Remigio r****o@g****m 17
kawaidev 10
Jan Janßen j****n@m****e 9
Hugo h****k 6
dependabot[bot] 4****] 4
Richard Gowers r****s@g****m 4
Martin Scherer m****r@f****e 4
Stefan Doerr s****r@u****u 3
David Dotson d****n@a****u 3
Hai Nguyen h****n 2
Paweł T. Jochym j****m 2
Toshiki Kataoka t****r@g****m 2
Wanja Schulze w****u 2
Yunqi Shao y****o@y****m 2
kawaidev k****y@g****m 2
Max Linke m****e@g****e 2
hai-schrodinger 3****r 2
Zachary Riedlshah g****t@z****e 1
Viktor Horvath v****h 1
Toon Verstraelen T****n@U****e 1
Hai Nguyen n****n@n****l 1
Lily Wang l****g@l****u 1
Paolo Tosco p****l@g****m 1
Marvin Poul p****r@c****e 1
Martin Hunt h****m@g****m 1
Josh A. Mitchell y****i@g****m 1
John Chodera j****a@c****g 1
Joe Greener j****r@h****k 1
and 10 more...
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 10 months ago

All Time
  • Total issues: 136
  • Total pull requests: 80
  • Average time to close issues: 6 months
  • Average time to close pull requests: 24 days
  • Total issue authors: 106
  • Total pull request authors: 12
  • Average comments per issue: 9.71
  • Average comments per pull request: 1.39
  • Merged pull requests: 60
  • Bot issues: 0
  • Bot pull requests: 6
Past Year
  • Issues: 14
  • Pull requests: 29
  • Average time to close issues: N/A
  • Average time to close pull requests: 9 days
  • Issue authors: 12
  • Pull request authors: 2
  • Average comments per issue: 1.36
  • Average comments per pull request: 0.52
  • Merged pull requests: 19
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • hainm (18)
  • wangenau (6)
  • scottwsides (5)
  • johnnytam100 (3)
  • phisanti (2)
  • Dan-Burns (2)
  • Yoshanuikabundi (2)
  • Quynh2710 (1)
  • alexberlaga (1)
  • Panzer-vor-08 (1)
  • chabi-fin (1)
  • DA-L3 (1)
  • superstar54 (1)
  • ratleyg (1)
  • dprada (1)
Pull Request Authors
  • hainm (79)
  • dependabot[bot] (6)
  • wangenau (4)
  • toslunar (2)
  • hai-schrodinger (2)
  • pmrv (1)
  • Yoshanuikabundi (1)
  • jaimergp (1)
  • tovrstra (1)
  • robertodr (1)
  • gph82 (1)
  • satary (1)
Top Labels
Issue Labels
bug (14) Q&A (5) NGL-issue (2) jupyterlab (2) enhancement (1) good first issue (1) deprecation (1) VSCode (1)
Pull Request Labels
dependencies (6)

Packages

  • Total packages: 1
  • Total downloads:
    • npm 369 last-month
  • Total docker downloads: 45,073
  • Total dependent packages: 2
  • Total dependent repositories: 1
  • Total versions: 63
  • Total maintainers: 1
npmjs.org: nglview-js-widgets

nglview-js-widgets

  • Versions: 63
  • Dependent Packages: 2
  • Dependent Repositories: 1
  • Downloads: 369 Last month
  • Docker Downloads: 45,073
Rankings
Docker downloads count: 0.6%
Downloads: 2.0%
Stargazers count: 2.6%
Forks count: 2.8%
Average: 4.5%
Dependent packages count: 8.8%
Dependent repos count: 10.3%
Maintainers (1)
Last synced: 10 months ago

Dependencies

.github/workflows/build-extension.yml actions
  • actions/cache v2 composite
  • actions/checkout v2 composite
  • actions/setup-node v1 composite
  • actions/setup-python v2 composite
.github/workflows/test.yml actions
  • actions/cache v1 composite
  • actions/checkout v2 composite
  • conda-incubator/setup-miniconda v2 composite
environment.yml conda
  • ase
  • biopython
  • coverage
  • coveralls
  • imageio
  • ipywidgets 7.*
  • jupyterlab
  • matplotlib
  • mdanalysis
  • mdtraj
  • mock
  • moviepy
  • nodejs
  • nose
  • numpy
  • pandas
  • parmed
  • pillow
  • pip
  • pymatgen
  • pytest
  • pytest-cov
  • python >=3.6
  • rdkit
  • simpletraj
  • yarn
Dockerfile docker
  • hainm/jupyterlab 0.25.2 build
js/package.json npm
  • @jupyterlab/builder ^3.0.0 development
  • @types/chai ^4.1.4 development
  • @types/expect.js ^0.3.29 development
  • @types/mocha ^2.2.48 development
  • @types/node ^14.0.0 development
  • @types/requirejs ^2.1.31 development
  • @typescript-eslint/eslint-plugin ^4.8.1 development
  • @typescript-eslint/parser ^4.8.1 development
  • babel-register ^6.11.6 development
  • css-loader ^0.23.1 development
  • eslint ^7.14.0 development
  • file-loader ^1.1.6 development
  • json-loader ^0.5.4 development
  • mkdirp ^1.0.3 development
  • ngl 2.0.0-dev.39 development
  • npm-run-all ^4.1.5 development
  • prettier ^2.1.1 development
  • rimraf ^3.0.2 development
  • style-loader ^0.13.1 development
  • typescript ~4.1.3 development
  • webpack ^3.5.5 development
  • @jupyter-widgets/base ^4.0.0
  • @jupyter-widgets/jupyterlab-manager ^3.0.0
  • jquery ^3.2.1
  • jquery-ui ^1.12.1
  • lodash ^4.17.4
  • ngl 2.0.0-dev.39
  • underscore ^1.8.3
nglview/staticlab/package.json npm
  • @jupyterlab/builder ^3.0.0 development
  • @types/chai ^4.1.4 development
  • @types/expect.js ^0.3.29 development
  • @types/mocha ^2.2.48 development
  • @types/node ^14.0.0 development
  • @types/requirejs ^2.1.31 development
  • @typescript-eslint/eslint-plugin ^4.8.1 development
  • @typescript-eslint/parser ^4.8.1 development
  • babel-register ^6.11.6 development
  • css-loader ^0.23.1 development
  • eslint ^7.14.0 development
  • file-loader ^1.1.6 development
  • json-loader ^0.5.4 development
  • mkdirp ^1.0.3 development
  • ngl 2.0.0-dev.39 development
  • npm-run-all ^4.1.5 development
  • prettier ^2.1.1 development
  • rimraf ^3.0.2 development
  • style-loader ^0.13.1 development
  • typescript ~4.1.3 development
  • webpack ^3.5.5 development
  • @jupyter-widgets/base ^4.0.0
  • @jupyter-widgets/jupyterlab-manager ^3.0.0
  • jquery ^3.2.1
  • jquery-ui ^1.12.1
  • lodash ^4.17.4
  • ngl 2.0.0-dev.39
  • underscore ^1.8.3
binder/environment.yml pypi
  • ipython_blocking *
  • moviepy *
  • pytraj *
docs/nglview-jupyterlab/environment.yml pypi
  • nglview ==1.1.2
  • numpy ==1.14.2
js/setup.py pypi
  • jupyterlab *
pip-requirements-test.txt pypi
  • ase * test
  • biopython * test
  • coverage * test
  • coveralls * test
  • imageio ==1.6 test
  • ipywidgets ==7 test
  • matplotlib ==2.0.2 test
  • mock * test
  • moviepy ==0.2.2.11 test
  • nose * test
  • pandas ==0.24 test
  • parmed * test
  • pillow ==9.3.0 test
  • pymatgen * test
  • pytest * test
  • pytraj * test
  • simpletraj * test
  • traitlets ==4.3.2 test