Skip to main content

1.4 VSCode

Visual Studio Code for Bioinformatics

This guide covers using Visual Studio Code (VSCode) for bioinformatics workflows and analysis.

Why VSCode?

VSCode is a powerful, free code editor that provides:

  • Integrated terminal - Run commands without switching windows
  • Git integration - Version control built-in
  • Extensions - Add language support and tools as needed
  • Remote development - Work on remote servers seamlessly
  • Jupyter notebooks - Edit and run notebooks natively

Download the VSCode Application

Go to the VSCode download page and download the appropriate version for your operating system. Follow the installation instructions.

Download the important extensions

Go to the Extensions tab on the left sidebar (or press Ctrl+Shift+X), search for the extensions listed above, and click “Install” for each.

Here are recommended extensions for bioinformatics work:

  • Remote - SSH - Connect to remote servers
  • vscode-pdf - View PDF files directly in VSCode
  • Python - Python language support with IntelliSense
  • Jupyter - Work with Jupyter notebooks
  • Git Graph - Visualize git history
  • Rainbow CSV - Better CSV file viewing
  • Live Preview - Preview HTML files in real-time

Initially connecting to the CCB via VSCode

VSCode can connect to the CCB remote servers via SSH:

  1. On VSCode, open the Command Palette (Cmd+Shift+P on Mac or Ctrl+Shift+P on Windows/Linux), or click the >< symbol at the very bottom left hand corner of the window.
  2. Type and select Remote-SSH: Connect to Host....
  3. Click on Add New SSH Host... and enter the following:
Host login1.molbiol.ox.ac.uk
  HostName login1.molbiol.ox.ac.uk
  User {your CCB username}

Host login2.molbiol.ox.ac.uk
  HostName login2.molbiol.ox.ac.uk
  User {your CCB username}
  1. Enter your CCB SSH details when prompted. It will request your CCB password in the panel at the top of the window. Followed by the 2FA code

Once connected, you can open folders and files on the CCB directly in the left hand panel in VSCode.

Subsequent logins via Remote-SSH

On the welcome screen there may be options to directly connect to previous remote hosts. If not, follow these steps:

  1. On VSCode, open the Command Palette (Cmd+Shift+P on Mac or Ctrl+Shift+P on Windows/Linux), or click the >< symbol at the very bottom left hand corner of the window.
  2. Type and select Remote-SSH: Connect to Host....
  3. Select either login1.molbiol.ox.ac.uk or login2.molbiol.ox.ac.uk from the list.
  4. Enter your CCB SSH details when prompted. It will request your CCB password and 2FA code in the panel at the top of the window.

Once connected, you can edit files and run commands on the remote server as if working locally.

Opening a Project

  1. Confirm you are connected to the CCB by looking for SSH: login1.molbiol.ox.ac.uk or login2.molbiol.ox.ac.uk at the >< symbol at the very bottom left hand corner
  2. To open a folder, at the top of the left menu, there is an icon that looks like 2 pages called Explorer, click Explorer → Open Folder... or open with Cmd+Shift+E
    • This will open a file dialog at the naviation bar
  3. Navigate to your project directory
    • You may need to type /project/higgslab/your_CCB_username/ to find your files
  4. Click OK to open the folder to the left sidebar

The folder structure will appear in the left sidebar. This allows you to easily navigate and open files within your project. Whilst helpful, you still have to be careful when editing files directly on the CCB as you may accidentally overwrite important files. You can click on a file to open and edit it in the main window.

However, many commands and folder editing is better done via the integrated terminal.

Using the Integrated Terminal

To open the integrated terminal in VSCode: - Open with Ctrl+` (backtick) or View → Terminal - The terminal opens at the bottom of the VSCode window - Run commands just like in a regular terminal - Multiple terminals can be opened side-by-side by clicking the + icon in the terminal panel

To move to your project directory in the terminal, use the cd command. For example:

cd /project/higgslab/your_CCB_username/

Tips and Tricks

You can right click on files in the files explorer and select Copy Path to copy the full file path to use in terminal commands. You can also download files from the CCB to your local machine by right clicking on the file in the explorer and selecting Download.

Getting Python and Jupyter Notebooks working on the CCB via VSCode

To use Python and Jupyter notebooks on the CCB via VSCode, you will need to set up a Python environment and install the necessary packages. See the Mamba section for instructions on how to do this.

Once you have an mamba environment set up with Python and Jupyter installed, you can use the Jupyter extension in VSCode to create and edit notebooks directly on the CCB. The environment will need ipkernel installed to allow you to select it as the kernel for your notebooks.

Make sure you have the Jupyter extension installed in VSCode, and that you have activated your mamba environment in the integrated terminal before opening a notebook. In the command palette, you can select Python: Select Interpreter to choose the Python interpreter from your mamba environment.

TipLoading the Genomics environment in VSCode for Jupyter notebooks

The Genomics_pipelines_env environment has been set up with the necessary packages for running Jupyter notebooks. To make this environment available as a kernel in VSCode, you need to install the ipykernel package in your mamba environment and register it. To do this, source the environment:

source /project/higgslab/lcornell/mamba_installation/conda/bin/activate Genomics_pipelines_env

and run the following command:

python -m ipykernel install --user --name Genomics_pipelines_env --display-name "Python (Genomics_pipelines_env)"

You may need to restart VSCode after this step for the kernel to appear in the Jupyter extension.

I have faced some issues with the VSCode Jupyter extension not recognizing the kernel, but this can often be resolved by restarting VSCode, or by making sure the .vscode folder in your project directory has the correct settings for a Python interpreter path.

ie in the .vscode/settings.json file, you should have the following line with the correct path to your Python interpreter in your mamba environment:

```json { “python.pythonPath”: “/project/higgslab/your_CCB_username/mamba_installation/*” }

Useful Keyboard Shortcuts

  • Command Palette: Cmd+Shift+P (Mac) or Ctrl+Shift+P (Windows/Linux) - Access all VSCode commands
  • Quick Open: Cmd+P - Quickly open files by name
  • Format Document: Shift+Alt+F - Auto-format your code

Additional Resources