Ejemplo n.º 1
0
 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")
Ejemplo n.º 2
0
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")
Ejemplo n.º 3
0
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")
Ejemplo n.º 4
0
 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")
Ejemplo n.º 5
0
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