Skip to content

Instantly share code, notes, and snippets.

@kdaily
kdaily / semi-annual-usage-report.Rmd
Created May 1, 2020 14:45
Semi-annual report for AMP-AD
---
title: "AMP-AD Semi-Annual Report"
author: "Kenneth Daily"
date: "`r format(Sys.time(), '%B %d, %Y')`"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE,
message = FALSE,
@kdaily
kdaily / fastq-to-bam-add-provenance.R
Created April 15, 2020 19:23
fastq to bam add provenance, was used in BSMN
library(synapseClient)
synapseLogin()
table_id <- "syn7871084"
fileview_df <- synTableQuery(sprintf('select * from %s', table_id))@values
fastq2bam <- fileview_df %>%
filter(fileFormat %in% c("fastq", "bam")) %>% # keep fastq and bam
# group for cases where there are multiple files per file format
group_by(sample_id_biorepository,
class Counter(object):
value = 0
def mergeSort(myList):
if len(myList) > 1:
depth.value += 1
mid = (len(myList) + 1) // 2
left = myList[:mid]
right = myList[mid:]
"""Linked list.
"""
from collections.abc import Sequence
import logging
logging.basicConfig()
logger = logging.getLogger(__name__)
logger.setLevel(level=logging.INFO)
@kdaily
kdaily / bootstrap-genie-project.py
Last active October 31, 2019 17:36
Bootstrap a project for use with the GENIE framework
"""Bootstrap the components of a project to be used with the GENIE framework.
"""
import synapseclient
import genie
import pandas
import random
import tempfile
@kdaily
kdaily / batch_file_request_download.py
Created October 3, 2019 21:32
Use a batch file request to get file handle URLs for download.
"""Example code for using Synapse pre-signed URLs to download directly.
This only uses the Synapse Python client to perform the POST operation to get
the pre-signed URLs and generate signed headers. The `requests` library is used
to fetch the file.
"""
import synapseclient
import json
@kdaily
kdaily / remove_veoibd_submissions.py
Last active September 19, 2019 21:37
Remove submissions for a center in the VEOIBD data submission project.
"""Script to remove all artifacts of submissionf for a center.
"""
import logging
import synapseclient
import genie.config
logging.basicConfig()
logger = logging.getLogger(__name__)
@kdaily
kdaily / dog.jpg
Created July 7, 2019 22:12
Test upload of two dog pictures, one JPG and one PNG
dog.jpg
library(tidyr)
library(dplyr)
library(readr)
library(synapser)
synLogin()
id <- 'syn19034850'
obj <- synGet(id)
d <- readr::read_csv(obj$path)
@kdaily
kdaily / validate_syn18486863.sh
Created June 5, 2019 21:59
Validate annotations on files from syn18486863 for MEP-LINCS MDD
# Uses https://gist.github.com/kdaily/fea5b0f72fac1264048e39e6c4d04647#file-query_to_json-py
query_to_json.py "select assay,Level,CellLine,DataType from syn18486863" > /tmp/syn18486863_file_annotations.json
# uses ajv-cli - https://github.com/jessedc/ajv-cli
ajv validate -s file_annotations_file_schema.json -r file_annotation.json -d /tmp/syn18486863_file_annotations.json --errors=line