Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading