Skip to content

Instantly share code, notes, and snippets.

View pjotrp's full-sized avatar
🚣‍♂️
Leaving github is harder than it should be

Pjotr Prins pjotrp

🚣‍♂️
Leaving github is harder than it should be
View GitHub Profile
case class Symbol()
case object Gap extends Symbol
case class Nucleotide() extends Symbol
case object GapN extends Nucleotide
case object A extends Nucleotide
case object G extends Nucleotide
case object C extends Nucleotide
case object T extends Nucleotide
case object AnyGap
def splitSimplePass6[T >: Symbol](seq: List[T]): List[List[T]] = {
case class Symbol() {
def isGap() = false
}
case object Gap extends Symbol {
override def isGap() = true
}
case class Nucleotide() extends Symbol
case object GapN extends Nucleotide {
override def isGap() = true
}
case class Symbol()
case object Gap extends Symbol
case class Nucleotide() extends Symbol
case object GapN extends Nucleotide
case object A extends Nucleotide
case object G extends Nucleotide
case object C extends Nucleotide
case object T extends Nucleotide
def splitSimplePass4(seq: List[Symbol]): List[List[Symbol]] = {
val gap = GapN
class GapSplitting3Spec extends FlatSpec with ShouldMatchers {
case class Symbol()
case object Gap extends Symbol
case object A extends Symbol
case object G extends Symbol
case object C extends Symbol
case object T extends Symbol
def splitSimplePass3(seq: List[Symbol]): List[List[Symbol]] = {
val gap = Gap
val isGap = (seq(0) == gap)
case class Symbol()
case object Gap2 extends Symbol
case object A extends Symbol
case object G extends Symbol
case object C extends Symbol
case object T extends Symbol
def splitSimplePass2(seq: List[Symbol], gap: Symbol): List[List[Symbol]] = {
def isMatch(inGapped: Boolean, c: Symbol) = {
if (inGapped)
"splitSimplePass2" should "split on Gap2" in {
splitSimplePass2(List(A,G,Gap2,Gap2,C,T,Gap2,T),Gap2) should equal (List(List(A,G),List(Gap2,Gap2),List(C,T),List(Gap2),List(T)))
}
val Gap1 = '-'
def splitSimplePass1(seq: List[Char], gap: Char): List[List[Char]] = {
def isMatch(inGapped: Boolean, c: Char) = {
if (inGapped)
c == gap
else
c != gap
}
val isGap = (seq(0) == gap)
val s = seq.takeWhile{ isMatch(isGap,_) }
"splitSimplePass1" should "split on dash" in {
splitSimplePass1("ag--ct-t".toList,Gap1) should equal (List(List('a','g'),List('-','-'),List('c','t'),List('-'),List('t')))
}
#! /bin/sh
classpath=.:/usr/share/java/jruby.jar:~/.scala/jruby-complete-1.5.0.RC1.jar
echo "Compile Rubyadapters"
mkdir -p bio/ruby
cd src/bio/ruby
jrubyc --java rbsequence.rb
echo "package bio.ruby;"|cat - RbSequence.java > x.java && mv x.java RbSequence.java
javac -cp $classpath RbSequence.java
mv RbSequence.class ../../../bio/ruby/
import org.scalatest.FlatSpec
import org.scalatest.matchers.ShouldMatchers
package bio.test {
class BioRubySpec extends FlatSpec with ShouldMatchers {
import bio.ruby._
"A DNA sequence" should "translate" in {
val rbseq = new RbSequence