if( scalar @ARGV < 4 ) {
    print "normalize_coverage.pl <input_bedGraph> [normalization_factor] [num_aligned_fragments] <output_bedGraph>\n";
} else {

$input_file = shift(@ARGV);
$normalization_factor = shift(@ARGV);
$num_aligned_fragments = shift(@ARGV);
$output_file = shift(@ARGV);

open( IN, "<".$input_file );
open( OUT, ">".$output_file );

while( $L = <IN> ) {
    chomp( $L );
    @D = split( /\t/, $L );

    print OUT $D[0]."\t".$D[1]."\t".$D[2]."\t".( $D[3] * $normalization_factor / $num_aligned_fragments )."\n";
}

close( IN );
close( OUT );

}
