-
Notifications
You must be signed in to change notification settings - Fork 17
145 lines (135 loc) · 7.3 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
name: UniFrac CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: flake8
uses: actions/setup-python@v3
with:
python-version: 3.9
- name: install dependencies
run: python -m pip install --upgrade pip
- name: lint
run: |
pip install -q flake8
flake8 unifrac setup.py
build-and-test:
needs: lint
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
os: [ubuntu-latest, macos-latest, linux-gpu-cuda]
exclude:
- os: macos-latest
python-version: '3.9'
- os: macos-latest
python-version: '3.10'
- os: linux-gpu-cuda
python-version: '3.8'
- os: linux-gpu-cuda
python-version: '3.9'
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: conda-incubator/setup-miniconda@v2
with:
miniconda-version: "latest"
auto-update-conda: true
python-version: ${{ matrix.python-version }}
- name: Install
shell: bash -l {0}
run: |
conda create --yes -n unifrac -c conda-forge -c bioconda python=${{ matrix.python-version }}
conda activate unifrac
conda config --add channels conda-forge
conda config --add channels bioconda
if [[ "$(uname -s)" == "Linux" ]];
then
conda install --yes -c conda-forge -c bioconda gxx_linux-64
else
conda install --yes -c conda-forge -c bioconda clangxx_osx-64
fi
conda install --yes -c conda-forge -c bioconda "unifrac-binaries>=1.2"
conda install --yes -c conda-forge -c bioconda cython biom-format numpy "h5py>3.3.0" "scikit-bio>=0.5.8" nose
echo "$(uname -s)"
if [[ "$(uname -s)" == "Linux" ]];
then
which x86_64-conda-linux-gnu-gcc
x86_64-conda-linux-gnu-gcc -v
x86_64-conda-linux-gnu-g++ -v
else
which clang
clang -v
fi
which h5c++
pip install iow
pip install -e .
- name: Tests
shell: bash -l {0}
run: |
conda activate unifrac
# keep it low for runs in containers
# and a weird number to potentially catch potential bugs
export OMP_NUM_THREADS=3
# diagnostic messages for debugging, if needed
export UNIFRAC_GPU_INFO=Y
ls -lrt $CONDA_PREFIX/lib/libhdf5_cpp*
nosetests
- name: Sanity checks
shell: bash -l {0}
run: |
conda activate unifrac
# keep it low for runs in containers
# and a weird number to potentially catch potential bugs
export OMP_NUM_THREADS=3
# diagnostic messages for debugging, if needed
export UNIFRAC_GPU_INFO=Y
set -e
ssu -i unifrac/tests/data/crawford.biom -t unifrac/tests/data/crawford.tre -o ci/test.dm -m unweighted
python -c "import skbio; dm = skbio.DistanceMatrix.read('ci/test.dm')"
pushd unifrac/tests
export UNIFRAC_TIMING_INFO=Y
python -c "import unifrac; unifrac.unweighted_to_file('data/crawford.biom','data/crawford.tre','../../ci/test.dm.h5')"
python -c "import unifrac,skbio; dm_u=unifrac.unweighted('data/crawford.biom','data/crawford.tre'); dm = skbio.DistanceMatrix.read('../../ci/test.dm'); t=abs(dm_u.data-dm.data).max(); print(t); assert t < 0.1"
python -c "import unifrac; unifrac.unweighted_to_file('data/crawford.biom','data/crawford.tre','../../ci/test2.dm.h5',permanova_perms=99,grouping_filename='data/crawford.group.tsv',grouping_columns='Treatment')"
python -c "import unifrac; unifrac.weighted_normalized_to_file('data/crawford.biom','data/crawford.tre','../../ci/test3.dm.h5',subsample_depth=2,pcoa_dims=2)"
export UNIFRAC_TIMING_INFO=N
popd
python -c "import h5py,skbio; f_u=h5py.File('ci/test.dm.h5','r'); dm_u=skbio.stats.distance.DistanceMatrix(f_u['matrix'][:,:],f_u['order'][:])"
python -c "import h5py,skbio; dm = skbio.DistanceMatrix.read('ci/test.dm'); f_u=h5py.File('ci/test.dm.h5','r'); dm_u=skbio.stats.distance.DistanceMatrix(f_u['matrix'][:,:],f_u['order'][:]); t=abs(dm_u.data-dm.data).max(); print(t); assert t < 0.1"
python -c "import h5py,skbio; dm = skbio.DistanceMatrix.read('ci/test.dm'); f_u=h5py.File('ci/test2.dm.h5','r'); dm_u=skbio.stats.distance.DistanceMatrix(f_u['matrix'][:,:],f_u['order'][:]); t=abs(dm_u.data-dm.data).max(); print(t); assert t < 0.1"
python -c "import h5py; f_u=h5py.File('ci/test2.dm.h5','r'); print(f_u.keys()); assert len(f_u['stat_methods'][:]) == 1"
python -c "import h5py; f_u=h5py.File('ci/test3.dm.h5','r'); print(f_u.keys()); assert len(f_u['pcoa_eigvals'][:]) == 2"
# repeat using unifrac's h5 interfaces
python -c "import unifrac; dm_u=unifrac.h5unifrac('ci/test.dm.h5'); dm_l=unifrac.h5unifrac_all('ci/test.dm.h5')"
python -c "import unifrac,skbio; dm = skbio.DistanceMatrix.read('ci/test.dm'); dm_u=unifrac.h5unifrac('ci/test.dm.h5'); t=abs(dm_u.data-dm.data).max(); print(t); assert t < 0.1"
python -c "import unifrac,skbio; dm = skbio.DistanceMatrix.read('ci/test.dm'); dm_u=unifrac.h5unifrac_all('ci/test.dm.h5')[0]; t=abs(dm_u.data-dm.data).max(); print(t); assert t < 0.1"
python -c "import unifrac,skbio; dm = skbio.DistanceMatrix.read('ci/test.dm'); dm_u=unifrac.h5unifrac('ci/test2.dm.h5'); t=abs(dm_u.data-dm.data).max(); print(t); assert t < 0.1"
python -c "import unifrac; st_l=unifrac.h5permanova_dict('ci/test2.dm.h5'); assert len(st_l) == 1"
python -c "import unifrac; pc=unifrac.h5pcoa('ci/test3.dm.h5'); print(pc); assert len(pc.eigvals) == 2"
ssu -i unifrac/tests/data/crawford.biom -t unifrac/tests/data/crawford.tre --pcoa 3 --mode multi --subsample-depth 2 --n-subsamples 10 -r hdf5 -o ci/test4.dm.h5 -m unweighted
python -c "import unifrac; dm_u=unifrac.h5unifrac_all('ci/test4.dm.h5'); assert len(dm_u) == 10; print(dm_u[0]); print(dm_u[4]); print(dm_u[9]); dm_u.close(); assert len(dm_u) == 0"
if [[ "$(uname -s)" == "Linux" ]];
then
MD5=md5sum
else
MD5='md5 -r'
fi
ssu -i unifrac/tests/data/crawford.biom -t unifrac/tests/data/crawford.tre -o ci/test.dm.start0.stop3 -m unweighted --mode partial --start 0 --stop 3
ssu -i unifrac/tests/data/crawford.biom -t unifrac/tests/data/crawford.tre -o ci/test.dm.start3.stop5 -m unweighted --mode partial --start 3 --stop 5
ssu -i unifrac/tests/data/crawford.biom -t unifrac/tests/data/crawford.tre -o ci/test.dm.partial --mode merge-partial --partial-pattern "ci/test.dm.start*"
exp=$($MD5 ci/test.dm | awk '{ print $1 }')
obs=$($MD5 ci/test.dm.partial | awk '{ print $1 }')
python -c "assert '${obs}' == '${exp}'"
faithpd -i unifrac/tests/data/crawford.biom -t unifrac/tests/data/crawford.tre -o ci/test.faith.obs
tail -n +2 ci/test.faith.obs > ci/test.faith.header-removed.obs
exp1=$($MD5 unifrac/tests/data/test.faith.exp | awk '{ print $1 }')
obs1=$($MD5 ci/test.faith.header-removed.obs | awk '{ print $1 }')
python -c "assert '${obs1}' == '${exp1}'"