@@ -75,11 +75,11 @@ def create(self) -> bool:
7575 e.g bam_sort or bam_sort_samtools, respectively.
7676
7777 If <directory> is a pipeline, this function creates a file called:
78- '<directory>/modules/local/tool.nf'
78+ '<directory>/modules/local/tool/main .nf'
7979 OR
80- '<directory>/modules/local/tool_subtool .nf'
80+ '<directory>/modules/local/tool/subtool/main .nf'
8181 OR for subworkflows
82- '<directory>/subworkflows/local/subworkflow_name.nf'
82+ '<directory>/subworkflows/local/subworkflow_name/main .nf'
8383
8484 If <directory> is a clone of nf-core/modules, it creates or modifies the following files:
8585
@@ -355,70 +355,46 @@ def _get_component_dirs(self) -> Dict[str, Path]:
355355 """
356356 file_paths = {}
357357 if self .repo_type == "pipeline" :
358- local_component_dir = Path (self .directory , self .component_type , "local" )
359- # Check whether component file already exists
360- component_file = local_component_dir / f"{ self .component_name } .nf"
361- if component_file .exists () and not self .force_overwrite :
362- raise UserWarning (
363- f"{ self .component_type [:- 1 ].title ()} file exists already: '{ component_file } '. Use '--force' to overwrite"
364- )
365-
366- if self .component_type == "modules" :
367- # If a subtool, check if there is a module called the base tool name already
368- if self .subtool and (local_component_dir / f"{ self .component } .nf" ).exists ():
369- raise UserWarning (
370- f"Module '{ self .component } ' exists already, cannot make subtool '{ self .component_name } '"
371- )
372-
373- # If no subtool, check that there isn't already a tool/subtool
374- tool_glob = glob .glob (f"{ local_component_dir } /{ self .component } _*.nf" )
375- if not self .subtool and tool_glob :
376- raise UserWarning (
377- f"Module subtool '{ tool_glob [0 ]} ' exists already, cannot make tool '{ self .component_name } '"
378- )
379-
380- # Set file paths
381- file_paths ["main.nf" ] = component_file
358+ component_dir = Path (self .directory , self .component_type , "local" , self .component_dir )
382359
383360 elif self .repo_type == "modules" :
384361 component_dir = Path (self .directory , self .component_type , self .org , self .component_dir )
385- # Check if module/subworkflow directories exist already
386- if component_dir .exists () and not self .force_overwrite and not self .migrate_pytest :
387- raise UserWarning (
388- f"{ self .component_type [:- 1 ]} directory exists: '{ component_dir } '. Use '--force' to overwrite"
389- )
362+ else :
363+ raise ValueError ("`repo_type` not set correctly" )
390364
391- if self .component_type == "modules" :
392- # If a subtool, check if there is a module called the base tool name already
393- parent_tool_main_nf = Path (
394- self .directory ,
395- self .component_type ,
396- self .org ,
397- self .component ,
398- "main.nf" ,
365+ # Check if module/subworkflow directories exist already
366+ if component_dir .exists () and not self .force_overwrite and not self .migrate_pytest :
367+ raise UserWarning (
368+ f"{ self .component_type [:- 1 ]} directory exists: '{ component_dir } '. Use '--force' to overwrite"
369+ )
370+
371+ if self .component_type == "modules" :
372+ # If a subtool, check if there is a module called the base tool name already
373+ parent_tool_main_nf = Path (
374+ self .directory ,
375+ self .component_type ,
376+ self .org ,
377+ self .component ,
378+ "main.nf" ,
379+ )
380+ if self .subtool and parent_tool_main_nf .exists () and not self .migrate_pytest :
381+ raise UserWarning (
382+ f"Module '{ parent_tool_main_nf } ' exists already, cannot make subtool '{ self .component_name } '"
399383 )
400- if self .subtool and parent_tool_main_nf .exists () and not self .migrate_pytest :
401- raise UserWarning (
402- f"Module '{ parent_tool_main_nf } ' exists already, cannot make subtool '{ self .component_name } '"
403- )
404384
405- # If no subtool, check that there isn't already a tool/subtool
406- tool_glob = glob .glob (
407- f"{ Path (self .directory , self .component_type , self .org , self .component )} /*/main.nf"
385+ # If no subtool, check that there isn't already a tool/subtool
386+ tool_glob = glob .glob (f"{ Path (self .directory , self .component_type , self .org , self .component )} /*/main.nf" )
387+ if not self .subtool and tool_glob and not self .migrate_pytest :
388+ raise UserWarning (
389+ f"Module subtool '{ tool_glob [0 ]} ' exists already, cannot make tool '{ self .component_name } '"
408390 )
409- if not self .subtool and tool_glob and not self .migrate_pytest :
410- raise UserWarning (
411- f"Module subtool '{ tool_glob [0 ]} ' exists already, cannot make tool '{ self .component_name } '"
412- )
413- # Set file paths
414- # For modules - can be tool/ or tool/subtool/ so can't do in template directory structure
415- file_paths ["main.nf" ] = component_dir / "main.nf"
416- file_paths ["meta.yml" ] = component_dir / "meta.yml"
417- if self .component_type == "modules" :
418- file_paths ["environment.yml" ] = component_dir / "environment.yml"
419- file_paths ["tests/main.nf.test.j2" ] = component_dir / "tests" / "main.nf.test"
420- else :
421- raise ValueError ("`repo_type` not set correctly" )
391+ # Set file paths
392+ # For modules - can be tool/ or tool/subtool/ so can't do in template directory structure
393+ file_paths ["main.nf" ] = component_dir / "main.nf"
394+ file_paths ["meta.yml" ] = component_dir / "meta.yml"
395+ if self .component_type == "modules" :
396+ file_paths ["environment.yml" ] = component_dir / "environment.yml"
397+ file_paths ["tests/main.nf.test.j2" ] = component_dir / "tests" / "main.nf.test"
422398
423399 return file_paths
424400
0 commit comments