Skip to content
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

Fix #638 [MAG_DEPTHS_PLOT fails if only a single bin is produced] #639

Merged
merged 10 commits into from
Aug 16, 2024
11 changes: 10 additions & 1 deletion subworkflows/local/depths.nf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ def getColNo(filename) {
return lines[0].split('\t').size()
}

/*
jfy133 marked this conversation as resolved.
Show resolved Hide resolved
* Get number of rows in a file
*/
def getRowNo(filename) {
lines = file(filename).readLines()
return lines.size()
}

workflow DEPTHS {
take:
bins_unbins //channel: val(meta), [ path(bins) ]
Expand Down Expand Up @@ -53,9 +61,10 @@ workflow DEPTHS {
.collectFile(name:'sample_groups.tsv'){ meta, reads -> meta.id + '\t' + meta.group + '\n' }

// Filter MAG depth files: use only those for plotting that contain depths for > 2 samples
// as well as > 2 bins
ch_mag_depths_plot = MAG_DEPTHS.out.depths
.map { meta, bin_depths_file ->
if (getColNo(bin_depths_file) > 2) [ meta, bin_depths_file ]
if (getColNo(bin_depths_file) > 2 && getRowNo(bin_depths_file) > 2) [ meta, bin_depths_file ]
d-callan marked this conversation as resolved.
Show resolved Hide resolved
}

MAG_DEPTHS_PLOT ( ch_mag_depths_plot, ch_sample_groups.collect() )
Expand Down
Loading