comparison maaslin-4450aa4ecc84/src/test-Maaslin/test-Maaslin.R @ 1:a87d5a5f2776

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