Пример #1
0
 def run(self):
     # Check #
     if glob.glob('454Reads.*.sff'):
         raise Exception(
             "Demultiplexed files already present in current directory.")
     # Extract #
     for sff in self.sff_files:
         sff.split()
     # Assign #
     for sample in self.samples:
         sample.pieces = []
     for sff in self.sff_files:
         sff.assign_pieces()
     # Report #
     columns = [sff.name for sff in self.sff_files]
     rows = [sample.name for sample in self.samples]
     data = [[sff.count_reads_in(sample) for sff in self.sff_files]
             for sample in self.samples]
     self.frame = pandas.DataFrame(data, index=rows, columns=columns)
     self.frame['Total'] = self.frame.sum(1)
     # Regroup #
     for sample in self.samples:
         if len(sample.pieces) == 1:
             shutil.move(sample.pieces[0].path, sample.p.raw_sff)
         else:
             sh.sfffile("-o", sample.p.raw_sff,
                        *[p.path for p in sample.pieces])
             for p in sample.pieces:
                 os.remove(p.path)
     # Save report #
     self.frame.to_csv(illumitag.view_dir + 'pyrosamples/report.csv')
Пример #2
0
 def split(self):
     # Call Roche binary #
     barcode_file = TmpFile.from_string(self.barcode_text)
     sh.sfffile("-s", "barcodes_keyword", "-mcf", barcode_file.path, self.path)
     # Check result #
     produced_files = set(sh.glob('454Reads.*.sff'))
     expected_files = set(['454Reads.%s.sff' % (sample.name.upper()) for sample in self.sample_links.values()])
     assert produced_files == expected_files
     # Make piece objects #
     self.pieces = [SamplePiece(p, self) for p in sh.glob('454Reads.*.sff')]
     for piece in self.pieces: piece.rename()
     # Cleanup #
     barcode_file.remove()
Пример #3
0
 def split(self):
     # Call Roche binary #
     handle = tempfile.NamedTemporaryFile(delete=False)
     handle.write(self.barcode_file)
     handle.close()
     sh.sfffile("-s", "barcodes_keyword", "-mcf", handle.name, self.path)
     # Check result #
     produced_files = set(sh.glob('454Reads.*.sff'))
     expected_files = set(['454Reads.%s.sff' % (sample.name.upper()) for sample in self.sample_links.values()])
     assert produced_files == expected_files
     # Make piece objects #
     self.pieces = [SamplePiece(p, self) for p in sh.glob('454Reads.*.sff')]
     for piece in self.pieces: piece.rename()
     os.remove(handle.name)
Пример #4
0
 def split(self):
     # Call Roche binary #
     barcode_file = TmpFile.from_string(self.barcode_text)
     sh.sfffile("-s", "barcodes_keyword", "-mcf", barcode_file.path,
                self.path)
     # Check result #
     produced_files = set(sh.glob('454Reads.*.sff'))
     expected_files = set([
         '454Reads.%s.sff' % (sample.name.upper())
         for sample in self.sample_links.values()
     ])
     assert produced_files == expected_files
     # Make piece objects #
     self.pieces = [SamplePiece(p, self) for p in sh.glob('454Reads.*.sff')]
     for piece in self.pieces:
         piece.rename()
     # Cleanup #
     barcode_file.remove()
Пример #5
0
 def run(self):
     # Check #
     if glob.glob('454Reads.*.sff'): raise Exception("Demultiplexed files already present in current directory.")
     # Extract #
     for sff in self.sff_files: sff.split()
     # Assign #
     for sample in self.samples: sample.pieces = []
     for sff in self.sff_files: sff.assign_pieces()
     # Report #
     columns = [sff.name for sff in self.sff_files]
     rows = [sample.name for sample in self.samples]
     data = [[sff.count_reads_in(sample) for sff in self.sff_files] for sample in self.samples]
     self.frame = pandas.DataFrame(data, index=rows, columns=columns)
     self.frame['Total'] = self.frame.sum(1)
     # Regroup #
     for sample in self.samples:
         if len(sample.pieces) == 1: shutil.move(sample.pieces[0].path, sample.p.raw_sff)
         else:
             sh.sfffile("-o", sample.p.raw_sff, *[p.path for p in sample.pieces])
             for p in sample.pieces: os.remove(p.path)
     # Save report #
     self.frame.to_csv(illumitag.view_dir + 'pyrosamples/report.csv')