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>
# <bin_file> should be a bed file representing 10 bp bins along the genome
# <orientation> must be "all", "fwd" or "rev"
......@@ -30,7 +30,6 @@
# * python3 -> module load Python/3.6.0
# * samtools -> module load samtools/1.9
# * bedtools -> module load bedtools/2.25.0
# * mawk -> use alias if absent
# * parallel (for niceload) -> module load parallel/20170122
# * UCSC-tools (for bedGraphToBigWig) -> module load UCSC-tools/v373
......@@ -66,7 +65,6 @@ error_exit ()
exit 1
}
mawk --version 1> /dev/null 2> /dev/null || alias mawk='awk'
load_tools || error_exit "Some tools are not available"
......@@ -74,7 +72,7 @@ bam=${1}
bin_file=${2}
# Example of how to generate the bin_file from iGenome data:
# 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://' \
# | bedops --chop 10 - \
# > Caenorhabditis_elegans/Ensembl/WBcel235/Sequence/genome_binned_10.bed
......@@ -163,7 +161,7 @@ fi
echo "getting chromosome bounds"
genome_file="${workdir}/chrom_sizes.txt"
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://' \
> ${genome_file} || error_exit "making ${genome_file} failed"
#> ${genome_file} || cleanup && error_exit "making ${genome_file} failed"
......@@ -172,7 +170,7 @@ compute_coverage()
{
cmd="niceload --noswap bedtools genomecov -bg -split ${orient_filter} ${scaling} -ibam ${bam}"
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"
#|| 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