comparison maaslin-4450aa4ecc84/SConscript_maaslin.py @ 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 #!/usr/bin/env python
2 """
3 Authors: Timothy Tickle and Curtis Huttenhower
4 Description: Find associations in two matrices of data.
5 """
6
7 __author__ = "Timothy Tickle and Curtis Huttenhower"
8 __copyright__ = "Copyright 2012"
9 __credits__ = ["Timothy Tickle","Curtis Huttenhower"]
10 __maintainer__ = "Timothy Tickle"
11 __email__ = "ttickle@hsph.harvard.edu"
12
13 import argparse
14 import os
15 import sfle
16 import sys
17
18 c_strSufRC = ".read.config"
19
20 c_fileDirSrc = Dir( sfle.d( os.path.dirname( sfle.current_file( ) ), sfle.c_strDirSrc ) )
21 c_fileProgMaaslin = File( sfle.d( c_fileDirSrc, "Maaslin.R" ) )
22 sArgsExt = ".args"
23 #Commandline to ignore
24 lsIgnore = ["-i","-I","--input_config","--input_process"]
25
26 def MaAsLin( filePCL ):
27 #Build input file name if they exist or give ""
28 strBase = filePCL.get_abspath().replace( sfle.c_strSufPCL, "" )
29 strR, strRC, strArgs = (( strBase + s ) for s in (sfle.c_strSufR, c_strSufRC, sArgsExt))
30 fileR, fileRC, fileArgs = (( File( s ) if os.path.exists( s ) else "" ) for s in (strR, strRC, strArgs))
31
32 ## Read in an args file if it exists
33 lsArgs = []
34 if fileArgs:
35 fReader = csv.reader(open(fileArgs.get_abspath(),'r'), delimiter = " ")
36 lsArgsTmp = []
37 [lsArgsTmp.extend(lsLine) for lsLine in fReader]
38 fSkip = False
39 for s in lsArgsTmp:
40 if s in lsIgnore:
41 fSkip=True
42 continue
43 if fSkip:
44 fSkip = not fSkip
45 continue
46 lsArgs.append(s)
47
48 lsInputArgs = ["-I",[fileR]] if fileR else []
49 lsInputArgs.extend(["-i",[fileRC]] if fileRC else [])
50 lsArgs.extend(lsInputArgs)
51
52 strBase = os.path.basename( strBase )
53 fileTSVFile = File(sfle.d(fileDirTmp,sfle.rebase(filePCL,sfle.c_strSufPCL,sfle.c_strSufTSV)))
54 strT = File( sfle.d( os.path.join(fileDirOutput.get_abspath(), strBase, strBase + sfle.c_strSufTXT) ) )
55
56 #Transpose PCL
57 sfle.spipe(pE, filePCL, c_fileProgTranspose, fileTSVFile)
58 #Run MaAsLin
59 sfle.op(pE, c_fileProgMaaslin, lsArgs+[[True,strT],[False, fileTSVFile]])
60 if fileArgs: Depends(c_fileProgMaaslin, fileArgs)
61 Default(strT)