set -euo pipefail

#samtools view -b ../results/ONT_matched/fire/ONT_matched.fire.cram chrX:47,081,183-47,305,924 | ft track --bed12 read.bed.gz - | bedtools sort | bgzip > dec.bed.gz

echo "Making read level bigbed"
bgzip -cd read.bed.gz | grep -v '^#' >tmp.bed
bigtools bedtobigbed -a bed12_filter.as -s start --nzooms 0 \
    tmp.bed hg38.fai read.bed.bb
bedToBigBed -type=bed12+ -allow1bpOverlap -as=bed12_filter.as tmp.bed hg38.fai ucsc.read.bed.bb

echo "Making decoration level bigbed"
bgzip -cd dec.bed.gz | grep -v '^#' >tmp.bed
bigtools bedtobigbed -a decoration.as -s start --nzooms 0 \
    tmp.bed hg38.fai dec.bed.bb
bedToBigBed -type=bed12+ -allow1bpOverlap -as=decoration.as tmp.bed hg38.fai ucsc.dec.bed.bb

echo "Uploading to s3"
rm tmp.bed
aws s3 sync --profile Mitchell_Vollger $@ . s3://stergachis-public1/Mitchell/tests/bigtools-test/
