X-Git-Url: http://woldlab.caltech.edu/gitweb/?a=blobdiff_plain;f=htsworkflow%2Fpipelines%2Fsrf.py;h=c313efe76e303db6a3508342204f482e87736a72;hb=2ad045b9026e0cb9e7d3d325c26f900bf1cbe334;hp=7f11cbce6d6d71a67749713bbcae9ab6b1fd0079;hpb=61ce2870651f2f3d7d63d3f7efce2d4bd84cc92f;p=htsworkflow.git diff --git a/htsworkflow/pipelines/srf.py b/htsworkflow/pipelines/srf.py index 7f11cbc..c313efe 100644 --- a/htsworkflow/pipelines/srf.py +++ b/htsworkflow/pipelines/srf.py @@ -52,7 +52,7 @@ def make_srf_commands(run_name, bustard_dir, lanes, site_name, destdir, cmdlevel cmd_list = [] for lane in lanes: - name_prefix = '%s_%%l_%%t_' % (run_name,) + name_prefix = '%s_%%l_' % (run_name,) destname = '%s_%s_%d.srf' % (site_name, run_name, lane) destdir = os.path.normpath(destdir) dest_path = os.path.join(destdir, destname) @@ -82,34 +82,38 @@ def make_srf_commands(run_name, bustard_dir, lanes, site_name, destdir, cmdlevel return cmd_list def create_qseq_patterns(bustard_dir): - """ - Scan a bustard directory for qseq files and determine a glob pattern - """ - # grab one tile for each lane. - qseqs = glob(os.path.join(bustard_dir, '*_0001_qseq.txt')) - qseqs = [ os.path.split(x)[-1] for x in qseqs ] - if len(qseqs[0].split('_')) == 4: - # single ended - return [(None, "s_%d_[0-9][0-9][0-9][0-9]_qseq.txt")] - elif len(qseqs[0].split('_')) == 5: - # more than 1 read - # build a dictionary of read numbers by lane - # ( just in case we didn't run all 8 lanes ) - lanes = {} - for q in qseqs: - sample, lane, read, tile, extension = q.split('_') - lanes.setdefault(lane, []).append(read) - qseq_patterns = [] - # grab a lane from the dictionary - # I don't think it matters which one. - k = lanes.keys()[0] - # build the list of patterns - for read in lanes[k]: - read = int(read) - qseq_patterns.append((read, 's_%d_' + '%d_[0-9][0-9][0-9][0-9]_qseq.txt' % (read,))) - return qseq_patterns - else: - raise RuntimeError('unrecognized qseq pattern, not a single or multiple read pattern') + """Scan a bustard directory for qseq files and determine a glob pattern + """ + # grab one tile for each lane. + qseqs = glob(os.path.join(bustard_dir, '*_1101_qseq.txt')) + # handle old runfolders + if len(qseqs) == 0: + qseqs = glob(os.path.join(bustard_dir, '*_0001_qseq.txt')) + if len(qseqs) == 0: + r + qseqs = [ os.path.split(x)[-1] for x in qseqs ] + if len(qseqs[0].split('_')) == 4: + # single ended + return [(None, "s_%d_[0-9][0-9][0-9][0-9]_qseq.txt")] + elif len(qseqs[0].split('_')) == 5: + # more than 1 read + # build a dictionary of read numbers by lane + # ( just in case we didn't run all 8 lanes ) + lanes = {} + for q in qseqs: + sample, lane, read, tile, extension = q.split('_') + lanes.setdefault(lane, []).append(read) + qseq_patterns = [] + # grab a lane from the dictionary + # I don't think it matters which one. + k = lanes.keys()[0] + # build the list of patterns + for read in lanes[k]: + read = int(read) + qseq_patterns.append((read, 's_%d_' + '%d_[0-9][0-9][0-9][0-9]_qseq.txt' % (read,))) + return qseq_patterns + else: + raise RuntimeError('unrecognized qseq pattern, not a single or multiple read pattern') def make_qseq_commands(run_name, bustard_dir, lanes, site_name, destdir, cmdlevel=ILLUMINA2SRF11): """ @@ -172,3 +176,4 @@ def make_md5_commands(destdir): cmd_list.append(cmd) return cmd_list +