annotate tests/test_shm_csr.py @ 96:385dea3c6cb5 draft

planemo upload commit 423a48569c69301fdbf893ac3a649128404dfff5
author rhpvorderman
date Fri, 05 Jan 2024 08:53:22 +0000
parents 84e9e5c8c101
children d714f5ea83d7
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
83
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
52 @pytest.fixture(scope="module")
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
53 def shm_csr_result():
90
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
54 temp_dir = Path(tempfile.mkdtemp())
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
55 tool_dir = temp_dir / "shm_csr"
93
8fcf31272f6e planemo upload commit a43893724cc769bed8a1f19a5b19ec1ba20cb63c
rhpvorderman
parents: 92
diff changeset
56 shutil.copytree(
8fcf31272f6e planemo upload commit a43893724cc769bed8a1f19a5b19ec1ba20cb63c
rhpvorderman
parents: 92
diff changeset
57 GIT_ROOT, tool_dir,
8fcf31272f6e planemo upload commit a43893724cc769bed8a1f19a5b19ec1ba20cb63c
rhpvorderman
parents: 92
diff changeset
58 # Ignore .venv and .git directories.
8fcf31272f6e planemo upload commit a43893724cc769bed8a1f19a5b19ec1ba20cb63c
rhpvorderman
parents: 92
diff changeset
59 ignore=ignore_files)
90
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
60 working_dir = temp_dir / "working"
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
61 working_dir.mkdir(parents=True)
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
62 output_dir = temp_dir / "outputs"
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
63 output_dir.mkdir(parents=True)
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
64 wrapper = str(tool_dir / "wrapper.sh")
83
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
65 input = str(CONTROL_NWK377_PB_IGHC_MID1_40nt_2)
90
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
66 out_files_path = output_dir / "results"
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
67 out_file = out_files_path / "result.html"
83
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
68 infile_name = "input_data"
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
69 functionality = "productive"
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
70 unique = "Sequence.ID"
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
71 naive_output = "no"
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
72 naive_output_ca = "None"
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
73 naive_output_cg = "None"
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
74 naive_output_cm = "None"
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
75 naive_output_ce = "None"
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
76 naive_output_all = "None"
94
84e9e5c8c101 "planemo upload commit d4be85014b638f1d50b318d4b735be7f6e973140"
rhpvorderman
parents: 93
diff changeset
77 naive_output_igm_naive = "None"
84e9e5c8c101 "planemo upload commit d4be85014b638f1d50b318d4b735be7f6e973140"
rhpvorderman
parents: 93
diff changeset
78 naive_output_igm_naive_memory = "None"
83
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
79 filter_unique = "remove"
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
80 filter_unique_count = '2'
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
81 class_filter = '70_70'
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
82 empty_region_filter = 'FR1'
92
cf8ad181628f planemo upload commit 36be3b053802693392f935e6619ba3f2b1704e3c
rhpvorderman
parents: 90
diff changeset
83 # Skip baseline and changeo by default. These tools cannot be modified
cf8ad181628f planemo upload commit 36be3b053802693392f935e6619ba3f2b1704e3c
rhpvorderman
parents: 90
diff changeset
84 # anyway and take most of the test time to execute. The environment
cf8ad181628f planemo upload commit 36be3b053802693392f935e6619ba3f2b1704e3c
rhpvorderman
parents: 90
diff changeset
85 # variable can be set to "no" on the CI so the code path is tested
cf8ad181628f planemo upload commit 36be3b053802693392f935e6619ba3f2b1704e3c
rhpvorderman
parents: 90
diff changeset
86 # at the time a PR is ready.
cf8ad181628f planemo upload commit 36be3b053802693392f935e6619ba3f2b1704e3c
rhpvorderman
parents: 90
diff changeset
87 fast = os.environ.get("SHM_CSR_FAST", "yes")
83
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
88 cmd = [
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
89 "bash",
90
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
90 wrapper,
83
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
91 input,
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
92 "custom",
90
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
93 str(out_file),
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
94 str(out_files_path),
83
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
95 infile_name,
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
96 "-",
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
97 functionality,
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
98 unique,
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
99 naive_output,
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
100 naive_output_ca,
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
101 naive_output_cg,
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
102 naive_output_cm,
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
103 naive_output_ce,
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
104 naive_output_all,
94
84e9e5c8c101 "planemo upload commit d4be85014b638f1d50b318d4b735be7f6e973140"
rhpvorderman
parents: 93
diff changeset
105 naive_output_igm_naive,
84e9e5c8c101 "planemo upload commit d4be85014b638f1d50b318d4b735be7f6e973140"
rhpvorderman
parents: 93
diff changeset
106 naive_output_igm_naive_memory,
83
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
107 filter_unique,
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
108 filter_unique_count,
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
109 class_filter,
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
110 empty_region_filter,
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
111 fast
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
112 ]
90
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
113 docker_cmd = ["docker", "run", "-v", f"{temp_dir}:{temp_dir}",
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
114 "--rm", # Remove container after running
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
115 "-v", f"{input}:{input}",
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
116 "-w", str(working_dir),
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
117 # Run as current user which allows deletion of files.
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
118 # It also mitigates some security considerations
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
119 "-u", f"{os.getuid()}:{os.getgid()}",
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
120 # Run with default seccomp profile to mitigate mitigation slowdown
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
121 # http://mamememo.blogspot.com/2020/05/cpu-intensive-rubypython-code-runs.html
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
122 # This knocks down test runtime from 8 to 6 minutes.
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
123 "--security-opt", "seccomp=unconfined",
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
124 # Use a mulled container generated with `planemo mull`
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
125 "quay.io/biocontainers/mulled-v2-f7d31c9d7424063a492fc0e5ecbf89bc757c0107:2b50bdd4d8c1fefc6ec24b0753fad0dcecec843b-0"
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
126 ] + cmd
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
127 with open(temp_dir / "stderr", "wt") as stderr_file:
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
128 with open(temp_dir / "stdout", "wt") as stdout_file:
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
129 subprocess.run(docker_cmd, cwd=working_dir, stdout=stdout_file,
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
130 stderr=stderr_file, check=True)
83
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
131 yield Path(out_files_path)
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
132
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
133
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
134 def test_check_output(shm_csr_result):
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
135 assert shm_csr_result.exists()
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
136
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
137
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
138 @pytest.mark.parametrize("filename", os.listdir(VALIDATION_DATA_DIR))
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
139 def test_results_match_validation(shm_csr_result, filename):
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
140 with open(Path(shm_csr_result, filename)) as result_h:
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
141 with open(Path(VALIDATION_DATA_DIR, filename)) as validate_h:
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
142 for line in result_h:
90
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
143 # Skip two faulty lines in shm_overview.
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
144 # TODO: Fix the issue.
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
145 validation_line = validate_h.readline()
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
146 if filename == "shm_overview.txt":
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
147 if (line.startswith("RGYW (%)") or
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
148 line.startswith("WRCY (%)")):
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
149 continue
6809c63d9161 "planemo upload commit fd64827ff6e63df008f6f50ddb8576ad2b1dbb26"
rhpvorderman
parents: 83
diff changeset
150 assert line == validation_line
83
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
151
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
152
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
153 def test_nt_overview(shm_csr_result):
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
154 with open(Path(shm_csr_result, "sequence_overview", "ntoverview.txt")
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
155 ) as result_h:
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
156 with open(Path(TEST_DIR, "sequence_overview", "ntoverview.txt")
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
157 ) as validate_h:
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
158 for line in result_h:
729738462297 "planemo upload commit c0ffc68aec5836d5b20b543106493056a87edf57"
rhpvorderman
parents:
diff changeset
159 assert line == validate_h.readline()