@@ -10,70 +10,16 @@ include { SINGLE_MOUSE_TRACKING; SPLIT_BY_CORNERS } from './nextflow/workflows/s
1010include { SINGLE_MOUSE_V2_FEATURES ; SINGLE_MOUSE_V6_FEATURES } from ' ./nextflow/workflows/feature_generation'
1111include { MULTI_MOUSE_TRACKING } from ' ./nextflow/workflows/multi_mouse_pipeline'
1212include { MANUALLY_CORRECT_CORNERS ; INTEGRATE_CORNER_ANNOTATIONS } from ' ./nextflow/workflows/sleap_manual_correction'
13- include { ADD_DUMMY_VIDEO ; validateInputFile } from ' ./nextflow/modules/utils'
14-
15- /*
16- * Convert input_batch into a single list
17- */
18- all_files = []
19- invalid_files = []
20- valid_files = []
21-
22- if (params. input_batch != null ) {
23- def batch_lines = file(params. input_batch). text. readLines()
24-
25- // Validate each file in the batch
26- batch_lines. each { file_path ->
27- def (is_valid, error_message) = validateInputFile(file_path, params. workflow)
28-
29- if (is_valid) {
30- valid_files. add(file_path)
31- } else {
32- invalid_files. add([file_path, error_message])
33- }
34- }
35-
36- // Report any invalid files
37- if (invalid_files. size() > 0 ) {
38- println " The following files failed validation:"
39- invalid_files. each { file_path, error_message ->
40- println " - ${ error_message} "
41- }
42-
43- if (! params. ignore_invalid_inputs) {
44- println " Please check the input files and try again."
45- println " If you want to ignore invalid inputs, please set the parameter ignore_invalid_inputs to true."
46- System . exit(1 )
47- }
48-
49- // If all files are invalid, exit
50- if (valid_files. size() == 0 ) {
51- println " No valid files to process. Exiting."
52- System . exit(1 )
53- }
54-
55- // Otherwise, continue with valid files and warn the user
56- println " Continuing with ${ valid_files.size()} valid files out of ${ batch_lines.size()} total files."
57- }
58-
59- all_files. addAll(valid_files)
60- }
61-
62- if (all_files. size() == 0 ){
63- println " Missing any data to process, please assign either input_data or input_batch"
64- System . exit(1 )
65- }
13+ include { ADD_DUMMY_VIDEO } from ' ./nextflow/modules/utils'
6614
6715/*
6816 * Run the selected workflow
6917 */
7018workflow{
71- // Download the data locally if necessary
72- PREPARE_DATA (Channel . fromList(all_files), params. location)
73-
7419 // Generate pose files
7520 if (params. workflow == " single-mouse" ){
76- SINGLE_MOUSE_TRACKING (PREPARE_DATA . out. out_file)
21+ PREPARE_DATA (params. input_batch, params. location, false )
22+ SINGLE_MOUSE_TRACKING (PREPARE_DATA . out. file_processing_channel)
7723 v2_outputs = SINGLE_MOUSE_TRACKING . out[0 ]
7824 all_v6_outputs = SINGLE_MOUSE_TRACKING . out[1 ]
7925 // Split and publish pose_v6 files depending on if corners were successful
@@ -93,22 +39,24 @@ workflow{
9339 if (params. workflow == " single-mouse-corrected-corners" ){
9440 // Integrate annotations back into pose files
9541 // This branch requires files to be local and already url-ified
96- // Use a channel of `all_files` instead of ` PREPARE_DATA.out.out_file`
97- INTEGRATE_CORNER_ANNOTATIONS (Channel . fromList(all_files) , params. sleap_file)
42+ PREPARE_DATA (params . input_batch, params . location, true )
43+ INTEGRATE_CORNER_ANNOTATIONS (PREPATE_DATA . out . file_processing_channel , params. sleap_file)
9844 ADD_DUMMY_VIDEO (INTEGRATE_CORNER_ANNOTATIONS . out, params. clip_duration)
9945 paired_video_and_pose = ADD_DUMMY_VIDEO . out[0 ]
10046
10147 // Pose v6 features
10248 SINGLE_MOUSE_V6_FEATURES (paired_video_and_pose)
10349 }
10450 if (params. workflow == " single-mouse-v6-features" ){
51+ PREPARE_DATA (params. input_batch, params. location, false )
10552 // Generate features from pose_v6 files
10653 ADD_DUMMY_VIDEO (PREPARE_DATA . out. out_file, params. clip_duration)
10754 paired_video_and_pose = ADD_DUMMY_VIDEO . out[0 ]
10855 SINGLE_MOUSE_V6_FEATURES (paired_video_and_pose)
10956 }
11057 if (params. workflow == " multi-mouse" ){
111- MULTI_MOUSE_TRACKING (PREPARE_DATA . out. video_file, params. num_mice)
58+ PREPARE_DATA (params. input_batch, params. location, false )
59+ MULTI_MOUSE_TRACKING (PREPARE_DATA . out. file_processing_channel, params. num_mice)
11260 }
11361}
11462
0 commit comments