Skip to content

Commit a2cc0ea

Browse files
committed
find a way to use relative path in input csv file. Change test file name to be different that the AliNe one and avoid confusion whoch file is really used
1 parent 777031b commit a2cc0ea

12 files changed

+70
-27
lines changed

data/chr21/chr21_small_mix.csv

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
sample,input_1,input_2,strandedness,read_type
2-
test1,data/chr21/chr21_small_R1.fastq.gz,data/chr21/chr21_small_R2.fastq.gz,auto,short_paired
3-
test2,data/chr21/chr21_small_single.fastq.gz,,ISR,short_single
4-
test3,data/chr21/chr21sample2_small.bam,,ISR,short_paired
2+
test1,data/chr21/rain_chr21_small_R1.fastq.gz,data/chr21/rain_chr21_small_R2.fastq.gz,auto,short_paired
3+
test2,data/chr21/rain_chr21_small_single.fastq.gz,,ISR,short_single
4+
test3,data/chr21/rain_chr21sample2_small.bam,,ISR,short_paired

data/chr21/chr21_small_paired.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
sample,input_1,input_2,strandedness,read_type
2-
test1,data/chr21/chr21_small_R1.fastq.gz,data/chr21/chr21_small_R2.fastq.gz,auto,short_single
2+
test1,data/chr21/rain_chr21_small_R1.fastq.gz,data/chr21/rain_chr21_small_R2.fastq.gz,auto,short_single

data/chr21/chr21_small_single.csv

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
sample,input_1,input_2,strandedness,read_type
2-
test1,data/chr21/chr21_small_R1.fastq.gz,,auto,short_single
3-
test2,data/chr21/chr21_small_R2.fastq.gz,,ISR,short_single
2+
test1,data/chr21/rain_chr21_small_R1.fastq.gz,,auto,short_single
3+
test2,data/chr21/rain_chr21_small_R2.fastq.gz,,ISR,short_single

data/chr21/chr21_small_single.fastq.gz

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rain_chr21_small_R1.fastq.gz

lib/RainUtils.groovy

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,17 @@ class RainUtils {
8080
.replaceAll(/\.bam$/, '') // Remove .bam
8181
}
8282
}
83+
// Function to get absolute path from relative or absolute input
84+
public static String getAbsolutePath( path ) {
85+
if (!path) return null
86+
def trimmedPath = path.toString().trim()
87+
def f = new File(trimmedPath)
88+
89+
// If path is already absolute, return it
90+
if (f.isAbsolute()) {
91+
return f.toString()
92+
}
93+
f = f.getAbsoluteFile()
94+
return f.toString()
95+
}
8396
}

modules/bash.nf

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,9 @@ process create_aline_csv_he {
124124
* Collect CSV files for AliNe input from converted FASTQ reads
125125
* Generates a single CSV with columns: sample,fastq_1,fastq_2,strandedness,read_type
126126
*/
127-
process collect_aline_csv_he {
127+
process collect_aline_csv {
128128
label 'bash'
129-
publishDir("${output_dir}", mode:"copy", pattern: "*.csv")
129+
publishDir("${params.outdir}/${output_dir}", mode:"copy", pattern: "*.csv")
130130

131131
input:
132132
val all_csv // List of tuples (meta, fastq_files)
@@ -141,9 +141,36 @@ process collect_aline_csv_he {
141141
list_csv = all_csv
142142
list_csv_bash = list_csv.join(" "); // remove bracket and replace comma by space to be processed by bash
143143
"""
144-
echo "sample,fastq_1,fastq_2,strandedness,read_type" > hyper_editing_samples.csv
144+
echo "sample,fastq_1,fastq_2,strandedness,read_type" > aline_input.csv
145145
for entry in ${list_csv_bash}; do
146-
cat \$entry >> hyper_editing_samples.csv
146+
cat \$entry >> aline_input.csv
147147
done
148148
"""
149+
}
150+
151+
/*
152+
* Recreate CSV file with absolute paths from metadata
153+
* Takes input samples with metadata and generates a new CSV with absolute file paths
154+
* This allows conversion of relative paths to absolute paths for CI/CD compatibility
155+
*/
156+
process recreate_csv_with_abs_paths {
157+
label 'bash'
158+
tag "${meta.uid}"
159+
160+
input:
161+
tuple val(meta), path(file)
162+
163+
output:
164+
path "*.csv", emit: csv
165+
166+
script:
167+
168+
def sample_id = meta.sample_id
169+
def strandedness = meta.strandedness
170+
def read_type = meta.read_type
171+
def file1 = meta.file_abspath[0]
172+
def file2 = meta.file_abspath[1] ? meta.file_abspath[1] : ""
173+
"""
174+
echo "${sample_id},${file1},${file2},${strandedness},${read_type}" > ${meta.uid}.csv
175+
"""
149176
}

0 commit comments

Comments
 (0)