This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object PlayWithURLs extends App { | |
// Some ids for the BRCA1 gene | |
val refseqids = List("uc010whl.1", "uc002icp.3", "uc010whp.1") | |
def queryRefSeqId(refSeqId: String): String = { | |
def read(url: String): String = io.Source.fromURL(url).mkString | |
val document = read("http://genome.ucsc.edu/cgi-bin/hgGene?hgg_gene=" + refSeqId + "&org=human") | |
val regexp = """.*Genetic Association Database:\s\<A HREF=.*\>(\w+)\<.*""".r |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object UglyCodeExample extends App { | |
def m(stringToTransform: String): String = { | |
def t(string: String): List[String] = { | |
def th(string: String, si: Int): List[String] = { | |
if (si == 0) Nil | |
else { | |
val (firstString, secondString) = string.splitAt(si); val newString = secondString + firstString | |
newString :: th(string, si - 1)}} | |
th(string, string.length) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object BetterCodeExample extends App { | |
/** | |
* Burrows-Wheeler transform of string | |
* | |
* Perform the Burrows-Wheeler transform on a string. See http://en.wikipedia.org/wiki/Burrows%E2%80%93Wheeler_transform | |
* for a introduction to the algorithm. | |
* | |
* This particular implementation is recursive. | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.scalatest.FunSuite | |
import BetterCodeExample._ | |
class BetterCodeExampleUnitTests extends FunSuite { | |
test("Burrow wheelers transform of ^BANANA|") { | |
assert(BetterCodeExample.burrowsWheelersTransform("^BANANA|") === """BNN^AA|A""") | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(">")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Licence: | |
# https://creativecommons.org/licenses/by/3.0/ | |
library(ggplot2) | |
library(reshape2) | |
library(dplyr) | |
# Data: | |
# Downloaded at: http://www.statistikdatabasen.scb.se/pxweb/sv/ssd/START__HE__HE0110__HE0110A/SamForvInk2/?rxid=c58583e1-7fc3-418a-9395-0300e138fe7f | |
# Sammanräknad förvärvsinkomst, medianinkomst för boende i Sverige den 31/12, tkr efter region, kön, ålder och år |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo "Time in container" | |
for i in $(seq 1 5) | |
do | |
/usr/bin/time -f "time: %e" proot -S debian-sid --bind=/proj/a2009002/webexport/opendata/HiSeqX_CEPH/CEP-13-3/03-BAM/ samtools mpileup -r 22:1-23096112 /proj/a2009002/webexport/opendata/HiSeqX_CEPH/CEP-13-3/03-BAM/CEP-13-3.clean.dedup.recal.bam 2>&1 > test.pileup | grep time | |
done | |
echo "Time outside container" | |
for i in $(seq 1 5) | |
do | |
/usr/bin/time -f "time: %e" samtools mpileup -r 22:1-23096112 /proj/a2009002/webexport/opendata/HiSeqX_CEPH/CEP-13-3/03-BAM/CEP-13-3.clean.dedup.recal.bam 2>&1 > test.pileup | grep time |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def rawbuffer2JsValue(rawBuffer: RawBuffer): Option[JsValue] = { | |
for { | |
bytes <- rawBuffer.asBytes() | |
} yield { | |
Json.parse(bytes.utf8String) | |
} | |
} | |
def receiveFacebookMessages = withVerifiedPayload { | |
Action (parse.raw) { |