Mercurial > repos > richard-burhans > ncbi_egapx
annotate get-bams.bash @ 39:4f85da43b40c draft
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/ncbi_egapx commit d96d9578e86e3a3d3569dbc2294cfb15f6678729
| author | richard-burhans |
|---|---|
| date | Mon, 30 Jun 2025 23:21:01 +0000 |
| parents | 1429b9638055 |
| children |
| rev | line source |
|---|---|
|
31
1429b9638055
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/ncbi_egapx commit 7fab8f3658c9289e1d229bcde0beff80a0814c4c
richard-burhans
parents:
diff
changeset
|
1 #!/usr/bin/env bash |
|
1429b9638055
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/ncbi_egapx commit 7fab8f3658c9289e1d229bcde0beff80a0814c4c
richard-burhans
parents:
diff
changeset
|
2 |
|
1429b9638055
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/ncbi_egapx commit 7fab8f3658c9289e1d229bcde0beff80a0814c4c
richard-burhans
parents:
diff
changeset
|
3 set -o errexit |
|
1429b9638055
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/ncbi_egapx commit 7fab8f3658c9289e1d229bcde0beff80a0814c4c
richard-burhans
parents:
diff
changeset
|
4 set -o nounset |
|
1429b9638055
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/ncbi_egapx commit 7fab8f3658c9289e1d229bcde0beff80a0814c4c
richard-burhans
parents:
diff
changeset
|
5 set -o pipefail |
|
1429b9638055
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/ncbi_egapx commit 7fab8f3658c9289e1d229bcde0beff80a0814c4c
richard-burhans
parents:
diff
changeset
|
6 |
|
1429b9638055
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/ncbi_egapx commit 7fab8f3658c9289e1d229bcde0beff80a0814c4c
richard-burhans
parents:
diff
changeset
|
7 ## |
|
1429b9638055
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/ncbi_egapx commit 7fab8f3658c9289e1d229bcde0beff80a0814c4c
richard-burhans
parents:
diff
changeset
|
8 ## Collect output bam files from STAR |
|
1429b9638055
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/ncbi_egapx commit 7fab8f3658c9289e1d229bcde0beff80a0814c4c
richard-burhans
parents:
diff
changeset
|
9 ## |
|
1429b9638055
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/ncbi_egapx commit 7fab8f3658c9289e1d229bcde0beff80a0814c4c
richard-burhans
parents:
diff
changeset
|
10 |
|
1429b9638055
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/ncbi_egapx commit 7fab8f3658c9289e1d229bcde0beff80a0814c4c
richard-burhans
parents:
diff
changeset
|
11 bam_temp_dir=$(mktemp --directory ./egapx_out/bam.XXXXXXXXXX) || { |
|
1429b9638055
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/ncbi_egapx commit 7fab8f3658c9289e1d229bcde0beff80a0814c4c
richard-burhans
parents:
diff
changeset
|
12 echo "ERROR: failed making temporary directory" |
|
1429b9638055
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/ncbi_egapx commit 7fab8f3658c9289e1d229bcde0beff80a0814c4c
richard-burhans
parents:
diff
changeset
|
13 exit 1 |
|
1429b9638055
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/ncbi_egapx commit 7fab8f3658c9289e1d229bcde0beff80a0814c4c
richard-burhans
parents:
diff
changeset
|
14 } |
|
1429b9638055
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/ncbi_egapx commit 7fab8f3658c9289e1d229bcde0beff80a0814c4c
richard-burhans
parents:
diff
changeset
|
15 |
|
1429b9638055
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/ncbi_egapx commit 7fab8f3658c9289e1d229bcde0beff80a0814c4c
richard-burhans
parents:
diff
changeset
|
16 bam_files_file="$bam_temp_dir/bam-files.txt" |
|
1429b9638055
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/ncbi_egapx commit 7fab8f3658c9289e1d229bcde0beff80a0814c4c
richard-burhans
parents:
diff
changeset
|
17 touch "$bam_files_file" || { |
|
1429b9638055
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/ncbi_egapx commit 7fab8f3658c9289e1d229bcde0beff80a0814c4c
richard-burhans
parents:
diff
changeset
|
18 echo "ERROR: failed creating temporary file" |
|
1429b9638055
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/ncbi_egapx commit 7fab8f3658c9289e1d229bcde0beff80a0814c4c
richard-burhans
parents:
diff
changeset
|
19 exit 1 |
|
1429b9638055
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/ncbi_egapx commit 7fab8f3658c9289e1d229bcde0beff80a0814c4c
richard-burhans
parents:
diff
changeset
|
20 } |
|
1429b9638055
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/ncbi_egapx commit 7fab8f3658c9289e1d229bcde0beff80a0814c4c
richard-burhans
parents:
diff
changeset
|
21 trap 'rm -f -- "$bam_files_file"' EXIT |
|
1429b9638055
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/ncbi_egapx commit 7fab8f3658c9289e1d229bcde0beff80a0814c4c
richard-burhans
parents:
diff
changeset
|
22 |
|
1429b9638055
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/ncbi_egapx commit 7fab8f3658c9289e1d229bcde0beff80a0814c4c
richard-burhans
parents:
diff
changeset
|
23 find . -type f -name \*Aligned.out.Sorted.bam -print > "$bam_files_file" || { |
|
1429b9638055
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/ncbi_egapx commit 7fab8f3658c9289e1d229bcde0beff80a0814c4c
richard-burhans
parents:
diff
changeset
|
24 echo "ERROR: failed finding bam files" |
|
1429b9638055
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/ncbi_egapx commit 7fab8f3658c9289e1d229bcde0beff80a0814c4c
richard-burhans
parents:
diff
changeset
|
25 exit 1 |
|
1429b9638055
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/ncbi_egapx commit 7fab8f3658c9289e1d229bcde0beff80a0814c4c
richard-burhans
parents:
diff
changeset
|
26 } |
|
1429b9638055
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/ncbi_egapx commit 7fab8f3658c9289e1d229bcde0beff80a0814c4c
richard-burhans
parents:
diff
changeset
|
27 |
|
1429b9638055
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/ncbi_egapx commit 7fab8f3658c9289e1d229bcde0beff80a0814c4c
richard-burhans
parents:
diff
changeset
|
28 idx=0 |
|
1429b9638055
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/ncbi_egapx commit 7fab8f3658c9289e1d229bcde0beff80a0814c4c
richard-burhans
parents:
diff
changeset
|
29 while IFS="" read pathname; do |
|
1429b9638055
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/ncbi_egapx commit 7fab8f3658c9289e1d229bcde0beff80a0814c4c
richard-burhans
parents:
diff
changeset
|
30 filename=$(basename "$pathname" ".bam") |
|
1429b9638055
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/ncbi_egapx commit 7fab8f3658c9289e1d229bcde0beff80a0814c4c
richard-burhans
parents:
diff
changeset
|
31 |
|
1429b9638055
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/ncbi_egapx commit 7fab8f3658c9289e1d229bcde0beff80a0814c4c
richard-burhans
parents:
diff
changeset
|
32 dest_path_prefix="$bam_temp_dir/$filename" |
|
1429b9638055
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/ncbi_egapx commit 7fab8f3658c9289e1d229bcde0beff80a0814c4c
richard-burhans
parents:
diff
changeset
|
33 if [ -e "${dest_path_prefix}.bam" ]; then |
|
1429b9638055
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/ncbi_egapx commit 7fab8f3658c9289e1d229bcde0beff80a0814c4c
richard-burhans
parents:
diff
changeset
|
34 dest_path_prefix="${dest_path_prefix}.${idx}" |
|
1429b9638055
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/ncbi_egapx commit 7fab8f3658c9289e1d229bcde0beff80a0814c4c
richard-burhans
parents:
diff
changeset
|
35 idx=$((idx + 1)) |
|
1429b9638055
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/ncbi_egapx commit 7fab8f3658c9289e1d229bcde0beff80a0814c4c
richard-burhans
parents:
diff
changeset
|
36 fi |
|
1429b9638055
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/ncbi_egapx commit 7fab8f3658c9289e1d229bcde0beff80a0814c4c
richard-burhans
parents:
diff
changeset
|
37 dest_pathname="${dest_path_prefix}.bam" |
|
1429b9638055
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/ncbi_egapx commit 7fab8f3658c9289e1d229bcde0beff80a0814c4c
richard-burhans
parents:
diff
changeset
|
38 |
|
1429b9638055
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/ncbi_egapx commit 7fab8f3658c9289e1d229bcde0beff80a0814c4c
richard-burhans
parents:
diff
changeset
|
39 cp "$pathname" "$dest_pathname" || { |
|
1429b9638055
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/ncbi_egapx commit 7fab8f3658c9289e1d229bcde0beff80a0814c4c
richard-burhans
parents:
diff
changeset
|
40 echo "ERROR: failed: cp \"$pathname\" \"$dest_pathname\"" |
|
1429b9638055
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/ncbi_egapx commit 7fab8f3658c9289e1d229bcde0beff80a0814c4c
richard-burhans
parents:
diff
changeset
|
41 exit 1 |
|
1429b9638055
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/ncbi_egapx commit 7fab8f3658c9289e1d229bcde0beff80a0814c4c
richard-burhans
parents:
diff
changeset
|
42 } |
|
1429b9638055
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/ncbi_egapx commit 7fab8f3658c9289e1d229bcde0beff80a0814c4c
richard-burhans
parents:
diff
changeset
|
43 |
|
1429b9638055
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/ncbi_egapx commit 7fab8f3658c9289e1d229bcde0beff80a0814c4c
richard-burhans
parents:
diff
changeset
|
44 done < "$bam_files_file" |
|
1429b9638055
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/ncbi_egapx commit 7fab8f3658c9289e1d229bcde0beff80a0814c4c
richard-burhans
parents:
diff
changeset
|
45 |
|
1429b9638055
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/ncbi_egapx commit 7fab8f3658c9289e1d229bcde0beff80a0814c4c
richard-burhans
parents:
diff
changeset
|
46 exit 0 |
