-
Notifications
You must be signed in to change notification settings - Fork 2
Minor fixes #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Minor fixes #16
Changes from all commits
c5c002b
c30be3e
e542859
2944534
4250e09
44e82f3
42ff4d0
fd6784f
e002156
824a555
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am adding CPU support back, so let's remove this as well, thanks! |
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -3,57 +3,75 @@ | |||
| // ------------------------------------------------------- | ||||
| def validateSamplesheet(samplesheet_ch) { | ||||
| samplesheet_ch.map { path -> | ||||
| def header = path.text.readLines()[0] | ||||
| def cols = header.split(/,|\t/) // handle CSV or TSV | ||||
| def sep = path.name.endsWith('.tsv') ? '\t' : ',' | ||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the variable sep was computed before the function call, and can be passed as an argument to this function |
||||
|
|
||||
| def lines = path.text.readLines() | ||||
| if (!lines) error "Samplesheet is empty: ${path}" | ||||
|
|
||||
| def header = lines[0].split(sep).collect { colname -> colname.trim() } | ||||
| def required = ['sample_name','pair_identifier','tumor_bam','normal_bam'] | ||||
| def missing = required.findAll { it !in cols } | ||||
| def missing = required.findAll { colname -> colname !in header } | ||||
| if (missing) { | ||||
| error "Samplesheet is missing required columns: ${missing.join(', ')}" | ||||
| } | ||||
|
|
||||
| // Optional: check BAM files exist | ||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The existence of BAM paths is checked elsewhere already: VariantMedium/bin/prepare_input_files.py Line 19 in 42ff4d0
|
||||
| path.text.readLines().tail().each { line -> | ||||
| def vals = line.split(/,|\t/) | ||||
| lines.tail().eachWithIndex { line, idx -> | ||||
| def vals = line.split(sep).collect { val -> val.trim() } | ||||
| if (vals.size() < 4) error "Line ${idx + 2} is malformed: ${line}" | ||||
|
|
||||
| def tumor = file(vals[2]) | ||||
| def normal = file(vals[3]) | ||||
|
|
||||
| if (!tumor.exists()) error "Tumor BAM missing: $tumor" | ||||
| if (!normal.exists()) error "Normal BAM missing: $normal" | ||||
| if (!tumor.exists()) error "Tumor BAM missing: ${tumor}" | ||||
| if (!normal.exists()) error "Normal BAM missing: ${normal}" | ||||
| } | ||||
|
|
||||
| return [path, sep] // pass separator for downstream use | ||||
| } | ||||
| } | ||||
|
|
||||
|
|
||||
| workflow PARSE_SAMPLESHEET { | ||||
|
|
||||
| take: | ||||
| ch_samplesheet // channel ["path-to-samplesheet"] | ||||
| ch_samplesheet // channel ["path-to-samplesheet"] | ||||
|
|
||||
| main: | ||||
|
|
||||
| validateSamplesheet(ch_samplesheet) | ||||
| log.info "[INFO] Samplesheet validated" | ||||
|
|
||||
| def sep = ch_samplesheet_file.name.endsWith('.tsv') ? '\t' : ',' | ||||
| def sep = params.samplesheet.endsWith('.tsv') ? '\t' : ',' | ||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here it seems the file extension is read from params.samplesheet, but the file that's being read is ch_samplesheet. This looks error-prone, please use the same file path for both. Also overall, there are variable names like samplesheet, ch_samplesheet, samplesheet_ch. are these all referring to the same file? if so, we can use the same name, if not, let's use more descriptive names |
||||
| ch_samplesheet | ||||
| .splitCsv(header: true, sep: sep) | ||||
| .map { row -> | ||||
|
|
||||
| def tumorPath = row.tumor_bam.trim() | ||||
| def normalPath = row.normal_bam.trim() | ||||
| // Validate samplesheet | ||||
| def validated_ch = validateSamplesheet(ch_samplesheet) | ||||
| log.info "[INFO] Samplesheet validated" | ||||
|
|
||||
| // get file object | ||||
| def tumorFile = file(tumorPath) | ||||
| def normalFile = file(normalPath) | ||||
| // Split samplesheet into sample info | ||||
| validated_ch | ||||
| .map { path, sep -> | ||||
| path.text.readLines().tail().collect { line -> | ||||
| def vals = line.split(sep).collect { val -> val.trim() } | ||||
|
|
||||
| tuple(row.sample_name, row.pair_identifier, tumorFile, normalFile) | ||||
| tuple( | ||||
| vals[0], // sample_name | ||||
| vals[1], // pair_identifier | ||||
| file(vals[2]), // tumor_bam | ||||
| file(vals[3]) // normal_bam | ||||
| ) | ||||
| } | ||||
| } | ||||
| .flatten() | ||||
| .set { sample_info_ch } | ||||
|
|
||||
|
|
||||
| emit: | ||||
|
|
||||
| emit: | ||||
| ch_samples = sample_info_ch | ||||
|
|
||||
| } | ||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will be updating the torch in this environment, so please remove this part from the PR