create_test_data.sh 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/bin/bash
  2. create_test_cool(){
  3. url=$1
  4. outpath=$2
  5. binsize=$3
  6. if [[ -f ${outpath}/test.cool ]]; then return; fi
  7. if [[ ! -f ${outpath}/source.pairs.gz ]]
  8. then
  9. echo "[Error] Please manually download the file ${url} to ${outpath}"
  10. echo " and give it source.pairs.gz as name"
  11. exit -1
  12. fi
  13. zcat ${outpath}/source.pairs.gz | head -26 | tail -2 | cut -d' ' --output-delimiter=$'\t' -f 2,3 > ${outpath}/test.chrom.sizes
  14. cooler cload pairs --chrom1 2 --pos1 3 --chrom2 4 --pos2 5 \
  15. ${outpath}/test.chrom.sizes:${binsize} \
  16. ${outpath}/source.pairs.gz \
  17. ${outpath}/test.cool
  18. rm ${outpath}/source.pairs.gz
  19. cooler balance --force --max-iters 1000 ${outpath}/test.cool
  20. }
  21. create_test_mcool(){
  22. cool_path=$1
  23. outpath=$2
  24. binsize=$3
  25. if [[ ! -f ${outpath} ]]
  26. then
  27. cooler zoomify --resolutions ${binsize}N \
  28. --balance \
  29. --balance-args '--force --max-iters 1000' \
  30. --out ${outpath} ${cool_path}
  31. fi
  32. }
  33. test_data_path="tests/testthat/data"
  34. mkdir -p ${test_data_path}
  35. # Test cool file
  36. source_cool_file="https://data.4dnucleome.org/files-processed/4DNFI2EK1IOQ/@@download/4DNFI2EK1IOQ.pairs.gz"
  37. test_cool_binsize=50000
  38. create_test_cool ${source_cool_file} ${test_data_path} ${test_cool_binsize}
  39. # Creating MCOOL from COOL
  40. create_test_mcool ${test_data_path}/test.cool ${test_data_path}/test.mcool ${test_cool_binsize}