def test_basic_depends_on(self): q = JobQueue(1) g = CommandGraph(q) q.set_command_graph(g) c1 = CommandNode("sleep 1", "1") c2 = CommandNode("echo hello", "2", stdout="test.txt") g.add_node(command_node=c1, depends_on=[c2]) assert set(g.nodes()) == set(['1', '2']) g.start() g.finish_block() os.remove('test.txt')
def test_two_depends_on(self): q = JobQueue(1) g = CommandGraph(q) q.set_command_graph(g) c1 = CommandNode("sleep 1", "1") c2 = CommandNode("echo hello", "2", stdout="test.txt") c3 = CommandNode("echo hello", "3", stdout="test2.txt") g.add_node(command_node=c1, depends_on=[c3, c2]) g.add_node(command_node=c3, depends_on=[c2]) g.start() g.finish_block() os.remove("test.txt") os.remove("test2.txt")
def bwa_samse(args, config, sai, fq): """ Single-ended read processing for bwa """ reference = config['reference']['fasta'] cmd = __BWA_SAMSE__.format(config['bwa']['executable'], reference, sai, fq) id_string = os.path.basename(fq) + ".samse" stdout_output = os.path.basename(fq) + ".sam" return CommandNode(cmd, id_string, stdout_output, args.temp_directory)
def bwa_sampe(args, config, sai1, sai2, fq1, fq2): """ Paired-end sample processing. """ reference = config['reference']['fasta'] cmd = __BWA_SAMPE__.format(config['bwa']['executable'], reference, sai1, sai2, fq1, fq2) id_string = os.path.basename(fq1) + ".samse" stdout_output = os.path.basename(fq1) + ".sam" return CommandNode(cmd, id_string, stdout_output, args.temp_directory)
def ancient_filter(args, config, bam_file): """ Run the ancient filtration procedure """ bam_prefix = bam_file.split('.bam')[0] bam_out_name = bam_prefix + ".ancient_filter.bam" id_string = bam_prefix + "ancient_filter" cmd = __ANCIENT_FILTER__.format(config['scripts_dir']['directory'], args.ancient_downweight_number, bam_file, bam_out_name) return CommandNode(cmd, id_string, bam_out_name, args.temp_directory)
def map_damage(args, config, bam_file): """ Create the mapdamage command for use in the pipeline """ bam_prefix = bam_file.split('.bam')[0] id_string = bam_prefix + "_filter_unique_bam" cmd = __MAP_DAMAGE__.format( os.path.join(config['map_damage']['executable']), bam_file, os.path.abspath(os.path.join(args.temp_directory, bam_prefix)), config['reference']['fasta']) bam_out_name = os.path.join(bam_prefix, bam_prefix + '.rescaled.bam') return CommandNode(cmd, id_string, bam_out_name, args.temp_directory)
def bwa_aln(args, config, fq): """ Aln algorithm """ seeding_off = args.bwa_seeding reference = config['reference']['fasta'] if seeding_off: cmd = __BWA_ALN__.format(config['bwa']['executable'], args.bwa_edit_distance, args.bwa_gap_opens, '1024', reference, fq) else: cmd = __BWA_ALN_NO_SEED__.format(config['bwa']['executable'], args.bwa_edit_distance, args.bwa_gap_opens, reference, fq) id_string = os.path.basename(fq) + 'aln' stdout_output = os.path.basename(fq) + '.sai' return CommandNode(cmd, id_string, stdout_output, args.temp_directory)
def picard_rg(args, config, bam_file): sample_id = bam_file.split('_')[0] bam_out_name = bam_file.split('.bam')[0] + ".rg.bam" id_string = bam_out_name + "_rg_bam" cmd = __READ__GROUPS__.format(config['java']['executable'], config['picard']['jar'], bam_file, bam_out_name, sample_id) return CommandNode(cmd, id_string, bam_out_name, args.temp_directory)
def adapter_removal(config, args, fq1 ,fq2): fq1o = os.path.abspath(fq1) fq2o = os.path.abspath(fq2) cmd = __ADAPTER_REMOVAL__.format(config['adapter_removal']['executable'], fq1o, fq2o, fq1, fq2, args.adapt_min_length, args.adapt_mismatch_rate ,args.adapt_min_qual, args.adapt_alignment_length) job_id = fq1 + ".adapter_removal" return CommandNode(cmd, job_id, None, args.temp_directory)
def test_create_command_node(self): c = CommandNode("echo hello", "1") assert (str(c) == "1") assert (c.command == "echo hello")