annotate src/test-SummarizeMaaslin/test-SummarizeMaaslin.R @ 0:e0b5980139d9

maaslin
author george-weingart
date Tue, 13 May 2014 22:00:40 -0400
parents
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 source(file.path(c_strDir,"lib","SummarizeMaaslin.R"))
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
5 source(file.path(c_strDir,"lib","Utility.R"))
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
6
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
7 context("Test funcSummarizeDirectory")
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
8 strDirectoryNone = file.path(c_strDir,c_strTestingDirectory,c_strTestingInput,"funcSummarizeDirectory","None")
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
9 strDirectory1 = file.path(c_strDir,c_strTestingDirectory,c_strTestingInput,"funcSummarizeDirectory","1")
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
10 strDirectory3 = file.path(c_strDir,c_strTestingDirectory,c_strTestingInput,"funcSummarizeDirectory","3")
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
11 strFileBase1 = "FileBase1.txt"
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
12 strFileBase2 = "FileBase2.txt"
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
13
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
14 sKeyword = "Q.value"
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
15 sAltKeyword = "P.value"
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
16 sAltSignificance = "0.35"
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
17
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
18 sBaseName = "FuncSummarizeDirectory"
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
19
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
20 #Output and answer files
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
21 sNoFileResult = file.path(c_strDir,c_strTestingDirectory,c_strTemporaryFiles,"FuncSummarizeDirectory-NoFileResult.txt")
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
22 sNoFileResultAltKeyword = file.path(c_strDir,c_strTestingDirectory,c_strTemporaryFiles,"FuncSummarizeDirectory-NoFileAltKeyResult.txt")
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
23 sNoFileResultAltSig = file.path(c_strDir,c_strTestingDirectory,c_strTemporaryFiles,"FuncSummarizeDirectory-NoFileAltSigResult.txt")
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
24 sNoFileResultAnswer = file.path(c_strDir,c_strTestingDirectory,c_strCorrectAnswers,"FuncSummarizeDirectory-NoFileAnswer.txt")
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
25 sNoFileResultAnswerAltKeyword = file.path(c_strDir,c_strTestingDirectory,c_strCorrectAnswers,"FuncSummarizeDirectory-NoFileAltKeyAnswer.txt")
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
26 sNoFileResultAnswerAltSig = file.path(c_strDir,c_strTestingDirectory,c_strCorrectAnswers,"FuncSummarizeDirectory-NoFileAltSigAnswer.txt")
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
27 unlink(sNoFileResult)
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
28 sCorrectResults1File = file.path(c_strDir,c_strTestingDirectory,c_strTemporaryFiles,"FuncSummarizeDirectory-1FileResult.txt")
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
29 sCorrectResults1FileAltKeyword = file.path(c_strDir,c_strTestingDirectory,c_strTemporaryFiles,"FuncSummarizeDirectory-1FileAltKeyResult.txt")
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
30 sCorrectResults1FileAltSig = file.path(c_strDir,c_strTestingDirectory,c_strTemporaryFiles,"FuncSummarizeDirectory-1FileAltSigResult.txt")
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
31 sCorrectResults1FileAnswer = file.path(c_strDir,c_strTestingDirectory,c_strCorrectAnswers,"FuncSummarizeDirectory-1FileResult.txt")
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
32 sCorrectResults1FileAnswerAltKeyword = file.path(c_strDir,c_strTestingDirectory,c_strCorrectAnswers,"FuncSummarizeDirectory-1FileAltKeyResult.txt")
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
33 sCorrectResults1FileAnswerAltSig = file.path(c_strDir,c_strTestingDirectory,c_strCorrectAnswers,"FuncSummarizeDirectory-1FileAltSigResult.txt")
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
34 unlink(sCorrectResults1File)
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
35 sCorrectResults3Files = file.path(c_strDir,c_strTestingDirectory,c_strTemporaryFiles,"FuncSummarizeDirectory-3FileResult.txt")
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
36 sCorrectResults3FilesAltKeyword = file.path(c_strDir,c_strTestingDirectory,c_strTemporaryFiles,"FuncSummarizeDirectory-3FileAltKeyResult.txt")
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
37 sCorrectResults3FilesAltSig = file.path(c_strDir,c_strTestingDirectory,c_strTemporaryFiles,"FuncSummarizeDirectory-3FileAltSigResult.txt")
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
38 sCorrectResults3FilesAnswer = file.path(c_strDir,c_strTestingDirectory,c_strCorrectAnswers,"FuncSummarizeDirectory-3FileResult.txt")
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
39 sCorrectResults3FilesAnswerAltKeyword = file.path(c_strDir,c_strTestingDirectory,c_strCorrectAnswers,"FuncSummarizeDirectory-3FileAltKeyResult.txt")
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
40 sCorrectResults3FilesAnswerAltSig = file.path(c_strDir,c_strTestingDirectory,c_strCorrectAnswers,"FuncSummarizeDirectory-3FileAltSigResult.txt")
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
41 unlink(sCorrectResults3Files)
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
42
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
43 #Run tests
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
44 funcSummarizeDirectory(astrOutputDirectory=strDirectoryNone, strBaseName=sBaseName, astrSummaryFileName=sNoFileResult, astrKeyword=sKeyword, afSignificanceLevel="0.25")
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
45 funcSummarizeDirectory(astrOutputDirectory=strDirectory1, strBaseName=sBaseName, astrSummaryFileName=sCorrectResults1File, astrKeyword=sKeyword, afSignificanceLevel="0.25")
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
46 funcSummarizeDirectory(astrOutputDirectory=strDirectory3, strBaseName=sBaseName, astrSummaryFileName=sCorrectResults3Files, astrKeyword=sKeyword, afSignificanceLevel="0.25")
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
47
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
48 funcSummarizeDirectory(astrOutputDirectory=strDirectoryNone, strBaseName=sBaseName, astrSummaryFileName=sNoFileResultAltKeyword, astrKeyword=sAltKeyword, afSignificanceLevel="0.25")
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
49 funcSummarizeDirectory(astrOutputDirectory=strDirectory1, strBaseName=sBaseName, astrSummaryFileName=sCorrectResults1FileAltKeyword, astrKeyword=sAltKeyword, afSignificanceLevel="0.25")
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
50 funcSummarizeDirectory(astrOutputDirectory=strDirectory3, strBaseName=sBaseName, astrSummaryFileName=sCorrectResults3FilesAltKeyword, astrKeyword=sAltKeyword, afSignificanceLevel="0.25")
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
51
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
52 funcSummarizeDirectory(astrOutputDirectory=strDirectoryNone, strBaseName=sBaseName, astrSummaryFileName=sNoFileResultAltSig, astrKeyword= sKeyword, afSignificanceLevel=sAltSignificance)
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
53 funcSummarizeDirectory(astrOutputDirectory=strDirectory1, strBaseName=sBaseName, astrSummaryFileName=sCorrectResults1FileAltSig, astrKeyword= sKeyword, afSignificanceLevel=sAltSignificance)
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
54 funcSummarizeDirectory(astrOutputDirectory=strDirectory3, strBaseName=sBaseName, astrSummaryFileName=sCorrectResults3FilesAltSig, astrKeyword= sKeyword, afSignificanceLevel=sAltSignificance)
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
55
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
56 test_that("Check the cases where no, and real summary files exist.",{
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
57 expect_equal(readLines(sNoFileResult),readLines(sNoFileResultAnswer))
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
58 expect_equal(readLines(sCorrectResults1File),readLines(sCorrectResults1FileAnswer))
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
59 expect_equal(readLines(sCorrectResults3Files),readLines(sCorrectResults3FilesAnswer))
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
60 })
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
61
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
62 test_that("Check changing the keyword.",{
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
63 expect_equal(readLines(sNoFileResultAltKeyword),readLines(sNoFileResultAnswerAltKeyword))
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
64 expect_equal(readLines(sCorrectResults1FileAltKeyword),readLines(sCorrectResults1FileAnswerAltKeyword))
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
65 expect_equal(readLines(sCorrectResults3FilesAltKeyword),readLines(sCorrectResults3FilesAnswerAltKeyword))
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
66 })
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
67
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
68 test_that("Check that changing the significance threshold effects inclusion.",{
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
69 expect_equal(readLines(sNoFileResultAltSig),readLines(sNoFileResultAnswerAltSig))
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
70 expect_equal(readLines(sCorrectResults1FileAltSig),readLines(sCorrectResults1FileAnswerAltSig))
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
71 expect_equal(readLines(sCorrectResults3FilesAltSig),readLines(sCorrectResults3FilesAnswerAltSig))
e0b5980139d9 maaslin
george-weingart
parents:
diff changeset
72 })