Skip to content

Commit

Permalink
Refactoring the 'replicate-results' into a makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
recursion-ninja committed Feb 28, 2022
1 parent 7cdebb2 commit 475514e
Show file tree
Hide file tree
Showing 6 changed files with 156 additions and 55 deletions.
Empty file removed bin/README.md
Empty file.
29 changes: 29 additions & 0 deletions bin/measure-scaling-performance.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

# # # # #
#
# Function to call the requisite Haskell and Python binary/script (respectively)
# which will generate the results data and figures presented in the paper.
#
# # # # #

function using()
{
./bin/generate-timings $5 \
--data "data-sets/$1.afasta" \
--tree "data-sets/$1.tree" \
--tcm "data-sets/tcm-${2}.tcm" \
--output "$1-$2" \
-n "$3" \
-k "$4"

python3 ./bin/plot-figure.py \
"replicate-results/csv/${1}-${2}.preorder.csv" \
"replicate-results/img/${1}-preorder.eps"

python3 ./bin/plot-figure.py \
"replicate-results/csv/${1}-${2}.postorder.csv" \
"replicate-results/img/${1}-postorder.eps"
}

"$@"
2 changes: 2 additions & 0 deletions plot-figure.py → bin/plot-figure.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/python3

from mpl_toolkits import mplot3d
import math
import matplotlib.pyplot as plt
Expand Down
9 changes: 4 additions & 5 deletions cabal.project
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
allow-newer:
base,
Cabal,
ghc-prim,
template-haskell
installdir: ./bin

install-method: copy

packages: .

with-compiler: ghc-9.2.1

69 changes: 69 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# # # # #
#
# Script to reproduce the results of the paper from a clean environment.
# Installs all required dependencies. Builds the required binaries.
# Run the experimental algorithm on datasets to generate the empirical results.
#
# # # # #

bin-dir := ./bin
data-dir := replicate-results
executable := $(bin-dir)/generate-timings
generate := $(bin-dir)/measure-scaling-performance.sh using
biological-scale := [1%1,1%2,1%4,1%8,1%16,1%32]
customized-scale := [1%1,1%2,1%4,1%8,1%16,1%32,1%64]
customized-nodes := [4,8,16,32,64,128,256]


# All synonyms for replicating the paper's results.
all: results

replicate: results

reproduce: results

results: fungi metazoa pathological


# Install dependencies required to replicate results:
ensure-Haskell: $(bin-dir)/generate-timings
@command -v ghcup &> /dev/null || curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh

ensure-Python:
@command -v python3 &> /dev/null || apt-get install python3 --yes
@command -v pip3 &> /dev/null || apt-get install python3-pip --yes
@pip3 show matplotlib &> /dev/null || pip3 install --upgrade matplotlib

ensure-R:
command -v &> /dev/null || sudo apt install r-base

compile-binaries: ensure-Haskell
@echo "Copiling binaries"
@ghcup run \
--ghc 9.2.1 \
--cabal 3.6.2.0 \
-- cabal update && \
cabal install \
--installdir=$(bin-dir) \
--install-method=copy

ensure-workspace:
@mkdir -p $(data-dir)/csv
@mkdir -p $(data-dir)/data
@mkdir -p $(data-dir)/img
@mkdir -p $(data-dir)/taxa
@mkdir -p $(data-dir)/tree

fungi: compile-binaries ensure-Python ensure-R ensure-workspace
$(generate) \
'fungi' '11' '[25,50,100,200,400,800,1553]' $(biological-scale)

metazoa: compile-binaries ensure-Python ensure-R ensure-workspace
$(generate) \
'metazoa' '11' '[25,50,100,200,400,800,1766]' $(biological-scale)

pathological: compile-binaries ensure-Python ensure-R ensure-workspace
$(generate) \
'pathological' '12' $(customized-nodes) $(customized-scale)
$(generate) \
'pathological' '31' $(customized-nodes) $(customized-scale) '--no-generate'
102 changes: 52 additions & 50 deletions replicate-results.sh
Original file line number Diff line number Diff line change
@@ -1,65 +1,67 @@
#!/bin/bash
#Script to run implied alingment data sets

#load Haskell dependencies
which stack || curl -sSL https://get.haskellstack.org/ | sh

#load Python3 dependencies
which python3 || apt-get install python3 --yes
which pip3 || apt-get install python3-pip --yes
pip3 show matplotlib || pip3 install --upgrade matplotlib
# # # # #
#
# Script to reproduce the results of the paper from a clean environment.
# Installs all required dependencies. Builds the required binaries.
# Run the experimental algorithm on datasets to generate the empirical results.
#
# # # # #

