my $f = 0; # my $id_file=$ARGV[0]; my $step=150; ## mc: 7; hmc: 18 my @lists = qw(h3k4me3_down_genebody h3k4me3_nochange_genebody h3k4me3_up_genebody); my @files = qw( tcc140 tcc136 tcc137 tcc141 ); my $element = ".NM_genebody.ud10k"; for($s=0;$s <= $#files;$s++){ $stage=$s; $scan_file = $files[$s] . $element; $dep=`wc -l ../reads_pos/$files[$s]/chr* |grep total`; $dep2=0; if ($dep=~m/(\d+)\stotal/){ $dep2=$1; } for($l=0;$l <= $#lists;$l++){ $id_file = $lists[$l] . ".bed"; @arr = split /\./,$scan_file; $sample = $arr[0]; open my $idin, "<", "./$id_file" or die $!; my %hash ; $g=0; while (my $line = <$idin>){ chomp $line; my @arr4=split /\t/,$line; $gen=$arr4[3]; $g++; $hash{$gen}=$g; } open my $locfile, "<", "./density_files/$scan_file" or die $!; my $count = 0; while (my $line = <$locfile>){ chomp $line; my @arr = split /\t/, $line; my $gene = $arr[0]; $yes=''; if (exists($hash{$gene})){$yes = 'yes';$xh= $hash{$gene};#print"$gene\t$xh\n"; } if($yes eq 'yes'){ #print"$xh"; $count++; my @arr = split /\t/, $line; for ($i = 2; $i < $step + 2; $i++){ $num = 0; $num = $arr[$i]; $num = ($num/$dep2)*1000000; $num = sprintf "%0.3f",$num; $lie = ""; $lie = lie."$i"; $$lie = $$lie + $num; # print "\t$num"; } } } print"$sample\t$id_file"; for ($i = 2; $i < $step + 2; $i++){ $lie = lie."$i"; $$lie = $$lie/$count; $avg = sprintf "%0.2f",$$lie; printf "\t$avg"; $$lie = 0; $avg=0; } print"\n"; $count=0; } }