Skip to content

Commit

Permalink
Merge pull request nf-core#643 from genomic-medicine-sweden/upd_fix
Browse files Browse the repository at this point in the history
Upd fix
  • Loading branch information
jemten authored Nov 1, 2024
2 parents 31249da + 86f0373 commit 2eae461
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- bcftools annotate declaration in annotate CADD subworkflow [#624](https://github.com/nf-core/raredisease/pull/624)
- Rhocallviz subworkflow will only be invocated once per sample [#621](https://github.com/nf-core/raredisease/pull/621)
- Allow for VEP version 112 to be used and set it to default [#617](https://github.com/nf-core/raredisease/pull/617)
- Updated createCaseChannel function to include a check for maternal and paternal ids being set to a numeric 0 [#643](https://github.com/nf-core/raredisease/pull/643)

### Parameters

Expand Down
27 changes: 16 additions & 11 deletions lib/CustomFunctions.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,39 @@ import nextflow.Nextflow

class CustomFunctions {

// Helper function to check if a value is neither 0, "0", nor ""
private static boolean isNonZeroNonEmpty(value) {
return (value instanceof String && value != "" && value != "0") ||
(value instanceof Number && value != 0)
}

// Function to get a list of metadata (e.g. case id) for the case [ meta ]
public static LinkedHashMap createCaseChannel(List rows) {
def case_info = [:]
def probands = []
def upd_children = []
def probands = [] as Set
def upd_children = [] as Set
def father = ""
def mother = ""

for (item in rows) {
if (item.phenotype == 2) {
probands.add(item.sample)
rows.each { item ->
if (item?.phenotype == 2) {
probands << item.sample
}
if ( (item.paternal!="0") && (item.paternal!="") && (item.maternal!="0") && (item.maternal!="") ) {
upd_children.add(item.sample)
if (isNonZeroNonEmpty(item?.paternal) && isNonZeroNonEmpty(item?.maternal)) {
upd_children << item.sample
}
if ( (item.paternal!="0") && (item.paternal!="") ) {
if (isNonZeroNonEmpty(item?.paternal)) {
father = item.paternal
}
if ( (item.maternal!="0") && (item.maternal!="") ) {
if (isNonZeroNonEmpty(item?.maternal)) {
mother = item.maternal
}
}

case_info.father = father
case_info.mother = mother
case_info.probands = probands.unique()
case_info.upd_children = upd_children.unique()
case_info.probands = probands.toList()
case_info.upd_children = upd_children.toList()
case_info.id = rows[0].case_id

return case_info
Expand Down

0 comments on commit 2eae461

Please sign in to comment.