view cytosine_report_to_bedgraph/bismark2bedgraph.awk @ 2:9e00d7d3fea5 draft

Deleted selected files
author charles-bernard
date Mon, 14 Nov 2016 05:01:41 -0500
parents b03e31cab4a6
children ee5badb527cd
line wrap: on
line source

#!/usr/bin/awk

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)	
		}
	}
}