File: theseus_align

package info (click to toggle)
theseus 3.3.0-8
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 91,384 kB
  • sloc: ansic: 41,744; makefile: 267; sh: 121
file content (225 lines) | stat: -rwxr-xr-x 6,877 bytes parent folder | download | duplicates (5)
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
#!/bin/bash
# THESEUS: Maximum likelihood superpositioning of multiple 
#          macromolecular structures
# 
# -/_|:|_|_\- 
# Douglas L. Theobald
# Department of Biochemistry
# Brandeis University
# Waltham, MA  02454
#
# dtheobald@brandeis.edu
# dtheobald@gmail.com
#
# theseus_align
#
# Usage: theseus_align [theseus_options] -f pdbfile1.pdb pdbfile2.pdb ...
#
# 'theseus_align' allows for a quick-and-dirty way to ML superposition proteins
# with different sequences. It should work very well when the protein sequences
# are relatively similar, although the ML method will still give much better
# results than least-squares when the sequences are moderately divergent.
# Technically, this procedure gives a structure-based superposition of a
# sequence-based alignment. It _does not_ perform a structure-based alignment.
#
# First, the script uses THESEUS to create FASTA formatted sequence files
# corresponding to the exact protein sequences found in the pdb files that you
# supply.
#
# Second, these sequences are aligned using the multiple sequence alignment
# program of your choice -- currently set up for MUSCLE and easily modified for
# CLUSTALW, T_COFFEE, KALIGN, DIALIGN2, or MAFFT. Any multiple sequence
# alignment program can be used, as long as it can generate clustal-formatted
# files. However, I highly recommend Bob Edgar's MUSCLE program for both its
# speed and accuracy. It is easy to install using either precompiled binaries or
# by compiling from scratch:
# http://www.drive5.com/muscle/
#
# Third, THESEUS performs a superposition of the structures using the sequence
# alignment as a guide.
#
# The following six constant strings should be modified to whatever is
# convenient and applicable.

CAT="/bin/cat";
SED="/usr/bin/sed";
TEE="/usr/bin/tee";
theseus="/usr/local/bin/theseus"; # where to find the THESEUS binary executable
fastafile="theseus.fasta";
filemapfile="theseus.filemap";
alignmentfile="theseus.aln";

# for MUSCLE -- http://www.drive5.com/muscle/
alignprog="/usr/local/bin/muscle";
align_cmd="${alignprog} -maxiters 32 -in ${fastafile} -out ${alignmentfile} -clwstrict";

# for PROBCONS -- http://probcons.stanford.edu/
# alignprog="/usr/local/bin/probcons";
# align_cmd="( ${alignprog} -clustalw ${fastafile} | ${SED} 's/PROBCONS/CLUSTALW/' | ${TEE} ${alignmentfile} )";
# echo $align_cmd

# for CLUSTAL-OMEGA -- http://www.clustal.org/omega/
# alignprog="/usr/local/bin/clustalo";
# align_cmd="${alignprog} --force --output-order=input-order -i ${fastafile} -o ${alignmentfile} -v";


# for CLUSTALW -- http://www.clustal.org/clustal2/
#alignprog="/usr/local/bin/clustalw";
#align_cmd="${alignprog} -outorder=input -infile=${fastafile} -outfile=${alignmentfile}";

# for MAFFT -- http://www.biophys.kyoto-u.ac.jp/%7Ekatoh/programs/align/mafft/
# alignprog="/usr/local/bin/mafft";
# align_cmd="${alignprog} --maxiterate 1000 --localpair --clustalout ${fastafile} > ${alignmentfile}";

# for T_COFFEE -- http://igs-server.cnrs-mrs.fr/%7Ecnotred/Projects_home_page/t_coffee_home_page.html
#alignprog="/usr/local/bin/t_coffee";
#align_cmd="${alignprog} ${fastafile} -outfile=${alignmentfile}";

# for KALIGN -- http://msa.cgb.ki.se/
#alignprog="/usr/local/bin/kalign"
#align_cmd="${alignprog} -i ${fastafile} -f aln | sed 's/Kalign/CLUSTALW/' > ${alignmentfile}";

