misc/fixReferenceAllele.py
def check_vcf(vcf_file, fasta):
    """Read through VCF and fix incorrect references for variants"""
    with open(vcf_file) as f:
        for line in f:
            if (not line.startswith("#")): # 1=COORD 3=REF 4=ALT
                split_line = line.split()
                ref_allele = fasta.seq[int(split_line[1])-1]
                if ref_allele != split_line[3]:
                    new_variant_line = fix_variant(split_line, ref_allele)
                    sys.stdout.write(new_variant_line)
                    new_variant_line_split = new_variant_line.split()
                    sys.stderr.write(f"{split_line[2]}" + 
                            f", REF: {ref_allele}" + 
                            f", VCF_REF: {split_line[3]}" + 
                            f", ALT: {split_line[4]}" +
                            f", NEW_REF: {new_variant_line_split[3]}" +
                            f", NEW_ALT: {new_variant_line_split[4]}\n")
                else:
                    sys.stdout.write(line)
            else:
                sys.stdout.write(line)
Read through VCF and fix incorrect references for variants
Read through VCF and fix incorrect references for variants
Read through VCF and fix incorrect references for variants
def check_vcf(vcf_file, fasta):
    with open(vcf_file) as f:
        for line in f:
            if (not line.startswith("#")): 
                split_line = line.split()
                ref_allele = fasta.seq[int(split_line[1])-1]
                if ref_allele != split_line[3]:
                    new_variant_line = fix_variant(split_line, ref_allele)
                    sys.stdout.write(new_variant_line)
                    new_variant_line_split = new_variant_line.split()
                    sys.stderr.write(f"{split_line[2]}" + 
                            f", REF: {ref_allele}" + 
                            f", VCF_REF: {split_line[3]}" + 
                            f", ALT: {split_line[4]}" +
                            f", NEW_REF: {new_variant_line_split[3]}" +
                            f", NEW_ALT: {new_variant_line_split[4]}\n")
                else:
                    sys.stdout.write(line)
            else:
                sys.stdout.write(line)
def check_vcf ( vcf_file , fasta ) : with open ( vcf_file ) as f : for line in f : if ( not line . startswith ( "#" ) ) : split_line = line . split ( ) ref_allele = fasta . seq [ int ( split_line [ 1 ] ) - 1 ] if ref_allele != split_line [ 3 ] : new_variant_line = fix_variant ( split_line , ref_allele ) sys . stdout . write ( new_variant_line ) new_variant_line_split = new_variant_line . split ( ) sys . stderr . write ( f"{split_line[2]}" + f", REF: {ref_allele}" + f", VCF_REF: {split_line[3]}" + f", ALT: {split_line[4]}" + f", NEW_REF: {new_variant_line_split[3]}" + f", NEW_ALT: {new_variant_line_split[4]}\n" ) else : sys . stdout . write ( line ) else : sys . stdout . write ( line )
Read through VCF and fix incorrect references for variants
Read through VCF and fix incorrect references for variants
"""Read through VCF and fix incorrect references for variants""" # 1=COORD 3=REF 4=ALT
vcf_file
fasta