Skip to content

Commit

Permalink
more consistent arg names, remove "paired" argument and adapt script
Browse files Browse the repository at this point in the history
  • Loading branch information
emmarousseau committed Jul 20, 2024
1 parent beeaae5 commit 56adf70
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 18 deletions.
3 changes: 2 additions & 1 deletion src/umi_tools/umi_tools_extract/config.vsh.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ argument_groups:
description: File containing the input data for the R2 reads (if paired). If provided, a <list of other required arguments> need to be provided.
example: sample_R2.fastq
- name: --bc_pattern
alternatives: -p
type: string
description: |
The UMI barcode pattern to use e.g. 'NNNNNN' indicates that the first 6 nucleotides
Expand All @@ -38,7 +39,7 @@ argument_groups:

- name: "Output"
arguments:
- name: --read1_out
- name: --output
type: file
required: true
description: Output file for read 1.
Expand Down
31 changes: 19 additions & 12 deletions src/umi_tools/umi_tools_extract/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ set -exo pipefail

test_dir="${metal_executable}/test_data"

[[ "$par_paired" == "false" ]] && unset par_paired
[[ "$par_error_correct_cell" == "false" ]] && unset par_error_correct_cell
[[ "$par_reconcile_pairs" == "false" ]] && unset par_reconcile_pairs
[[ "$par_three_prime" == "false" ]] && unset par_three_prime
Expand All @@ -19,29 +18,37 @@ test_dir="${metal_executable}/test_data"
# Check if we have the correct number of input files and patterns for paired-end or single-end reads

# For paired-end rends, check that we have two read files, two patterns
if [ -n "$par_paired" ]; then
if [ -z "$par_input" ] || [ -z "$par_read2_in" ] ||
[ -z "$par_bc_pattern" ] || [ -z "$par_bc_pattern2" ];
then
echo "Paired end input requires two read files, two UMI patterns, and two output files"
# Check for paired-end inputs
if [ -n "$par_input" ] && [ -n "$par_read2_in" ]; then
# Paired-end checks: Ensure both UMI patterns are provided
if [ -z "$par_bc_pattern" ] || [ -z "$par_bc_pattern2" ]; then
echo "Paired end input requires two UMI patterns."
exit 1
fi
else # For single-end reads, check that we have only one read file, one pattern
if [ -n "$par_read2_in" ] || [ -n "$par_bc_pattern2" ]; then
echo "Single end input requires only one read file and one UMI pattern"
elif [ -n "$par_input" ]; then
# Single-end checks: Ensure no second read or UMI pattern for the second read is provided
if [ -n "$par_bc_pattern2" ]; then
echo "Single end input requires only one read file and one UMI pattern."
exit 1
# if par_umi_discard_read is not empty or not 0:
elif [ -n "$par_umi_discard_read" ] && [ "$par_umi_discard_read" != 0 ]; then
fi
# Check that discard_read is not set or set to 0 for single-end reads
if [ -n "$par_umi_discard_read" ] && [ "$par_umi_discard_read" != 0 ]; then
echo "umi_discard_read is only valid when processing paired end reads."
exit 1
fi
else
# No inputs provided
echo "No input files provided."
exit 1
fi




umi_tools extract \
-I "$par_input" \
${par_read2_in:+ --read2-in "$par_read2_in"} \
-S "$par_read1_out" \
-S "$par_output" \
${par_read2_out:+--read2-out "$par_read2_out"} \
${par_extract_method:+--extract-method "$par_extract_method"} \
--bc-pattern "$par_bc_pattern" \
Expand Down
8 changes: 3 additions & 5 deletions src/umi_tools/umi_tools_extract/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ echo ">>> Testing $meta_functionality_name"

echo ">>> Test 1: Testing for paired-end reads"
"$meta_executable" \
--paired \
--input "$test_dir/scrb_seq_fastq.1_30"\
--read2_in "$test_dir/scrb_seq_fastq.2_30" \
--bc_pattern "CCCCCCNNNNNNNNNN"\
Expand All @@ -17,7 +16,7 @@ echo ">>> Test 1: Testing for paired-end reads"
--umi_separator '_' \
--grouping_method directional \
--umi_discard_read 0 \
--read1_out scrb_seq_fastq.1_30.extract \
--output scrb_seq_fastq.1_30.extract \
--read2_out scrb_seq_fastq.2_30.extract \
--random_seed 1

Expand All @@ -39,7 +38,6 @@ rm scrb_seq_fastq.1_30.extract scrb_seq_fastq.2_30.extract

echo ">>> Test 2: Testing for paired-end reads with umi_discard_reads option"
"$meta_executable" \
--paired \
--input "$test_dir/scrb_seq_fastq.1_30" \
--read2_in "$test_dir/scrb_seq_fastq.2_30" \
--bc_pattern CCCCCCNNNNNNNNNN \
Expand All @@ -48,7 +46,7 @@ echo ">>> Test 2: Testing for paired-end reads with umi_discard_reads option"
--umi_separator '_' \
--grouping_method directional \
--umi_discard_read 2 \
--read1_out scrb_seq_fastq.1_30.extract \
--output scrb_seq_fastq.1_30.extract \
--random_seed 1

echo ">> Checking if the correct files are present"
Expand All @@ -71,7 +69,7 @@ echo ">>> Test 3: Testing for single-end reads"
--extract_method regex \
--umi_separator '_' \
--grouping_method directional \
--read1_out slim_30.extract \
--output slim_30.extract \
--random_seed 1

echo ">> Checking if the correct files are present"
Expand Down

0 comments on commit 56adf70

Please sign in to comment.