Skip to content

Instantly share code, notes, and snippets.

@pontikos
Last active August 29, 2015 14:12
Show Gist options
  • Select an option

  • Save pontikos/8a9f21013c9c140b1d65 to your computer and use it in GitHub Desktop.

Select an option

Save pontikos/8a9f21013c9c140b1d65 to your computer and use it in GitHub Desktop.
Prepends the string Levine_ to fields which do not start with the prefix Levine_
#! /bin/awk -f
BEGIN {
OFS = FS
}
{
# only one line starting with #CHROM needs to be modified in file
# all others just print out unmoodified
if ( $1 !~ /^#CHROM/ ) {
print $0;
} else {
for (i=1; i < NF; i++) {
# samples start at 10th field
# if field does not start with Levine
# does inplace replacement of the field, pretty handy
if ((i > 9) && ($i !~ /^Levine/)) $i="Levine_"$i;
}
print $0;
}
}
@pontikos
Copy link
Author

pontikos commented Jan 7, 2015

Can be combined with bgziptabix to repace lines in VCF file:

for x in ../*.vcf.gz; do echo $x; zcat $x | replaceline | bgziptabix `basename $x` ; sleep 10; done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment