ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/owl/trunk/modelit/scripts/align_paul.sh
Revision: 1299
Committed: Tue Jan 11 17:38:33 2011 UTC (8 years, 9 months ago) by hstehr
File size: 3004 byte(s)
Log Message:
adding Model-It server files to repository
Line File contents
1 #!/bin/sh
2 # Convenience script for structurally aligning templates using paul
3 # Henning Stehr, h.stehr@molgen.mpg.de
4 # 11/Apr/2008
5
6 if [ -z "$3" ]
7 then
8 echo "Usage: $0 <list.templates> <outfile.fasta> <tempdir> <veryfast|fast|slow|veryslow>"
9 exit 1
10 fi
11
12 # input
13 templates=$1
14 outfile=$2
15 tempdir=$3
16 paul_mode=$4
17
18 # parameters
19 ct="Cb"
20 d="8.0"
21
22 # directories
23 scriptsdir=`dirname $0`
24
25 # output
26 basename=`basename $templates`
27
28 paul_listfile="$tempdir/$basename.paul"
29 paul_seqfile="$tempdir/$basename.paul.seqs"
30
31 # if only one template is given, we skip the alignment steps and simply output the sequence of the template
32 numTemps=`cat $templates | grep -v "^#" | wc -l`
33 if [ "$numTemps" -eq "0" ]
34 then
35 echo "NO TEMPLATES FOUND, CAN'T ALIGN!"
36 exit 1
37 fi
38 if [ "$numTemps" -eq "1" ]
39 then
40 echo "SINGLE TEMPLATE, SKIPPING ALIGNMENT STEP!"
41 for template in `cat $templates | grep -v "^#"` # this loop should stop after 1 iteration unless something is wrong
42 do
43 pdb=`echo $template | cut -c1-4`
44 chain=`echo $template | cut -c5`
45 dumpseq -p ${pdb}${chain} -s > $outfile
46 echo "Template sequence written to $outfile"
47 exit 0
48 done
49 fi
50
51 # make sure files are empty
52 rm -f $paul_listfile
53 rm -f $paul_seqfile
54
55 echo "Getting graphs"
56 # parse template list
57 for template in `cat $templates | grep -v "^#"`
58 do
59 echo $template
60 pdb=`echo $template | cut -c1-4`
61 chain=`echo $template | cut -c5`
62
63 # generate graph directly in paul format (with -P)
64 # we capture the output (number of successful structures) so that we can know if there were problems getting the info from pdbase
65 numPassed=`genGraph -p ${pdb}${chain} -d $d -t $ct -o $tempdir -P | grep "^Number" | sed -e "s/Number of structures done successfully: \(.*\)/\1/"`
66 graphfile="${tempdir}/${pdb}${chain}_${ct}_${d}.cm"
67
68 if [ "$numPassed" -ne "1" ]
69 then
70 echo "No structure info could be found for $pdb, skipping"
71 else
72 dumpseq -p ${pdb}${chain} -s > $graphfile.seq
73 # add to paul list
74 echo `basename $graphfile` >> $paul_listfile
75 echo `basename $graphfile.seq` >> $paul_seqfile
76 fi
77 done
78
79 # run paul
80 cur=`pwd`
81 cd $tempdir
82 paul -i `basename $paul_listfile` -s `basename $paul_seqfile` -m $paul_mode
83 if [ "$?" -ne "0" ]
84 then
85 # paul fails sometimes: better to catch it soon and exit
86 echo "ERROR: paul failed, exit code was $?"
87 exit 1
88 fi
89 cd $cur
90
91 # convert result to fasta format
92 t_coffee -other_pg seq_reformat -in ${paul_listfile}.prog.aln -output fasta_aln > ${outfile}.temp
93
94 # convert headers and upper casing the sequences
95 cat ${outfile}.temp | sed 's/_Cb_8.0//' | sed 's/_//' | perl -ne 'if(/^>/){print}else{print uc($_)}' > $outfile
96
97 # rename/delete temporary files
98 rm -f ${outfile}.temp
99 for template in `cat $templates`
100 do
101 pdb=`echo $template | cut -c1-4`
102 chain=`echo $template | cut -c5`
103 graphfile="${tempdir}/${pdb}${chain}_${ct}_${d}.cm"
104 rm -f $graphfile $graphfile.seq
105 done
106 rm -f $paul_listfile $paul_seqfile $tempdir/$basename.paul.*
107
108
109 echo "Alignment of templates written to $outfile"

Properties

Name Value
svn:executable *