Created
January 8, 2015 17:46
-
-
Save cwhelan/ca16a67086af606ee591 to your computer and use it in GitHub Desktop.
Genome STRiP VCF to Plink CNV format
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env python | |
import fileinput | |
idx = 1 | |
samples = [] | |
for line in fileinput.input(): | |
if line.startswith("##"): | |
continue | |
if line.startswith("#CHROM"): | |
samples = line.rstrip().split("\t")[9:] | |
else: | |
fields = line.rstrip().split("\t") | |
chrom = fields[0] | |
start = fields[1] | |
end = fields[7].split(";")[0].split("=")[1] | |
for i in range(len(samples)): | |
sample_fields = fields[9+i].split(":") | |
cn = sample_fields[1] | |
filt = sample_fields[len(sample_fields)-1] | |
if filt != "LowQual" and cn != "2": | |
print "\t".join([samples[i], samples[i], chrom, start, end, cn, "0", "0"]) | |
idx = idx + 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment