0
|
1 import sfle
|
|
2 import csv
|
|
3
|
|
4 Import( "*" )
|
|
5 pE = DefaultEnvironment( )
|
|
6
|
|
7 # Extensions
|
|
8 sGraphlanAnnotationFileExtension = "-ann.txt"
|
|
9 sGraphlanCoreAnnotFileExtension = "-ann-core.txt"
|
|
10 sGraphlanCoreGenesFileExtension = "-core.txt"
|
|
11 sGraphlanFigureExtension = "-graphlan.pdf"
|
|
12 sMaaslinDataFileExtension = ".txt"
|
|
13 sMaaslinReadConfigFileExtension = ".read.config"
|
|
14 sMaaslinSummaryFileExtension = ".txt"
|
|
15
|
|
16 sCustomRScriptExtension = ".R"
|
|
17 sPCLExtension = ".pcl"
|
|
18 sTransposeExtension = ".tsv"
|
|
19
|
|
20 # Files
|
|
21 strMaaslinGraphlanSettings = "Graphlan_settings.txt"
|
|
22
|
|
23 # Script
|
|
24 sScriptGraphlan = File(os.path.join("..","graphlan","graphlan.py"))
|
|
25 sScriptGraphlanAnnotate = File(os.path.join("..","graphlan","graphlan_annotate.py"))
|
|
26 sScriptMaaslinSummaryToGraphlanAnnotation = File(sfle.d(fileDirSrc,"MaaslinToGraphlanAnnotation.py"))
|
|
27 sScriptPCLToCoreGene = File(sfle.d(fileDirSrc,"PCLToGraphlanCoreGene.py"))
|
|
28
|
|
29 sProgMaaslin = sfle.d(fileDirSrc,"Maaslin.R")
|
|
30
|
|
31 # Settings
|
|
32 iGraphlanDPI = 150
|
|
33 iGraphlanFigureSize = 4
|
|
34 iGraphlanPad = 0.2
|
|
35 strGraphlanDirectory = "graphlan"
|
|
36
|
|
37 c_fileDirLib = sfle.d( fileDirSrc, "lib" )
|
|
38 c_fileInputMaaslinR = sfle.d( pE, fileDirSrc, "Maaslin.R" )
|
|
39 c_afileTestsR = [sfle.d( pE, c_fileDirLib, s ) for s in
|
|
40 ("IO.R", "SummarizeMaaslin.R", "Utility.R", "ValidateData.R")]
|
|
41
|
|
42 c_afileDocsR = c_afileTestsR + [sfle.d( pE, c_fileDirLib, s ) for s in
|
|
43 ( "AnalysisModules.R", "scriptBiplotTSV.R", "BoostGLM.R", "Constants.R", "MaaslinPlots.R")]
|
|
44
|
|
45 ##Test scripts
|
|
46 for fileInputR in c_afileTestsR:
|
|
47 strBase = sfle.rebase( fileInputR, True )
|
|
48 #Testing summary file
|
|
49 fileTestingSummary = sfle.d( pE, fileDirOutput, strBase +"-TestReport.txt" )
|
|
50 dirTestingR = Dir( sfle.d( fileDirSrc, "test-" + strBase ) )
|
|
51 Default( sfle.testthat( pE, fileInputR, dirTestingR, fileTestingSummary ) )
|
|
52
|
|
53 ##Inline doc
|
|
54 for fileProg in c_afileDocsR:
|
|
55 filePDF = sfle.d( pE, fileDirOutput, sfle.rebase( fileProg, sfle.c_strSufR, sfle.c_strSufPDF ) )
|
|
56 Default( sfle.inlinedocs( pE, fileProg, filePDF, fileDirTmp ) )
|
|
57
|
|
58 ##Start regression suite
|
|
59 execfile( "SConscript_maaslin.py" )
|
|
60
|
|
61 ##Input pcl files
|
|
62 lsMaaslinInputFiles = Glob( sfle.d( fileDirInput, "*" + sfle.c_strSufPCL ) )
|
|
63
|
|
64 ## Run MaAsLin and generate output
|
|
65 for strPCLFile in lsMaaslinInputFiles:
|
|
66 Default( MaAsLin( strPCLFile ))
|
|
67
|
|
68 # #Graphlan figure
|
|
69 # #TODO Fix path dependent, better way to know it is installed?
|
|
70 # if(os.path.exists(sScriptGraphlan.get_abspath())):
|
|
71
|
|
72 # ## Run Graphlan on all output projects
|
|
73 # strProjectName = os.path.splitext(os.path.split(strPCLFile.get_abspath())[1])[0]
|
|
74 # strMaaslinOutputDir = sfle.d(fileDirOutput,strProjectName)
|
|
75
|
|
76 # ##Get maaslin data files
|
|
77 # strMaaslinSummaryFile = sfle.d(os.path.join(strMaaslinOutputDir, strProjectName + sMaaslinSummaryFileExtension))
|
|
78
|
|
79 # # Make core gene file
|
|
80 # sCoreGeneFile = File(sfle.d(strMaaslinOutputDir, os.path.join(strGraphlanDirectory,sfle.rebase(strMaaslinSummaryFile, sMaaslinSummaryFileExtension,sGraphlanCoreGenesFileExtension))))
|
|
81 # sReadConfigFile = File(sfle.d(fileDirInput,sfle.rebase(strMaaslinSummaryFile, sMaaslinSummaryFileExtension,sMaaslinReadConfigFileExtension)))
|
|
82 # sfle.op(pE, sScriptPCLToCoreGene, [[False, strPCLFile],[False, sReadConfigFile],[True, sCoreGeneFile]])
|
|
83
|
|
84 # # Make annotation file
|
|
85 # sAnnotationFile = File(sfle.d(strMaaslinOutputDir, os.path.join(strGraphlanDirectory,sfle.rebase(strMaaslinSummaryFile, sMaaslinSummaryFileExtension,sGraphlanAnnotationFileExtension))))
|
|
86 # sfle.op(pE, sScriptMaaslinSummaryToGraphlanAnnotation, [[False, strMaaslinSummaryFile],[False,sCoreGeneFile],[False,File(sfle.d(fileDirSrc,strMaaslinGraphlanSettings))],[True,sAnnotationFile]])
|
|
87
|
|
88 # # Generate core gene annotation file names
|
|
89 # sCoreGeneAnnotationFile = File(sfle.d(strMaaslinOutputDir, os.path.join(strGraphlanDirectory,sfle.rebase(strMaaslinSummaryFile, sMaaslinSummaryFileExtension,sGraphlanCoreAnnotFileExtension))))
|
|
90 # sfle.op(pE, sScriptGraphlanAnnotate, ["--annot",[sAnnotationFile],[False, sCoreGeneFile],[True, sCoreGeneAnnotationFile]])
|
|
91
|
|
92 # # Call graphlan
|
|
93 # # graphlan.py --dpi 150 --size 4 --pad 0.2 core_genes.annot.xml core_genes.png
|
|
94 # sGraphlanFigure = File(sfle.d(strMaaslinOutputDir, os.path.join(strGraphlanDirectory, sfle.rebase(strMaaslinSummaryFile, sMaaslinSummaryFileExtension,sGraphlanFigureExtension))))
|
|
95 # sfle.op(pE, sScriptGraphlan, [[False, sCoreGeneAnnotationFile],[True, sGraphlanFigure],"--dpi",iGraphlanDPI,"--size",iGraphlanFigureSize,"--pad",iGraphlanPad])
|
|
96
|
|
97 # Default(sCoreGeneFile,sAnnotationFile,sCoreGeneAnnotationFile,sGraphlanFigure)
|