Skip to content

Instantly share code, notes, and snippets.

View theosanderson's full-sized avatar

Theo Sanderson theosanderson

View GitHub Profile
@theosanderson
theosanderson / translate.py
Created April 26, 2024 22:46
Translating GISAID named files to EPI_ISL files
# Example of how to run: tar -xJOf sequences_fasta_2024_04_25.tar.xz sequences.fasta | python translate.py | pv -l | zstd > seqs.fa.zst
import sys
import tarfile
import pandas as pd
def load_virus_to_accession_dict(tar_path):
""" Load the virus to accession ID dictionary from a tar.xz file containing a .tsv. """
with tarfile.open(tar_path, 'r:xz') as tar:
# Find the tsv file within the archive, assuming there's only one .tsv
tsv_file = [member for member in tar.getmembers() if member.name.endswith('.tsv')][0]
LOCUS MN908947 29903 bp ss-RNA linear VRL 18-MAR-2020
DEFINITION Severe acute respiratory syndrome coronavirus 2 isolate Wuhan-Hu-1,
complete genome.
ACCESSION MN908947
VERSION MN908947.3
KEYWORDS .
SOURCE Severe acute respiratory syndrome coronavirus 2 (SARS-CoV-2)
ORGANISM Severe acute respiratory syndrome coronavirus 2
Viruses; Riboviria; Orthornavirae; Pisuviricota; Pisoniviricetes;
Nidovirales; Cornidovirineae; Coronaviridae; Orthocoronavirinae;
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@theosanderson
theosanderson / gist:7a86e3d3731031d59781997fc07f1a6b
Last active December 20, 2023 13:17
GISAID extract from MSA archive
cat ~/Desktop/hCoV-19_msa_1125.tar.xz | xz -dT10 | tar -xJO msa_1125/msa_1125.fasta | pv -c | zstd -c > msa.fa.zst
cat ~/Desktop/metadata_tsv_2023_12_18.tar.xz | xz -dT10 | tar -xJO metadata.tsv | pv -c | zstd -c > metadata.tsv.zst
```{r}
mutations_in_highly_mutated_seq = "A543G, G1068A, G1186A, G1264A, T1370C, G1743A, A2497G, C2583T, T2824C, G3287A, C3393T, A3430G, C3604T, G3794A, A4179G, G4300A, G4352A, G4444A, G4474A, A4501G, G4975A, T5117C, G5230A, G5720A, G5861A, C6031T, G6123A, C6198T, G6362A, A6565G, T6661C, G6759A, A6833G, C7051T, C7086T, T7114C, A7558G, C7749T, A7795G, G7934A, C8169T, T8779C, T8875C, T9148C, G9209A, A9409G, C9438T, C9521T, G9575A, A9984G, C10015T, G11198A, C11199T, G11330A, G11605A, T11701C, G11837A, G11944A, A12030G, A12271G, G12442A, C12540T, C12633T, T12703C, C13818T, C14216T, G14622A, C15026T, C15656T, C15783T, C16767T, G16861A, C17481T, T17505C, A17993G, C18201T, C18888T, A19574G, G20062A, T20502C, C21297T, C21588T, G21668A, A21717G, T21752C, A21996G, A22101G, T22189C, T22254C, G22770A, C22783T, A22893G, A23004G, C23013T, G23048A, T23425C, A23734G, T23948C, A24003G, A24062G, C24961T, G24977A, C25066T, G25537A, T25779C, C25872T, C26176T, C26195T, C26335T, G26428A, C26645T, T26819G, G27014A, A27146G, A27386
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
from fastapi import FastAPI, WebSocket
import openai
import time
import json
import asyncio
import os
#get the api key from the environment variable
You are LabGPT. You are in charge of conducting scientific experiments to achieve a stated goal. You have access to an OpenTrons OT2 robot and a lab helper
You have access to the following commands:
Request: enter a request to a user. you can use this for example to get them to set some labware up inside the robot in desired positions.
ExecuteRobotCommands: runs a Python script written in the OT2 API. This will be executed immediately using the Jupyter-notebook style implementation on the robot. State is maintained between calls to this.
The first time, set up like this:
```
```{r}
library(tidyverse)
library(gganimate)
library(tweenr)
# Read in the CSV file
df <- read_csv("~/Downloads/ambulance.csv", col_names = c("date","minutes"))
df$difftime = as.difftime(df$minutes, units = 'mins')
p<-ggplot(df,aes(x=date,y=difftime))+geom_line(color="#142bdb") +coord_cartesian(ylim=c(0,NA)) + geom_hline(yintercept=18,linetype=2,color="#666666") +theme_bw() +scale_y_time(labels = function(l) strftime(l, '%M:%S')) +labs(x="Date",y="Response time\n(hours:minutes)",