Skip to content

Instantly share code, notes, and snippets.

View johandahlberg's full-sized avatar

Johan Dahlberg johandahlberg

View GitHub Profile
@johandahlberg
johandahlberg / MinimalKmerProblemExample.scala
Last active August 29, 2015 14:24
Example of java.io.NotSerializableException: org.bdgenomics.formats.avro.NucleotideContigFragment in Adam
package example
import org.apache.spark.{SparkConf, SparkContext}
import org.apache.spark.rdd.RDD
import org.bdgenomics.adam.rdd.ADAMContext
import org.bdgenomics.formats.avro.NucleotideContigFragment
/**
* Created by dahljo on 7/14/15.
*/
@johandahlberg
johandahlberg / ParallelShellJobManager.scala
Created February 16, 2015 15:43
Code for a ParallelShellJobRunner for Queue
/*
* Copyright (c) 2012 The Broad Institute
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
<link rel="import" href="../polymer/polymer.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
width: 100%;
height: 100%;
@johandahlberg
johandahlberg / shiny-server.conf
Created March 27, 2014 17:48
My Shiny Server conf
# Instruct Shiny Server to run applications as the user "shiny"
run_as shiny;
# Define a server that listens on port 3838
server {
listen 3838;
# Define a location at the base URL
location / {
@johandahlberg
johandahlberg / contriesAndParticipantsForKP2014.R
Created March 1, 2014 13:15
Just a little visualization of the participants for KP2014.
library(ggplot2)
library(reshape2)
library(maps)
# A tab separated file with contries and participats.
# Note that Unites States needs to be changed to USA and United Kingdom
# to UK.
path.to.contry.and.participants.file <- "~/Desktop/contries.csv"
participants <-
@johandahlberg
johandahlberg / prepareReference.sh
Created November 5, 2013 16:18
A script for preparing a reference for running with piper on Uppmax.
#!/bin/bash -l
#SBATCH -A b2010028
#SBATCH -p core
#SBATCH -n 2
#SBATCH -t 10:00:00
#SBATCH -J prepare_ref
#SBATCH -o prepare_ref-%j.out
#SBATCH -e prepare_ref-%j.error
# Author: Johan D
@johandahlberg
johandahlberg / DemoIteratorSkipsRecords.scala
Last active December 25, 2015 12:19
Having problems with the SortingCollection which seems to skip records. Created this gist to use for reference when e-mailing samtools-devel list.
package molmed
import net.sf.samtools.util.SortingCollection
import net.sf.samtools.BAMRecordCodec
import net.sf.picard.fastq.FastqRecord
import java.util.Comparator
import java.io.InputStream
import java.io.PrintStream
import net.sf.picard.fastq.FastqConstants
@johandahlberg
johandahlberg / plotCoverageProportions.R
Created June 27, 2013 16:35
A R script to plot cumulative coverage based on GATK DepthOfCoverage output files. Not very pretty, but perhaps helpful to somebody.
library(ggplot2)
setwd("<my working directory>")
removeExtraLine <- function(x) {
x[,2:length(x)]
}
createInitialDataset <- function(x, sampleName) {
extraLineRemoved <- t(removeExtraLine(x))
@johandahlberg
johandahlberg / GCCounter.scala
Last active December 17, 2015 12:39
GCCounter in Scala inspired by http://saml.rilspace.org/moar-languagez-gc-content-in-python-d-fpc-c-and-c. This is no match performance wise for the C/D/C++ etc solutions, but I think that it makes a nice point of showing how Scalas parallel collections can be used to with very little extra effort parallelize operations. Test file available for …
import scala.io.Source
import java.io.File
object GCCounter extends App {
val file = new File("Homo_sapiens.GRCh37.67.dna_rm.chromosome.Y.fa")
// The actual GC counting function
def countGCOnLine(line: String): (Long, Long) = {
if (line.startsWith(">"))
@johandahlberg
johandahlberg / BetterCodeExampleUnitTests.scala
Created April 25, 2013 13:33
Unit test example for the BetterCodeExample burrows wheeler functions
import org.scalatest.FunSuite
import BetterCodeExample._
class BetterCodeExampleUnitTests extends FunSuite {
test("Burrow wheelers transform of ^BANANA|") {
assert(BetterCodeExample.burrowsWheelersTransform("^BANANA|") === """BNN^AA|A""")
}