annotate tests/test_shm_csr.py @ 98:d714f5ea83d7 draft default tip

planemo upload commit 1a01065a084a817382872154f779b94090a35ebf
author rhpvorderman
date Wed, 10 Jan 2024 12:32:47 +0000
parents 84e9e5c8c101
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
83
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
1 # Copyright (c) 2021 Leiden University Medical Center
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
2 #
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
3 # Permission is hereby granted, free of charge, to any person obtaining a copy
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
4 # of this software and associated documentation files (the "Software"), to deal
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
5 # in the Software without restriction, including without limitation the rights
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
6 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
7 # copies of the Software, and to permit persons to whom the Software is
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
8 # furnished to do so, subject to the following conditions:
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
9 #
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
10 # The above copyright notice and this permission notice shall be included in
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
11 # all copies or substantial portions of the Software.
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
12 #
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
13 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
14 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
15 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
16 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
17 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
18 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
19 # SOFTWARE.
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
20
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
21 import os
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
22 import shutil
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
23 import subprocess
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
24 import sys
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
25 import tempfile
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
26 from pathlib import Path
90
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
27 from xml.etree import ElementTree
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
28 from xml.etree.ElementTree import Element
83
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
29
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
30 import pytest
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
31
90
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
32 GIT_ROOT = Path(__file__).parent.parent.absolute()
83
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
33 TEST_DIR = Path(__file__).parent
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
34 TEST_DATA_DIR = TEST_DIR / "data"
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
35 VALIDATION_DATA_DIR = TEST_DIR / "validation_data"
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
36 CONTROL_NWK377_PB_IGHC_MID1_40nt_2 = TEST_DATA_DIR / "CONTROL_NWK377_PB_IGHC_MID1_40nt_2.txz"
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
37
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
38
90
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
39 def get_container():
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
40 tool = ElementTree.parse(GIT_ROOT / "shm_csr.xml").getroot()
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
41 requirements: Element = tool.find("requirements")
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
42 container = requirements.find("container")
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
43 return container.text
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
44
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
45
93
8fcf31272f6e planemo upload commit a43893724cc769bed8a1f19a5b19ec1ba20cb63c
rhpvorderman
parents: 92
diff changeset
46 def ignore_files(src, files):
8fcf31272f6e planemo upload commit a43893724cc769bed8a1f19a5b19ec1ba20cb63c
rhpvorderman
parents: 92
diff changeset
47 "Ignore virtualenv and git directories to prevent massive tmp folders"
8fcf31272f6e planemo upload commit a43893724cc769bed8a1f19a5b19ec1ba20cb63c
rhpvorderman
parents: 92
diff changeset
48 if os.path.basename(src) in (".venv", ".git"):
8fcf31272f6e planemo upload commit a43893724cc769bed8a1f19a5b19ec1ba20cb63c
rhpvorderman
parents: 92
diff changeset
49 return files
8fcf31272f6e planemo upload commit a43893724cc769bed8a1f19a5b19ec1ba20cb63c
rhpvorderman
parents: 92
diff changeset
50 return ()
8fcf31272f6e planemo upload commit a43893724cc769bed8a1f19a5b19ec1ba20cb63c
rhpvorderman
parents: 92
diff changeset
51
98
d714f5ea83d7 planemo upload commit 1a01065a084a817382872154f779b94090a35ebf
rhpvorderman
parents: 94
diff changeset
52
d714f5ea83d7 planemo upload commit 1a01065a084a817382872154f779b94090a35ebf
rhpvorderman
parents: 94
diff changeset
53 def run_shm_csr(
d714f5ea83d7 planemo upload commit 1a01065a084a817382872154f779b94090a35ebf
rhpvorderman
parents: 94
diff changeset
54 input=str(CONTROL_NWK377_PB_IGHC_MID1_40nt_2),
d714f5ea83d7 planemo upload commit 1a01065a084a817382872154f779b94090a35ebf
rhpvorderman
parents: 94
diff changeset
55 infile_name = "input_data",
d714f5ea83d7 planemo upload commit 1a01065a084a817382872154f779b94090a35ebf
rhpvorderman
parents: 94
diff changeset
56 functionality = "productive",
d714f5ea83d7 planemo upload commit 1a01065a084a817382872154f779b94090a35ebf
rhpvorderman
parents: 94
diff changeset
57 unique = "Sequence.ID",
d714f5ea83d7 planemo upload commit 1a01065a084a817382872154f779b94090a35ebf
rhpvorderman
parents: 94
diff changeset
58 naive_output = "no",
d714f5ea83d7 planemo upload commit 1a01065a084a817382872154f779b94090a35ebf
rhpvorderman
parents: 94
diff changeset
59 naive_output_ca = "None",
d714f5ea83d7 planemo upload commit 1a01065a084a817382872154f779b94090a35ebf
rhpvorderman
parents: 94
diff changeset
60 naive_output_cg = "None",
d714f5ea83d7 planemo upload commit 1a01065a084a817382872154f779b94090a35ebf
rhpvorderman
parents: 94
diff changeset
61 naive_output_cm = "None",
d714f5ea83d7 planemo upload commit 1a01065a084a817382872154f779b94090a35ebf
rhpvorderman
parents: 94
diff changeset
62 naive_output_ce = "None",
d714f5ea83d7 planemo upload commit 1a01065a084a817382872154f779b94090a35ebf
rhpvorderman
parents: 94
diff changeset
63 naive_output_all = "None",
d714f5ea83d7 planemo upload commit 1a01065a084a817382872154f779b94090a35ebf
rhpvorderman
parents: 94
diff changeset
64 naive_output_igm_naive = "None",
d714f5ea83d7 planemo upload commit 1a01065a084a817382872154f779b94090a35ebf
rhpvorderman
parents: 94
diff changeset
65 naive_output_igm_naive_memory = "None",
d714f5ea83d7 planemo upload commit 1a01065a084a817382872154f779b94090a35ebf
rhpvorderman
parents: 94
diff changeset
66 filter_unique = "remove",
d714f5ea83d7 planemo upload commit 1a01065a084a817382872154f779b94090a35ebf
rhpvorderman
parents: 94
diff changeset
67 filter_unique_count = '2',
d714f5ea83d7 planemo upload commit 1a01065a084a817382872154f779b94090a35ebf
rhpvorderman
parents: 94
diff changeset
68 class_filter = '70_70',
d714f5ea83d7 planemo upload commit 1a01065a084a817382872154f779b94090a35ebf
rhpvorderman
parents: 94
diff changeset
69 empty_region_filter = 'FR1',
d714f5ea83d7 planemo upload commit 1a01065a084a817382872154f779b94090a35ebf
rhpvorderman
parents: 94
diff changeset
70 # Skip baseline and changeo by default. These tools cannot be modified
d714f5ea83d7 planemo upload commit 1a01065a084a817382872154f779b94090a35ebf
rhpvorderman
parents: 94
diff changeset
71 # anyway and take most of the test time to execute. The environment
d714f5ea83d7 planemo upload commit 1a01065a084a817382872154f779b94090a35ebf
rhpvorderman
parents: 94
diff changeset
72 # variable can be set to "no" on the CI so the code path is tested
d714f5ea83d7 planemo upload commit 1a01065a084a817382872154f779b94090a35ebf
rhpvorderman
parents: 94
diff changeset
73 # at the time a PR is ready.
d714f5ea83d7 planemo upload commit 1a01065a084a817382872154f779b94090a35ebf
rhpvorderman
parents: 94
diff changeset
74 run_changeo = "yes" if os.environ.get("SHM_CSR_FAST") == "no" else "no",
d714f5ea83d7 planemo upload commit 1a01065a084a817382872154f779b94090a35ebf
rhpvorderman
parents: 94
diff changeset
75 run_baseline = "yes" if os.environ.get("SHM_CSR_FAST") == "no" else "no",
d714f5ea83d7 planemo upload commit 1a01065a084a817382872154f779b94090a35ebf
rhpvorderman
parents: 94
diff changeset
76 ):
90
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
77 temp_dir = Path(tempfile.mkdtemp())
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
78 tool_dir = temp_dir / "shm_csr"
93
8fcf31272f6e planemo upload commit a43893724cc769bed8a1f19a5b19ec1ba20cb63c
rhpvorderman
parents: 92
diff changeset
79 shutil.copytree(
8fcf31272f6e planemo upload commit a43893724cc769bed8a1f19a5b19ec1ba20cb63c
rhpvorderman
parents: 92
diff changeset
80 GIT_ROOT, tool_dir,
8fcf31272f6e planemo upload commit a43893724cc769bed8a1f19a5b19ec1ba20cb63c
rhpvorderman
parents: 92
diff changeset
81 # Ignore .venv and .git directories.
8fcf31272f6e planemo upload commit a43893724cc769bed8a1f19a5b19ec1ba20cb63c
rhpvorderman
parents: 92
diff changeset
82 ignore=ignore_files)
90
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
83 working_dir = temp_dir / "working"
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
84 working_dir.mkdir(parents=True)
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
85 output_dir = temp_dir / "outputs"
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
86 output_dir.mkdir(parents=True)
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
87 wrapper = str(tool_dir / "wrapper.sh")
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
88 out_files_path = output_dir / "results"
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
89 out_file = out_files_path / "result.html"
83
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
90 cmd = [
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
91 "bash",
90
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
92 wrapper,
83
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
93 input,
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
94 "custom",
90
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
95 str(out_file),
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
96 str(out_files_path),
83
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
97 infile_name,
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
98 "-",
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
99 functionality,
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
100 unique,
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
101 naive_output,
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
102 naive_output_ca,
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
103 naive_output_cg,
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
104 naive_output_cm,
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
105 naive_output_ce,
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
106 naive_output_all,
94
84e9e5c8c101 "planemo upload commit d4be85014b638f1d50b318d4b735be7f6e973140"
rhpvorderman
parents: 93
diff changeset
107 naive_output_igm_naive,
84e9e5c8c101 "planemo upload commit d4be85014b638f1d50b318d4b735be7f6e973140"
rhpvorderman
parents: 93
diff changeset
108 naive_output_igm_naive_memory,
83
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
109 filter_unique,
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
110 filter_unique_count,
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
111 class_filter,
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
112 empty_region_filter,
98
d714f5ea83d7 planemo upload commit 1a01065a084a817382872154f779b94090a35ebf
rhpvorderman
parents: 94
diff changeset
113 run_changeo,
d714f5ea83d7 planemo upload commit 1a01065a084a817382872154f779b94090a35ebf
rhpvorderman
parents: 94
diff changeset
114 run_baseline
83
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
115 ]
90
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
116 docker_cmd = ["docker", "run", "-v", f"{temp_dir}:{temp_dir}",
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
117 "--rm", # Remove container after running
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
118 "-v", f"{input}:{input}",
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
119 "-w", str(working_dir),
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
120 # Run as current user which allows deletion of files.
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
121 # It also mitigates some security considerations
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
122 "-u", f"{os.getuid()}:{os.getgid()}",
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
123 # Run with default seccomp profile to mitigate mitigation slowdown
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
124 # http://mamememo.blogspot.com/2020/05/cpu-intensive-rubypython-code-runs.html
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
125 # This knocks down test runtime from 8 to 6 minutes.
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
126 "--security-opt", "seccomp=unconfined",
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
127 # Use a mulled container generated with `planemo mull`
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
128 "quay.io/biocontainers/mulled-v2-f7d31c9d7424063a492fc0e5ecbf89bc757c0107:2b50bdd4d8c1fefc6ec24b0753fad0dcecec843b-0"
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
129 ] + cmd
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
130 with open(temp_dir / "stderr", "wt") as stderr_file:
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
131 with open(temp_dir / "stdout", "wt") as stdout_file:
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
132 subprocess.run(docker_cmd, cwd=working_dir, stdout=stdout_file,
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
133 stderr=stderr_file, check=True)
98
d714f5ea83d7 planemo upload commit 1a01065a084a817382872154f779b94090a35ebf
rhpvorderman
parents: 94
diff changeset
134 return Path(out_files_path)
d714f5ea83d7 planemo upload commit 1a01065a084a817382872154f779b94090a35ebf
rhpvorderman
parents: 94
diff changeset
135
d714f5ea83d7 planemo upload commit 1a01065a084a817382872154f779b94090a35ebf
rhpvorderman
parents: 94
diff changeset
136
d714f5ea83d7 planemo upload commit 1a01065a084a817382872154f779b94090a35ebf
rhpvorderman
parents: 94
diff changeset
137 @pytest.fixture(scope="module")
d714f5ea83d7 planemo upload commit 1a01065a084a817382872154f779b94090a35ebf
rhpvorderman
parents: 94
diff changeset
138 def shm_csr_result():
d714f5ea83d7 planemo upload commit 1a01065a084a817382872154f779b94090a35ebf
rhpvorderman
parents: 94
diff changeset
139 yield run_shm_csr()
83
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
140
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
141
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
142 def test_check_output(shm_csr_result):
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
143 assert shm_csr_result.exists()
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
144
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
145
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
146 @pytest.mark.parametrize("filename", os.listdir(VALIDATION_DATA_DIR))
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
147 def test_results_match_validation(shm_csr_result, filename):
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
148 with open(Path(shm_csr_result, filename)) as result_h:
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
149 with open(Path(VALIDATION_DATA_DIR, filename)) as validate_h:
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
150 for line in result_h:
90
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
151 # Skip two faulty lines in shm_overview.
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
152 # TODO: Fix the issue.
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
153 validation_line = validate_h.readline()
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
154 if filename == "shm_overview.txt":
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
155 if (line.startswith("RGYW (%)") or
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
156 line.startswith("WRCY (%)")):
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
157 continue
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
158 assert line == validation_line
83
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
159
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
160
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
161 def test_nt_overview(shm_csr_result):
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
162 with open(Path(shm_csr_result, "sequence_overview", "ntoverview.txt")
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
163 ) as result_h:
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
164 with open(Path(TEST_DIR, "sequence_overview", "ntoverview.txt")
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
165 ) as validate_h:
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
166 for line in result_h:
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
167 assert line == validate_h.readline()
98
d714f5ea83d7 planemo upload commit 1a01065a084a817382872154f779b94090a35ebf
rhpvorderman
parents: 94
diff changeset
168
d714f5ea83d7 planemo upload commit 1a01065a084a817382872154f779b94090a35ebf
rhpvorderman
parents: 94
diff changeset
169
d714f5ea83d7 planemo upload commit 1a01065a084a817382872154f779b94090a35ebf
rhpvorderman
parents: 94
diff changeset
170 def test_baseline_succeeds():
d714f5ea83d7 planemo upload commit 1a01065a084a817382872154f779b94090a35ebf
rhpvorderman
parents: 94
diff changeset
171 run_shm_csr(
d714f5ea83d7 planemo upload commit 1a01065a084a817382872154f779b94090a35ebf
rhpvorderman
parents: 94
diff changeset
172 functionality="unproductive",
d714f5ea83d7 planemo upload commit 1a01065a084a817382872154f779b94090a35ebf
rhpvorderman
parents: 94
diff changeset
173 empty_region_filter="None",
d714f5ea83d7 planemo upload commit 1a01065a084a817382872154f779b94090a35ebf
rhpvorderman
parents: 94
diff changeset
174 filter_unique="no",
d714f5ea83d7 planemo upload commit 1a01065a084a817382872154f779b94090a35ebf
rhpvorderman
parents: 94
diff changeset
175 unique="VGene,DGene,JGene,CDR3.IMGT.seq",
d714f5ea83d7 planemo upload commit 1a01065a084a817382872154f779b94090a35ebf
rhpvorderman
parents: 94
diff changeset
176 class_filter="101_101_IGA",
d714f5ea83d7 planemo upload commit 1a01065a084a817382872154f779b94090a35ebf
rhpvorderman
parents: 94
diff changeset
177 naive_output="yes",
d714f5ea83d7 planemo upload commit 1a01065a084a817382872154f779b94090a35ebf
rhpvorderman
parents: 94
diff changeset
178 run_baseline="yes",
d714f5ea83d7 planemo upload commit 1a01065a084a817382872154f779b94090a35ebf
rhpvorderman
parents: 94
diff changeset
179 run_changeo="yes",
d714f5ea83d7 planemo upload commit 1a01065a084a817382872154f779b94090a35ebf
rhpvorderman
parents: 94
diff changeset
180 )