Skip to content

Instantly share code, notes, and snippets.

View tomsing1's full-sized avatar

Thomas Sandmann tomsing1

View GitHub Profile
@tomsing1
tomsing1 / accession2url.R
Created November 1, 2016 21:29 — forked from mikelove/accession2url.R
ENA accession to URL
accession2url <- function(x) {
prefix <- "ftp://ftp.sra.ebi.ac.uk/vol1/fastq"
dir1 <- paste0("/",substr(x,1,6))
dir2 <- ifelse(nchar(x) == 9, "",
ifelse(nchar(x) == 10, paste0("/00",substr(x,10,10)),
ifelse(nchar(x) == 11, paste0("/0",substr(x,10,11)),
paste0("/",substr(x,10,12)))))
paste0(prefix,dir1,dir2,"/",x)
}
@tomsing1
tomsing1 / pipeline.py
Created May 4, 2017 19:22 — forked from jfeala/pipeline.py
Airtable API update from simple samtools command
import os
from subprocess import check_output
from tempfile import mkstemp
import sys
import boto3
import requests
s3 = boto3.client('s3')
@tomsing1
tomsing1 / amazonctl.py
Created July 13, 2018 05:46 — forked from jtpaasch/amazonctl.py
A collection of functions commonly used to do AWS stuff.
# -*- coding: utf-8 -*-
"""A simple tool to document how to control AWS resources.
AWS AUTHENTICATION
-------------------
In order to run any of the code below, you need a profile with AWS credentials
set up on your computer. It's very easy to do this. Google how to configure
your profile with boto3, or visit the docs:
@tomsing1
tomsing1 / sample.py
Created August 9, 2018 22:14 — forked from amorgun/sample.py
SqlAlchemy postgres bulk upsert
from sqlalchemy.dialects import postgresql
def bulk_upsert(session: Session,
items: Sequence[Mapping[str, Any]]):
session.execute(
postgresql.insert(MyModel.__table__)
.values(items)
.on_conflict_do_update(
index_elements=[MyModel.id],
set_={MyModel.my_field.name: 'new_value'},