Commit 66415b36 authored by Blaise Li's avatar Blaise Li

Make slurm-compatible script.

parent b5c33ec8
#!/bin/dash #!/bin/bash -l
# Usage: bam2bigwig.sh <sorted.bam> <bin_file> <library_name> <orientation> <strandedness> [<normalization>] <bigwig> # Usage: bam2bigwig.sh <sorted.bam> <bin_file> <library_name> <orientation> <strandedness> [<normalization>] <bigwig>
# <bin_file> should be a bed file representing 10 bp bins along the genome # <bin_file> should be a bed file representing 10 bp bins along the genome
# <orientation> must be "all", "fwd" or "rev" # <orientation> must be "all", "fwd" or "rev"
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
# * python3 -> module load Python/3.6.0 # * python3 -> module load Python/3.6.0
# * samtools -> module load samtools/1.9 # * samtools -> module load samtools/1.9
# * bedtools -> module load bedtools/2.25.0 # * bedtools -> module load bedtools/2.25.0
# * mawk -> use alias if absent
# * parallel (for niceload) -> module load parallel/20170122 # * parallel (for niceload) -> module load parallel/20170122
# * UCSC-tools (for bedGraphToBigWig) -> module load UCSC-tools/v373 # * UCSC-tools (for bedGraphToBigWig) -> module load UCSC-tools/v373
...@@ -66,7 +65,6 @@ error_exit () ...@@ -66,7 +65,6 @@ error_exit ()
exit 1 exit 1
} }
mawk --version 1> /dev/null 2> /dev/null || alias mawk='awk'
load_tools || error_exit "Some tools are not available" load_tools || error_exit "Some tools are not available"
...@@ -74,7 +72,7 @@ bam=${1} ...@@ -74,7 +72,7 @@ bam=${1}
bin_file=${2} bin_file=${2}
# Example of how to generate the bin_file from iGenome data: # Example of how to generate the bin_file from iGenome data:
# cd /Genomes/C_elegans # cd /Genomes/C_elegans
# mawk '$1 == "@SQ" {print $2"\t0\t"$3}' Caenorhabditis_elegans/Ensembl/WBcel235/Sequence/WholeGenomeFasta/genome.dict \ # awk '$1 == "@SQ" {print $2"\t0\t"$3}' Caenorhabditis_elegans/Ensembl/WBcel235/Sequence/WholeGenomeFasta/genome.dict \
# | sed 's/SN://g' | sed 's/LN://' \ # | sed 's/SN://g' | sed 's/LN://' \
# | bedops --chop 10 - \ # | bedops --chop 10 - \
# > Caenorhabditis_elegans/Ensembl/WBcel235/Sequence/genome_binned_10.bed # > Caenorhabditis_elegans/Ensembl/WBcel235/Sequence/genome_binned_10.bed
...@@ -163,7 +161,7 @@ fi ...@@ -163,7 +161,7 @@ fi
echo "getting chromosome bounds" echo "getting chromosome bounds"
genome_file="${workdir}/chrom_sizes.txt" genome_file="${workdir}/chrom_sizes.txt"
samtools view -H ${bam} \ samtools view -H ${bam} \
| mawk '$1 == "@SQ" {print $2"\t"$3}' \ | awk '$1 == "@SQ" {print $2"\t"$3}' \
| sed 's/SN://g' | sed 's/LN://' \ | sed 's/SN://g' | sed 's/LN://' \
> ${genome_file} || error_exit "making ${genome_file} failed" > ${genome_file} || error_exit "making ${genome_file} failed"
#> ${genome_file} || cleanup && error_exit "making ${genome_file} failed" #> ${genome_file} || cleanup && error_exit "making ${genome_file} failed"
...@@ -172,7 +170,7 @@ compute_coverage() ...@@ -172,7 +170,7 @@ compute_coverage()
{ {
cmd="niceload --noswap bedtools genomecov -bg -split ${orient_filter} ${scaling} -ibam ${bam}" cmd="niceload --noswap bedtools genomecov -bg -split ${orient_filter} ${scaling} -ibam ${bam}"
eval ${cmd} \ eval ${cmd} \
| mawk '{ print $1"\t"$2"\t"$3"\tid-"NR"\t"$4; }' | sort-bed - \ | awk '{ print $1"\t"$2"\t"$3"\tid-"NR"\t"$4; }' | sort-bed - \
|| error_exit "compute_coverage failed" || error_exit "compute_coverage failed"
#|| cleanup && error_exit "compute_coverage failed" #|| cleanup && error_exit "compute_coverage failed"
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment