
# step-9
# convert some files


# download link :

# https://gist.github.com/svigneau/8846527
# https://www.encodeproject.org/software/bedgraphtobigwig/



for i in {56..64}
do
	#bdg to wig
	echo "SRR123315${i}"
	folder_name="SRR123315${i}_macs_output"
	chip_file="SRR123315${i}_treat_pileup.bdg"
	input_file="SRR123315${i}_control_lambda.bdg"
	wig_chip="SRR123315${i}_chip.wig"
	wig_input="SRR123315${i}_input.wig"
	echo "making chip wig file"
	perl bedgraph_to_wig.pl --bedgraph "$folder_name/$chip_file" --wig "$folder_name/$wig_chip" --step 50
	echo "making input wig file"
	perl bedgraph_to_wig.pl --bedgraph "$folder_name/$input_file" --wig "$folder_name/$wig_input" --step 50

	# bdg to bigwig

	chip_bigwig="SRR123315${i}_chip.bigwig"
	input_bigwig="SRR123315${i}_input.bigwig"
	echo "making chip bigwig file"
	./bedGraphToBigWig "$folder_name/$chip_file" hg38.chrom.sizes "$folder_name/$chip_bigwig"
	echo "making input bigwig file"
	./bedGraphToBigWig "$folder_name/$input_file" hg38.chrom.sizes "$folder_name/$input_bigwig"

	#narrowpeak to bed

	echo "making bed file from narrowpeak"
	narrow_file="SRR123315${i}_peaks.narrowPeak"
	bed_name="SRR123315${i}.bed"
	cut -f1,2,3,4 "$folder_name/$narrow_file" >"$folder_name/$bed_name"


done




