Giter VIP home page Giter VIP logo

cctbxsnips-vsc's Introduction

cctbxsnips for Visual Studio Code (VS Code or VSC)

Version License: MIT

CCTBX

CCTBX is the Computational Crystallography Toolbox. Its development is based at Lawrence-Berkeley National Laboratory. It provides code for computations with diffraction data and atomic coordinates of proteins and small molecules. It has C++ and Python ports. It is available in Anaconda in the conda-forge channel known as cctbx-base for python3.8 through 3.12 for Windows, macOS, and Linux.

Blaine's cctbx install protocol

I assume that Anaconda has already been installed. We will create a conda env specifically for CCTBX. CCTBX has numerous dependencies. It is best kept in an isolated env. We also create the corresponding Jupyter Notebook kernel while we are at it.

Execute one line at a time: Wait for the execution to finish before executing the next line.

conda create --name cctbx39 python=3.9
conda activate cctbx39
conda install -c conda-forge cctbx-base -y
conda install ipykernel -y
python -m ipykernel install --user --name cctbx39 --display-name "cctbx python3.9"

The second to last command triggers the installation of Jupyter in the cctbx39 env. The last command creates and installs the Jupyter kernel in ~/Library/Jupyter/kernels/cctbx39 on the Mac. Select cctbx python3.9 from the list of kernels when opening a new notebook in Jupyter.

Replace the 3.9 or 39 above with whatever version of Python you want to use (between 3.8 and 3.11).

The problems that this repo addresses

  1. ** Facilitation of code reuse **. Code snippets can save time by reusing existing code. The presence of tab stops in code snippets can help ensure that all parameters that need customization to a new problem are considered. Thus, tab stops can reduce subsequent debugging.

  2. Use VSC to edit Jupyter and Colab code and markdown cells The existing snippet formats for Jupyter and Colab notebooks do not support tab triggers and tab stops, which are standard features of code snippet systems in most text editors. We can overcome these limitations by sending the active code cell to VSC via the GhostText extension for the browser.

Installation

VSC has built-in support for snippets. The snippets are stored in a single JSON file by programming language.

  1. Install the snippets for VSC.

From the above folder vscpymolsnips, download and move the file source.python.json on the macOS to ~/Library/Application\ Support/Code/User/snippets/python.json ; on Windows to $HOME/APPDATA\Roaming\Code\User\snippets\python.json; on Linux to $HOME/.config/Code/User/snippets/python.json. If you have an existing python.json, you want to concatenate the files.

  1. Optional If you want to use these snippets from VSC to edit live cells in Jupyter or Colab notebooks, install GhostText browser extension in your browser and the GhostText extension for VSC. Open the command palette (Option-X on macOS) in VSC and enter "Enable GhostText".

Example of VSCode editing a live code cell in a Jupyter notebook

Note After opening a connection from a code cell in a Jupyter Notebook (light-theme) to VSCode (dark-theme), a markdown document will appear in VSCode. You must manually change the scope to Python by opening the command palette (enter Option-X on macOS) and entering Change Language Mode. This will open a menu with a list of programming languages. Select python. Now you will be able to access the cctbx snippets inside VSCode.

However, each new cell activated with GhostText opens a new temporary document in VScode. The scope has to be changed again. This grows old fast. The default file extension of this temporary document is *.tmp. The tmp file extension can be remapped to Python as follows in the settings.json file:

"files.associations": {
    "*.tmp": "python"
},

The image below shows a popup menu with the selected snippet and a preview of its code in VSC. This provides a chance to check that the snippet has the desired code. Hit tab to insert the code.

The image below shows two code blocks run in the Jupyter Notebook. Note that the output of a run code block is returned to the Jupyter notebook; however, it does not appear in the temporary document in VSC because it is outside of the active text area of the Jupyter notebook. In addition, the name of the mtz file is being changed. While this is happening, Jupyter automatically returns a popup menu of candidate files.

Related repositories

Update History

Version Changes Date
Version 0.1 Fixed typos in README.md 2024 April 10

Sources of funding

  • NIH: R01 CA242845
  • NIH: R01 AI088011
  • NIH: P30 CA225520 (PI: R. Mannel)
  • NIH P20GM103640 and P30GM145423 (PI: A. West)

cctbxsnips-vsc's People

Contributors

mooerslab avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.