-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #353 from rachelse/master
Multimer cluster
- Loading branch information
Showing
15 changed files
with
1,383 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
#!/bin/sh -e | ||
fail() { | ||
echo "Error: $1" | ||
exit 1 | ||
} | ||
|
||
notExists() { | ||
[ ! -f "$1" ] | ||
} | ||
|
||
exists() { | ||
[ -f "$1" ] | ||
} | ||
|
||
abspath() { | ||
if [ -d "$1" ]; then | ||
(cd "$1"; pwd) | ||
elif [ -f "$1" ]; then | ||
if [ -z "${1##*/*}" ]; then | ||
echo "$(cd "${1%/*}"; pwd)/${1##*/}" | ||
else | ||
echo "$(pwd)/$1" | ||
fi | ||
elif [ -d "$(dirname "$1")" ]; then | ||
echo "$(cd "$(dirname "$1")"; pwd)/$(basename "$1")" | ||
fi | ||
} | ||
|
||
mapCmplName2ChainKeys() { | ||
awk -F"\t" 'FNR==1 {++fIndex} | ||
fIndex==1 { | ||
repName[$1]=1 | ||
if (match($1, /MODEL/)){ | ||
tmpName[$1]=1 | ||
}else{ | ||
tmpName[$1"_MODEL_1"]=1 | ||
} | ||
next | ||
} | ||
fIndex==2{ | ||
if (match($2, /MODEL/)){ | ||
if ($2 in tmpName){ | ||
repId[$1]=1 | ||
}else{ | ||
ho[1]=1 | ||
} | ||
}else{ | ||
if ($2 in repName){ | ||
repId[$1]=1 | ||
} | ||
} | ||
next | ||
} | ||
{ | ||
if ($3 in repId){ | ||
print $1 | ||
} | ||
} | ||
' "${1}" "${2}.source" "${2}.lookup" > "${3}" | ||
} | ||
|
||
postprocessFasta() { | ||
awk ' BEGIN {FS=">"} | ||
$0 ~/^>/ { | ||
# match($2, /(.*).pdb*/) | ||
split($2,parts,"_") | ||
complex="" | ||
for (j = 1; j < length(parts); j++) { | ||
complex = complex parts[j] | ||
if (j < length(parts)-1){ | ||
complex=complex"_" | ||
} | ||
} | ||
if (!(complex in repComplex)) { | ||
print "#"complex | ||
repComplex[complex] = "" | ||
} | ||
} | ||
{print $0} | ||
' "${1}" > "${1}.tmp" && mv "${1}.tmp" "${1}" | ||
} | ||
|
||
if notExists "${TMP_PATH}/query.dbtype"; then | ||
# shellcheck disable=SC2086 | ||
"$MMSEQS" createdb "${INPUT}" "${TMP_PATH}/query" ${CREATEDB_PAR} \ | ||
|| fail "query createdb died" | ||
fi | ||
|
||
if notExists "${TMP_PATH}/multimer_clu.dbtype"; then | ||
# shellcheck disable=SC2086 | ||
"$MMSEQS" multimercluster "${TMP_PATH}/query" "${TMP_PATH}/multimer_clu" "${TMP_PATH}" ${MULTIMERCLUSTER_PAR} \ | ||
|| fail "Multimercluster died" | ||
fi | ||
|
||
SOURCE="${TMP_PATH}/query" | ||
INPUT="${TMP_PATH}/latest/multimer_db" | ||
if notExists "${TMP_PATH}/cluster.tsv"; then | ||
# shellcheck disable=SC2086 | ||
"$MMSEQS" createtsv "${INPUT}" "${INPUT}" "${TMP_PATH}/multimer_clu" "${TMP_PATH}/cluster.tsv" ${THREADS_PAR} \ | ||
|| fail "Convert Alignments died" | ||
# shellcheck disable=SC2086 | ||
"$MMSEQS" createtsv "${INPUT}" "${INPUT}" "${TMP_PATH}/multimer_clu_filt_info" "${TMP_PATH}/cluster_report" ${THREADS_PAR} \ | ||
|| fail "Convert Alignments died" | ||
fi | ||
|
||
if notExists "${TMP_PATH}/multimer_rep_seqs.dbtype"; then | ||
mapCmplName2ChainKeys "${TMP_PATH}/cluster.tsv" "${SOURCE}" "${TMP_PATH}/rep_seqs.list" | ||
# shellcheck disable=SC2086 | ||
"$MMSEQS" createsubdb "${TMP_PATH}/rep_seqs.list" "${SOURCE}" "${TMP_PATH}/multimer_rep_seqs" ${CREATESUBDB_PAR} \ | ||
|| fail "createsubdb died" | ||
fi | ||
|
||
if notExists "${TMP_PATH}/multimer_rep_seq.fasta"; then | ||
# shellcheck disable=SC2086 | ||
"$MMSEQS" result2flat "${SOURCE}" "${SOURCE}" "${TMP_PATH}/multimer_rep_seqs" "${TMP_PATH}/multimer_rep_seq.fasta" ${VERBOSITY_PAR} \ | ||
|| fail "result2flat died" | ||
postprocessFasta "${TMP_PATH}/multimer_rep_seq.fasta" | ||
fi | ||
|
||
#TODO: generate fasta file for all sequences | ||
# if notExists "${TMP_PATH}/multimer_all_seqs.fasta"; then | ||
# # shellcheck disable=SC2086 | ||
# "$MMSEQS" createseqfiledb "${INPUT}" "${TMP_PATH}/multimer_clu" "${TMP_PATH}/multimer_clust_seqs" ${THREADS_PAR} \ | ||
# || fail "Result2repseq died" | ||
|
||
# # shellcheck disable=SC2086 | ||
# "$MMSEQS" result2flat "${INPUT}" "${INPUT}" "${TMP_PATH}/multimer_clust_seqs" "${TMP_PATH}/multimer_all_seqs.fasta" ${VERBOSITY_PAR} \ | ||
# || fail "result2flat died" | ||
# fi | ||
|
||
# mv "${TMP_PATH}/multimer_all_seqs.fasta" "${RESULT}_all_seqs.fasta" | ||
mv "${TMP_PATH}/multimer_rep_seq.fasta" "${RESULT}_rep_seq.fasta" | ||
mv "${TMP_PATH}/cluster.tsv" "${RESULT}_cluster.tsv" | ||
mv "${TMP_PATH}/cluster_report" "${RESULT}_cluster_report" | ||
|
||
if [ -n "${REMOVE_TMP}" ]; then | ||
rm "${INPUT}.0" | ||
# shellcheck disable=SC2086 | ||
"$MMSEQS" rmdb "${TMP_PATH}/multimer_db" ${VERBOSITY_PAR} | ||
# shellcheck disable=SC2086 | ||
# "$MMSEQS" rmdb "${TMP_PATH}/multimer_clu_seqs" ${VERBOSITY_PAR} | ||
# shellcheck disable=SC2086 | ||
"$MMSEQS" rmdb "${TMP_PATH}/multimer_rep_seqs" ${VERBOSITY_PAR} | ||
# shellcheck disable=SC2086 | ||
"$MMSEQS" rmdb "${TMP_PATH}/multimer_rep_seqs_h" ${VERBOSITY_PAR} | ||
# shellcheck disable=SC2086 | ||
"$MMSEQS" rmdb "${TMP_PATH}/complex_clu" ${VERBOSITY_PAR} | ||
# shellcheck disable=SC2086 | ||
"$MMSEQS" rmdb "${TMP_PATH}/query" ${VERBOSITY_PAR} | ||
# shellcheck disable=SC2086 | ||
"$MMSEQS" rmdb "${TMP_PATH}/query_h" ${VERBOSITY_PAR} | ||
# shellcheck disable=SC2086 | ||
"$MMSEQS" rmdb "${INPUT}" ${VERBOSITY_PAR} | ||
# shellcheck disable=SC2086 | ||
"$MMSEQS" rmdb "${INPUT}_h" ${VERBOSITY_PAR} | ||
# shellcheck disable=SC2086 | ||
"$MMSEQS" rmdb "${TMP_PATH}/query_ca" ${VERBOSITY_PAR} | ||
# shellcheck disable=SC2086 | ||
"$MMSEQS" rmdb "${TMP_PATH}/query_ss" ${VERBOSITY_PAR} | ||
rm "${TMP_PATH}/rep_seqs.list" | ||
rm -rf "${TMP_PATH}/latest" | ||
rm -f "${TMP_PATH}/easymultimercluster.sh" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
#!/bin/sh -e | ||
fail() { | ||
echo "Error: $1" | ||
exit 1 | ||
} | ||
|
||
notExists() { | ||
[ ! -f "$1" ] | ||
} | ||
|
||
exists() { | ||
[ -f "$1" ] | ||
} | ||
|
||
abspath() { | ||
if [ -d "$1" ]; then | ||
(cd "$1"; pwd) | ||
elif [ -f "$1" ]; then | ||
if [ -z "${1##*/*}" ]; then | ||
echo "$(cd "${1%/*}"; pwd)/${1##*/}" | ||
else | ||
echo "$(pwd)/$1" | ||
fi | ||
elif [ -d "$(dirname "$1")" ]; then | ||
echo "$(cd "$(dirname "$1")"; pwd)/$(basename "$1")" | ||
fi | ||
} | ||
|
||
# Shift initial DB to complexDB using soft-linking | ||
# $1: input db | ||
# $2: output db | ||
buildCmplDb() { | ||
touch "${2}" | ||
awk -F"\t" 'BEGIN {OFFSET=0} | ||
FNR==NR{chain_len[$1]=$3;next} | ||
{ | ||
if (!($3 in off_arr)) { | ||
off_arr[$3]=OFFSET | ||
} | ||
cmpl_len[$3]+=chain_len[$1];OFFSET+=chain_len[$1] | ||
} | ||
END { | ||
for (cmpl in off_arr) { | ||
print cmpl"\t"off_arr[cmpl]"\t"cmpl_len[cmpl] | ||
} | ||
}' "${1}.index" "${1}.lookup" > "${2}.index" | ||
ln -s "$(abspath "${1}")" "${2}.0" | ||
cp "${1}.dbtype" "${2}.dbtype" | ||
} | ||
|
||
buldCmplhDb(){ | ||
awk -F"\t" 'BEGIN {INDEXVAL=0} | ||
{ | ||
split($2,words," ") | ||
split(words[1],parts,"_") | ||
output_string=parts[1] | ||
for (j = 2; j < length(parts); j++) { | ||
if (j < length(parts)){ | ||
output_string=output_string"_" | ||
} | ||
output_string = output_string parts[j] | ||
} | ||
headerstring="" | ||
for (k = 2; k < length(words)+1; k++) { | ||
headerstring = headerstring words[k]" " | ||
} | ||
if (!(output_string in gogo)){ | ||
print INDEXVAL"\t"output_string" "headerstring | ||
INDEXVAL++ | ||
} | ||
gogo[output_string]=1 | ||
}' "${1}" > "${2}" | ||
} | ||
|
||
|
||
# [ ! -d "$3" ] && echo "tmp directory $3 not found!" && mkdir -p "${TMP_PATH}"; | ||
|
||
if notExists "${TMP_PATH}/multimer_result.dbtype"; then | ||
# shellcheck disable=SC2086 | ||
"$MMSEQS" multimersearch "${INPUT}" "${INPUT}" "${TMP_PATH}/multimer_result" "${TMP_PATH}/multimersearch_tmp" ${MULTIMERSEARCH_PAR} \ | ||
|| fail "multimerSearch died" | ||
fi | ||
|
||
if notExists "multimer_filt.dbtype"; then | ||
# shellcheck disable=SC2086 | ||
"$MMSEQS" filtermultimer "${INPUT}" "${INPUT}" "${TMP_PATH}/multimer_result" "${TMP_PATH}/multimer_filt" ${FILTERMULTIMER_PAR} \ | ||
|| fail "FilterMultimer died" | ||
fi | ||
|
||
# shift query DB, .index, .dbtype | ||
if notExists "${TMP_PATH}/multimer_db.dbtype"; then | ||
# build complex db as output | ||
buildCmplDb "${INPUT}" "${TMP_PATH}/multimer_db" | ||
fi | ||
|
||
# Shift _h, _h.dbtype | ||
if notExists "${TMP_PATH}/multimer_db_h.dbtype"; then | ||
# # shellcheck disable=SC2086 | ||
# "$MMSEQS" tsv2db "${INPUT}.source" "${TMP_PATH}/complex_db_header_tmp" ${VERBOSITY_PAR} \ | ||
# || fail "tsv2db died" | ||
# shellcheck disable=SC2086 | ||
# "$MMSEQS" createtsv "${INPUT}" "${INPUT}_h" "${TMP_PATH}/chain_db_h.tsv" ${VERBOSITY_PAR} \ | ||
"$MMSEQS" createtsv "${INPUT}" "${INPUT}_h" "${TMP_PATH}/chain_db_h.tsv" --threads 1 \ | ||
|| fail "createtsv died" | ||
buldCmplhDb "${TMP_PATH}/chain_db_h.tsv" "${TMP_PATH}/multimer_header.tsv" | ||
# shellcheck disable=SC2086 | ||
"$MMSEQS" tsv2db "${TMP_PATH}/multimer_header.tsv" "${TMP_PATH}/multimer_db_h" ${VERBOSITY_PAR} \ | ||
|| fail "tsv2db died" | ||
fi | ||
|
||
COMP="${TMP_PATH}/multimer_db" | ||
|
||
if notExists "${RESULT}.dbtype"; then | ||
# shellcheck disable=SC2086 | ||
"$MMSEQS" clust "${COMP}" "${TMP_PATH}/multimer_filt" "${RESULT}" ${CLUSTER_PAR} \ | ||
|| fail "Clustering died" | ||
# shellcheck disable=SC2086 | ||
"$MMSEQS" mvdb "${TMP_PATH}/multimer_filt_info" "${RESULT}_filt_info" \ | ||
|| fail "mv died" | ||
|
||
fi | ||
|
||
if [ -n "${REMOVE_TMP}" ]; then | ||
# shellcheck disable=SC2086 | ||
"$MMSEQS" rmdb "${TMP_PATH}/multimer_filt" ${VERBOSITY_PAR} | ||
# shellcheck disable=SC2086 | ||
"$MMSEQS" rmdb "${TMP_PATH}/multimer_result" ${VERBOSITY_PAR} | ||
rm "${TMP_PATH}/chain_db_h.tsv" | ||
rm "${TMP_PATH}/multimer_header.tsv" | ||
rm -rf "${TMP_PATH}/multimersearch_tmp" | ||
rm -f "${TMP_PATH}/multimercluster.sh" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -124,5 +124,4 @@ class BasicFunction{ | |
// transform(t, u, x.x[i], x.y[i], x.z[i], y.x[i], y.y[i], y.z[i]); | ||
} | ||
} | ||
|
||
}; |
Oops, something went wrong.