def _generate_demultiplexed_fastq_demux(self, mtime): """Modularity helper""" # An artifact will hold only one file of type # `preprocessed_demux`. Thus, we only use the first one # (the only one present) ar = self.artifact demux = [ path for _, path, ftype in ar.filepaths if ftype == 'preprocessed_demux' ][0] demux_samples = set() with open_file(demux) as demux_fh: if not isinstance(demux_fh, File): error_msg = ("'%s' doesn't look like a demux file" % demux) LogEntry.create('Runtime', error_msg) raise EBISubmissionError(error_msg) for s, i in to_per_sample_ascii(demux_fh, self.prep_template.keys()): sample_fp = self.sample_demux_fps[s] wrote_sequences = False with GzipFile(sample_fp, mode='w', mtime=mtime) as fh: for record in i: fh.write(record) wrote_sequences = True if wrote_sequences: demux_samples.add(s) else: del (self.samples[s]) del (self.samples_prep[s]) del (self.sample_demux_fps[s]) remove(sample_fp) return demux_samples
def _generate_demultiplexed_fastq_demux(self, mtime): """Modularity helper""" # An artifact will hold only one file of type # `preprocessed_demux`. Thus, we only use the first one # (the only one present) ar = self.artifact demux = [path for _, path, ftype in ar.filepaths if ftype == 'preprocessed_demux'][0] demux_samples = set() with open_file(demux) as demux_fh: if not isinstance(demux_fh, File): error_msg = ( "'%s' doesn't look like a demux file" % demux) LogEntry.create('Runtime', error_msg) raise EBISubmissionError(error_msg) for s, i in to_per_sample_ascii(demux_fh, self.prep_template.keys()): sample_fp = self.sample_demux_fps[s] wrote_sequences = False with GzipFile(sample_fp, mode='w', mtime=mtime) as fh: for record in i: fh.write(record) wrote_sequences = True if wrote_sequences: demux_samples.add(s) else: del(self.samples[s]) del(self.samples_prep[s]) del(self.sample_demux_fps[s]) remove(sample_fp) return demux_samples