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