Skip to content

Commit 4215b10

Browse files
committed
output null for non-existing fields
1 parent e8ad060 commit 4215b10

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

tests/data/89176bbc-ffca-4d73-984a-4a92ed931a98.sequencing_experiment.4.analysis.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
"file_r2": "test_rg_3.bam",
8181
"insert_size": 298,
8282
"library_name": "Pond-147580",
83-
"is_paired_end": true,
83+
"is_paired_end": false,
8484
"platform_unit": "74_8c",
8585
"read_length_r1": 150,
8686
"read_length_r2": 150,

tools/metadata-parser/metadata-parser.nf

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,13 @@ process metadataParser {
4949

5050
script:
5151
"""
52-
set -euxo pipefail
52+
set -uxo pipefail
5353
STUDY_ID=`cat ${metadata_analysis} | jq -er '.studyId' | tr -d '\\n'`
5454
DONOR_ID=`cat ${metadata_analysis} | jq -er '.samples[0].donor.donorId' | tr -d '\\n'`
55-
EXP=`cat ${metadata_analysis} | jq -er '.experiment | if (.experimental_strategy | length)>0 then .experimental_strategy else .library_strategy end' | tr -d '\\n'`
56-
PAIRED=`cat ${metadata_analysis} | jq -er '[.read_groups[]? | .is_paired_end] | all | tostring' | tr -d '\\n'`
57-
VARIABLE=`cat ${metadata_analysis} | jq -er '[.files[] | .info? | .analysis_tools[]?] | unique | join(",")' | tr -d '\\n'`
58-
ANALYSIS_TOOLS=\${VARIABLE:-'null'}
55+
EXP=`cat ${metadata_analysis} | jq -er '.experiment | .experimental_strategy? // .library_strategy' | tr -d '\\n'`
56+
VARIABLE1=`cat ${metadata_analysis} | jq -er 'if ([.read_groups[]?] | length) >0 then [.read_groups[]? | .is_paired_end] | all | tostring else "" end' | tr -d '\\n'`
57+
PAIRED=\${VARIABLE1:-'null'}
58+
VARIABLE2=`cat ${metadata_analysis} | jq -er '[.files[] | .info? | .analysis_tools[]?] | unique | join(",")' | tr -d '\\n'`
59+
ANALYSIS_TOOLS=\${VARIABLE2:-'null'}
5960
"""
6061
}

0 commit comments

Comments
 (0)