Commit dca51f45 authored by Sander Bollen's avatar Sander Bollen
Browse files

SageCreateLibraryTest

parent ea4e9d7e
>ENST00000529862 havana:known chromosome:GRCh38:11:105194440:105194946:-1 gene:ENSG00000254767 gene_biotype:unprocessed_pseudogene transcript_biotype:unprocessed_pseudogene
ATGAATAATAATGGGAAATATCAACATAAGTCTTGAAAATTACTTTATTCTACTGGGTCT
TTCTAATTGACCTCCTCTGGAAATAGTTATTTTTGTAGTTCTCTTGATATTCTGCTTCAT
GACACTGATAGGCAAGCTGTTCAGCATCATTCTGTCATACCTGGACTCCCATCCCCACAC
TCTCGGTACTTATTCTCTTTTCTGGATTTCTGCTACACCATCAGTTCCATCTTTTAATTA
CAGTACAATCTCTGGGGCCCACAGAAGAACATCTCTTATGCCAGTGGTATGATTCAAATT
TATTTTGTTCTCACACTGGGAACCATGGATTGCGCTCTACTGGTGGTGATGTCCAGGACT
GTGATGCAGCTGGACACAGACACTTGCCTTATACTGTTGTTATGGCTGTGGCTTTTTGGG
TAAGTAGCTTTACCAACTCAGCATTTGATTCCTTTTTTACCTTCTGGGTAACCCTGTGTG
GACATCACTATTATGCTTACATCTTTA
>ENST00000528941 havana:known chromosome:GRCh38:11:105246880:105247060:-1 gene:ENSG00000255336 gene_biotype:unprocessed_pseudogene transcript_biotype:unprocessed_pseudogene
TATTCATAATTAAAGTCATACTTCAGCAAGCTGGCTTTAAATATACAACATATAATTCTT
TTAAATCAGACTCTCTGAATCCATGACCGCCATGTCTTCATGAAGCTGTCCTTCCTCAAT
CCCCATCTGTTTTAAGGGTTCCACCCATGTTCTTCCTTAGCACCCTGAGTATTTACTCTA
T
>ENST99999999999 havana:known chromosome:GRCh38:11:105246880:105247060:-1 gene:ENSG99999999999 gene_biotype:unprocessed_pseudogene transcript_biotype:unprocessed_pseudogene
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
ENSG00000255336
ENSG00000254767
ENSG99999999999
#tag firstTag AllTags FirstAntiTag AllAntiTags
CATGAAGACATGGCGGTCATG ENSG00000255336
CATGAAGCAGAATATCAAGAG ENSG00000254767
CATGACACTGATAGGCAAGCT ENSG00000254767
CATGACCGCCATGTCTTCATG ENSG00000255336
CATGGATTGCGCTCTACTGGT ENSG00000254767 ENSG00000254767
CATGGGTGGAACCCTTAAAAC ENSG00000255336 ENSG00000255336
CATGGTTCCCAGTGTGAGAAC ENSG00000254767 ENSG00000254767
CATGTTCTTCCTTAGCACCCT ENSG00000255336 ENSG00000255336
package nl.lumc.sasc.biopet.tools
import java.io.File
import java.nio.file.Paths
import org.biojava3.core.sequence.DNASequence
import org.biojava3.core.sequence.io.FastaReaderHelper
import org.scalatest.Matchers
import org.scalatest.mock.MockitoSugar
import org.scalatest.testng.TestNGSuite
import org.testng.annotations.Test
import scala.collection.JavaConversions._
import scala.io.Source
/**
* Created by ahbbollen on 7-9-15.
*/
class SageCreateLibaryTest extends TestNGSuite with MockitoSugar with Matchers {
import SageCreateLibrary._
private def resourcePath(p: String): String = {
Paths.get(getClass.getResource(p).toURI).toString
}
@Test
def testMain = {
val input = resourcePath("/mini.transcriptome.fa")
val output = File.createTempFile("sageCreateLibrary", ".tsv")
val noTagsOutput = File.createTempFile("sageCreateLibrary", ".tsv")
val antiTagsOutput = File.createTempFile("sageCreateLibrary", ".tsv")
val allGenesOutput = File.createTempFile("sageCreateLibrary", ".tsv")
val args = Array("-I", input, "-o", output.getAbsolutePath, "--tag", "CATG",
"--length", "17", "--noTagsOutput", noTagsOutput.getAbsolutePath, "--noAntiTagsOutput",
antiTagsOutput.getAbsolutePath,"--allGenesOutput", allGenesOutput.getAbsolutePath)
noException should be thrownBy main(args)
val args2 = Array("-I", input, "-o", output.getAbsolutePath, "--tag", "CATG",
"--length", "17")
noException should be thrownBy main(args2)
val args3 = Array("-I", input, "-o", output.getAbsolutePath, "--tag", "CATG",
"--length", "17", "--noTagsOutput", noTagsOutput.getAbsolutePath)
noException should be thrownBy main(args3)
}
@Test
def testOutPut = {
val input = resourcePath("/mini.transcriptome.fa")
val output = File.createTempFile("sageCreateLibrary", ".tsv")
val noTagsOutput = File.createTempFile("sageCreateLibrary", ".tsv")
val antiTagsOutput = File.createTempFile("sageCreateLibrary", ".tsv")
val allGenesOutput = File.createTempFile("sageCreateLibrary", ".tsv")
val args = Array("-I", input, "-o", output.getAbsolutePath, "--tag", "CATG",
"--length", "17", "--noTagsOutput", noTagsOutput.getAbsolutePath, "--noAntiTagsOutput",
antiTagsOutput.getAbsolutePath,"--allGenesOutput", allGenesOutput.getAbsolutePath)
main(args)
Source.fromFile(output).mkString should equal(
Source.fromFile(new File(resourcePath("/sageTest.tsv"))).mkString
)
Source.fromFile(noTagsOutput).mkString should equal (
Source.fromFile(new File(resourcePath("/sageNoTagsTest.tsv"))).mkString
)
Source.fromFile(antiTagsOutput).mkString should equal (
Source.fromFile(new File(resourcePath("/sageNoAntiTest.tsv"))).mkString
)
Source.fromFile(allGenesOutput).mkString should equal (
Source.fromFile(new File(resourcePath("/sageAllGenesTest.tsv"))).mkString
)
}
@Test
def testGetTags = {
val input = resourcePath("/mini.transcriptome.fa")
val reader = FastaReaderHelper.readFastaDNASequence(new File(input))
val records = reader.iterator.toList
tagRegex = ("CATG" + "[CATG]{" + 17 + "}").r
val record1 = records(0)
val record2 = records(1)
val record3 = records(2)
val result1 = getTags(record1._1, record1._2, tagRegex)
val result2 = getTags(record2._1, record2._2, tagRegex)
val result3 = getTags(record3._1, record3._2, tagRegex)
result1.allTags.size shouldBe 2
result1.allAntiTags.size shouldBe 2
result1.firstTag shouldBe "CATGGATTGCGCTCTACTGGT"
result1.firstAntiTag shouldBe "CATGGTTCCCAGTGTGAGAAC"
result2.allTags.size shouldBe 2
result2.allAntiTags.size shouldBe 2
result2.firstTag shouldBe "CATGTTCTTCCTTAGCACCCT"
result2.firstAntiTag shouldBe "CATGGGTGGAACCCTTAAAAC"
result3.allTags.size shouldBe 0
result3.allAntiTags.size shouldBe 0
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment