# HG changeset patch # User kellrott # Date 1371248357 14400 # Node ID f1f1f8437f7cdc507e0bdc52ca5af3c5e888e862 Uploaded diff -r 000000000000 -r f1f1f8437f7c genetorrent/genetorrent.py --- /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() diff -r 000000000000 -r f1f1f8437f7c genetorrent/genetorrent.xml --- /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 @@ + + download BAM files from CGHub + +genetorrent.py $uuid $cred_file $outfile $outfile.dataset.dataset.id + + + + + + + + + + + + + + +Download BAM files from CGHub + +