Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into Haploflow-test1
Browse files Browse the repository at this point in the history
  • Loading branch information
Donaim committed Jan 2, 2025
2 parents 0777234 + 2e64c4d commit 646ebf6
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 15 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ jobs:
run: docker run micall --help
- name: Check docker image entrypoint
run: docker run micall --help | grep -i -e 'docker'
- name: Check docker image microtest
run: python micall/main.py release_test_microtest micall --docker

singularity-test:
runs-on: ubuntu-20.04
Expand Down
54 changes: 41 additions & 13 deletions micall/utils/release_test_microtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,9 @@ def create_sample_scratch(fastq_file):


class SampleRunner:
def __init__(self, image_path: Path):
def __init__(self, image_path: Path, is_docker: bool = False):
self.image_path = image_path
self.is_docker = is_docker
self.is_denovo = False
self.bad_cycles_path = None

Expand Down Expand Up @@ -572,21 +573,46 @@ def process_resistance(self, sample_group: SampleGroup):
def build_command(self, inputs, outputs, app_name=None):
input_path = inputs[0].parent
output_path = outputs[0].parent
command = ['singularity',
'run',
'--contain',
'--cleanenv',
'-B',
'{}:/mnt/input,{}:/mnt/output'.format(input_path,
output_path)]
if app_name:
command.append('--app')
command.append(app_name)
command.append(self.image_path)

if self.is_docker:
command = ['docker',
'run',
'--rm',
'--read-only',
'--volume', '{}:/mnt/input'.format(input_path),
'--volume', '{}:/mnt/output'.format(output_path),
'--volume', '{}:/tmp'.format(output_path / 'tmp'),
'--entrypoint', 'micall',
'--', str(self.image_path),
]

app_arguments = {
None: ['micall_kive'],
'filter_quality': ['filter_quality'],
'resistance': ['micall_kive_resistance'],
'denovo': ['micall_kive', '--denovo'],
}[app_name]

command.extend(app_arguments)

else:
command = ['singularity',
'run',
'--contain',
'--cleanenv',
'-B',
'{}:/mnt/input,{}:/mnt/output'.format(input_path,
output_path)]
if app_name:
command.append('--app')
command.append(app_name)
command.append(str(self.image_path))

for arguments, guest_path in zip((inputs, outputs),
('/mnt/input', '/mnt/output')):
for argument in arguments:
command.append(os.path.join(guest_path, argument.name))

return command


Expand Down Expand Up @@ -622,6 +648,8 @@ def main():
help='Folder to copy microtest samples into.')
parser.add_argument('--sample',
help='Prefix of sample name to run.')
parser.add_argument('--docker', action='store_true',
help='If to use docker instead of Singularity.')
# noinspection PyTypeChecker
parser.add_argument('image',
type=Path,
Expand All @@ -642,7 +670,7 @@ def main():
for source_file in source_files:
target_file: Path = sandbox_path / source_file.name
shutil.copy(str(source_file), str(target_file))
runner = SampleRunner(args.image)
runner = SampleRunner(args.image, is_docker=args.docker)
with ProcessPoolExecutor() as pool:
search_pattern = '*_R1_*.fastq'
if args.sample:
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ dependencies = [
test = [
# Dependencies required for running the test suite
"pytest==8.3.4",
"coverage==7.6.9",
"coverage==7.6.10",
"pandas==2.2.3",
"seaborn==0.13.2",
"ete3",
Expand All @@ -59,7 +59,7 @@ test = [
dev = [
# Dependencies required for development (linting, type checking, etc.)
"ruff==0.8.4",
"mypy==1.14.0",
"mypy==1.14.1",
"mypy-extensions==1.0.0",
"gprof2dot==2024.6.6",
"codecov==2.1.13", # For reporting the code coverage.
Expand Down

0 comments on commit 646ebf6

Please sign in to comment.