Skip to content

Instantly share code, notes, and snippets.

@mzdravkov
Created April 13, 2023 21:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mzdravkov/443868e111263f8521268434436434e4 to your computer and use it in GitHub Desktop.
Save mzdravkov/443868e111263f8521268434436434e4 to your computer and use it in GitHub Desktop.
function allele_in_parent(allele, parent_alleles) {
return allele == parent_alleles[1] || allele == parent_alleles[2];
}
/^#/ { print $0; }
/^[^#]/ {
split($10, mfields, ":");
split(mfields[1], mother, "/");
split($11, ffields, ":");
split(ffields[1], father, "/");
split($12, cfields, ":");
split(cfields[1], child, "/");
if ((child[1] != 0 && child[2] != 0) &&
((allele_in_parent(child[1], father) && allele_in_parent(child[2], mother)) ||
(allele_in_parent(child[1], mother) && allele_in_parent(child[2], father)))) print $0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment