From 258fd070ef99854922a61d1979d2ce26cf8eb8db Mon Sep 17 00:00:00 2001 From: Bryan Roessler Date: Mon, 22 Jul 2024 16:33:35 -0400 Subject: [PATCH] Make functional --- workflow/script-run-workflow | 84 ++++++++++++++++++++++-------------- 1 file changed, 52 insertions(+), 32 deletions(-) diff --git a/workflow/script-run-workflow b/workflow/script-run-workflow index 9ef33075..98fa4c2f 100755 --- a/workflow/script-run-workflow +++ b/workflow/script-run-workflow @@ -138,7 +138,6 @@ parse_input() { fi } - # @section Helper functions # @internal module() { @@ -188,9 +187,9 @@ install_dependencies() { debug "Running: ${FUNCNAME[0]}" "$@" # Dependency arrays - depends_rpm=(graphviz pandoc pdftk-java gd-devel) - depends_deb=(graphviz pandoc pdftk-java libgd-dev) - depends_brew=(graphiz pandoc gd pdftk-java) + depends_rpm=(graphviz pandoc pdftk-java gd-devel shdoc) + depends_deb=(graphviz pandoc pdftk-java libgd-dev shdoc) + depends_brew=(graphiz pandoc gd pdftk-java shdoc) depends_perl=(File::Map ExtUtils::PkgConfig GD GO::TermFinder) depends_r=(BiocManager ontologyIndex ggrepel tidyverse sos openxlsx ggplot2 plyr extrafont gridExtra gplots stringr plotly ggthemes pandoc rmarkdown) @@ -501,11 +500,8 @@ py_gtf() { shopt -u nullglob for s in "${set2[@]}"; do - echo "$PERL analyze_v2.pl -an gene_association.sgd -as P -o gene_ontology_edit.obo -b $set1 $s" - echo "TODO: analyze_v2.pl should be translated" - "$PERL" analyze_v2.pl -an gene_association.sgd -as P -o gene_ontology_edit.obo -b "$set1" "$s" - echo "$PERL terms2tsv_v4.pl $s.terms > $s.tsv" - echo "TODO: terms2tsv_v4.pl should be translated" + pl_analyze "$set1" "$s" + pl_terms2tsv "$s" "$PERL" terms2tsv_v4.pl "$s.terms" > "$s.tsv" done @@ -518,36 +514,59 @@ py_gtf() { popd || return 1 } - - - # @description Perl analyze submodule - # @arg $1 string "Set 1" - # @arg $@ string - pl_analyze() { - : - - - } - - - pl_terms2tsv() { - : - - - - } - - - # Perform operations in each directory for d in "$process_dir" "$function_dir" "$component_dir"; do set1="ORF_List_Without_DAmPs.txt" out_file="${d##*/}Results.txt" # Use the dirname to create each Results filename _process "$d" & # parallelize done - } + +submodule pl_analyze +# @description Perl analyze submodule +# This seems weird to me because we're just overwriting the same data for all set2 members +# https://metacpan.org/dist/GO-TermFinder/view/examples/analyze.pl +# Is there a reason you need a custom version and not the original from cpan? +# @arg $1 string Set 1 +# @arg $2 string Set 2 +pl_analyze() { + script="analyze_v2.pl" + an="gene_association.sgd" + out_file="gene_ontology_edit.obo" + debug "$PERL $script -an $an -as P -o $out_file -b $1 $2" + "$PERL" "$script" -an "$an" -as P -o "$out_file" -b "$1" "$2" +} + + +submodule pl_terms2tsv +# @description Perl terms2tsv submodule +# Probably should be translated to shell/python +# @arg $1 string Set 2 +pl_terms2tsv() { + script="terms2tsv_v4.pl" + debug "$PERL $script $1.terms > $1.tsv" + "$PERL" "$script" "$1.terms" > "$1.tsv" +} + + +submodule documentation +# @section Documentation +# @description Generates markdown documentation from this script using shdoc +documentation() { + debug "Running: ${FUNCNAME[0]}" + + # Print markdown to stdout + shdoc < "$SCRIPT" + + # Create markdown file + shdoc < "$SCRIPT" > documentation.md + +} + + + + # @description Compile GTF in R r_compile_gtf() { debug "Running: ${FUNCNAME[0]}" @@ -564,7 +583,8 @@ main() { debug "Running: ${FUNCNAME[0]}" "$@" # Where are we located? - SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + SCRIPT=$(realpath -s "${BASH_SOURCE[0]}") + SCRIPT_DIR=$(dirname "$SCRIPT") # Set the automatic project directory prefix PROJECT_PREFIX="$(whoami)_$(date +%y_%m_%d)"