Python41

作者: rong酱 | 来源:发表于2023-10-12 17:19 被阅读0次
    #!/usr/bin/env python
    ##coding=utf-8
    
    import os
    import sys
    import argparse
    import vcf
    
    parser = argparse.ArgumentParser(description="")
    parser.add_argument('-i', '--invcf', help = 'the input vcf file', required = True)
    parser.add_argument('-o', '--outvcf', help = 'the output vcf file', required = True)
    argv = vars(parser.parse_args())
    inF = os.path.abspath(argv['invcf'].strip())
    ouF = os.path.abspath(argv['outvcf'].strip())
    
    def parser_vcf(infile,outfile):
        samplename=str(str(str(infile).strip().split('/')[-1]).strip().split("_")[0])
        vcf_r=vcf.Reader(filename=infile)
        for record in vcf_r:
            if len(record.FILTER) == 0 :
                print("samplename: "+str(samplename))
                sample1=samplename+".Mutect2"
                sample2=samplename+".vardict"
                print("sample1: "+str(record.genotype(sample1)['GT']))
                break
    #            if record.samples[sample2]['DP'] == "." and record.samples[sample2]['GT'] == ".":
    
    parser_vcf(inF,ouF)
    

    相关文章

      网友评论

          本文标题:Python41

          本文链接:https://www.haomeiwen.com/subject/ksrobdtx.html