Skip to content

Setting up the environment

genomewalker edited this page May 26, 2024 · 1 revision

The purpose of this section is to help you set up an environment for remote development and analysis. While I personally use VS Code, feel free to use any workflow that suits you best. With VS Code, I can utilize Jupyter notebooks, develop in R as if I were using RStudio, and benefit from its built-in integration with Git for version control of my code.

The image below illustrates the workflow we will be following during the hands-on sessions:

Installing Visual Studio Code

  1. Go to the Visual Studio Code website and click the "Download for Windows" button if you are using a Windows computer, or "Download for Mac" button if you are using a Mac.
  2. Open the downloaded file and follow the installation instructions.

Adding Basic Extensions

  1. Open Visual Studio Code.
  2. Click on the "Extensions" icon on the left-hand side of the screen.
  3. (Optional) Search for the following extensions and install them:
    • shell-format: A formatter for shell scripts, Dockerfile, gitignore, dotenv, /etc/hosts, jvmoptions, and other file types
    • autocomplate-shell: This extension adds rich language support for the shell script to VS Code
    • Bash Beautify: A simple extension that just works for shell script formatting based on Paul Lutus - Bash Script Beautifier
    • ShellCheck: Integrates ShellCheck into VS Code, a linter for Shell scripts.
    • Snakemake Language: Provides basic language support for Snakemake files (Snakefile, *.smk).
    • GitHub Copilot: GitHub Copilot provides autocomplete-style suggestions from an AI pair programmer as you code. (Apply for a GitHub education account to get access to this extension)

Configuring Remote SSH Access

I already ran all the steps related to generate and copy the public key into the cloud, but they might be useful for you in the future

Generate a new public/private key pair using the following command in your terminal:

ssh-keygen -t rsa -f mykey

Copy the public key to your remote server by running the following command in your terminal:

ssh-copy-id -i ~/.ssh/mykey.pub user@<remote server>

Replace user with your username on the remote server, and <remote server> with the IP address of your remote server.

  1. Open Visual Studio Code and click on the "Extensions" icon.
  2. Search for the "Remote Development" extension and install it.
  3. Click on the "Remote Explorer" icon on the left-hand side of the screen.
  4. Click on the "SSH Targets" dropdown menu and select "Configure SSH Hosts".
  5. Click on the "Add New SSH Host" button and fill in the following information:
    • Hostname: 129.70.51.184
    • User: Your username on the remote server
    • Port: Leave this blank
    • Private Key: Select the private key file that you downloaded from the email I sent
  6. Click "Connect" to establish the SSH connection.
  7. Once connected, you can open a remote terminal by clicking on the "Terminal" icon.
  8. You can also open a file on the remote server by clicking on the "Explorer" icon and selecting "Open Folder".

Congratulations, you have now installed Visual Studio Code, added basic extensions for Git, Bash, and Snakemake, and configured it to work remotely with SSH using a public key!

Conda environments

We have two different Conda environments on the cloud that we will be using. By default, the fundata environment is activated, and it contains all the necessary programs for the tasks. The second environment is called snakemake, and it has all the tools needed for the Snakemake hands-on sessions. To activate the snakemake environment, you can use the following command:

conda activate snakemake

To deactivate the environment and return to the fundata environment, you can use the following command:

conda deactivate
Clone this wiki locally