-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPROVEAN.pbs
111 lines (83 loc) · 2.83 KB
/
PROVEAN.pbs
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/bin/bash
#PBS -N PROVEAN
#PBS -S /bin/bash
set -e
function die {
>&2 echo "error: ${1}"
exit 1
}
#######################################
# If provided, source the config file #
#######################################
if [[ -n "${config}" && ! -f "${config}" ]] ; then
die "Config file not found: ${config}"
fi
if [[ -n "${config}" && -f "${config}" ]] ; then
. "${config}"
fi
######################################################################
# Check that we have a BLAST_DB, CACHE_DIR and JOB_FILE in our $PATH #
######################################################################
if [[ -z "${BLAST_DB}" || ! -d "${BLAST_DB}" ]] ; then
die '$BLAST_DB not found.'
fi
if [[ -z "${CACHE_DIR}" || ! -d "${CACHE_DIR}" ]] ; then
die '$CACHE_DIR not found.'
fi
if [[ -z "${JOB_FILE}" || ! -f "${JOB_FILE}" ]] ; then
die '$JOB_FILE not found.'
fi
##################################################################
# Check that we have NCBI-BLAST, CD-HIT and PROVEAN in our $PATH #
##################################################################
for i in "psiblast" "blastdbcmd" "cd-hit" "provean" ; do
hash "${i}" 2>/dev/null || {
die "${i^^}: command not found."
}
done
##########################################################
# Read the job file and slice out the peptide identifier #
##########################################################
n=1
while IFS= read -r peptide_id ; do
peptide_ids[$n]="${peptide_id}"
((n++))
done < "${JOB_FILE}"
peptide_id="${peptide_ids[$PBS_ARRAY_INDEX]}"
peptide_dir="${CACHE_DIR%/}/${peptide_id}"
############################################################
# Check that the variations and query sequence files exist #
############################################################
variation_file="${peptide_dir}/${peptide_id}.var"
if [ ! -f "${variation_file}" ] ; then
die "Variation file not found: ${variation_file}"
fi
query_file="${peptide_dir}/${peptide_id}.fasta"
if [ ! -f "${query_file}" ] ; then
die "Query file not found: ${query_file}"
fi
#############################
# Build the PROVEAN command #
#############################
cmd=(provean)
cmd+=(-q "${query_file}")
cmd+=(-d "${BLAST_DB%/}/nr")
cmd+=(-v "${variation_file}")
cmd+=(--psiblast "$(type -P 'psiblast')")
cmd+=(--cdhit "$(type -P 'cd-hit')")
cmd+=(--blastdbcmd "$(type -P 'blastdbcmd')")
supporting_set="${peptide_dir}/${peptide_id}.sss"
if [ -e "${supporting_set}" ] ; then
cmd+=(--supporting_set "${supporting_set}")
else
cmd+=(--save_supporting_set "${supporting_set}")
fi
if [ -n "${TMPDIR}" ] ; then
cmd+=(--tmp_dir "${TMPDIR}")
fi
#################################################
# Run PROVEAN and write the output to CACHE_DIR #
#################################################
stdout="${peptide_dir}/${peptide_id}.out"
stderr="${peptide_dir}/${peptide_id}.err"
"${cmd[@]}" 1> "${stdout}" 2> "${stderr}"