### Import molli and pyvista, start xvfb Source: https://molli.readthedocs.io/en/latest/cookbook/011-gbca.html Imports the necessary libraries and starts an X virtual framebuffer for display. Ensure pyvista is installed separately. ```python # Import the necessary packages import molli as ml import pyvista as pv #This is currently being run on a virtual server and needs a separate server for display via pyvista pv.start_xvfb() ``` -------------------------------- ### Install Molli from Source (with Egg) Source: https://molli.readthedocs.io/en/latest/01-molli-preamble.html Install Molli from its GitHub repository, specifying the egg name. ```bash pip install -e git+https://github.com/SEDenmarkLab/molli.git#egg=molli ``` -------------------------------- ### Install Molli from Source (Direct) Source: https://molli.readthedocs.io/en/latest/01-molli-preamble.html Install Molli directly from its GitHub repository using pip. ```bash pip install git+https://github.com/SEDenmarkLab/molli.git ``` -------------------------------- ### Verify Molli Installation Source: https://molli.readthedocs.io/en/latest/01-molli-preamble.html Run these commands after installation to check the Molli version and execute the test suite. ```bash molli --VERSION molli test -vv ``` -------------------------------- ### Generate a Simple Molecule Source: https://molli.readthedocs.io/en/latest/_sources/cookbook/008-chemdraw.ipynb.txt Creates a basic chemical structure for ethanol. This is a fundamental example for starting with molecule generation. ```python from openbabel import openbabel ob = openbabel.OBMol() # Create a molecule of ethanol ob.SetFormula("C2H5OH") # You can also set properties like IUPAC name, SMILES, etc. ob.SetIUPACName("ethanol") # Convert to a format that can be visualized # For example, to SMILES smi = openbabel.OBConversion() smi.SetOutFormat("smi") smiles_string = smi.WriteString(ob) print(f"Ethanol SMILES: {smiles_string}") ``` -------------------------------- ### Editable Installation of Molli Source: https://molli.readthedocs.io/en/latest/01-molli-preamble.html Perform an editable installation of Molli from a local clone of the repository, optimized for development. ```bash pip install -e molli/ --config-settings editable_mode=compat ``` -------------------------------- ### Basic ChemDraw Setup Source: https://molli.readthedocs.io/en/latest/_sources/cookbook/008-chemdraw.ipynb.txt Initializes ChemDraw and sets up the drawing environment. This is a foundational step for most ChemDraw operations. ```python from molli.chem import ChemDraw draw = ChemDraw() draw.setup() ``` -------------------------------- ### Install Molli from PyPI Source: https://molli.readthedocs.io/en/latest/01-molli-preamble.html Use this command to install the latest Molli package from the Python Package Index. ```bash pip install molli ``` -------------------------------- ### Load CDXML File Source: https://molli.readthedocs.io/en/latest/_sources/cookbook/008-chemdraw.ipynb.txt Loads an example CDXML file named 'parser_demo.cdxml' using Molli's CDXMLFile class. This file is designed to include boundary cases and demonstrate parsing capabilities. ```python cdxf = ml.CDXMLFile(ml.files.parser_demo_cdxml) ``` -------------------------------- ### Load 3Dmol.js and Initialize Viewer Source: https://molli.readthedocs.io/en/latest/_sources/cookbook/008-chemdraw.ipynb.txt Loads the 3Dmol.js library asynchronously and initializes a viewer instance. This is the primary setup for displaying molecular structures. ```javascript var loadScriptAsync = function(uri){ return new Promise((resolve, reject) => { //this is to ignore the existence of requirejs amd var savedexports, savedmodule; if (typeof exports !== 'undefined') savedexports = exports; else exports = {} if (typeof module !== 'undefined') savedmodule = module; else module = {} var tag = document.createElement('script'); tag.src = uri; tag.async = true; tag.onload = () => { exports = savedexports; module = savedmodule; resolve(); }; var firstScriptTag = document.getElementsByTagName('script')[0]; firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); }); }; if(typeof $3Dmolpromise === 'undefined') { $3Dmolpromise = null; $3Dmolpromise = loadScriptAsync('https://cdnjs.cloudflare.com/ajax/libs/3Dmol/2.0.4/3Dmol-min.js'); } var viewer_17295271057526786 = null; var warn = document.getElementById("3dmolwarning_17295271057526786"); if(warn) { warn.parentNode.removeChild(warn); } $3Dmolpromise.then(function() { viewer_17295271057526786 = $3Dmol.createViewer(document.getElementById("3dmolviewer_17295271057526786"),{backgroundColor:"white"}); viewer_17295271057526786.zoomTo(); ``` -------------------------------- ### Load and Display Chemical Structures with ChemDraw Source: https://molli.readthedocs.io/en/latest/_sources/cookbook/008-chemdraw.ipynb.txt Demonstrates loading chemical structures from a file and displaying them using ChemDraw's visualization capabilities. Ensure ChemDraw is properly installed and configured. ```python from molli.chem import ChemDraw from pathlib import Path # Assuming 'path/to/your/molecule.sdf' is a valid path to a chemical file file_path = Path('path/to/your/molecule.sdf') # Create a ChemDraw instance cd = ChemDraw() # Load the molecule from the file cd.load(file_path) # Display the molecule (this might open a viewer or render an image depending on the environment) cd.show() ``` -------------------------------- ### Perform Calculations with ChemDraw Data Source: https://molli.readthedocs.io/en/latest/_sources/cookbook/008-chemdraw.ipynb.txt Calculates properties for molecules loaded from ChemDraw. This example shows a simple energy calculation. ```python from molli.chem.chemdraw import ChemDraw from molli.chem.calculators import MMFF94 cd = ChemDraw("path/to/your/file.cdx") mol = cd.molecules[0] calc = MMFF94() calc.calculate(mol) ``` -------------------------------- ### Initialize BOX Client Source: https://molli.readthedocs.io/en/latest/_sources/cookbook/013-BOX_workflow.ipynb.txt Demonstrates how to initialize the BOX client with necessary configurations. Ensure you have the correct API keys and tokens. ```python from boxsdk import Client, OAuth2 # Replace with your actual client ID, client secret, and access token CLIENT_ID = 'YOUR_CLIENT_ID' CLIENT_SECRET = 'YOUR_CLIENT_SECRET' ACCESS_TOKEN = 'YOUR_ACCESS_TOKEN' # Create an OAuth2 object auth = OAuth2( client_id=CLIENT_ID, client_secret=CLIENT_SECRET, access_token=ACCESS_TOKEN, ) # Initialize the BOX client b_client = Client(auth) ``` -------------------------------- ### Install Molli using Conda Source: https://molli.readthedocs.io/en/latest/_sources/01-molli-preamble.md.txt Installs Molli using the conda package manager. Note that conda setup is still under development. ```bash conda install molli ``` -------------------------------- ### Install Molli using Conda Source: https://molli.readthedocs.io/en/latest/01-molli-preamble.html Install the Molli package from a conda repository. Note that conda setup may still be evolving. ```bash conda install molli ``` -------------------------------- ### Getting molecular formula with Promolecule Source: https://molli.readthedocs.io/en/latest/API/molli.chem/atom.html Demonstrates how to get the molecular formula of a molecule using the 'formula' property of the Promolecule class. The example uses Dendrobine. ```python >>> promol = ml.Promolecule(dendrobine) >>> promol.formula C16 H25 N1 O2 ``` -------------------------------- ### Getting attachment points with Promolecule Source: https://molli.readthedocs.io/en/latest/API/molli.chem/atom.html Demonstrates how to get attachment points using the Promolecule class. This example also shows that Dendrobine has no attachment points. ```python >>> promol = ml.Promolecule(dendrobine) >>> generator = promol.get_attachment_points() () #Dendrobine does not have attachment points ``` -------------------------------- ### Initialize ConformerEnsemble from Multi-mol2 File Source: https://molli.readthedocs.io/en/latest/API/molli.chem/ensemble.html Demonstrates initializing a ConformerEnsemble directly from a multi-mol2 file using the load_mol2 class method. ```python >>> ml.ConformerEnsemble.load_mol2(ml.files.pentane_confs_mol2) ConformerEnsemble(name='pentane', formula='C5 H12', n_conformers=7) ``` -------------------------------- ### Adding Reaction Arrows Source: https://molli.readthedocs.io/en/latest/_sources/cookbook/008-chemdraw.ipynb.txt Inserts reaction arrows onto the canvas, typically used in reaction schemes. Specify start and end points. ```python draw.add_reaction_arrow(start_x=0, start_y=0, end_x=1, end_y=0) ``` -------------------------------- ### Read Conformer Library Source: https://molli.readthedocs.io/en/latest/cookbook/006-libraries.html This example demonstrates how to read a ConformerLibrary. It shows instantiation, opening for reading, iterating through library entries, and retrieving ConformerEnsemble objects. The output includes the library's representation and details of a specific entry. ```python #This is the path for an existing ConformerLibrary clib_path = ml.files.cinchonidine_rd_conf #This instantiates the MoleculeLibrary to be read clib = ml.ConformerLibrary(clib_path, overwrite=False, readonly=True) #This reads the MoleculeLibrary with clib.reading(): print(clib) #This iterates through the names in the library for name in clib: #This retrieves the associated ConformerEnsemble Object ens = clib[name] print(f'Here is an example name: {name}') print(f"Here is it's associated ConformerEnsemble object: {ens}") ``` -------------------------------- ### Get Root Folder Source: https://molli.readthedocs.io/en/latest/_sources/cookbook/013-BOX_workflow.ipynb.txt Retrieves the root folder of the BOX account. This is the starting point for navigating the file system. ```python # Get the root folder root_folder = client.root_folder() ``` -------------------------------- ### Create and Access Conformer Source: https://molli.readthedocs.io/en/latest/API/molli.chem/ensemble.html Demonstrates how to load conformers from a mol2 file and access individual conformers. ```python >>> ens = ml.ConformerEnsemble.load_mol2(ml.files.pentane_confs_mol2) >>> ens[0] Conformer(name='pentane', conf_id=0) ``` -------------------------------- ### Add Implicit Hydrogens to Molecule Source: https://molli.readthedocs.io/en/latest/_sources/cookbook/008-chemdraw.ipynb.txt Adds implicit hydrogens to a molecule object. This method provides a reasonable starting point for molecular structures but does not perform optimization. ```python mol.add_implicit_hydrogens() ``` -------------------------------- ### Using Dictionaries for Configuration Source: https://molli.readthedocs.io/en/latest/_sources/cookbook/014-map.ipynb.txt Shows how dictionaries can be used to store configuration settings. This allows for easy access and modification of parameters. ```python config = { "database": { "host": "localhost", "port": 5432, "user": "admin" }, "api_key": "your_secret_key", "debug_mode": True } print(f"Database host: {config['database']['host']}") print(f"Debug mode: {config['debug_mode']}") ``` -------------------------------- ### Get Folder Tree Source: https://molli.readthedocs.io/en/latest/_sources/cookbook/013-BOX_workflow.ipynb.txt Retrieves the entire folder structure (tree) starting from a given folder. Useful for visualizing the hierarchy. ```python root_folder_id = '0' def print_folder_tree(folder_id, indent=0): folder = b_client.folder(folder_id=folder_id).get() print(' ' * indent + f'- {folder.name} (ID: {folder.id})') for item in folder.get_items(): if item.type == 'folder': print_folder_tree(item.id, indent + 1) print_folder_tree(root_folder_id) ``` -------------------------------- ### Get Folder Items with Offset and Filter Source: https://molli.readthedocs.io/en/latest/_sources/cookbook/013-BOX_workflow.ipynb.txt Lists items in a folder starting from a specified offset and filters by item type. ```python # Get files starting from the 15th item offset = 15 files_offset = root_folder.get_items(offset=offset, item_type='file') for file_item in files_offset: print(f"File name: {file_item.name}") ``` -------------------------------- ### ORCA Driver Setup and Equilibrium Structure Optimization Source: https://molli.readthedocs.io/en/latest/zenodo/07-kras-inhibitor-rotation-barrier/rb_w3_opt.html Sets up the ORCA driver with specified cores and memory, then optimizes equilibrium structures from a source library to a destination library. Uses a specific set of ORCA keywords for optimization. ```python # Both the eq and the TS will be optimized here. import molli as ml from molli.pipeline.orca import ORCADriver N_CORES = 32 TOTAL_CORES = 32 # increase for a more powerful machine orca = ORCADriver( "orca", nprocs=N_CORES, memory=N_CORES * 4000, # check_exe=False, # Uncheck for actual production ready calculations # find=False, # Uncheck for actual production ready calculations ) print("=" * 80) print("Optimizing the equilibrium structures (again)", flush=True) source = ml.MoleculeLibrary("rb_eq_fix.mlib", readonly=True) dest = ml.MoleculeLibrary("rb_eq_fix_g1.mlib", readonly=False) ml.pipeline.jobmap( orca.basic_calc_m, source=source, destination=dest, cache_dir="_orca_eq_opt2", n_workers=TOTAL_CORES // N_CORES, kwargs={"keywords": "rks b97-3c tightopt freq miniprint noprintmos"}, strict_hash=False, log_level="debug", ) ``` -------------------------------- ### Run ASO Calculation Source: https://molli.readthedocs.io/en/latest/cookbook/011-gbca.html Example of running an Average Steric Occupancy (ASO) calculation from the command line. Specify the input conformer library, output file, and grid file. ```bash molli gbca aso example.clib -o example_aso.hdf5 -g example_grid.hdf5 -n 16 ``` -------------------------------- ### Getting molecular formula with Molecule Source: https://molli.readthedocs.io/en/latest/API/molli.chem/atom.html Retrieves the molecular formula of a molecule using the 'formula' property. The example uses Dendrobine. ```python >>> dendrobine = ml.Molecule.load_mol2(ml.files.dendrobine_mol2) >>> dendrobine.formula C16 H25 N1 O2 ``` -------------------------------- ### Get Folder Items with Offset, Sort, and Filter Source: https://molli.readthedocs.io/en/latest/_sources/cookbook/013-BOX_workflow.ipynb.txt Lists items in a folder starting from an offset, sorting, and filtering by item type. ```python # Get folders starting from the 10th, sorted by name offset = 10 sorted_folders_offset = root_folder.get_items(offset=offset, sort='name', direction='ASC', item_type='folder') for folder_item in sorted_folders_offset: print(f"Folder name: {folder_item.name}") ``` -------------------------------- ### Initialize Molli Conformer Library and Load Ensembles Source: https://molli.readthedocs.io/en/latest/zenodo/004-readwrite.html Initializes a Molli ConformerLibrary and loads all ensembles into memory for subsequent writing speed tests. This setup ensures that only writing performance is measured. ```python # This script is to show the process of timing measurement import molli as ml import timeit N = 3 # ml.aux.assert_molli_version_min("1.0.0b2") _clib = ml.ConformerLibrary("bpa_aligned.clib") # Loading all ensembles into memory # So that we are only testing the writing speeds with _clib.reading(): ensembles = {k: v for k, v in _clib.items()} ``` -------------------------------- ### Getting attachment points with Molecule Source: https://molli.readthedocs.io/en/latest/API/molli.chem/atom.html Retrieves the attachment points of a molecule using the get_attachment_points() method. Dendrobine is used as an example, which has no attachment points. ```python >>> dendrobine = ml.Molecule.load_mol2(ml.files.dendrobine_mol2) >>> generator = dendrobine.get_attachment_points() () #Dendrobine does not have attachment points ``` -------------------------------- ### Yielding atoms by label with Molecule Source: https://molli.readthedocs.io/en/latest/API/molli.chem/atom.html Shows how to get a generator of atoms based on their labels using the Molecule class. This example yields atoms labeled 'H'. ```python >>> dendrobine = ml.Molecule.load_mol2(ml.files.dendrobine_mol2) >>> generator = dendrobine.yield_atoms_by_label("H") ``` -------------------------------- ### Initialize Conformer Library for Timing Source: https://molli.readthedocs.io/en/latest/_sources/zenodo/004-readwrite.ipynb.txt Loads a ConformerLibrary and all its ensembles into memory to isolate writing speed measurements. This setup ensures that only the writing process is timed. ```python # This script is to show the process of timing measurement import molli as ml import timeit N = 3 # ml.aux.assert_molli_version_min("1.0.0b2") _clib = ml.ConformerLibrary("bpa_aligned.clib") # Loading all ensembles into memory # So that we are only testing the writing speeds with _clib.reading(): ensembles = {k: v for k, v in _clib.items()} ``` -------------------------------- ### Initialize ConformerEnsemble from List of Molecules Source: https://molli.readthedocs.io/en/latest/API/molli.chem/ensemble.html Shows how to create a ConformerEnsemble by first loading molecules into a list and then passing that list to the ConformerEnsemble constructor. ```python >>> mol_list = ml.Molecule.load_all_mol2(ml.files.pentane_confs_mol2) >>> ml.ConformerEnsemble(mol_list) ConformerEnsemble(name='pentane', formula='C5 H12', n_conformers=7) ``` -------------------------------- ### Get Folder Items with Limit and Offset Source: https://molli.readthedocs.io/en/latest/_sources/cookbook/013-BOX_workflow.ipynb.txt Lists items in a folder with pagination. Use 'limit' to set the number of items per page and 'offset' to specify the starting point. ```python # List items in the root folder, retrieving 10 items starting from the 20th item limit = 10 offset = 20 items = root_folder.get_items(limit=limit, offset=offset) for item in items: print(f"Item name: {item.name}") ``` -------------------------------- ### Accessing n_attachment_points in Molecule Source: https://molli.readthedocs.io/en/latest/API/molli.chem/atom.html Illustrates how to get the number of attachment points using the n_attachment_points property on a Molecule object. The example shows that the dendrobine molecule has zero attachment points. ```python >>> dendrobine = ml.Molecule.load_mol2(ml.files.dendrobine_mol2) >>> dendrobine.n_attachment_points 0 #There are no attachment points in the dendrobine file ``` -------------------------------- ### Initialize Crest Driver for Conformer Generation Source: https://molli.readthedocs.io/en/latest/zenodo/08-workflow-nmr-prediction/workflow.html Sets up the CrestDriver for conformer generation. `check_exe` and `find` are set to False for repeating workflows. ```python import molli as ml from molli.pipeline.crest import CrestDriver from molli.pipeline.orca import ORCADriver source = ml.MoleculeLibrary("cladosporin_g1.mlib", readonly=True) confs_gff = ml.ConformerLibrary("cladosporin_g2.clib", readonly=False) confs_gfn2 = ml.ConformerLibrary("cladosporin_g3.clib", readonly=False) crest = CrestDriver( "crest", nprocs=32, check_exe=False, # this is only to repeat the workflows find=False, # This is only to repeat the workflows ) print("Running conformer generation with:", crest.executable, crest.nprocs) print("debug: nprocs", crest.conformer_search.nprocs) ``` -------------------------------- ### Create a BigQuery Table Source: https://molli.readthedocs.io/en/latest/_sources/cookbook/011-gbca.ipynb.txt Illustrates how to create a new table in BigQuery with a specified schema. This is useful for setting up tables before loading data. ```Python from google.cloud import bigquery client = bigquery.Client() # TODO(developer): Construct a BigQuery client object. # client = bigquery.Client(project='your-project-id') # TODO(developer): Set table_id to the ID of the table to create. table_id = "your-project.your_dataset.your_table" table = bigquery.Table(table_id) table.schema = ( bigquery.SchemaField("name", "STRING", mode="REQUIRED"), bigquery.SchemaField("age", "INTEGER", mode="REQUIRED"), bigquery.SchemaField("city", "STRING", mode="NULLABLE"), ) table = client.create_table(table) print(f"Created table {table.project}.{table.dataset_id}.{table.table_id}") ``` -------------------------------- ### Accessing the n_atoms property of Molecule Source: https://molli.readthedocs.io/en/latest/API/molli.chem/atom.html Demonstrates how to get the total count of atoms in a Molecule instance using the 'n_atoms' property. The example shows that the dendrobine molecule contains 44 atoms. ```python >>> dendrobine = ml.Molecule.load_mol2(ml.files.dendrobine_mol2) >>> dendrobine.n_atoms 44 ``` -------------------------------- ### Accessing the elements property of Molecule Source: https://molli.readthedocs.io/en/latest/API/molli.chem/atom.html Shows how to retrieve an ordered list of elements present in a Molecule instance via the 'elements' property. The example output displays a sequence of elements starting with Nitrogen and Carbon. ```python >>> dendrobine = ml.Molecule.load_mol2(ml.files.dendrobine_mol2) >>> dendrobine.elements [N, C, C, C, C, ...] ``` -------------------------------- ### Go Map Declaration and Usage Source: https://molli.readthedocs.io/en/latest/_sources/cookbook/014-map.ipynb.txt Illustrates how to declare, initialize, and use a map in Go. Maps are reference types and must be initialized before use. ```go package main import "fmt" func main() { // Declare and initialize a map userAges := make(map[string]int) userAges["Alice"] = 30 userAges["Bob"] = 25 // Accessing values fmt.Println("Alice's age:", userAges["Alice"]) // Checking for key existence age, ok := userAges["Charlie"] if !ok { fmt.Println("Charlie not found") } // Adding a new entry userAges["Charlie"] = 35 fmt.Println("Charlie's age:", userAges["Charlie"]) fmt.Println("All ages:", userAges) } ``` -------------------------------- ### Import Packages and Load Molecule Source: https://molli.readthedocs.io/en/latest/_sources/cookbook/003-bond.ipynb.txt Imports necessary molli packages and asserts the minimum version. Loads the benzene molecule for demonstration. ```python import molli as ml ml.aux.assert_molli_version_min("1.0a") #Loads in the dendrobine molecule mol = ml.load(ml.files.benzene_mol2) ``` -------------------------------- ### Load and Visualize Molecular Data with 3Dmol.js Source: https://molli.readthedocs.io/en/latest/_sources/zenodo/003-buildlibrary.ipynb.txt This snippet loads a molecular structure from a string (in PDB format) and visualizes it using 3Dmol.js. It includes setup for asynchronous script loading, viewer creation, styling, hover effects, and background rendering. It also provides a warning for JupyterLab users to install the necessary extension. ```javascript var loadScriptAsync = function(uri){ return new Promise((resolve, reject) => { //this is to ignore the existence of requirejs amd var savedexports, savedmodule; if (typeof exports !== 'undefined') savedexports = exports; else exports = {} if (typeof module !== 'undefined') savedmodule = module; else module = {} var tag = document.createElement('script'); tag.src = uri; tag.async = true; tag.onload = () => { exports = savedexports; module = savedmodule; resolve(); }; var firstScriptTag = document.getElementsByTagName('script')[0]; firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); }); }; if(typeof $3Dmolpromise === 'undefined') { $3Dmolpromise = null; $3Dmolpromise = loadScriptAsync('https://cdnjs.cloudflare.com/ajax/libs/3Dmol/2.0.4/3Dmol-min.js'); } var viewer_17296129342946353 = null; var warn = document.getElementById("3dmolwarning_17296129342946353"); if(warn) { warn.parentNode.removeChild(warn); } $3Dmolpromise.then(function() { viewer_17296129342946353 = $3Dmol.createViewer(document.getElementById("3dmolviewer_17296129342946353"),{backgroundColor:"white"}); viewer_17296129342946353.zoomTo(); viewer_17296129342946353.addModel("@MOLECULE\nP_15_17_14\n44 46 0 0 0\nSMALL\nNO_CHARGES\n\n@ATOM\n1 P 0.2007 0.0338 0.0946 P\n2 None -1.2758 2.3979 0.3119 C\n3 None -0.0207 1.8203 0.5387 C\n4 None 1.0124 2.6152 1.0611 C\n5 None 0.7840 3.9601 1.3647 C\n6 None -0.4767 4.5376 1.1466 C\n7 None -1.5066 3.7427 0.6139 C\n8 None -0.6920 5.9920 1.4818 C\n9 None 0.1840 6.7686 0.7452 F\n10 None -1.9850 6.3973 1.1990 F\n11 None -0.4514 6.1941 2.8286 F\n12 None -2.0812 1.8024 -0.0997 H\n13 None 1.9999 2.2158 1.2220 H\n14 None 1.5949 4.5557 1.7660 H\n15 None -2.4896 4.1551 0.4277 H\n16 None 2.9491 -0.7558 -0.1197 C\n17 None 1.9244 0.0830 -0.5943 C\n18 None 2.1949 0.9719 -1.6426 C\n19 None 3.4717 1.0426 -2.1975 C\n20 None 4.4896 0.2195 -1.7162 C\n21 None 4.2464 -0.6895 -0.6787 C\n22 None 5.2907 -1.4630 -0.2730 O\n23 None 5.3352 -2.4303 0.7144 C\n24 None 2.7186 -1.4492 0.6670 H\n25 None 1.4146 1.6164 -2.0275 H\n26 None 3.6729 1.7367 -3.0032 H\n27 None 5.4766 0.2846 -2.1571 H\n28 None 5.6410 -3.3944 0.2586 H\n29 None 4.3777 -2.5872 1.2392 H\n30 None 6.0968 -2.1403 1.4670 H\n31 None -0.4848 -1.6901 2.1865 C\n32 None 0.4212 -0.6956 1.7914 C\n33 None 1.4302 -0.2998 2.6862 C\n34 None 1.5269 -0.8915 3.9474 C\n35 None 0.6189 -1.8785 4.3345 C\n36 None -0.3985 -2.2871 3.4554 C\n37 None -1.3992 -3.3473 3.8424 C\n38 None -1.3167 -4.4049 2.9551 F\n39 None -1.1712 -3.8256 5.1214 F\n40 None -2.6748 -2.8150 3.7928 F\n41 None -1.2673 -1.9984 1.5031 H\n42 None 2.1544 0.4491 2.4219 H\n43 None 2.3104 -0.5840 4.6282 H\n44 None 0.7166 -2.3180 5.3187 H\n@BOND\n1 2 3 2\n2 3 4 1\n3 4 5 2\n4 5 6 1\n5 6 7 2\n6 7 2 1\n7 8 9 1\n8 8 10 1\n9 8 11 1\n10 6 8 1\n11 2 12 1\n12 4 13 1\n13 5 14 1\n14 7 15 1\n15 1 3 1\n16 16 17 2\n17 17 18 1\n18 18 19 2\n19 19 20 1\n20 20 21 2\n21 21 16 1\n22 22 23 1\n23 21 22 1\n24 16 24 1\n25 18 25 1\n26 19 26 1\n27 20 27 1\n28 23 28 1\n29 23 29 1\n30 23 30 1\n31 1 17 1\n32 31 32 2\n33 32 33 1\n34 33 34 2\n35 34 35 1\n36 35 36 2\n37 36 31 1\n38 37 38 1\n39 37 39 1\n40 37 40 1\n41 36 37 1\n42 31 41 1\n43 33 42 1\n44 34 43 1\n45 35 44 1\n46 1 32 1\n\n","mol2"); viewer_17296129342946353.setStyle({"stick": {"radius": 0.1}, "sphere": {"scale": 0.15}}); viewer_17296129342946353.setHoverable({},true,"\n function(atom,viewer,event,container) {\n if(!atom.label) {\n atom.label = viewer.addLabel(atom.elem + '(' + atom.index + ')', {position: atom, backgroundColor: 'silver', fontColor:'black'});\n }\n }\n ","\n function(atom,viewer) { \n if(atom.label) {\n viewer.removeLabel(atom.label);\n delete atom.label;\n }\n }\n "); viewer_17296129342946353.zoomTo(); viewer_17296129342946353.setBackgroundColor("black"); viewer_17296129342946353.render(); }); ``` -------------------------------- ### Loading ConformerEnsemble from Mol2 Source: https://molli.readthedocs.io/en/latest/cookbook/001-helloworld.html Demonstrates how to load a ConformerEnsemble from a mol2 string, file stream, or file path. Ensure the mol2 data is correctly formatted. ```python # This function imports a mol2 file from a string ens = ml.ConformerEnsemble.loads_mol2(mol2_string) # or, similarly, from a file stream ens = ml.ConformerEnsemble.load_mol2(file_io) # or file path ens = ml.ConformerEnsemble.load_mol2(file_path) ``` -------------------------------- ### Getting Implicit Valence of an Atom Source: https://molli.readthedocs.io/en/latest/API/molli.chem/atom.html Demonstrates how to get the implicit valence of an atom, which is an integer value. ```python >>> ml.Atom(element='C').implicit_valence 4 ``` -------------------------------- ### Creating a Dictionary Source: https://molli.readthedocs.io/en/latest/_sources/cookbook/014-map.ipynb.txt Demonstrates how to create a dictionary in Python using curly braces and key-value pairs. This is the most common way to initialize a dictionary. ```python my_dict = {"name": "Alice", "age": 30, "city": "New York"} ``` -------------------------------- ### Import necessary libraries Source: https://molli.readthedocs.io/en/latest/zenodo/06-gbca-calculation-vis/006-calcvis.html Imports Molli, PyVista, HDF5, NumPy, tqdm, and PCA from scikit-learn. It also starts an xvfb instance for remote rendering. ```python import molli as ml from molli.visual._pyvista import draw_wireframe, plot_descriptor import pyvista as pv from pyvista.plotting.plotter import Plotter import h5py import numpy as np from tqdm import tqdm from sklearn.decomposition import PCA pv.start_xvfb() # Important for rendering due to being run on remote server lib = ml.ConformerLibrary("bpa_aligned.clib") ``` -------------------------------- ### Download a file from BOX Source: https://molli.readthedocs.io/en/latest/_sources/cookbook/013-BOX_workflow.ipynb.txt This example demonstrates how to download a file from your BOX account. You need the file ID and a local path to save the downloaded file. ```python from boxsdk import Client, OAuth2 # Replace with your actual access token ACCESS_TOKEN = "YOUR_ACCESS_TOKEN" # Initialize the BOX client auth = OAuth2(client_id='YOUR_CLIENT_ID', client_secret='YOUR_CLIENT_SECRET', access_token=ACCESS_TOKEN) client = Client(auth) # Specify the ID of the file you want to download file_id = 'YOUR_FILE_ID' # Specify the local path where you want to save the downloaded file local_path = '/path/to/save/downloaded_file.txt' # Get the file object file_to_download = client.file(file_id=file_id) # Download the file with open(local_path, 'wb') as f: file_to_download.download_to(f) print(f"File downloaded successfully to: {local_path}") ```