@@ -391,8 +391,9 @@ def create_sample_scratch(fastq_file):
391391
392392
393393class SampleRunner :
394- def __init__ (self , image_path : Path ):
394+ def __init__ (self , image_path : Path , is_docker : bool = False ):
395395 self .image_path = image_path
396+ self .is_docker = is_docker
396397 self .is_denovo = False
397398 self .bad_cycles_path = None
398399
@@ -572,21 +573,46 @@ def process_resistance(self, sample_group: SampleGroup):
572573 def build_command (self , inputs , outputs , app_name = None ):
573574 input_path = inputs [0 ].parent
574575 output_path = outputs [0 ].parent
575- command = ['singularity' ,
576- 'run' ,
577- '--contain' ,
578- '--cleanenv' ,
579- '-B' ,
580- '{}:/mnt/input,{}:/mnt/output' .format (input_path ,
581- output_path )]
582- if app_name :
583- command .append ('--app' )
584- command .append (app_name )
585- command .append (self .image_path )
576+
577+ if self .is_docker :
578+ command = ['docker' ,
579+ 'run' ,
580+ '--rm' ,
581+ '--read-only' ,
582+ '--volume' , '{}:/mnt/input' .format (input_path ),
583+ '--volume' , '{}:/mnt/output' .format (output_path ),
584+ '--volume' , '{}:/tmp' .format (output_path / 'tmp' ),
585+ '--entrypoint' , 'micall' ,
586+ '--' , str (self .image_path ),
587+ ]
588+
589+ app_arguments = {
590+ None : ['micall_kive' ],
591+ 'filter_quality' : ['filter_quality' ],
592+ 'resistance' : ['micall_kive_resistance' ],
593+ 'denovo' : ['micall_kive' , '--denovo' ],
594+ }[app_name ]
595+
596+ command .extend (app_arguments )
597+
598+ else :
599+ command = ['singularity' ,
600+ 'run' ,
601+ '--contain' ,
602+ '--cleanenv' ,
603+ '-B' ,
604+ '{}:/mnt/input,{}:/mnt/output' .format (input_path ,
605+ output_path )]
606+ if app_name :
607+ command .append ('--app' )
608+ command .append (app_name )
609+ command .append (str (self .image_path ))
610+
586611 for arguments , guest_path in zip ((inputs , outputs ),
587612 ('/mnt/input' , '/mnt/output' )):
588613 for argument in arguments :
589614 command .append (os .path .join (guest_path , argument .name ))
615+
590616 return command
591617
592618
@@ -622,6 +648,8 @@ def main():
622648 help = 'Folder to copy microtest samples into.' )
623649 parser .add_argument ('--sample' ,
624650 help = 'Prefix of sample name to run.' )
651+ parser .add_argument ('--docker' , action = 'store_true' ,
652+ help = 'If to use docker instead of Singularity.' )
625653 # noinspection PyTypeChecker
626654 parser .add_argument ('image' ,
627655 type = Path ,
@@ -642,7 +670,7 @@ def main():
642670 for source_file in source_files :
643671 target_file : Path = sandbox_path / source_file .name
644672 shutil .copy (str (source_file ), str (target_file ))
645- runner = SampleRunner (args .image )
673+ runner = SampleRunner (args .image , is_docker = args . docker )
646674 with ProcessPoolExecutor () as pool :
647675 search_pattern = '*_R1_*.fastq'
648676 if args .sample :
0 commit comments