Created
July 3, 2010 09:15
-
-
Save pjotrp/462444 to your computer and use it in GitHub Desktop.
This file contains hidden or 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() | |
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]] = { | |
def isGapType(c : T) = { | |
c match { | |
case Gap => true | |
case GapN => true | |
case _ => false | |
} | |
} | |
val isGap = isGapType(seq(0)) | |
def isMatch(c : T) = { 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 :: splitSimplePass6(tail) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment