#!/bin/bash #plot_profile.sh script_name="plot_profile.sh" #Help function usage() { echo "-h --Help documentation for $script_name" echo "-g --File path to gtf/bed files" echo "Example: $script_name -g 'genome.gtf'" exit 1 } raise() { echo "${1}" >&2 } check_tools() { raise " Checking for required libraries and components on this system " deeptools --version &> version_deeptools.txt if [ $? -gt 0 ] then raise "Missing deeptools" return 1 fi } compute_matrix() { raise " Computing matrix on ${1} using ${2} " computeMatrix reference-point \ --referencePoint TSS \ -S ${1} \ -R ${2} \ --skipZeros \ -o computeMatrix.gz \ -p max/2 if [ $? -gt 0 ] then raise "Problem building matrix" return 1 fi } plot_profile() { raise " Plotting profile " plotProfile -m computeMatrix.gz \ -out plotProfile.png if [ $? -gt 0 ] then raise "Problem plotting" return 1 fi } run_main() { # Parsing options OPTIND=1 # Reset OPTIND <<<<<<< HEAD while getopts :g:h opt ======= while getopts g:h opt >>>>>>> 61db854ac1fcdb60431ad48a0a5cab0255d9c2d3 do case $opt in g) gtf=$OPTARG;; h) usage;; esac done shift $(($OPTIND -1)) # Check for mandatory options if [[ -z $gtf ]]; then usage fi bws=$(ls *.pooled.fc_signal.bw) check_tools || exit 1 compute_matrix "${bws}" "${gtf}" || return 1 plot_profile || return 1 raise "ALL COMPLETE" } if [[ "${BASH_SOURCE[0]}" == "${0}" ]] then run_main "$@" if [ $? -gt 0 ] then exit 1 fi fi