Skip to content

Instantly share code, notes, and snippets.

View mpkocher's full-sized avatar

M. Kocher mpkocher

View GitHub Profile
import spray.http.HttpMethods._
import spray.http.{HttpResponse, HttpMethod, HttpMethods, AllOrigins}
import spray.http.HttpHeaders.{`Access-Control-Allow-Methods`, `Access-Control-Max-Age`, `Access-Control-Allow-Headers`, `Access-Control-Allow-Origin`}
import spray.routing._
import spray.routing.directives.BasicDirectives
/**
* Forked from
*
* https://gist.github.com/joseraya/176821d856b43b1cfe19
@mpkocher
mpkocher / bam_to_fasta.py
Created May 14, 2015 22:39
Bam Records to Fasta
from pbcore.io import FastaReader, BamReader
def to_records(reader_klass, transform_func, file_name):
with reader_klass(file_name) as r:
for record in r:
yield transform_func(record)
def bam_record_to_fasta_record(b_record):
# fill me in here
return b_record
@mpkocher
mpkocher / example_cli_app.py
Last active October 2, 2019 15:26
Example CLI using pbsystem and new ToolContract interface
"""Simple CLI dev app for testing"""
import logging
import sys
from pbsystem.common.cmdline.core2 import (get_default_parser,
pacbio_args_or_contract_runner,
add_resolved_tool_contract_option)
from pbsystem.common.utils import setup_log
from pbsystem.common.validators import validate_file
@mpkocher
mpkocher / example.scala
Last active October 2, 2019 15:24
Scala's Cake Patten Example
// This is all write by hand and probably has typos.
// The general idea is to show how it composes and how other
// system that extend the core services can choose which implementations
// of the coreservice DAOs to use
trait CoreServiceDaos {
val logDao: LogDao
val healthDao: HealthDao
}
@mpkocher
mpkocher / dev_mixed_app.py
Created July 15, 2015 20:51
Mixed Parser Example of exposing a subset of your tool interface to tool contract, and adding all options to the raw argparse instance
import json
import logging
from pbcommand.models import TaskTypes, FileTypes, get_default_contract_parser
log = logging.getLogger(__name__)
TOOL_ID = "pbcommand.tools.dev_mixed_app"
__version__ = "0.2.0"
@mpkocher
mpkocher / ipdSummary.py
Last active August 29, 2015 14:25
Example of Using pbcommand with ipdSummary.py
from pbcommand.models import get_default_contract_parser, TaskTypes, ResourceTypes, FileTypes
from pbcommand.validators import validate_file
def get_pbparser():
driver_exe = "my-exe"
p = get_default_contract_parser("pbexample.tasks.my_tool", "My Tool Desc", "0.1.0", driver_exe, TaskTypes.LOCAL, 1, ())
return p
def add_common(p):
p.add_input_file_type(FileTypes.DS_BAM, "algn_ds", "Alignment DataSet", "Alignment Set Desc")
@mpkocher
mpkocher / registry.R
Last active October 2, 2019 15:22
Registry Example
library(methods)
#' @export
ExampleRegistry <- setRefClass("ExampleRegistry", fields=list(namespace="character", driver="character", rtcRunners="list", toolContracts="list"))
registerFunc <- function(r, funcId, func) {
r$rtcRunners[[funcId]] <- func
return(r)
}
@mpkocher
mpkocher / readme.md
Last active October 2, 2019 15:22
pbcommand ToolContract High Level Overview

pbcommand High Level Overview

Full Docs

Note the APIs are still in flux. WIP.

Circle CI

PacBio library for common utils, models, and tools to interface with pbsmrtpipe workflow engine.

@mpkocher
mpkocher / pysiv1_validator.py
Created August 20, 2015 22:57
Old Validators For Nat
import os
import re
import abc
import logging
import h5py
import json
import collections
import gzip
from tarfile import TarFile
from xml.etree.ElementTree import ElementTree
@mpkocher
mpkocher / metric_rules.py
Last active October 2, 2019 15:20
Metric Rules sketch
class InValidMetricError(Exception):
pass
class TestReportMetric(TestBase):
REPORT_ID = ""
DEFAULT_VALUES = {}
# this will be populated via metaclass or @monkey_metrics model
RULES = []
def _apply_rules(self, rules):