Skip to content

Instantly share code, notes, and snippets.

from morphosource import search_media
from functools import wraps
from time import time
import requests
from bs4 import BeautifulSoup
def timing(f):
@wraps(f)
def wrap(*args, **kw):
ts = time()
@johnbradley
johnbradley / python-bin-dir
Created November 13, 2020 19:13
Command to print out the likely bin directory for console_scripts
python3 -c 'import sys; print(sys.exec_prefix + "/bin")'
@johnbradley
johnbradley / echo-passing-array.cwl
Last active December 3, 2019 21:09
CWL workflow that demonstrates a TypeError when run with toil
class: Workflow
cwlVersion: v1.1
requirements:
- class: SubworkflowFeatureRequirement
- class: MultipleInputFeatureRequirement
inputs:
str1:
type: string
default: "red"
str2:
import re
with open("toiloutput.log") as infile:
lines = infile.readlines()
jobs = {}
for line in lines:
time, end = line.strip().split(" ")
time = re.sub(r',.*', '', time)
{
"$graph": [
{
"class": "Workflow",
"label": "exomeseq-gatk4/v2.0.0",
"doc": "Whole Exome Sequence analysis using GATK4 - v2.0.0",
"requirements": [
{
"class": "ScatterFeatureRequirement"
},
{
"$graph": [
{
"class": "Workflow",
"label": "exomeseq-gatk3/v4.1.1",
"doc": "Whole Exome Sequence analysis using GATK3 - v4.1.1",
"requirements": [
{
"class": "ScatterFeatureRequirement"
},
{
"$graph": [
{
"class": "Workflow",
"doc": "Reverse the lines in a document, then sort those lines.",
"requirements": [
{
"class": "ScatterFeatureRequirement"
}
],
{
"class": "CommandLineTool",
"inputs": [
{
"type": "File",
"id": "#main/file1"
}
],
"outputs": [
{
@johnbradley
johnbradley / small_exome.py
Last active October 1, 2018 15:38
Example Bespin command line python script
# command line program to demonstrate how to run exomeseq workflow
# against some files stored in a DukeDS project.
# Should be run within a python enviroment that has installed `bespin-cli`.
# Assumes that bespin-cli and DukeDSClient config files are already setup.
# command line program to demonstrate how to run exomeseq workflow
# against some files stored in a DukeDS project
# does not handle a read split across multiple files
from __future__ import print_function
@johnbradley
johnbradley / bespin_qiime2_cli.sh
Created June 5, 2018 17:10
Example bespin curl job creation
#!/bin/bash
set -e
TOKEN=TODO
DDS_USER_CREDENTIAL=TODO
QUESTIONNAIRE=TODO
PROJECT_ID=TODO
BARCODE_FILE_ID=TODO
SEQUENCES_FILE_ID=TODO