def setUp(self): self.sample = Sample( project_id="project", sample_id="sample", sample_prefix="project/sample/sample", project_prefix="project", sample_run_prefix="project/sample/samplerun/samplerun")
class TestABCSample(unittest.TestCase): def setUp(self): self.sample = Sample(project_id="project", sample_id="sample", sample_prefix="project/sample/sample", project_prefix="project", sample_run_prefix="project/sample/samplerun/samplerun") def test_sample(self): self.assertEqual(self.sample.prefix(), "project/sample/sample") self.assertEqual(self.sample.path(), "project/sample") self.assertEqual(self.sample.prefix("project"), "project") self.assertEqual(self.sample.path("project"), ".") self.assertEqual(self.sample.prefix("sample_run"), "project/sample/samplerun/samplerun") self.assertEqual(self.sample.path("sample_run"), "project/sample/samplerun") self.assertEqual(self.sample.project_id(), "project")
class TestABCSample(unittest.TestCase): def setUp(self): self.sample = Sample( project_id="project", sample_id="sample", sample_prefix="project/sample/sample", project_prefix="project", sample_run_prefix="project/sample/samplerun/samplerun") def test_sample(self): self.assertEqual(self.sample.prefix(), "project/sample/sample") self.assertEqual(self.sample.path(), "project/sample") self.assertEqual(self.sample.prefix("project"), "project") self.assertEqual(self.sample.path("project"), ".") self.assertEqual(self.sample.prefix("sample_run"), "project/sample/samplerun/samplerun") self.assertEqual(self.sample.path("sample_run"), "project/sample/samplerun") self.assertEqual(self.sample.project_id(), "project")
def setUp(self): self.sample = Sample(project_id="project", sample_id="sample", sample_prefix="project/sample/sample", project_prefix="project", sample_run_prefix="project/sample/samplerun/samplerun")
def make_fastq_links(targets, indir, outdir, fastq_suffix="001.fastq.gz", ssheet="SampleSheet.csv"): """Given a set of targets and an output directory, create links from targets (source raw data) to an output directory. :param targets: list of :class:`ratatosk.experiment.ISample` objects :param outdir: (top) output directory :param fastq_suffix: fastq suffix :param ssheet: sample sheet name :returns: new targets list with updated output directory """ newtargets = [] for tgt in targets: fastq = glob.glob("{}*{}".format(tgt.prefix("sample_run"), fastq_suffix)) if len(fastq) == 0: logger.warn("No fastq files for prefix {} in {}".format( tgt.prefix("sample_run"), "make_fastq_links")) for f in fastq: newpath = os.path.join(outdir, os.path.relpath(f, indir)) if not os.path.exists(os.path.dirname(newpath)): logger.info("Making directories to {}".format( os.path.dirname(newpath))) os.makedirs(os.path.dirname(newpath)) if not os.path.exists( os.path.join(os.path.dirname(newpath), ssheet)): try: os.symlink( os.path.abspath( os.path.join(os.path.dirname(f), ssheet)), os.path.join(os.path.dirname(newpath), ssheet)) except: logger.warn("No sample sheet found for {}".format()) if not os.path.exists(newpath): logger.info("Linking {} -> {}".format(newpath, os.path.abspath(f))) os.symlink(os.path.abspath(f), newpath) if not os.path.lexists( os.path.join( os.path.dirname(newpath), ssheet)) and os.path.exists( os.path.abspath( os.path.join(os.path.dirname(f), ssheet))): os.symlink( os.path.abspath(os.path.join(os.path.dirname(f), ssheet)), os.path.join(os.path.dirname(newpath), ssheet)) newsample = Sample(project_id=tgt.project_id(), sample_id=tgt.sample_id(), project_prefix=outdir, sample_prefix=os.path.join( outdir, os.path.relpath(tgt.prefix("sample"), indir)), sample_run_prefix=os.path.join( outdir, os.path.relpath(tgt.prefix("sample_run"), indir))) newtargets.append(newsample) # newtargets.append((tgt.sample_id(), # os.path.join(outdir, os.path.relpath(tgt.prefix("sample"), indir)), # os.path.join(outdir, os.path.relpath(tgt.prefix("sample_run"), indir)))) return newtargets