Python API for Materials Science Part 1: Working with Molecules
Tutorial Created with Software Release: 2024-2
Topics: Catalysis & Reactivity , Consumer Packaged Goods , Energy Capture & Storage , Informatics and Team Collaboration , Metals, Alloys & Ceramics , Organic Electronics , Pharmaceutical Formulations , Polymeric Materials
Methodology: All-Atom Molecular Dynamics , Coarse-Grained Modeling , Machine Learning , Molecular Quantum Mechanics , Periodic Quantum Mechanics
|
1.2 MB |
This tutorial is written for use with a 3-button mouse with a scroll wheel.
Abstract:
In this tutorial, we will introduce the Python API for materials science. In this first part of a series, we will use a Jupyter Notebook to get acquainted with the Python API documentation, learn some of the typical modules and perform exercises for an introduction to working with molecules. This document includes only the instructions for launching the Jupyter Notebook. Depending on your operating system, please follow the associated instructions.
Tutorial Content
1. Prerequisites
This tutorial is entirely self-contained in a Jupyter notebook with instructions for launching on different operating systems below.
Before beginning, we recommend that users interested in this tutorial have a:
- Basic understanding of Python
- Basic understanding of Schrödinger Materials Science Maestro and its capabilities (various materials science tutorials can be accessed from the Introduction to Maestro for Materials Science tutorial)
- Download of the Schrödinger suite on their computer (release 2021-2 or later)
Note: The instructions provided herein for launching the Jupyter Notebook are specific to this tutorial. For general Jupyter Notebook instructions and use, visit Project Jupyter.
2. Accessing the Jupyter Notebook from Mac or Linux
This tutorial is taught and executed in full in a Jupyter Notebook. The steps herein outline how to access the notebook on a Mac or Linux operating system.
- Using the following link: schrodinger.com/sites/default/files/s3/release/current/Tutorials/zip/python_api_part1.zip, download python_api_part1.zip to your Desktop or another easy to find location and unzip the file
- A directory called Python_API_Part1 containing several files is now on your local system
Figure 2-2. Navigating to the Python_API_Part1 directory (version 2021-3 is shown in the figure, but you should use any version 2021-2 or later).
- Open the terminal
-
Prepare your Schrödinger environment variable by running
export SCHRODINGER=/opt/schrodinger/suites2024-2/
- This will set an environment variable tied to the Schrödinger suite installation
- This tutorial requires version 2021-2 or later (adjust suites* in the export command so as to match your version), you can adjust the version number for the software version you have installed
- If your installation is not in the default location, you will need to adjust the command accordingly
Note: If you are using csh/tcsh instead of bash/sh/zsh, please see the help documentation for setting environment variables
-
In your terminal, navigate in to the unzipped Python_API_Part1 directory
- The command in Figure 2-2 may not match exactly depending on where you placed the directory
- If you are unfamiliar with navigating directories in the terminal, see here
- To confirm you are in the correct directory, run ls and make sure you see the same files shown in Figure 2-2
You are now ready to launch the Notebook. It is possible to optionally include a Jupyter Notebook add-on to view a Table of Contents for ease of navigation. If you’d like to set this up, jump down to Section 4 before launching the notebook.
-
To launch the Jupyter Notebook, run
$SCHRODINGER/run jupyter notebook Python_API_Part1.ipynb
- The notebook will launch in your browser
Note: If you performed the steps in the addendum (Section 4), a Table of Contents should appear. If not, click the Table of Contents button (
) in the Jupyter Notebook toolbar
The rest of the information and instructions associated with the tutorial are found in the Jupyter Notebook. If you need to quit the notebook, close the window in your browser, and back in the terminal, type Ctrl+C twice to exit.
- To relaunch the notebook, simply repeat Step 5.
3. Accessing the Jupyter Notebook from Windows
This tutorial is taught and executed in full in a Jupyter Notebook. The steps herein outline how to access the notebook on a Windows operating system.
- Using the following link: schrodinger.com/sites/default/files/s3/release/current/Tutorials/zip/python_api_part1.zip, download python_api_part1.zip to your Documents\Schrodinger directory or another easy to find location and unzip the file
- A directory called Python_API_Part1 containing several files is now on your local system
- From the Start menu (the windows icon) go to your apps. Within apps, go to the Schrodinger folder associated with your latest installation and launch Schrodinger Power Shell
Note: This tutorial requires version 2021-2 or later
Note: The Power Shell can also be found by searching in the search box accessible from the Start menu.
- In your Power Shell, navigate into the unzipped Python_API_Part1 directory
- The command in Figure 3-2 may not match exactly depending on where you placed the directory
- If you are unfamiliar with navigating directories in the Power Shell, see here
- To confirm you are in the correct directory, run ls and make sure you see the same files shown in Figure 3-2
-
To launch the Jupyter Notebook, run
run jupyter notebook Python_API_Part1.ipynb
- The notebook will launch in your browser
The rest of the information and instructions associated with the tutorial are found in the Jupyter Notebook. If you need to quit the notebook, close the window in your browser, and back in the terminal, type Ctrl+C twice to exit.
- To relaunch the notebook, simply repeat Step 4.
4. Optional: Table of Contents Add-On for Mac or Linux
Follow these optional steps if you would like to add the Table of Contents add-on on Mac or Linux. This involves setting up a Schrödinger virtual environment, which requires using the bash/sh/zsh. Other shells such as csh/tcsh are not supported at the moment.
These steps will set up a Table of Contents add-on in the Jupyter Notebook. This is not requisite, so feel free to proceed to Section 2 Step 5 above if you prefer to just launch the notebook.
-
Run
$SCHRODINGER/run schrodinger_virtualenv.py Tutorial_venv
- This will create an isolated Python environment called Tutorial_venv for working on the tutorial
-
Activate the virtual environment by running
source Tutorial_venv/bin/activate
-
Run
source env.config
-
Run
make
- This activates the Table of Contents in the Jupyter Notebook
- Several automated processes will occur in the terminal
Note: A “validation: OK” message should indicate that the setup was performed successfully. Otherwise, confirm that you followed the previous steps exactly or simply proceed to Section 2 Step 5 and launch the tutorial without the Table of Contents. You can contact online-learning-materials@schrodinger.com for help.