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
# BioRuby to BioScala adapter | |
require 'java' | |
require 'bio' | |
class RbSequence | |
def translate(sequence, frame, codon_table) | |
seq = Bio::Sequence::NA.new(sequence) | |
seq.translate(frame,codon_table) | |
end |
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.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 |
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/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/ |
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
"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'))) | |
} |
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
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,_) } |
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
"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))) | |
} |
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() | |
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) |
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
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) |
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() | |
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 |
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 | |
} |
OlderNewer