def test_find_samples(self):
     plist = find_samples(j_doe_00_01)
     self.assertEqual([os.path.basename(x) for x in plist], ALLSAMPLES)
     plist = find_samples(j_doe_00_01, sample="P111")
     self.assertEqual([os.path.basename(x) for x in plist], [])
     plist = find_samples(j_doe_00_01, sample=SAMPLE)
     self.assertEqual([os.path.basename(x) for x in plist], [SAMPLE])
     plist = find_samples(j_doe_00_01, sample="P001")
     self.assertEqual([os.path.basename(x) for x in plist], [])
     samplefile = os.path.join(j_doe_00_01, "samples.txt")
     with open(samplefile, "w") as fh:
         fh.write(SAMPLE)
     plist = find_samples(j_doe_00_01, sample=samplefile)
     self.assertEqual([os.path.basename(x) for x in plist], [SAMPLE])
 def test_find_samples(self):
     plist = find_samples(j_doe_00_01)
     self.assertEqual([os.path.basename(x) for x in plist], ALLSAMPLES)
     plist = find_samples(j_doe_00_01, sample="P111")
     self.assertEqual([os.path.basename(x) for x in plist], [])
     plist = find_samples(j_doe_00_01, sample=SAMPLE)
     self.assertEqual([os.path.basename(x) for x in plist], [SAMPLE])
     plist = find_samples(j_doe_00_01, sample="P001")
     self.assertEqual([os.path.basename(x) for x in plist], [])
     samplefile = os.path.join(j_doe_00_01, "samples.txt")
     with open(samplefile, "w") as fh:
         fh.write(SAMPLE)
     plist = find_samples(j_doe_00_01, sample=samplefile)
     self.assertEqual([os.path.basename(x) for x in plist], [SAMPLE])
Exemple #3
0
def run_halo(path=None, project=None, batch_size=8, **kw):
    """Run halo application. Setup parameter files and call
    halo_pipeline.sh script.

    :param project: project name
    :param batch_size: number of samples to run in each project config file
    """
    plist = sorted(find_samples(path, **kw))
    plist_chunks=[plist[x:x+batch_size] for x in xrange(0, len(plist), batch_size)]
    i = 0
    param_list = []
    for pl in plist_chunks:
        i += 1
        outfile = os.path.join(path, "{}_{}_halo.projectrc".format(project, i))
        param = {'cl':None, 'platform_args':None, 'workingDirectory':None}
        label = '{}_halo_{}'.format(project[0:3].replace(".", "_"), i)
        d = {'samples' : '"{}"'.format(" ".join([os.path.basename(x) for x in pl])),
             'indir' : path,
             'baits_file' : kw.get('baits', ""),
             'targets_file' : kw.get('targets', ""),
             'target_region' : kw.get('target_region', ""),
             'output' : os.path.join(os.path.dirname(outfile), "{}.out".format(label)),
             'error' : os.path.join(os.path.dirname(outfile), "{}.err".format(label))
             }
        if kw.get("setup", False):
            dry_write(outfile, PROJECTTEMPLATE.render(**d), dry_run=kw.get("dry_run", False))
        if not os.path.exists(outfile):
            LOG.warn("No such configuration file {}; rerun command with '--setup' option")
            return []
        if kw.get("config", None) and os.path.basename(outfile) != kw.get("config", None):
            continue
        param['cl'] = [HALOSCRIPT, "-c", HALORC, outfile]
        param['platform_args'] = ['--output', os.path.join("{}.out".format(label)),
                                  '--error', os.path.join("{}.err".format(label)),
                                  '--job-name', label]
        param['workingDirectory'] = os.path.dirname(outfile)
        param_list.append(param)
    return param_list