Skip to content

Commit

Permalink
fix empty
Browse files Browse the repository at this point in the history
  • Loading branch information
y9c committed Nov 15, 2023
1 parent e7d84d5 commit 9c7a3c5
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -784,21 +784,26 @@ rule count_bases_combined:
"""
echo {params.header:q} > {output}
paste_files() {{
first_non_empty_file=""
for file in $@; do
if [[ -s $file ]]; then
first_non_empty_file=$file
break
fi
done
cmd="paste <(cut -f 1-4 $first_non_empty_file)"
for file in $@; do
if [[ ! -s $file ]]; then
cmd+=" <(sed 'c0,0,0,0,0,0,0,0,0,0,,' $first_non_empty_file)"
else
cmd+=" <(cut -f 5 $file)"
fi
done
eval $cmd
if [[ "$first_non_empty_file" != "" ]]; then
cmd="paste <(cut -f 1-4 $first_non_empty_file)"
for file in $@; do
if [[ ! -s $file ]]; then
cmd+=" <(sed 'c0,0,0,0,0,0,0,0,0,0,,' $first_non_empty_file)"
else
cmd+=" <(cut -f 5 $file)"
fi
done
eval $cmd
else
printf ""
fi
}}
paste_files {input.fwd} >> {output}
paste_files {input.rev} >> {output}
Expand Down

0 comments on commit 9c7a3c5

Please sign in to comment.