Beispiel #1
0
 def __init__(self, parent):
     # Save parent #
     self.parent, self.pool = parent, parent
     self.samples = parent.samples
     # Paths #
     self.base_dir = self.pool.p.groups_dir + self.short_name + '/'
     self.p = AutoPaths(self.base_dir, self.all_paths)
     # Super #
     self.fwd_path = self.p.fwd_fastq
     self.rev_path = self.p.rev_fastq
     self.gzipped = True if self.fwd_path.endswith('gz') else False
     # Compatible with fasta module #
     self.fwd = FASTQ(self.fwd_path)
     self.rev = FASTQ(self.rev_path)
     # Add assembly files #
     self.assembled = Assembled('', self)
     self.unassembled = Unassembled('', self)
     self.children = (self.assembled, self.unassembled)
     self.first = self.assembled
     # Graphs #
     self.graphs = [getattr(outcome_plots, cls_name)(self) for cls_name in outcome_plots.__all__]
Beispiel #2
0
 def __init__(self, parent):
     # Save parent #
     self.parent, self.pool = parent, parent
     self.samples = parent.samples
     # Paths #
     self.base_dir = self.pool.p.groups_dir + self.short_name + '/'
     self.p = AutoPaths(self.base_dir, self.all_paths)
     # Super #
     self.fwd_path = self.p.fwd_fastq
     self.rev_path = self.p.rev_fastq
     self.gziped = True if self.fwd_path.endswith('gz') else False
     # Add assembly files #
     self.assembled = Assembled(self)
     self.unassembled = Unassembled(self)
     self.children = (self.assembled, self.unassembled)
     self.first = self.assembled
     # Graphs #
     self.graphs = [
         getattr(outcome_plots, cls_name)(self)
         for cls_name in outcome_plots.__all__
     ]
Beispiel #3
0
class BarcodeGroup(PairedFASTQ):
    """A bunch of sequences all having the same type of barcode outcome"""
    short_name = "generic_barcode_outcome"

    all_paths = """
    /fwd.fastq
    /rev.fastq
    /graphs/
    /assembled/
    /unassembled/
    """

    def __iter__(self): return iter(self.children)
    def __repr__(self): return '<%s object of pool %i>' % (self.__class__.__name__, self.pool.num)

    def __init__(self, parent):
        # Save parent #
        self.parent, self.pool = parent, parent
        self.samples = parent.samples
        # Paths #
        self.base_dir = self.pool.p.groups_dir + self.short_name + '/'
        self.p = AutoPaths(self.base_dir, self.all_paths)
        # Super #
        self.fwd_path = self.p.fwd_fastq
        self.rev_path = self.p.rev_fastq
        self.gzipped = True if self.fwd_path.endswith('gz') else False
        # Compatible with fasta module #
        self.fwd = FASTQ(self.fwd_path)
        self.rev = FASTQ(self.rev_path)
        # Add assembly files #
        self.assembled = Assembled('', self)
        self.unassembled = Unassembled('', self)
        self.children = (self.assembled, self.unassembled)
        self.first = self.assembled
        # Graphs #
        self.graphs = [getattr(outcome_plots, cls_name)(self) for cls_name in outcome_plots.__all__]

    def join(self):
        """Uses pandaseq 2.8"""
        self.assembled.remove()
        command = 'pandaseq28 -T 1 -f %s -r %s -u %s -F 1> %s 2> %s'
        command = command % (self.fwd_path, self.rev_path, self.unassembled.path, self.assembled.path, self.assembled.p.out)
        shell_call(command) # Because it exits with status 1 https://github.com/neufeld/pandaseq/issues/40

    def check_noalign_counts(self):
        """Check the sanity of pandaseq"""
        assert len(self.assembled) + len(self.unassembled) + self.assembled.stats['lowqual'] == len(self)
        assert self.assembled.stats['noalign'] == self.unassembled.count

    def barcode_fastqc(self):
        sh.fastqc(self.fwd_path, '-q')
        os.remove(os.path.splitext(self.fwd_path)[0] + '_fastqc.zip')
        sh.fastqc(self.rev_path, '-q')
        os.remove(os.path.splitext(self.rev_path)[0] + '_fastqc.zip')

    def assembly_fastqc(self):
        sh.fastqc(self.assembled.path, '-q')
        os.remove(os.path.splitext(self.assembled.path)[0] + '_fastqc.zip')

    def make_outcome_plots(self):
        for graph in self.graphs: graph.plot()