Mercurial > repos > melissacline > xena_import
changeset 2:b3cd322f7749
Uploaded
author | melissacline |
---|---|
date | Wed, 03 Sep 2014 15:34:45 -0400 |
parents | a42384446daf |
children | cae2b765ca5d |
files | tool_dependencies.xml xena_import.py xena_import.xml |
diffstat | 3 files changed, 69 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tool_dependencies.xml Wed Sep 03 15:34:45 2014 -0400 @@ -0,0 +1,12 @@ +<?xml version="1.0"?> +<tool_dependency> + <package name="installXena2" version="1.0"> + <install version="1.0"> + <actions> + <action type="set_environment"> + <environment_variable name="XENA_BASE_DIR" action="set_to">$INSTALL_DIR/xena</environment_variable> + </action> + </actions> + </install> + </package> +</tool_dependency>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/xena_import.py Wed Sep 03 15:34:45 2014 -0400 @@ -0,0 +1,40 @@ +#!/usr/bin/env python + +""" + xena_import.py: import a dataset into Xena + + Given a cmdline-specified genomic data file and a cmdline-specified Xena + directory, import the genomic data fle into Xena. This requires assembling + the necessary json file, based on cmdline input. +""" + +import argparse +import json +import shutil + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("genomicDataPathname", type=str) + parser.add_argument("cohort", type=str) + parser.add_argument("type", type=str) + parser.add_argument("xenaInputDir", type=str) + args = parser.parse_args() + + # Assemble the metadata in JSON format + metadata = { 'cohort': args.cohort, 'type': args.type } + jsonMetadata = json.dumps(metadata, indent=2) + + # Write the metadata to a file in the Xena directory. Use the filename + # of the genomic data file, with an added .json extension. + genomicDataFilename = args.genomicDataPathname.split("/")[-1] + jsonMetadataPathname = "%s/%s.json" % (args.xenaInputDir, + genomicDataFilename) + fp = open(jsonMetadataPathname, "w") + fp.write("%s\n" % (jsonMetadata)) + fp.close() + + # Finally, copy the genomic data into the Xena directory + shutil.copy(args.genomicDataPathname, args.xenaInputDir) + +if __name__ == "__main__": + main()
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/xena_import.xml Wed Sep 03 15:34:45 2014 -0400 @@ -0,0 +1,17 @@ +<tool id="xenaImport" description="XENA Import" name="XENA Import" version="0.0.1"> + <description>Import into the Xena VM</description> + <requirements> + <requirement type="package" version="1.0">installXena2</requirement> + </requirements> + <command interpreter="python"> + xena_import.py ${xenaInputData} ${cohort} ${metadataType} ${XENA_BASE_DIR}/files/ + </command> + <inputs> + <param format="data" type="data" name="xenaInputData" label="Data to import to Xena" optional="false"/> + <param format="str" type="text" name="cohort" label="Cohort" optional="false"/> + <param format="str" type="text" name="metadataType" label="Data Type (e.g. clinicalMatrix)" optional="false"/> + </inputs> + <help> + To Appear + </help> +</tool>