#load R dependencies
which R || sudo apt install r-base

#build binaries
stack install
# Install dependencies required to replicate results:
# * Load Python3 dependencies
which python3 &> /dev/null || apt-get install python3 --yes
which pip3 &> /dev/null || apt-get install python3-pip --yes
pip3 show matplotlib &> /dev/null || pip3 install --upgrade matplotlib

#ensure target directories exist
# * Load R dependencies
which R &> /dev/null || sudo apt install r-base

# * Load Haskell dependencies
which ghcup &> /dev/null || curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh


# Build binaries
ghcup run \
--ghc 9.2.1 \
--cabal 3.6.2.0 \
-- cabal update && \
cabal install \
--installdir=./bin \
--install-method=copy


# Ensure output directories exist to place results data
mkdir -p replicate-results/csv
mkdir -p replicate-results/data
mkdir -p replicate-results/img
mkdir -p replicate-results/taxa
mkdir -p replicate-results/tree

#run data sets
./bin/generate-timings \
--data data-sets/fungi.afasta \
--tree data-sets/fungi.tree \
--tcm data-sets/tcm-11.tcm \
--output fungi-11 \
-n [25,50,100,200,400,800,1553] \
-k [1%1,1%2,1%4,1%8,1%16,1%32]
python3 plot-figure.py replicate-results/csv/fungi-11.preorder.csv replicate-results/img/fungi-preorder.eps
python3 plot-figure.py replicate-results/csv/fungi-11.postorder.csv replicate-results/img/fungi-postorder.eps

./bin/generate-timings \
--data data-sets/metazoa.afasta \
--tree data-sets/metazoa.tree \
--tcm data-sets/tcm-11.tcm \
--output metazoa-11 \
-n [25,50,100,200,400,800,1766] \
-k [1%1,1%2,1%4,1%8,1%16,1%32]
python3 plot-figure.py replicate-results/csv/metazoa-11.preorder.csv replicate-results/img/metazoa-preorder.eps
python3 plot-figure.py replicate-results/csv/metazoa-11.postorder.csv replicate-results/img/metazoa-postorder.eps
# Run data sets to produce the results data
function generate()
{
./bin/generate-timings $5 \
--data "data-sets/$1.afasta" \
--tree "data-sets/$1.tree" \
--tcm "data-sets/tcm-${2}.tcm" \
--output "$1-$2" \
-n "$3" \
-k "$4"

python3 plot-figure.py \
"replicate-results/csv/${1}-${2}.preorder.csv" \
"replicate-results/img/${1}-preorder.eps"

./bin/generate-timings \
--data data-sets/pathological.afasta \
--tree data-sets/pathological.tree \
--tcm data-sets/tcm-12.tcm \
--output pathological-12 \
-n [4,8,16,32,64,128,256] \
-k [1%1,1%2,1%4,1%8,1%16,1%32,1%64]
python3 plot-figure.py replicate-results/csv/pathological-12.preorder.csv replicate-results/img/pathological-12-preorder.eps
python3 plot-figure.py replicate-results/csv/pathological-12.postorder.csv replicate-results/img/pathological-12-postorder.eps
python3 plot-figure.py \
"replicate-results/csv/${1}-${2}.postorder.csv" \
"replicate-results/img/${1}-postorder.eps"
}

./bin/generate-timings \
--no-generate \
--data data-sets/pathological.afasta \
--tree data-sets/pathological.tree \
--tcm data-sets/tcm-31.tcm \
--output pathological-31 \
-n [4,8,16,32,64,128,256] \
-k [1%1,1%2,1%4,1%8,1%16,1%32,1%64]
python3 plot-figure.py replicate-results/csv/pathological-31.preorder.csv replicate-results/img/pathological-31-preorder.eps
python3 plot-figure.py replicate-results/csv/pathological-31.postorder.csv replicate-results/img/pathological-31-postorder.eps
generate 'fungi' '11' '[25,50,100,200,400,800,1553]' '[1%1,1%2,1%4,1%8,1%16,1%32]'
generate 'metazoa' '11' '[25,50,100,200,400,800,1766]' '[1%1,1%2,1%4,1%8,1%16,1%32]'
generate 'pathological' '12' '[4,8,16,32,64,128,256]' '[1%1,1%2,1%4,1%8,1%16,1%32,1%64]'
generate 'pathological' '31' '[4,8,16,32,64,128,256]' '[1%1,1%2,1%4,1%8,1%16,1%32,1%64]' '--no-generate'

0 comments on commit 475514e

Please sign in to comment.