-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenzymeseq_pipe_6_4.sh
More file actions
78 lines (66 loc) · 2.02 KB
/
Copy pathenzymeseq_pipe_6_4.sh
File metadata and controls
78 lines (66 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
topdir=$(pwd)
account="b1042"
queue="genomicslong"
DEBUG="${topdir}/debug"
aligned_dir="${topdir}/aligned_UTR"
aligned_sort="${topdir}/aligned_sort"
mkdir -p "$DEBUG" "$aligned_sort"
for sample_dir in "$aligned_dir"/*; do
[[ -d "$sample_dir" ]] || continue
sample=$(basename "$sample_dir")
echo "Submitting job for sample: $sample"
mkdir -p "$aligned_sort/$sample"
sbatch --export=ALL,sample_dir="$sample_dir",sample="$sample",aligned_sort="$aligned_sort" <<EOF
#!/bin/bash -l
#SBATCH -A $account
#SBATCH --partition=$queue
#SBATCH -J aligned_sort_${sample}
#SBATCH -o $DEBUG/aligned_sort_${sample}.%j.out
#SBATCH -e $DEBUG/aligned_sort_${sample}.%j.err
#SBATCH -t 10-00:00:00
#SBATCH -c 4
#SBATCH --mem-per-cpu=40G
MAXLEN=20
# Loop over all aligned FASTA for this sample
for f in \$sample_dir/*_highscore_aligned_seqs.fa; do
base=\$(basename "\$f" .fa)
short_out="\$aligned_sort/$sample/\${base}_short.fa"
long_out="\$aligned_sort/$sample/\${base}_long.fa"
awk -v maxlen="\$MAXLEN" '
/^>/ {header=\$0; next}
{
seq=\$0
if(length(seq) < maxlen) {
print header
print seq
} else {
print header > "'"\$long_out"'"
print seq > "'"\$long_out"'"
}
}
' "\$f" > "\$short_out"
echo "Created \$short_out and \$long_out"
done
# Loop over all unaligned FASTA for this sample
for f in \$sample_dir/*_unaligned.fa; do
base=\$(basename "\$f" .fa)
short_out="\$aligned_sort/$sample/\${base}_short.fa"
long_out="\$aligned_sort/$sample/\${base}_long.fa"
awk -v maxlen="\$MAXLEN" '
/^>/ {header=\$0; next}
{
seq=\$0
if(length(seq) < maxlen) {
print header
print seq
} else {
print header > "'"\$long_out"'"
print seq > "'"\$long_out"'"
}
}
' "\$f" > "\$short_out"
echo "Created \$short_out and \$long_out"
done
EOF
done