...
| Code Block | ||
|---|---|---|
| ||
cat yeast_mrna.gene_coverage.almost.bedGraph | awk '
BEGIN{FS=OFS="\t"; chr=""; start=-1; end=-1; tot=0}
{if (chr != $1) { # new contig; finish previous
if (start > -1) { print chr,start,end,tot }
chr=$1; start=$2; end=$3; tot=$4
} else if ($2==pos start|| $2==posstart+1) { # same or adjacent position
tot = tot + $4; start=$2; end=$3;
} else { # new region on same contig; finish prev
if (start > -1) { print chr,start,end,tot }
chr=$1; start=$2; end=$3; tot=$4
}
}
END{ # finish last
if (start > -1) { print chr,start,end,tot }
}' > yeast_mrna.gene_coverage.bedGraph
wc -l yeast_mrna.gene_coverage.bedGraph # |
...