# HG changeset patch # User jingchunzhu # Date 1437693273 25200 # Node ID d8dc482ef9705e5a54d0071f29de4fc0939e2af3 # Parent a3fbe077a14cb21c84fa3952675d93fe0da6a318 add functionality to import probeMap diff -r a3fbe077a14c -r d8dc482ef970 xena_import.py --- a/xena_import.py Thu Jul 23 01:02:24 2015 -0700 +++ b/xena_import.py Thu Jul 23 16:14:33 2015 -0700 @@ -53,6 +53,7 @@ parser.add_argument("--dataSubType", type=str, default=None) parser.add_argument("--label", type=str, default=None) parser.add_argument("--colNormalization", type=bool, default=False) + parser.add_argument("--probeMap", type=str, default=None) args = parser.parse_args() fp2 = open(args.outfile, "w") @@ -62,6 +63,10 @@ jsonMetadataTargetPathname = "%s/%s.json" % (xenaFileDir, genomicDataFile) + if args.probeMap is not None: + probeMapDataFile = args.probeMap.split("/")[-1] + jsonProbeMapMetadataTargetPathname = "%s/%s.json" % (xenaFileDir, + probeMapDataFile) # The metadata either came as the name of a JSON file or a series of # command line arguments. @@ -83,13 +88,27 @@ metadata['colNormalization'] = "true" else: updateColNormalization(metadata) + if args.probeMap is not None: + metadata[':probeMap'] = probeMapDataFile + jsonMetadata = json.dumps(metadata, indent=2) fp = open(jsonMetadataTargetPathname, "w") fp.write("%s\n" % (jsonMetadata)) fp.close() + if args.probeMap is not None: + probeMapMetadata={"type":"probeMap"} + jsonProbeMapMetadata = json.dumps(probeMapMetadata, indent=2) + jsonProbeMapMetadataTargetPathname = "%s/%s.json" % (xenaFileDir, + probeMapDataFile) + fp = open(jsonProbeMapMetadataTargetPathname, "w") + fp.write("%s\n" % ( jsonProbeMapMetadata)) + fp.close() + # Finally, copy the genomic data into the Xena directory shutil.copy(args.genomicDataPath, xenaFileDir) + if args.probeMap is not None: + shutil.copy(args.probeMap, xenaFileDir) # Set up the xena load comamnd and try to execute it. If an exception # is generated, output a traceback and exit with nonzero status. If @@ -99,6 +118,16 @@ xenaFileDir, genomicDataFile, xena.port()) + loadInToXena (xenaLoadCmd, fp2) + if args.probeMap is not None: + xenaLoadCmd = "java -jar %s -l --force %s/%s -p %s" % (xena.jarPath(), + xenaFileDir, + probeMapDataFile, + xena.port()) + loadInToXena (xenaLoadCmd, fp2) + + +def loadInToXena (xenaLoadCmd, fp2): try: subprocess.call(xenaLoadCmd, shell=True) except: @@ -113,6 +142,5 @@ fp2.close() sys.exit(0) - if __name__ == "__main__": main() diff -r a3fbe077a14c -r d8dc482ef970 xena_import.xml --- a/xena_import.xml Thu Jul 23 01:02:24 2015 -0700 +++ b/xena_import.xml Thu Jul 23 16:14:33 2015 -0700 @@ -1,124 +1,103 @@ - + Import from Galaxy into the Xena VM installXena xena_import.py ${xenaInputData} $outfile - #if $source.metadataSource == "json" - --json ${source.xenaMetadata} - #else - --cohort "${source.cohort}" --type ${source.format.metadataType} - #if $source.format.metadataType == "genomicMatrix" or $source.format.metadataType == "clinicalMatrix": - #if $source.format.isCustom.dataSubType == "custom" - #if $source.format.isCustom.customSubType - --dataSubType "${source.format.isCustom.customSubType}" - #end if - #else - --dataSubType "${source.format.isCustom.dataSubType}" + --cohort "${cohort}" --type ${format.metadataType} + #if $format.metadataType == "genomicMatrix" or $format.metadataType == "clinicalMatrix": + #if $format.isCustom.dataSubType == "custom" + #if $format.isCustom.customSubType + --dataSubType "${format.isCustom.customSubType}" #end if - #end if - #if $source.label - --label "${source.label}" #else - --label "${xenaInputData.name}" + --dataSubType "${format.isCustom.dataSubType}" #end if #end if + + #if $label + --label "${label}" + #else + --label "${xenaInputData.name}" + #end if + + #if $format.withProbeMap.probeMap =="select" + --probeMap "${format.withProbeMap.probeMapFile}" + #end if + #if $colNormalization: --colNormalization 1 #end if - - - - + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + +