Skip to content

Commit

Permalink
Fix: Incorrect merging of samples - Issue #54
Browse files Browse the repository at this point in the history
  • Loading branch information
praveenraj2018 committed Jun 14, 2022
1 parent ed9e2a3 commit 249728c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
17 changes: 7 additions & 10 deletions bin/check_samplesheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,19 +114,16 @@ def validate_unique_samples(self):
"""
Assert that the combination of sample name and FASTQ filename is unique.
In addition to the validation, also rename the sample if more than one sample,
FASTQ file combination exists.
In addition to the validation, also rename all samples to have a suffix of _T{n}, where n is the
number of times the same sample exist, but with different FASTQ file(s).
"""
assert len(self._seen) == len(self.modified), "The pair of sample name and FASTQ must be unique."
if len({pair[0] for pair in self._seen}) < len(self._seen):
counts = Counter(pair[0] for pair in self._seen)
seen = Counter()
for row in self.modified:
sample = row[self._sample_col]
seen[sample] += 1
if counts[sample] > 1:
row[self._sample_col] = f"{sample}_T{seen[sample]}"
seen = Counter()
for row in self.modified:
sample = row[self._sample_col]
seen[sample] += 1
row[self._sample_col] = f"{sample}_T{seen[sample]}"


def read_head(handle, num_lines=10):
Expand Down
6 changes: 4 additions & 2 deletions workflows/rnavar.nf
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,10 @@ workflow RNAVAR {
.reads
.map {
meta, fastq ->
meta.id = meta.id.split('_')[0..meta.id.split('_').size()-2].join('_')
[ meta, fastq ] }
def meta_clone = meta.clone()
meta_clone.id = meta_clone.id.split('_')[0..-2].join('_')
[ meta_clone, fastq ]
}
.groupTuple(by: [0])
.branch {
meta, fastq ->
Expand Down

0 comments on commit 249728c

Please sign in to comment.