#bedtools multicov -bams ../bam/1A.rmdup.bam ../bam/1B.rmdup.bam ../bam/1C.rmdup.bam -bed /export/database/hg19_annotation/bed/10k_win.bed |awk 'BEGIN{print "A1" "\t" "B1" "\t" "C1"} {print $7 "\t" $8 "\t" $9}' >10k_win.test3 $rg_bed = $ARGV[0]; my @arr = qw( tcc140 tcc136 tcc137 tcc141 ); $cmd="bedtools multicov -bams"; $awk= " |awk 'BEGIN{print \"id\" \"\\t\" "; $awk2 = "\{print \$4 \"\\t\" "; for ($i = 0; $i <= $#arr; $i++){ $sample=$arr[$i]; $bam = $sample . ".bam"; $dep = `samtools view ../bed/bed2bam/$bam |grep chr |wc -l`; @arr2 = split /\s/,$dep; $dept = $arr2[0]; #$d = d."$b"; #$$d = $dept * 2; # print"$dept\t"; $radio = 1000000/($dept); $radio=sprintf "%0.2f",$radio; $num=$i+7; #print"\ts$sample"; if($i == $#arr){$awkf=$awkf . "\"$sample\"" . "\}";} else{$awkf=$awkf . "\"$sample\"" . " \"\\t\" ";} if($i == $#arr){$awkf2=$awkf2 . "\$$num*$radio" . "\}\'";} else{$awkf2=$awkf2 . "\$$num*$radio" . " \"\\t\" ";} $samplefile= "../bed/bed2bam/" . $sample . ".bam"; $cmdf = $cmdf . " $samplefile"; } $awk = $awk . $awkf; #print"$awk\n"; $awk2 = $awk2 . $awkf2; #print"$awk\t$awk2\n"; $cmd = $cmd . $cmdf . " -bed $rg_bed"; print"$cmd\t$awk\t$awk2\n";