+queue
+"""
+ for f in files:
+ if not os.path.exists(f):
+ raise RuntimeError("Missing %s" % (f,))
+
+ context = {'archivename': make_submission_name(ininame),
+ 'filelist': " ".join(files),
+ 'initialdir': os.getcwd()}
+
+ condor_script = make_condor_name(ininame, 'archive')
+ condor_stream = open(condor_script,'w')
+ condor_stream.write(script % context)
+ condor_stream.close()
+ return condor_script
+
+def make_condor_upload_script(ininame):
+ script = """Universe = vanilla
+
+Executable = /usr/bin/lftp
+arguments = -c put ../%(archivename)s -o ftp://detrout@encodeftp.cse.ucsc.edu/
+
+Error = upload.err.$(Process).log
+Output = upload.out.$(Process).log
+Log = /tmp/submission-upload.log
+initialdir = %(initialdir)s
+
+queue
+"""
+ context = {'archivename': make_submission_name(ininame),
+ 'initialdir': os.getcwd()}
+
+ condor_script = make_condor_name(ininame, 'upload')
+ condor_stream = open(condor_script,'w')
+ condor_stream.write(script % context)
+ condor_stream.close()
+ return condor_script
+
+def make_dag_fragment(ininame, archive_condor, upload_condor):
+ """
+ Make the couple of fragments compress and then upload the data.
+ """
+ cur_dir = os.getcwd()
+ archive_condor = os.path.join(cur_dir, archive_condor)
+ upload_condor = os.path.join(cur_dir, upload_condor)
+ job_basename = make_base_name(ininame)
+
+ fragments = []
+ fragments.append('JOB %s_archive %s' % (job_basename, archive_condor))
+ fragments.append('JOB %s_upload %s' % (job_basename, upload_condor))
+ fragments.append('PARENT %s_archive CHILD %s_upload' % (job_basename, job_basename))
+
+ return fragments
+
+def get_library_info(host, apidata, library_id):
+ url = api.library_url(host, library_id)
+ contents = api.retrieve_info(url, apidata)
+ return contents
+
+def condor_srf_to_fastq(srf_file, target_pathname, paired, flowcell=None,
+ mid=None):
+ args = ['-c', srf_file, ]
+ if paired:
+ args.extend(['--left', target_pathname])
+ # this is ugly. I did it because I was pregenerating the target
+ # names before I tried to figure out what sources could generate
+ # those targets, and everything up to this point had been
+ # one-to-one. So I couldn't figure out how to pair the
+ # target names.
+ # With this at least the command will run correctly.
+ # however if we rename the default targets, this'll break
+ # also I think it'll generate it twice.
+ args.extend(['--right',
+ target_pathname.replace('_r1.fastq', '_r2.fastq')])
+ else:
+ args.extend(['--single', target_pathname ])
+ if flowcell is not None:
+ args.extend(['--flowcell', flowcell])
+
+ if mid is not None:
+ args.extend(['-m', str(mid)])
+
+ script = """
+arguments="%s"
+queue
+""" % (" ".join(args),)