Get 20M+ Full-Text Papers For Less Than $1.50/day. Start a 14-Day Trial for You or Your Team.

Learn More →

PyChimera: use UCSF Chimera modules in any Python 2.7 project

PyChimera: use UCSF Chimera modules in any Python 2.7 project Motivation: UCSF Chimera is a powerful visualization tool remarkably present in the computational chemistry and structural biology communities. Built on a Cþþ core wrapped under a Python 2.7 environment, one could expect to easily import UCSF Chimera’s arsenal of resources in custom scripts or software projects. Nonetheless, this is not readily possible if the script is not executed within UCSF Chimera due to the isolation of the platform. UCSF ChimeraX, successor to the original Chimera, partially solves the problem but yet major upgrades need to be undergone so that this updated version can offer all UCSF Chimera features. Results: PyChimera has been developed to overcome these limitations and provide access to the UCSF Chimera codebase from any Python 2.7 interpreter, including interactive programming with tools like IPython and Jupyter Notebooks, making it easier to use with additional third-party software. Availability and implementation: PyChimera is LGPL-licensed and available at https://github.com/ insilichem/pychimera. Contact: [email protected] or [email protected] Supplementary information: Supplementary data are available at Bioinformatics online. 1 Introduction analysis of steric clashes or hydrophobic interactions, construction of peptides, energy minimization or trajectory analysis. UCSF Chimera is Python is one of the most used programming languages in science writteninbothCþþ and Python and distributed as a stand-alone due to its readability, smooth learning curve and excellent availabil- application that ships its own versions of Python and other packages to ity of packages dedicated to data analysis and numeric computing. achieve a robust, fail-proof behavior in every major platform. A lot of scientific software is being either developed in, converted to Although this ensures that every user will get the same experience no or wrapped under Python, most of the time as open-source projects, matter their system environment, it also creates a barrier for those who which leads to higher reproducibility and collaborative efforts. want to call UCSF Chimera functions from their Python scripts by forc- This is also true in molecular modeling, either for structural biol- ing the user to run it from within UCSF Chimera’s process. ogy, computational chemistry or anything in between like visualization In bigger projects, it can also slow down the development process. tools [PyMol (Sanner, 1999)], protein-ligand docking software For example, configuring an Integrated Development Environment or [AutoDock Vina (Trott and Olson, 2010)], molecular dynamics simu- text editor can represent a real tour de force if you want to use auto- lations [OpenMM (Eastman et al., 2013)] or trajectory analysis completion, automated testing or inline documentation. In addition, [MDTraj (McGibbon et al., 2015)]. UCSF Chimera (Pettersen et al., most modern Python development tools are not distributed by default 2004) is one peculiar project that falls within several categories at the with UCSF Chimera, and installing them with the proper version can same time: a powerful visualization engine that also doubles as a versa- be struggling. For example, latest UCSF Chimera version (1.12) ships tile molecular modeling toolkit thanks to advanced features like multi- its own version of NumPy (van der Walt et al.,2011), but is not format input parsers and output writers, hydrogen bonds detection, V The Author(s) 2018. Published by Oxford University Press. All rights reserved. For Permissions, please e-mail: [email protected] 1784 PyChimera 1785 updated (v1.7.2, released in 2013) and causes compatibility problems 3.1.1 IPython and Jupyter notebook integrations with modern data analysis packages like Scipy. By enhancing the native Python interpreter with additional inter- Here, we present PyChimera, a Python project built to evade the active features, IPython (Perez and Granger, 2007) has obtained a limitations of UCSF Chimera’s isolated framework and use it under golden place in development environments. Its success also led to any Python 2.7 interpreter. This contributes to increasing the pos- the creation of IPython Notebooks, later renamed as Jupyter ition of UCSF Chimera in the Python scientific ecosystem and should Notebooks, which wrap a web-based interface around a running allow the rapid development of new applications and proof-of- Python process, allowing the display of dynamic content (plots, concept ideas for molecular modeling tools. images, animations or even molecular visualizations) with JavaScript. To take advantage of these useful resources, two subcommands are included: pychimera ipython and pychimera notebook. The first 2 Materials and methods subcommand will launch a patched IPython instance, while the se- UCSF Chimera isolation works by modifying several environment cond will launch a Jupyter server that will pre-populate notebooks variables with its own pre-launcher. After patching the environment, with a cell that gives support for all UCSF Chimera modules and the pre-launcher will find and use UCSF Chimera’s own Python in- visualization tools not originally available in UCSF Chimera: (1) a terpreter, neglecting the existence of any other system distribution, wrapper around NGL Viewer (Rose and Hildebrand, 2015) to pre- to run the initialization code. view molecules loaded with the UCSF Chimera parsers, and (2) a PyChimera code is written in Python to mimic this patch-and- WebGL 3D model of the canvas. USCF Chimera commands can launch scheme. First, PyChimera will try to find the installation path also be run directly with the call %chimera_run. of UCSF Chimera with several alternative strategies: (1) Check if the PyChimera is opening new horizons for the development of pro- environment variable $CHIMERADIR has been defined by the user, jects that benefit from UCSF Chimera as a dependency. Combined (2) try to locate the chimera binary in the directories listed under with a package manager like pip or conda, using UCSF Chimera $PATH and (3) search the default locations for the platform in use along the scientific Python stack is no longer a problem. In fact, for directories that contain the name ‘chimera’ and find the chimera PyChimera was born during the development of GaudiMM executable under the bin subdirectory. After finding a valid UCSF (Rodrı ´guez-Guerra Pedregal et al., 2017) and we can only hope that Chimera installation, PyChimera will modify the library paths and this small but powerful tool will also help other researchers to use other environment variables to include both the modifications that UCSF Chimera in custom scripts or applications. the initialization code is expecting, and the ones given by the current user execution environment. This strategy allows to install new packages in a virtual environment and then use them together with Acknowledgements UCSF Chimera’s own packages in any software project. To make The authors want to thank the UCSF Chimera’s team, and more particularly the changes available to the running Python interpreter, the new en- Greg Couch, for the ideas and inputs on the chimera-dev mailing list. vironment is injected through an os.execve call that will restart the process in situ. After the restart, UCSF Chimera initialization rou- tines (chimeraInit.init) can be executed normally. Funding The authors are thankful for the support given by the Spanish MINECO (project CTQ2014-54071-P) and the Generalitat de Catalunya (project 2014SGR989). 3 Results Support of COST Action CM1306 is kindly acknowledged. Research grant to JRGP (Generalitat de Catalunya, 2017FI_B2_00168) is acknowledged. PyChimera is distributed as a command line application with sup- port for major Linux distributions (tested on Ubuntu 14.04, CentOS Conflict of Interest: none declared. 6, Arch Linux), Mac OS X (tested on 10.11 and 10.12), and Windows 7þ, with UCSF Chimera 1.10þ. For PyChimera to work, UCSF Chimera must be installed before-hand. The PyChimera in- References stallation itself can be performed with the same command in the Eastman,P. et al. (2013) OpenMM 4: a reusable, extensible, hardware inde- three platforms: pip install pychimera. The only drawback is that, pendent library for high performance molecular simulation. J. Chem. since UCSF Chimera uses Python 2.7, PyChimera will only run from Theory Comput., 9, 461–469. a Python 2.7 interpreter. Virtual or conda environments are recom- McGibbon,R.T. et al. (2015) MDTraj: a modern open library for the analysis mended to solve compatibility problems. The installation procedure of molecular dynamics trajectories. Biophys. J., 109, 1528–1532. Perez,F. and Granger,B.E. (2007) IPython: a system for interactive scientific is detailed in the accompanying Supplementary Material. computing. Comput. Sci. Eng., 9, 21–29. Pettersen,E.F. et al. (2004) UCSF Chimera–a visualization system for explora- 3.1 Usage tory research and analysis. J. Comput. Chem., 25, 1605–1612. Rodrı ´guez-Guerra Pedregal,J. et al. (2017) GaudiMM: a modular multi-objective Running pychimera in the terminal will launch system’s Python in- platform for molecular modeling. J. Comput. Chem., 38, 2118–2126. terpreter with the ability to import any UCSF Chimera module. This Rose,A.S., and Hildebrand,P.W. (2015) NGL Viewer: a web application for command also supports some of the standard interpreter flags, like molecular visualization. Nucleic Acids Res., 43, W576–W579. -m to run a module or -c to run a single line of code. A --gui flag is Sanner,M.F. (1999) Python: a programming language for software integration also available, which will launch a patched UCSF Chimera with and development. J. Mol. Graph. Model., 17, 57–61. graphic interface. This can be useful to use extensions that depend Trott,O. and Olson,A.J. (2010) AutoDock Vina: improving the speed and ac- on third-party packages not available in the UCSF Chimera distribu- curacy of docking with a new scoring function, efficient optimization, and tion. PyChimera can also be used to run normal Python scripts dir- multithreading. J. Comput. Chem., 31, 455–461. ectly, especially if they rely on any UCSF Chimera module. The van der Walt,S. et al. (2011) The NumPy array: a structure for efficient numer- syntax is straightforward: pychimera script.py. ical computation. Comput. Sci. Eng., 13, 22–30. http://www.deepdyve.com/assets/images/DeepDyve-Logo-lg.png Bioinformatics Oxford University Press

