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