Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests for proprocess and svd #26

Merged
merged 17 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,8 @@ jobs:

- name: Test with pytest
run: |
pytest tests/test_preprocessing.py
pytest tests/test_svd.py
pytest tests/test_map_to_map.py
pytest tests/test_distribution_to_distribution.py

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
input_fname: tests/results/test_map_to_map_distance_matrix_submission_0.pkl
metrics:
- l2
gt_metadata_fname: tests/data/test_metadata_10.csv
gt_metadata_fname: tests/data/Ground_truth/test_metadata_10.csv
n_replicates: 3
n_pool_microstate: 2
replicate_fraction: 0.9
Expand Down
6 changes: 3 additions & 3 deletions tests/config_files/test_config_map_to_map.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ data:
metadata_key: populations
label_key: id
ground_truth:
volumes: tests/data/test_maps_gt_flat_10.pt
metadata: tests/data/test_metadata_10.csv
volumes: tests/data/Ground_truth/test_maps_gt_flat_10.pt
metadata: tests/data/Ground_truth/test_metadata_10.csv
mask:
do: true
volume: data/mask_dilated_wide_224x224.mrc
volume: data/Ground_truth/mask_dilated_wide_224x224.mrc
analysis:
metrics:
- l2
Expand Down
8 changes: 8 additions & 0 deletions tests/config_files/test_config_preproc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
submission_config_file: tests/data/unprocessed_dataset_2_submissions/submission_x/submission_config.json
seed_flavor_assignment: 0
thresh_percentile: 93.0
BOT_box_size: 32
BOT_loss: wemd
BOT_iter: 200
BOT_refine: True
output_path: tests/results/preproccessed_submission_x/
14 changes: 14 additions & 0 deletions tests/config_files/test_config_svd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
path_to_volumes: tests/data/dataset_2_submissions/
box_size_ds: 32
submission_list: [0]
experiment_mode: "all_vs_ref" # options are "all_vs_all", "all_vs_ref"
# optional unless experiment_mode is "all_vs_ref"
path_to_reference: tests/data/Ground_truth/test_maps_gt_flat_10.pt
dtype: "float32" # options are "float32", "float64"
output_options:
# path will be created if it does not exist
output_path: tests/results/svd
# whether or not to save the processed volumes (downsampled, normalized, etc.)
save_volumes: True
# whether or not to save the SVD matrices (U, S, V)
save_svd_matrices: True
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"gt": {
"name": "gt",
"path": "tests/data/unprocessed_dataset_2_submissions/submission_x",
"box_size": 224,
"pixel_size": 2.146,
"ref_align_fname": "1.mrc"
},
"0": {
"name": "raw_submission_in_testdata",
"align": 1,
"box_size": 244,
"pixel_size": 2.146,
"path": "tests/data/unprocessed_dataset_2_submissions/submission_x"
}
}
17 changes: 12 additions & 5 deletions tests/scripts/fetch_test_data.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
mkdir -p data/dataset_2_submissions tests/data/dataset_2_submissions tests/results
wget https://files.osf.io/v1/resources/8h6fz/providers/dropbox/dataset_2_submissions/test_submission_0_n8.pt?download=true -O tests/data/dataset_2_submissions/test_submission_0_n8.pt
wget https://files.osf.io/v1/resources/8h6fz/providers/dropbox/Ground_truth/test_maps_gt_flat_10.pt?download=true -O tests/data/test_maps_gt_flat_10.pt
wget https://files.osf.io/v1/resources/8h6fz/providers/dropbox/Ground_truth/test_metadata_10.csv?download=true -O tests/data/test_metadata_10.csv
wget https://files.osf.io/v1/resources/8h6fz/providers/dropbox/Ground_truth/mask_dilated_wide_224x224.mrc?download=true -O data/mask_dilated_wide_224x224.mrc
mkdir -p tests/data/dataset_2_submissions data/dataset_2_submissions tests/results tests/data/unprocessed_dataset_2_submissions/submission_x tests/data/Ground_truth/ data/Ground_truth
wget https://files.osf.io/v1/resources/8h6fz/providers/dropbox/tests/dataset_2_submissions/test_submission_0_n8.pt?download=true -O tests/data/dataset_2_submissions/test_submission_0_n8.pt
ADIR=$(pwd)
ln -s $ADIR/tests/data/dataset_2_submissions/test_submission_0_n8.pt $ADIR/tests/data/dataset_2_submissions/submission_0.pt # symlink for svd which needs submission_0.pt for filename
wget https://files.osf.io/v1/resources/8h6fz/providers/dropbox/tests/Ground_truth/test_maps_gt_flat_10.pt?download=true -O tests/data/Ground_truth/test_maps_gt_flat_10.pt
wget https://files.osf.io/v1/resources/8h6fz/providers/dropbox/tests/Ground_truth/test_metadata_10.csv?download=true -O tests/data/Ground_truth/test_metadata_10.csv
wget https://files.osf.io/v1/resources/8h6fz/providers/dropbox/tests/Ground_truth/1.mrc?download=true -O tests/data/Ground_truth/1.mrc
wget https://files.osf.io/v1/resources/8h6fz/providers/dropbox/Ground_truth/mask_dilated_wide_224x224.mrc?download=true -O data/Ground_truth/mask_dilated_wide_224x224.mrc
for FILE in 1.mrc 2.mrc 3.mrc 4.mrc populations.txt
do
wget https://files.osf.io/v1/resources/8h6fz/providers/dropbox/tests/unprocessed_dataset_2_submissions/submission_x/${FILE}?download=true -O tests/data/unprocessed_dataset_2_submissions/submission_x/${FILE}
done
7 changes: 7 additions & 0 deletions tests/test_preprocessing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from omegaconf import OmegaConf
from cryo_challenge._commands import run_preprocessing


def test_run_preprocessing():
args = OmegaConf.create({'config': 'tests/config_files/test_config_preproc.yaml'})
run_preprocessing.main(args)
7 changes: 7 additions & 0 deletions tests/test_svd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from omegaconf import OmegaConf
from cryo_challenge._commands import run_svd


def test_run_preprocessing():
args = OmegaConf.create({'config': 'tests/config_files/test_config_svd.yaml'})
run_svd.main(args)
23 changes: 19 additions & 4 deletions tutorials/2_tutorial_svd.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -12,7 +12,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -40,9 +40,24 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "c199472d76994ca7b2639a2709536f6d",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"FileChooser(path='/mnt/home/gwoollard', filename='', title='', show_hidden=False, select_desc='Select', change…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Select path to SVD config file\n",
"# An example of this file is available in the path ../config_files/config_svd.yaml\n",
Expand Down
Loading