示例#1
0
def post_aln_qc(args, bam_file, logger=None):
    """ perform post alignment quality check """

    post_aln_dir = os.path.join(args.workDir, 'post_alignment_qc')
    if not os.path.isdir(post_aln_dir):
        os.mkdir(post_aln_dir)
    #Fix mate information for bam file
    exit_code, fix_mate_out = post_alignment_qc.fix_mate_information(args.picard, bam_file,
                                                                    args.id, args.workDir, logger)
    if exit_code == 0:
        os.remove(bam_file)
        assert(not os.path.isfile(bam_file))
        os.rename(fix_mate_out, bam_file)
        assert(os.path.isfile(bam_file))

    #validate the post-alignment BAM file
    post_alignment_qc.validate_bam_file(args.picard, bam_file, args.id, post_aln_dir, logger)

    #collect RNA-seq metrics
    post_alignment_qc.collect_rna_seq_metrics(args.picard, bam_file, args.id,
                                              post_aln_dir, args.ref_flat, logger)
    #run rna_seq_qc from broad institute

    post_alignment_qc.bam_index(bam_file, args.id, logger)
    rna_seq_qc_dir = os.path.join(post_aln_dir, 'rna_seq_qc')
    if not os.path.isdir(rna_seq_qc_dir):
        os.mkdir(rna_seq_qc_dir)

    exit_code = post_alignment_qc.rna_seq_qc(args.rna_seq_qc_path, bam_file, args.id, rna_seq_qc_dir,
                                args.ref_genome,args.rna_seq_qc_annotation, logger)

    if not(exit_code == 0):

        reordered_bam = post_alignment_qc.reorder_bam(args.picard, bam_file, args.id, args.workDir,
                                                args.ref_genome, logger)
        post_alignment_qc.bam_index(reordered_bam, args.id, logger)
        post_alignment_qc.rna_seq_qc(args.rna_seq_qc_path, reordered_bam, args.id, rna_seq_qc_dir,
                                args.ref_genome,args.rna_seq_qc_annotation, logger)

        if os.path.isfile(reordered_bam):
            os.remove(reordered_bam)
        if os.path.isfile('%s.bai' %reordered_bam):
            os.remove('%s.bai' %reordered_bam)
示例#2
0
def post_aln_qc(args, bam_file, logger=None):
    """ perform post alignment quality check """

    #validate the post-alignment BAM file
    post_alignment_qc.validate_bam_file(args.picard, bam_file, args.id, args.workDir, logger)

    #collect RNA-seq metrics
    post_alignment_qc.collect_rna_seq_metrics(args.picard, bam_file, args.id,
                                              args.workDir, args.ref_flat, logger)
    #run rna_seq_qc from broad institute
    post_alignment_qc.bam_index(bam_file, args.id, logger)

    exit_code = post_alignment_qc.rna_seq_qc(args.rna_seq_qc_path, bam_file, args.id, args.workDir,
                                args.ref_genome,args.rna_seq_qc_annotation, logger)

    if not(exit_code == 0):

        reordered_bam = post_alignment_qc.reorder_bam(args.picard, bam_file, args.id, args.workDir,
                                                args.ref_genome, logger)
        post_alignment_qc.bam_index(reordered_bam, args.id, logger)
        post_alignment_qc.rna_seq_qc(args.rna_seq_qc_path, reordered_bam, args.id, args.workDir,
                                args.ref_genome,args.rna_seq_qc_annotation, logger)