Example #1
0
def make_raw_zip_bundle(cluster):
    """Zip all the raw samples files in one file"""
    result_dir = DirectoryPath(cluster.base_dir + "raw_reads")
    result_dir.remove()
    result_dir.create()
    for sample in tqdm(cluster.samples):
        subdir = DirectoryPath(result_dir + sample.short_name)
        subdir.create()
        shutil.copy(sample.raw.fwd, subdir)
        shutil.copy(sample.raw.rev, subdir)
    result_dir.zip(keep_orig=False)
Example #2
0
class FastQC(object):
    """Takes care of running the FastQC program.
    See http://www.bioinformatics.babraham.ac.uk/projects/fastqc/
    Expects version 0.10.1."""

    def __init__(self, source, dest=None):
        # Basic #
        self.source = FASTQ(source)
        self.dest = DirectoryPath(dest)
        # Default case #
        if dest is None:
            self.dest = DirectoryPath(self.source.prefix_path + '.fastqc')

    def check(self):
        assert sh.fastqc('--v', )

    def run(self):
        if self.dest is None:
            sh.fastqc(self.source, '-q')
            os.remove(self.source.prefix_path + '_fastqc.zip')
        if self.dest is not None:
            if self.dest.exists: self.dest.remove()
            self.tmp_dir = new_temp_dir()
            sh.fastqc(self.source, '-q', '-o', self.tmp_dir)
            created_dir = self.tmp_dir + self.source.prefix.split('.')[0] + '_fastqc/'
            shutil.move(created_dir, self.dest)
            self.tmp_dir.remove()
            return self.results

    @property
    def output_dir(self):
        if self.dest is None: return self.source.split('.')[0] + '_fastqc/'
        else: return self.dest

    @property_cached
    def results(self):
        results = FastQCResults(self.output_dir)
        if not results: self.run()
        return results