<commit_before>import sys

from evolib.NGSFormats import VariantCallFormat

vcf = VariantCallFormat(sys.stdin)

args = sys.argv[1:]
names = args[0].split(",")

for row in vcf:
    chrom, pos = row['CHROM'], row['POS']
    GTs = list((smp['GT'] for smp in row.iter_samples() if smp.name in names and smp['GT'] is not None and smp['GT'] != "./." and smp['DP'] != "." and smp['DP'] is not None and int(smp['DP']) > 7))
    
    ngts = len(GTs)
    nhet = GTs.count("0/1")

    if ngts == 0:
        print chrom, pos, "NA"
    else:
        print chrom, pos, nhet / float(ngts)
<commit_msg>Update het.py<commit_after>import sys

from evolib.NGSFormats import VariantCallFormat

vcf = VariantCallFormat(sys.stdin)

args = sys.argv[1:]
names = args[0].split(",")

def gtiter(row, names):
    for samp in row.iter_samples():
        if samp.name in names:
            dp = samp['DP']
            if dp != "." and dp is not None and int(dp) > 7:
                gt = samp['GT']
                if gt is None or gt == "./.":
                    yield '0/0'
                else:
                    yield gt

for row in vcf:
    chrom, pos = row['CHROM'], row['POS']
    GTs = list(gtiter(row, names))
    #GTs = list((smp['GT'] for smp in row.iter_samples() if smp.name in names and smp['GT'] is not None and smp['GT'] != "./." and smp['DP'] != "." and smp['DP'] is not None and int(smp['DP']) > 7))
    
    ngts = len(GTs)
    nhet = GTs.count("0/1")

    if ngts == 0:
        print chrom, pos, "NA"
    else:
        print chrom, pos, nhet / float(ngts)

{'fraction_non_alphanumeric': 0.16709677419354838, 'fraction_numerical': 0.00967741935483871, 'mean_word_length': 2.3141025641025643, 'pattern_counts': {'":': 1, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2694895', 'n_tokens_mistral': 584, 'n_tokens_neox': 567, 'n_words': 168}