Created
July 2, 2010 07:46
-
-
Save pjotrp/461066 to your computer and use it in GitHub Desktop.
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
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 object A extends Nucleotide | |
case object G extends Nucleotide | |
case object C extends Nucleotide | |
case object T extends Nucleotide | |
def splitSimplePass5(seq: List[Symbol]): List[List[Symbol]] = { | |
def isGapType(c : Symbol) = c.isGap() | |
val isGap = isGapType(seq(0)) | |
def isMatch(c : Symbol) = { if (isGap) isGapType(c) else !isGapType(c) } | |
val s = seq.takeWhile{ isMatch } | |
val tail = seq.takeRight(seq.length - s.length) | |
tail match { | |
case Nil => s :: Nil | |
case _ => s :: splitSimplePass5(tail) | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment