annotate src/test-Maaslin/test-Maaslin.R @ 8:e9677425c6c3 default tip

Updated the structure of the libraries
author george.weingart@gmail.com
date Mon, 09 Feb 2015 12:17:40 -0500
parents e0b5980139d9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
1 c_strDir <- file.path(getwd( ),"..")
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
2
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
3 source(file.path(c_strDir,"lib","Constants.R"))
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
4 strTestingDirectory = file.path(c_strDir,c_strTestingDirectory)
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
5 sScriptMaaslin = file.path( c_strDir, "Maaslin.R" )
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
6
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
7 context("Test Run From Commandline")
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
8
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
9 #Input Files
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
10 sTestReadConfig = file.path(strTestingDirectory, c_strTestingInput, "TestMaaslin.read.config")
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
11 sTestCustomR = file.path(strTestingDirectory, c_strTestingInput, "TestMaaslin.R")
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
12 sTestMaaslinDirectory = file.path(strTestingDirectory, c_strTemporaryFiles, "testMaaslin")
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
13 sTestOutput = file.path(sTestMaaslinDirectory,"TestMaaslin_Summary.txt")
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
14 sTestTSV = file.path(strTestingDirectory, c_strTestingInput, "TestMaaslin.tsv")
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
15 #Test file answers
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
16 sTestOutputAnswer = file.path(strTestingDirectory, c_strCorrectAnswers, "TestMaaslin.tsv")
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
17
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
18 #Delete Test MaAsLin output
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
19 unlink(sTestMaaslinDirectory, recursive=TRUE)
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
20 #Make neccessary directories
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
21 dir.create(sTestMaaslinDirectory)
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
22 dir.create(file.path(sTestMaaslinDirectory,"QC"))
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
23
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
24 sCommand = paste(sScriptMaaslin, "-v", "ERROR", "-d", "0.25", "-r", "0.0001", "-p", "0.1", sTestOutput, sTestTSV, sTestReadConfig, sTestCustomR, sep=" ")
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
25 print(sCommand)
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
26 system(sCommand)
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
27
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
28 sExpectedTitle = "\tVariable\tFeature\tValue\tCoefficient\tN\tN.not.0\tP.value\tQ.value"
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
29 iExpectedNumberOfLines = 3
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
30 lsOutputSummaryFile = readLines(sTestOutput)
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
31
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
32 test_that("Make sure that the summary output file is what is expected (generally).",{
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
33 expect_equal(lsOutputSummaryFile[1], sExpectedTitle)
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
34 expect_equal(length(lsOutputSummaryFile),iExpectedNumberOfLines)
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
35 })
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
36
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
37 lsDirectoryStructure = list.files(sTestMaaslinDirectory)
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
38 lsDirectoryStructureAnswer = c(basename(sTestOutput),"QC","TestMaaslin-age.pdf","TestMaaslin-age.txt","TestMaaslin-dx.txt","TestMaaslin.pdf","TestMaaslin.txt")
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
39 test_that("Make sure the expected directory structure is created.",{
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
40 expect_equal(sort(lsDirectoryStructure), sort(lsDirectoryStructureAnswer))
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
41 })