1414trigger quick-run mode, setting most of the parameters to defaults.
1515"""
1616import os
17+ from copy import deepcopy
1718from typing import Any
1819
1920import numpy as np
@@ -50,7 +51,7 @@ class representing the options
5051
5152 def __init__ (self ,
5253 reference : Path | None = None ,
53- output_dir : Path | None = Path ( os . getcwd () ),
54+ output_dir : Path | None = Path . cwd ( ),
5455 fq1 : Path | None = None ,
5556 fq2 : Path | None = None ,
5657 vcf : Path | None = None ,
@@ -139,7 +140,7 @@ def __init__(self,
139140 super ().__init__ (** kwargs )
140141 self .reference : Path = reference
141142 self .output_dir : Path = output_dir
142- self .output = self . output_dir / output_prefix
143+ self .output_prefix : str = output_prefix
143144 self .overwrite_output = overwrite_output
144145 self .rng_seed = rng_seed
145146 self .read_len : int = read_len
@@ -206,9 +207,6 @@ def from_cli(output_dir: Path,
206207 should be the highest acceptable value (inclusive).
207208 (type, default, criteria1 (low/'exists'), criteria2 (high/None)
208209 """
209- # TODO maybe redo as a dataclass?
210- output = output_dir / output_prefix
211-
212210 # These are for checking
213211 defs = {
214212 'reference' : (Path , None , 'exists' , None ),
@@ -331,6 +329,29 @@ def read_yaml(self, config_yaml: Path, args: dict):
331329 value = Path (value )
332330 args [key ] = value
333331
332+ def copy_with_changes (self ,
333+ reference : Path | None = None ,
334+ current_output_dir : Path | None = None ,
335+ fq1 : Path | None = None ,
336+ fq2 : Path | None = None ,
337+ vcf : Path | None = None ,
338+ bam : Path | None = None ,
339+ ):
340+ return_options = deepcopy (self )
341+ if reference is not None :
342+ return_options .reference = reference
343+ if current_output_dir is not None :
344+ return_options .current_output_dir = current_output_dir
345+ if fq1 is not None :
346+ return_options .fq1 = fq1
347+ if fq2 is not None :
348+ return_options .fq2 = fq2
349+ if vcf is not None :
350+ return_options .vcf = vcf
351+ if bam is not None :
352+ return_options .bam = bam
353+ return return_options
354+
334355 def set_random_seed (self ) -> Generator :
335356 """
336357 Sets up random number generator, which will be used for the run.
@@ -376,26 +397,26 @@ def log_configuration(self):
376397 files_to_produce = f'Producing the following files:\n '
377398 if self .produce_fastq :
378399 if self .paired_ended :
379- fq1 = f'{ str (self .output ) } _r1.fastq.gz'
380- fq2 = f'{ str (self .output ) } _r2.fastq.gz'
400+ fq1 = f'{ str (self .output_dir ) } / { self . output_prefix } _r1.fastq.gz'
401+ fq2 = f'{ str (self .output_dir ) } / { self . output_prefix } _r2.fastq.gz'
381402 validate_output_path (fq1 , True , self .overwrite_output )
382403 validate_output_path (fq2 , True , self .overwrite_output )
383404 files_to_produce += f'\t - { fq1 } \n '
384405 files_to_produce += f'\t - { fq2 } \n '
385406 self .fq1 = Path (fq1 )
386407 self .fq2 = Path (fq2 )
387408 else :
388- fq1 = f'{ str (self .output ) } .fastq.gz'
409+ fq1 = f'{ str (self .output_dir ) } / { self . output_prefix } .fastq.gz'
389410 validate_output_path (fq1 , True , self .overwrite_output )
390411 files_to_produce += f'\t - { fq1 } \n '
391412 self .fq1 = Path (fq1 )
392413 if self .produce_bam :
393- bam = f'{ self .output } _golden.bam'
414+ bam = f'{ str ( self .output_dir ) } / { self . output_prefix } _golden.bam'
394415 validate_output_path (bam , True , self .overwrite_output )
395416 files_to_produce += f'\t - { bam } \n '
396417 self .bam = Path (bam )
397418 if self .produce_vcf :
398- vcf = f'{ self .output } _golden.vcf.gz'
419+ vcf = f'{ str ( self .output_dir ) } / { self . output_prefix } _golden.vcf.gz'
399420 validate_output_path (vcf , True , self .overwrite_output )
400421 files_to_produce += f'\t - { vcf } \n '
401422 self .vcf = Path (vcf )
@@ -420,8 +441,7 @@ def log_configuration(self):
420441 if splits_dir .is_dir ():
421442 _LOG .info (f'Reusing existing splits { splits_dir } .' )
422443 else :
423- _LOG .error (f'Reused splits set to True, but splits dir not found: { splits_dir } .' )
424- sys .exit (1 )
444+ _LOG .warning (f'Reused splits set to True, but splits dir not found: { splits_dir } . Creating new splits' )
425445
426446 validate_output_path (splits_dir , False )
427447 self .splits_dir = splits_dir
0 commit comments