Skip to content

Commit

Permalink
Multiple separator ";" and check there is only one input file
Browse files Browse the repository at this point in the history
  • Loading branch information
emmarousseau committed Oct 18, 2024
1 parent 52152c0 commit 25ad022
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 62 deletions.
23 changes: 11 additions & 12 deletions src/nanoplot/config.vsh.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@ argument_groups:
arguments:
- name: --fastq
type: file
description: Input fastq file(s).
description: Input fastq file(s), separated by ";".
example: read.fq
direction: input
multiple: true
- name: --fasta
type: file
description: Input fasta file(s).
description: Input fasta file(s), separated by ";".
example: read.fa
direction: input
multiple: true
- name: --fastq_rich
type: file
description: |
Input fastq file(s) generated by albacore or
MinKNOW with additional information concerning channel and time.
MinKNOW with additional information concerning channel and time, separated by ";".
example: read.fq
direction: input
multiple: true
Expand All @@ -38,45 +38,45 @@ argument_groups:
description: |
Input fastq file(s) generated by albacore or MinKNOW with
additional information concerning channel and time. Minimal data is extracted
swiftly without elaborate checks.
swiftly without elaborate checks. Separated by ";".
example: read.fq
direction: input
multiple: true
- name: --summary
type: file
description: |
Input summary file(s) generated by albacore or guppy.
Input summary file(s) generated by albacore or guppy, separated by ";".
example: read.txt
direction: input
multiple: true
- name: --bam
type: file
description: Input sorted bam file(s).
description: Input sorted bam file(s), separated by ";".
example: read.bam
direction: input
multiple: true
- name: --ubam
type: file
description: Input unmapped bam file(s).
description: Input unmapped bam file(s), separated by ";".
example: read.ubam
direction: input
multiple: true
- name: --cram
type: file
description: Input sorted cram file(s).
description: Input sorted cram file(s), separated by ";".
example: read.cram
direction: input
multiple: true
- name: --pickle
type: file
description: Input pickle file stored earlier.
description: Input pickle file stored earlier, separated by ";".
example: read.pkl
direction: input
multiple: true
- name: --feather
alternatives: [--arrow]
type: file
description: Input feather file(s).
description: Input feather file(s), separated by ";".
example: read.arrow
direction: input
multiple: true
Expand Down Expand Up @@ -219,11 +219,10 @@ test_resources:
path: test_data
engines:
- type: docker
image: quay.io/biocontainers/nanoplot:1.42.0--pyhdfd78af_0
image: quay.io/biocontainers/nanoplot:1.43.0--pyhdfd78af_1
setup:
- type: docker
run: |
touch ./var/software_versions.txt && \
version=$(NanoPlot --version) && \
echo "$version" > /var/software_versions.txt
runners:
Expand Down
123 changes: 82 additions & 41 deletions src/nanoplot/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,50 +6,89 @@ set -eo pipefail
## VIASH END

# Unset flags
[[ "$par_verbose" == "false" ]] && unset par_verbose
[[ "$par_store" == "false" ]] && unset par_store
[[ "$par_raw" == "false" ]] && unset par_raw
[[ "$par_huge" == "false" ]] && unset par_huge
[[ "$par_no_static" == "true" ]] && unset par_no_static
[[ "$par_tsv_stats" == "false" ]] && unset par_tsv_stats
[[ "$par_only_report" == "false" ]] && unset par_only_report
[[ "$par_info_in_report" == "false" ]] && unset par_info_in_report
[[ "$par_drop_outliers" == "true" ]] && unset par_drop_outliers
[[ "$par_loglength" == "false" ]] && unset par_loglength
[[ "$par_percentqual" == "false" ]] && unset par_percentqual
[[ "$par_alength" == "false" ]] && unset par_alength
[[ "$par_barcoded" == "false" ]] && unset par_barcoded
[[ "$par_no_supplementary" == "true" ]] && unset par_no_supplementary
[[ "$par_listcolors" == "false" ]] && unset par_listcolors
[[ "$par_listcolormaps" == "false" ]] && unset par_listcolormaps
[[ "$par_no_N50" == "true" ]] && unset par_no_N50
[[ "$par_N50" == "false" ]] && unset par_N50
[[ "$par_hide_stats" == "true" ]] && unset par_hide_stats
unset_if_false=(
par_verbose
par_store
par_raw
par_huge
par_no_static
par_tsv_stats
par_only_report
par_info_in_report
par_drop_outliers
par_loglength
par_percentqual
par_alength
par_barcoded
par_no_supplementary
par_listcolors
par_listcolormaps
par_no_N50
par_N50
par_hide_stats
)

for var in "${unset_if_false[@]}"; do
test_val="${!var}"
[[ "$test_val" == "false" ]] && unset $var
done

par_fastq="${par_fastq//;/ }"
par_fasta="${par_fasta//;/ }"
par_fastq_rich="${par_fastq_rich//;/ }"
par_fastq_minimal="${par_fastq_minimal//;/ }"
par_summary="${par_summary//;/ }"
par_bam="${par_bam//;/ }"
par_ubam="${par_ubam//;/ }"
par_cram="${par_cram//;/ }"
par_pickle="${par_pickle//;/ }"
par_feather="${par_feather//;/ }"


