If some one needs to know description on these, let me know.

sub filename #cut the file name { my $name = shift; chomp $name; my @x=split '\/',$name; return $x[$#x]; } sub dirname # get directory name { my $prog = shift; my $cwd = getcwd; return $cwd if ($prog !~ /\//); $prog =~ s/\/[^\s\/]+$//g; return $prog; } sub min_max_med { # get ave, median, sdv, min, max, sum, my @M=@_; my @M1=sort {$a$b}@M; my $sum=sumM(@M1); my $TOT=$#M+1; my $ave=sprintf "%0.2f",$sum/($TOT); #print "@M1"; my ($med,$medv,$endloop,$sdv_sum,$sdv_sum2); for (@M1) { #getting median and std ++$med; if ($med>$TOT*0.5 and $endloop ==0 ) { $medv=$_; $endloop=1; } $sdv_sum+=($_-$ave)*($_-$ave); } $sdv_sum2=sprintf "%0.3f",sqrt($sdv_sum/($TOT)); #min max median std shift @M1; #print ">>[@M1] $M1[0], $M1[$#M1],$sum,$ave,$medv,$sdv_sum2\n"; return ( $ave,$medv,$sdv_sum2, $M1[0], $M1[$#M1],$sum,$TOT); } sub min_max_med2 { # get ave, median, sdv, min, max, sum, my @M=@_; my @M1=sort {$a$b}@M; my $sum=sumM(@M1); my $TOT=$#M+1; my $ave=sprintf "%0.2f",$sum/($TOT); #print "@M1"; my ($med,$medv,$endloop,$sdv_sum,$sdv_sum2); for (@M1) { #getting median and std ++$med; if ($med>$TOT*0.5 and $endloop ==0 ) { $medv=$_; $endloop=1; } $sdv_sum+=($_-$ave)*($_-$ave); } $sdv_sum2=sprintf "%0.3f",sqrt($sdv_sum/($TOT)); #min max median std shift @M1; #print ">>[@M1] $M1[0], $M1[$#M1],$sum,$ave,$medv,$sdv_sum2\n"; return ( $ave,$medv,$sdv_sum2, $M1[0], $M1[$#M1],$TOT); } sub min_max_med3 { my $PLO=shift;#median all chrom my @M=@_; my @M1=sort {$a$b}@M; my $sum=sumM(@M1); my $TOT=$#M+1; my $ave=sprintf "%0.2f",$sum/($TOT); #print "@M1"; my ($med,$medv,$endloop,$sdv_sum,$sdv_sum2); for (@M1) { #getting median and std ++$med; if ($med>$TOT*0.5 and $endloop ==0 ) { $medv=$_; $endloop=1; } $sdv_sum+=($_-$ave)*($_-$ave); } $sdv_sum2=sprintf "%0.3f",sqrt($sdv_sum/($TOT)); #min max median std shift @M1; #print ">>[@M1] $M1[0], $M1[$#M1],$sum,$ave,$medv,$sdv_sum2\n"; return sprintf "%0.4f %0.4f %0.4f %0.4f %0.4f %0.0f", $ave*$PLO,$medv*$PLO,$sdv_sum2*$PLO, $M1[0]*$PLO, $M1[$#M1]*$PLO,$TOT; } sub sumM { my $sum=0; for (@_) { $sum+=$_; } return $sum; } sub chromID { my $in=shift; my $fai="$in.fai"; my (%Fai,@chrom); open F1,$fai; $chrom[0]=0; while (my $s=) { my($chr)=split '\s+',$s; push @chrom,$chr; } return @chrom; } sub medianID { my @x; my $in=shift; open F1,$in; my %median; while (my $s=) { @x=split '\s+',$s; $median{"$x[0] $x[1]"}=$x[3]; } return %median; } sub log10 { my $n = shift; return log($n)/log(10); } sub div{ my ($a,$b)=@_; if ($b==0){ return -1.0; }else{ return sprintf "%0.4f",$a*1.0/$b; } }