#!/usr/bin/perl use warnings; use Getopt::Long; use Getopt::ArgvFile; use Math::Bezier; use Math::Round; # input file is in this format # fields[0] = chr # fields[1] = peak start # fields[2] = peak end # fields[3] = peak length # fields[4] = coordinate of peak max height # fields[5] = read number # fields[6] = score (y-axis value) # fields[7] = enrichment # fields[8] = FDR(%) @peaks = $ARGV[0]; open ( IN, "@peaks" ) or die "Can't open file: $!"; print "track type=wiggle_0 name=track description=center_label visibility=full autoScale=on\n"; while () { next if /#/; # remove the header next if /start/; # inlcuding column descriptor chomp; my @fields = split ("\t",$_); print "fixedStep chrom=$fields[0] start=$fields[1] step=1\n"; my $bezier = Math::Bezier->new(0,0,$fields[4],$fields[6],$fields[3],0); my @points = $bezier->curve($fields[3]); while (@points) { my ($x,$y) = splice(@points,0,2); my $ynew = nearest(0.01,($y*2)); print "$ynew\n"; } } close IN;