Mercurial > repos > kellrott > genetorrent
changeset 0:f1f1f8437f7c draft
Uploaded
author | kellrott |
---|---|
date | Fri, 14 Jun 2013 18:19:17 -0400 |
parents | |
children | 0813ba200784 |
files | genetorrent/genetorrent.py genetorrent/genetorrent.xml |
diffstat | 2 files changed, 76 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/genetorrent/genetorrent.py Fri Jun 14 18:19:17 2013 -0400 @@ -0,0 +1,55 @@ +#!/usr/bin/env python + +import sys +import subprocess +import os +import shutil +from glob import glob +import json + +def which(cmd): + cmd = ["which",cmd] + p = subprocess.Popen(cmd, stdout=subprocess.PIPE) + res = p.stdout.readline().rstrip() + if len(res) == 0: return None + return res + +if __name__ == "__main__": + uuid = sys.argv[1] + cred_file = sys.argv[2] + output = sys.argv[3] + output_id = int(sys.argv[4]) + + gtdownload = which("gtdownload") + if gtdownload is None: + sys.stderr.write("gtdownload not found\n") + handle.close() + sys.exit(1) + + cred_dir = os.path.join(os.path.dirname(os.path.dirname(gtdownload)), "share", "GeneTorrent") + serr = open("std.error", "w") + + proc = subprocess.Popen( [gtdownload, "-c", cred_file, "-C", cred_dir, "-d", uuid, "-vv"], stderr=serr ) + proc.communicate() + serr.close() + + copied = False + for f in glob(os.path.join(uuid, "*.bam")): + copied = True + shutil.move(f, output) + + if not copied: + handle = open("std.error") + sys.stderr.write(handle.read()) + handle.close() + sys.exit(1) + + json_file = open( 'galaxy.json', 'w' ) + info = dict( type = 'dataset', + ext = "bam", + name = uuid + " CGHub BAM", + uuid = uuid, + dataset_id = output_id + ) + json_file.write( json.dumps( info ) ) + json_file.close()
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/genetorrent/genetorrent.xml Fri Jun 14 18:19:17 2013 -0400 @@ -0,0 +1,21 @@ +<tool id="cghub_genetorrent" name="CGHub GeneTorrent" version="1.0.0"> + <description>download BAM files from CGHub</description> + <command interpreter="python"> +genetorrent.py $uuid $cred_file $outfile $outfile.dataset.dataset.id + </command> + <inputs> + <param name="uuid" type="text" size="50" label="Analysis ID"/> + <param name="cred_file" type="select" label="Download Credentials"> + <options from_file="cghub_credentials.loc"> + <column name="name" index="0"/> + <column name="value" index="1"/> + </options> + </param> + </inputs> + <outputs> + <data name="outfile" format="bam" label="${uuid} BAM"/> + </outputs> + <help> +Download BAM files from CGHub + </help> +</tool>