Mercurial > repos > charles-bernard > cytosine_report_to_bedgraph
view cytosine_report_to_bedgraph/bismark2bedgraph.awk @ 5:ee5badb527cd draft default tip
Uploaded
author | charles-bernard |
---|---|
date | Wed, 16 Nov 2016 06:38:59 -0500 |
parents | b03e31cab4a6 |
children |
line wrap: on
line source
#!/usr/bin/awk #USAGE: #awk -v context=<list_of_contexts> -v coverage=<boolean> -f <script_path>/bismark2bedgraph.awk <cytosine_report_name> >> <bedgraph_name> BEGIN { FS = "\t"; } { if ( $6 ~ context && ( $4 > 0 || $5 > 0 ) ) { chr_name = $1; chr_pos = $2; strand = $3; c_meth_count = $4; c_unmeth_count = $5; if ( coverage == "true" ) { nb_reads = c_meth_count + c_unmeth_count printf("%s\t%s\t%s\t%s\n", chr_name, chr_pos, chr_pos, nb_reads) } else { if ( strand == "-" ) { s = "-"; } else { s = ""; } meth_ratio = c_meth_count / ( c_meth_count + c_unmeth_count ); printf( "%s\t%s\t%s\t%s%s\n", chr_name, chr_pos, chr_pos, s, meth_ratio ) } } }