changeset 35:d8dc482ef970

add functionality to import probeMap
author jingchunzhu <jingchunzhu@gmail.com>
date Thu, 23 Jul 2015 16:14:33 -0700
parents a3fbe077a14c
children d64a002c3b0c
files xena_import.py xena_import.xml
diffstat 2 files changed, 109 insertions(+), 102 deletions(-) [+]
line wrap: on
line diff
--- 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()
--- 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 @@
-<tool id="xenaImport" description="Import into XENA from Galaxy" name="XENA Import" version="0.0.1">
+<tool id="xenaImport" name="XENA Import" version="0.0.1">
   <description>Import from Galaxy into the Xena VM</description>
   <requirements>
     <requirement type="package" version="1.0">installXena</requirement>
   </requirements>
   <command interpreter="python">
     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
   </command>
   <inputs>
     <param format="data" type="data" name="xenaInputData" label="Data to import to Xena" optional="false"/>
-    <conditional name="source">
-      <param type="select" name="metadataSource" label="Metadata entry">
-	<option value="entry">Enter your own</option>
-	<option value="json">Specify json metadata file</option>
+    <param format="str" type="text" name="cohort" label="Cohort" optional="false"/>
+    <conditional name="format">
+      <param type="select" name="metadataType" label="File Format">
+	<option value="genomicMatrix">Rows (Identifiers) by Columns (Samples) (often genomic data)</option>
+	<option value="clinicalMatrix">Rows (Samples) by Columns (Identifiers) (often clinical data)</option>
+	<option value="mutationVector">Mutation By Position</option>
       </param>
-      <when value="json">
-          <param format="data" type="data" name="xenaMetadata" label="Metadata file" optional="false"/>
+      <when value="genomicMatrix">
+	<conditional name="withProbeMap">
+	  <param type="select" name="probeMap" label="Identifier to Gene Mapping">
+	    <option value="none">No id to gene mapping file</option>
+	    <option value="select">Select a id to gene mapping file</option>
+	  </param>
+	  <when value="none"/>
+	  <when value="select">
+	    <param type="data" format="tabular" multiple="false" name="probeMapFile" optional="false"/>
+	  </when>
+        </conditional>
+
+	<conditional name="isCustom">
+	  <param type="select" name="dataSubType" label="Type of data">
+	    <option value="custom">Enter your own</option>
+	    <option value="copy number">copy number</option>
+	    <option value="DNA methylation">DNA methylation</option>
+	    <option value="exon expression">exon expression</option>
+	    <option value="gene expression">gene expression</option>
+	    <option value="gene expression RNAseq">gene expression RNAseq</option>
+	    <option value="gene expression Array">gene expression Array</option>
+	    <option value="mRNA expression">mRNA expression</option>
+	    <option value="somatic mutation (SNP and small INDELs)">somatic mutation (SNP and small INDELs)</option>
+	    <option value="somatic mutation (gene level)">somatic mutation (gene level)</option>
+	    <option value="protein expression RPPA">protein expression RPPA</option>
+	    <option value="PARADIGM pathway activity">PARADIGM pathway activity</option>
+	  </param>
+	  <when value="custom">
+	    <param type="text" name="customSubType" label="Type of data" optional="true"/>
+	  </when>
+	  <when value="copy number"/>
+	  <when value="DNA methylation"/>
+	  <when value="exon expression"/>
+	  <when value="gene expression"/>
+	  <when value="gene expression RNAseq"/>
+	  <when value="gene expression Array"/>
+	  <when value="mRNA expression"/>
+	  <when value="somatic mutation (SNP and small INDELs)"/>
+	  <when value="somatic mutation (gene level)"/>
+	  <when value="protein expression RPPA"/>
+	  <when value="PARADIGM pathway activity"/>
+	</conditional>
+    
       </when>
-      <when value="entry">
-        <param format="str" type="text" name="cohort" label="Cohort" optional="false"/>
-        <conditional name="format">
-          <param type="select" name="metadataType" label="File Format">
-	    <option value="genomicMatrix">Rows (Identifiers) by Columns (Samples) (often genomic data)</option>
-	    <option value="clinicalMatrix">Rows (Samples) by Columns (Identifiers) (often clinical data)</option>
-	    <option value="mutationVector">Mutation By Position</option>
-          </param>
-          <when value="genomicMatrix">
-	    <conditional name="isCustom">
-	      <param type="select" name="dataSubType" label="Type of data">
-	        <option value="custom">Enter your own</option>
-	        <option value="phenotype">phenotype</option>
-	        <option value="copy number">copy number</option>
-	        <option value="DNA methylation">DNA methylation</option>
-	        <option value="exon expression">exon expression</option>
-	        <option value="gene expression">gene expression</option>
-	        <option value="gene expression RNAseq">gene expression RNAseq</option>
-	        <option value="gene expression Array">gene expression Array</option>
-	        <option value="mRNA expression">mRNA expression</option>
-	        <option value="somatic mutation (SNP and small INDELs)">somatic mutation (SNP and small INDELs)</option>
-	        <option value="somatic mutation (gene level)">somatic mutation (gene level)</option>
-	        <option value="protein expression RPPA">protein expression RPPA</option>
-	        <option value="PARADIGM pathway activity">PARADIGM pathway activity</option>
-	      </param>
-	      <when value="custom">
-	        <param type="text" name="customSubType" label="Type of data" optional="true"/>
-	      </when>
-	      <when value="phenotype"/>
-	      <when value="copy number"/>
-	      <when value="DNA methylation"/>
-	      <when value="exon expression"/>
-	      <when value="gene expression"/>
-	      <when value="gene expression RNAseq"/>
-	      <when value="gene expression Array"/>
-	      <when value="mRNA expression"/>
-	      <when value="somatic mutation (SNP and small INDELs)"/>
-	      <when value="somatic mutation (gene level)"/>
-	      <when value="protein expression RPPA"/>
-	      <when value="PARADIGM pathway activity"/>
-	    </conditional>
-          </when>
-          <when value="clinicalMatrix">
-	    <conditional name="isCustom">
-	      <param type="select" name="dataSubType" label="Type of data">
-	        <option value="custom">Enter your own</option>
-	        <option value="phenotype">phenotype</option>
-	        <option value="copy number">copy number</option>
-	        <option value="DNA methylation">DNA methylation</option>
-	        <option value="exon expression">exon expression</option>
-	        <option value="gene expression">gene expression</option>
-	        <option value="gene expression RNAseq">gene expression RNAseq</option>
-	        <option value="gene expression Array">gene expression Array</option>
-	        <option value="mRNA expression">mRNA expression</option>
-	        <option value="somatic mutation (SNP and small INDELs)">somatic mutation (SNP and small INDELs)</option>
-	        <option value="somatic mutation (gene level)">somatic mutation (gene level)</option>
-	        <option value="protein expression RPPA">protein expression RPPA</option>
-	        <option value="PARADIGM pathway activity">PARADIGM pathway activity</option>
-	      </param>
-	      <when value="custom">
-	        <param type="text" name="customSubType" label="Type of data" optional="true"/>
-	      </when>
-	      <when value="phenotype"/>
-	      <when value="copy number"/>
-	      <when value="DNA methylation"/>
-	      <when value="exon expression"/>
-	      <when value="gene expression"/>
-	      <when value="gene expression RNAseq"/>
-	      <when value="gene expression Array"/>
-	      <when value="mRNA expression"/>
-	      <when value="somatic mutation (SNP and small INDELs)"/>
-	      <when value="somatic mutation (gene level)"/>
-	      <when value="protein expression RPPA"/>
-	      <when value="PARADIGM pathway activity"/>
-	    </conditional>
-          </when>
-          <when value="mutationVector"/>
-        </conditional>
-        <param type="text" name="label" label="Display Name (Optional)" optional="true"/>
+      <when value="clinicalMatrix">
+	<conditional name="isCustom">
+	  <param type="select" name="dataSubType" label="Type of data">
+	    <option value="custom">Enter your own</option>
+	    <option value="phenotype">phenotype</option>
+	  </param>
+	  <when value="custom">
+	    <param type="text" name="customSubType" label="Type of data" optional="true"/>
+	  </when>
+	  <when value="phenotype"/>
+	</conditional>
       </when>
+      <when value="mutationVector"/>
     </conditional>
+    <param type="text" name="label" label="Display Name (Optional)" optional="true"/>
     <param type="boolean" name="colNormalization" label="Apply Column Normalization" checked="false"/>
   </inputs>
   <outputs>