def test_make_modified_TarInfo_when_one_dir_and_no_files(self): # setup archive = self.create_tar_archive([('/i/am/a/dir/', tarfile.DIRTYPE)]) # excercise modified_info = align.make_modified_TarInfo(archive) # verify self.assertEqual(modified_info, [])
def main(args): remove_bam_from_end_re = re.compile("\.bam$") bam_root = remove_bam_from_end_re.sub("", os.path.basename(args.anno_bam)) with tarfile.open(args.rsem_index, "r:gz") as archive: archive.extractall(".", members=make_modified_TarInfo( archive, "rsem_index")) rsem_call = shlex.split( RSEM_COMMAND.format( rnd_seed=args.rnd_seed, ncpus=args.ncpus, ramGB=args.ramGB, fwd_prob=strand_to_fwd_prob(args.read_strand), paired_end=format_endedness(args.endedness), anno_bam=args.anno_bam, bam_root=bam_root, )) logger.info("Running RSEM command %s", " ".join(rsem_call)) subprocess.call(rsem_call) gene_quant_fn = str(bam_root) + "_rsem.genes.results" number_of_genes_detected = calculate_number_of_genes_detected( gene_quant_fn) number_of_genes_detected_dict = { "number_of_genes_detected": number_of_genes_detected } qc_record = QCMetricRecord() number_of_genes_QC = QCMetric("number_of_genes_detected", number_of_genes_detected_dict) qc_record.add(number_of_genes_QC) with open(str(bam_root) + "_number_of_genes_detected.json", "w") as f: json.dump(qc_record.to_ordered_dict(), f)
def test_make_modified_TarInfo_with_one_file_and_empty_target_dir(self): # setup archive = self.create_tar_archive([('/i/am/a/file.txt', tarfile.REGTYPE)]) # excercise modified_info = align.make_modified_TarInfo(archive) # verify self.assertEqual(modified_info[0].name, 'file.txt')
def test_make_modified_TarInfo_when_filepath_changes_to_nonempty(self): # setup archive = self.create_tar_archive([('/my/old/path/file.txt', tarfile.REGTYPE)]) # excercise modified_info = align.make_modified_TarInfo(archive, target_dir='/my/new/path/') # verify self.assertEqual(modified_info[0].name, '/my/new/path/file.txt')
def test_make_modified_TarInfo_with_one_file_one_dir_and_empty_target_dir( self): # setup archive = self.create_tar_archive([("/i/am/a/dir/", tarfile.DIRTYPE), ("/i/am/a/file.txt", tarfile.REGTYPE)]) # excercise modified_info = align.make_modified_TarInfo(archive) # verify self.assertEqual(len(modified_info), 1) self.assertEqual(modified_info[0].name, "file.txt")
def main(args): remove_bam_from_end_re = re.compile('\.bam$') bam_root = remove_bam_from_end_re.sub('', os.path.basename(args.anno_bam)) with tarfile.open(args.rsem_index, 'r:gz') as archive: archive.extractall('.', members=make_modified_TarInfo( archive, 'rsem_index')) rsem_call = shlex.split( RSEM_COMMAND.format(rnd_seed=args.rnd_seed, ncpus=args.ncpus, ramGB=args.ramGB, fwd_prob=strand_to_fwd_prob(args.read_strand), paired_end=format_endedness(args.endedness), anno_bam=args.anno_bam, bam_root=bam_root)) subprocess.call(rsem_call)