PyChimera: use UCSF Chimera modules in any Python 2.7 project

Loading next page...
 
/lp/ou_press/pychimera-use-ucsf-chimera-modules-in-any-python-2-7-project-jZ9a4dPrVg

References (10)

Publisher
Oxford University Press
Copyright
© The Author(s) 2018. Published by Oxford University Press. All rights reserved. For Permissions, please e-mail: [email protected]
ISSN
1367-4803
eISSN
1460-2059
DOI
10.1093/bioinformatics/bty021
Publisher site
See Article on Publisher Site

Abstract

Motivation: UCSF Chimera is a powerful visualization tool remarkably present in the computational chemistry and structural biology communities. Built on a Cþþ core wrapped under a Python 2.7 environment, one could expect to easily import UCSF Chimera’s arsenal of resources in custom scripts or software projects. Nonetheless, this is not readily possible if the script is not executed within UCSF Chimera due to the isolation of the platform. UCSF ChimeraX, successor to the original Chimera, partially solves the problem but yet major upgrades need to be undergone so that this updated version can offer all UCSF Chimera features. Results: PyChimera has been developed to overcome these limitations and provide access to the UCSF Chimera codebase from any Python 2.7 interpreter, including interactive programming with tools like IPython and Jupyter Notebooks, making it easier to use with additional third-party software. Availability and implementation: PyChimera is LGPL-licensed and available at https://github.com/ insilichem/pychimera. Contact: [email protected] or [email protected] Supplementary information: Supplementary data are available at Bioinformatics online. 1 Introduction analysis of steric clashes or hydrophobic interactions, construction of peptides, energy minimization or trajectory analysis. UCSF Chimera is Python is one of the most used programming languages in science writteninbothCþþ and Python and distributed as a stand-alone due to its readability, smooth learning curve and excellent availabil- application that ships its own versions of Python and other packages to ity of packages dedicated to data analysis and numeric computing. achieve a robust, fail-proof behavior in every major platform. A lot of scientific software is being either developed in, converted to Although this ensures that every user will get the same experience no or wrapped under Python, most of the time as open-source projects, matter their system environment, it also creates a barrier for those who which leads to higher reproducibility and collaborative efforts. want to call UCSF Chimera functions from their Python scripts by forc- This is also true in molecular modeling, either for structural biol- ing the user to run it from within UCSF Chimera’s process. ogy, computational chemistry or anything in between like visualization In bigger projects, it can also slow down the development process. tools [PyMol (Sanner, 1999)], protein-ligand docking software For example, configuring an Integrated Development Environment or [AutoDock Vina (Trott and Olson, 2010)], molecular dynamics simu- text editor can represent a real tour de force if you want to use auto- lations [OpenMM (Eastman et al., 2013)] or trajectory analysis completion, automated testing or inline documentation. In addition, [MDTraj (McGibbon et al., 2015)]. UCSF Chimera (Pettersen et al., most modern Python development tools are not distributed by default 2004) is one peculiar project that falls within several categories at the with UCSF Chimera, and installing them with the proper version can same time: a powerful visualization engine that also doubles as a versa- be struggling. For example, latest UCSF Chimera version (1.12) ships tile molecular modeling toolkit thanks to advanced features like multi- its own version of NumPy (van der Walt et al.,2011), but is not format input parsers and output writers, hydrogen bonds detection, V The Author(s) 2018. Published by Oxford University Press. All rights reserved. For Permissions, please e-mail: [email protected] 1784 PyChimera 1785 updated (v1.7.2, released in 2013) and causes compatibility problems 3.1.1 IPython and Jupyter notebook integrations with modern data analysis packages like Scipy. By enhancing the native Python interpreter with additional inter- Here, we present PyChimera, a Python project built to evade the active features, IPython (Perez and Granger, 2007) has obtained a limitations of UCSF Chimera’s isolated framework and use it under golden place in development environments. Its success also led to any Python 2.7 interpreter. This contributes to increasing the pos- the creation of IPython Notebooks, later renamed as Jupyter ition of UCSF Chimera in the Python scientific ecosystem and should Notebooks, which wrap a web-based interface around a running allow the rapid development of new applications and proof-of- Python process, allowing the display of dynamic content (plots, concept ideas for molecular modeling tools. images, animations or even molecular visualizations) with JavaScript. To take advantage of these useful resources, two subcommands are included: pychimera ipython and pychimera notebook. The first 2 Materials and methods subcommand will launch a patched IPython instance, while the se- UCSF Chimera isolation works by modifying several environment cond will launch a Jupyter server that will pre-populate notebooks variables with its own pre-launcher. After patching the environment, with a cell that gives support for all UCSF Chimera modules and the pre-launcher will find and use UCSF Chimera’s own Python in- visualization tools not originally available in UCSF Chimera: (1) a terpreter, neglecting the existence of any other system distribution, wrapper around NGL Viewer (Rose and Hildebrand, 2015) to pre- to run the initialization code. view molecules loaded with the UCSF Chimera parsers, and (2) a PyChimera code is written in Python to mimic this patch-and- WebGL 3D model of the canvas. USCF Chimera commands can launch scheme. First, PyChimera will try to find the installation path also be run directly with the call %chimera_run. of UCSF Chimera with several alternative strategies: (1) Check if the PyChimera is opening new horizons for the development of pro- environment variable $CHIMERADIR has been defined by the user, jects that benefit from UCSF Chimera as a dependency. Combined (2) try to locate the chimera binary in the directories listed under with a package manager like pip or conda, using UCSF Chimera $PATH and (3) search the default locations for the platform in use along the scientific Python stack is no longer a problem. In fact, for directories that contain the name ‘chimera’ and find the chimera PyChimera was born during the development of GaudiMM executable under the bin subdirectory. After finding a valid UCSF (Rodrı ´guez-Guerra Pedregal et al., 2017) and we can only hope that Chimera installation, PyChimera will modify the library paths and this small but powerful tool will also help other researchers to use other environment variables to include both the modifications that UCSF Chimera in custom scripts or applications. the initialization code is expecting, and the ones given by the current user execution environment. This strategy allows to install new packages in a virtual environment and then use them together with Acknowledgements UCSF Chimera’s own packages in any software project. To make The authors want to thank the UCSF Chimera’s team, and more particularly the changes available to the running Python interpreter, the new en- Greg Couch, for the ideas and inputs on the chimera-dev mailing list. vironment is injected through an os.execve call that will restart the process in situ. After the restart, UCSF Chimera initialization rou- tines (chimeraInit.init) can be executed normally. Funding The authors are thankful for the support given by the Spanish MINECO (project CTQ2014-54071-P) and the Generalitat de Catalunya (project 2014SGR989). 3 Results Support of COST Action CM1306 is kindly acknowledged. Research grant to JRGP (Generalitat de Catalunya, 2017FI_B2_00168) is acknowledged. PyChimera is distributed as a command line application with sup- port for major Linux distributions (tested on Ubuntu 14.04, CentOS Conflict of Interest: none declared. 6, Arch Linux), Mac OS X (tested on 10.11 and 10.12), and Windows 7þ, with UCSF Chimera 1.10þ. For PyChimera to work, UCSF Chimera must be installed before-hand. The PyChimera in- References stallation itself can be performed with the same command in the Eastman,P. et al. (2013) OpenMM 4: a reusable, extensible, hardware inde- three platforms: pip install pychimera. The only drawback is that, pendent library for high performance molecular simulation. J. Chem. since UCSF Chimera uses Python 2.7, PyChimera will only run from Theory Comput., 9, 461–469. a Python 2.7 interpreter. Virtual or conda environments are recom- McGibbon,R.T. et al. (2015) MDTraj: a modern open library for the analysis mended to solve compatibility problems. The installation procedure of molecular dynamics trajectories. Biophys. J., 109, 1528–1532. Perez,F. and Granger,B.E. (2007) IPython: a system for interactive scientific is detailed in the accompanying Supplementary Material. computing. Comput. Sci. Eng., 9, 21–29. Pettersen,E.F. et al. (2004) UCSF Chimera–a visualization system for explora- 3.1 Usage tory research and analysis. J. Comput. Chem., 25, 1605–1612. Rodrı ´guez-Guerra Pedregal,J. et al. (2017) GaudiMM: a modular multi-objective Running pychimera in the terminal will launch system’s Python in- platform for molecular modeling. J. Comput. Chem., 38, 2118–2126. terpreter with the ability to import any UCSF Chimera module. This Rose,A.S., and Hildebrand,P.W. (2015) NGL Viewer: a web application for command also supports some of the standard interpreter flags, like molecular visualization. Nucleic Acids Res., 43, W576–W579. -m to run a module or -c to run a single line of code. A --gui flag is Sanner,M.F. (1999) Python: a programming language for software integration also available, which will launch a patched UCSF Chimera with and development. J. Mol. Graph. Model., 17, 57–61. graphic interface. This can be useful to use extensions that depend Trott,O. and Olson,A.J. (2010) AutoDock Vina: improving the speed and ac- on third-party packages not available in the UCSF Chimera distribu- curacy of docking with a new scoring function, efficient optimization, and tion. PyChimera can also be used to run normal Python scripts dir- multithreading. J. Comput. Chem., 31, 455–461. ectly, especially if they rely on any UCSF Chimera module. The van der Walt,S. et al. (2011) The NumPy array: a structure for efficient numer- syntax is straightforward: pychimera script.py. ical computation. Comput. Sci. Eng., 13, 22–30.

Journal

BioinformaticsOxford University Press

Published: Jan 11, 2018

There are no references for this article.