inputs=(
"$par_fastq"
"$par_fasta"
"$par_fastq_rich"
"$par_fastq_minimal"
"$par_summary"
"$par_bam"
"$par_ubam"
"$par_cram"
"$par_pickle"
"$par_feather"
)

one_input=false
for var in "${inputs[@]}"; do
if [ -n "$var" ]; then # if the parameter is not empty
if [ "$one_input" = "false" ]; then
one_input=true
else # Multiple input file types specified
echo "Error: Multiple input file types specified."
exit 1
fi
fi
done

if [ ! "$one_input" ]; then
echo "Error: No input file type specified."
exit 1
fi


# Multiple inputs - replace ';' with ' ' (space)
par_fastq=$(echo $par_fastq | tr ';' ' ')
par_fasta=$(echo $par_fasta | tr ';' ' ')
par_fastq_rich=$(echo $par_fastq_rich | tr ';' ' ')
par_fastq_minimal=$(echo $par_fastq_minimal | tr ';' ' ')
par_summary=$(echo $par_summary | tr ';' ' ')
par_bam=$(echo $par_bam | tr ';' ' ')
par_ubam=$(echo $par_ubam | tr ';' ' ')
par_cram=$(echo $par_cram | tr ';' ' ')
par_pickle=$(echo $par_pickle | tr ';' ' ')
par_feather=$(echo $par_feather | tr ';' ' ')

# Run NanoPlot
NanoPlot \
${par_fastq:+--fastq "$par_fastq"} \
${par_fasta:+--fasta "$par_fasta"} \
${par_fastq_rich:+--fastq_rich "$par_fastq_rich"} \
${par_fastq_minimal:+--fastq_minimal "$par_fastq_minimal"} \
${par_summary:+--summary "$par_summary"} \
${par_bam:+--bam "$par_bam"} \
${par_ubam:+--ubam "$par_ubam"} \
${par_cram:+--cram "$par_cram"} \
${par_pickle:+--pickle "$par_pickle"} \
${par_feather:+--feather "$par_feather"} \
${par_fastq:+--fastq $par_fastq} \
${par_fasta:+--fasta $par_fasta} \
${par_fastq_rich:+--fastq_rich $par_fastq_rich} \
${par_fastq_minimal:+--fastq_minimal $par_fastq_minimal} \
${par_summary:+--summary $par_summary} \
${par_bam:+--bam $par_bam} \
${par_ubam:+--ubam $par_ubam} \
${par_cram:+--cram $par_cram} \
${par_pickle:+--pickle $par_pickle} \
${par_feather:+--feather $par_feather} \
${par_verbose:+--verbose} \
${par_store:+--store} \
${par_raw:+--raw} \
Expand Down Expand Up @@ -85,4 +124,6 @@ NanoPlot \
${par_dpi:+--dpi "$par_dpi"} \
${par_hide_stats:+--hide_stats} \
${meta_cpus:+--threads "$meta_cpus"} \
--outdir "$par_outdir"
--outdir "$par_outdir"

exit 0
8 changes: 3 additions & 5 deletions src/nanoplot/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
set -eo pipefail

## VIASH START
meta_executable="$PWD/target/executable/nanoplot/nanoplot"
meta_resources_dir="$PWD/src/nanoplot"
## VIASH END

# Files at runtime (.gz, .pickle and .feather)
wget "https://github.com/wdecoster/nanotest/archive/refs/heads/master.zip"
wget https://github.com/wdecoster/nanotest/archive/refs/heads/master.zip
unzip master.zip

###########################################################################
Expand Down Expand Up @@ -62,7 +60,7 @@ pushd test2 > /dev/null

echo "> Run Test 2: multiple inputs (Fastq)"
"$meta_executable" \
--fastq "$meta_resources_dir/test_data/test1.fastq" "$meta_resources_dir/test_data/test2.fastq" \
--fastq "$meta_resources_dir/test_data/test1.fastq;$meta_resources_dir/test_data/test2.fastq" \
--outdir output

# Check if output directory exists
Expand Down Expand Up @@ -109,7 +107,7 @@ echo "> Run Test 3: multiple options-1"
--format jpg \
--prefix biobox_ \
--store \
--color yellow \
--color "yellow" \
--info_in_report \
--outdir output

Expand Down
3 changes: 1 addition & 2 deletions src/nanoplot/test_data/test1.fastq
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,4 @@ DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
@read_10
ACTGGTATGTCGTGGTACCCTTGA
+
111111111111111111111111

111111111111111111111111
3 changes: 1 addition & 2 deletions src/nanoplot/test_data/test2.fastq
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,4 @@ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
@read_7
AATAAAGCCCGTTCCACACTTTAGCAATGTCAAGACTGTATCATCGACAGCGGTAGTTATGTAGCCAGCACATTTCATTACCCCCTCGC
+
77777777777777777777777777777777777777777777777777777777777777777777777777777777777777777

77777777777777777777777777777777777777777777777777777777777777777777777777777777777777777

0 comments on commit 25ad022

Please sign in to comment.