# for DIALIGN2 -- http://bibiserv.techfak.uni-bielefeld.de/dialign/
#alignprog="/usr/local/bin/dialign2"
#align_cmd="${alignprog} -cw ${fastafile}; sed 's/\/\///' ${fastafile%.*}.cw | sed 's/DIALIGN/CLUSTALW/'";


################################################################################
################################################################################
# NOTHING BELOW HERE SHOULD BE CHANGED
################################################################################

if [ ! -f ${alignprog} ] || [ ! -x ${alignprog} ] || [ ! -s ${alignprog} ]
then
    printf "\nERROR: Problem with multiple sequence aligment executable, ${alignprog}\n";
    ${alignprog};
    exit 1;
elif [ ! -f ${theseus} ] || [ ! -x ${theseus} ] || [ ! -s ${theseus} ]
then
    printf "\nERROR: Problem with THESEUS executable, ${alignprog}\n";
    ${theseus};
    exit 1;
fi

usage="Usage: ${0} [theseus_options] -f pdbfile1.pdb pdbfile2.pdb ...";

declare -a opts=( $@ ); # save the command line arguments
(( argc = $# )); # save the number of command line arguments

# shift up until we get past '-f', which signifies that the rest are files
(( optn = 0 ));
while [ "${1}" != "-f" ] && [ ! -z "${1}" ]
do
    shift;
    (( optn++ ));
done

# Ensure that there is something on the command line
if [[ -z "$@" ]] # double brackets don't do word splitting
then
    printf "\n${usage}\n\n";
    exit 1;
else
    shift;
fi

for (( i = optn; i < argc; ++i ))
do
    unset opts[${i}]; # nix the pdb files from the options array
done

pdbs="$@";
echo "PDBs for superpositioning: ${pdbs}"

# Make sure there are pdb files on the command line
if [[ -z "${pdbs}" ]] # double brackets don't do word splitting
then
    printf "\n${usage}\n\n";
    exit 1;
else
    shift;
fi

# Check each pdb file to see if it exists, if it is readable, and if it is non-empty
for pdb in ${pdbs}
do
    if [ ! -f ${pdb} ] || [ ! -r ${pdb} ] || [ ! -s ${pdb} ]
    then
        printf "\nProblem with file: ${pdb}\n"
        printf "\n${usage}\n\n";
        exit 1;
    fi
done

theseus_cmd="${theseus} ${opts[@]} -f -M ${filemapfile} -A ${alignmentfile} ${pdbs}";

# Use THESEUS to make fasta sequence files corresponding to each pdb
${theseus} -f -F ${pdbs};

if [ ! $? ]
then
    printf "\nERROR: THESEUS did not successfully create all FASTA sequence files.\n";
	printf "\n${usage}\n\n";
	exit 1;
fi

for pdb in ${pdbs}
do
    fasta="${pdb}.fst";
    if [ ! -f ${fasta} ] || [ ! -r ${fasta} ] || [ ! -s ${fasta} ]
    then
        printf "\nProblem with FASTA sequence file ${fastafile} for ${pdb}\n"
        printf "\n${usage}\n\n";
        exit 1;
    fi
done

if [ -f ${fastafile} ]
then
    rm ${fastafile};
fi

# Concatenate all fasta files into one large multiple sequence fasta file
for pdb in ${pdbs}
do
    ${CAT} ${pdb}.fst >> ${fastafile};
done

#ls -1 ${pdbs} | awk '{print $1" "$1}' > ${filemapfile};

if [ -f ${filemapfile} ]
then
    rm ${filemapfile};
fi

# Make the mapfile for THESEUS to use (which sequence corresponds to which file)
for pdb in ${pdbs}
do
    echo "${pdb} ${pdb}" >> ${filemapfile};
done

# Align the sequences
printf "\n\n${align_cmd}\n";
eval ${align_cmd};

if [ ! $? ]
then
    printf "\nERROR: Sequence alignment failed.\n";
	printf "\n${usage}\n\n";
	exit 1;
fi


if [ ! -s ${alignmentfile} ]
then
    printf "\nERROR: Sequence alignment failed: no alignment file.\n";
    printf "\n${usage}\n\n";
    exit 1;
fi

# Superimpose with THESEUS based on the sequence alignment generated above
printf "\n\n${theseus_cmd}\n";
${theseus_cmd};

exit 0;