SYNOPSIS autodoals [file.fa or file.blc] [no]
if "no" is specified in the command line, the output ill be in black and white.
[dcoop Coms]-> cat autodoals
#!/bin/sh
if [ $1 ]; then file=$1
else echo "Please pick a .fa or .blc file. These are available:"
echo ; ls *.fa *.blc; echo ; echo -n "Which one? " ;read file
fi
if [ $2 = "no" ]; then color=no; else color=yes; fi
name=`echo $file |awk -F . '{print ($1)}'`
ext=`echo $file |awk -F . '{print ($NF)}'`
if [ $ext == "fa" ] ; then
clustalw -align -outorder=input -infile=$file -output=gcg
msf2blc -q < $name.msf > tEmP
sed '/iteration/,/endoffile/ s/\./ /g' tEmP > $name.blc
rm -f tEmP
fi
#Use this section to describe what goes on what line
nb=2 # number of lines before sequences
na=5 # number of lines after sequences
gap=. # Gap character
indent=6 # Indent width
# Necessary Calculations -- no changes should be necessary
ns=`grep -c ">" $name.blc` # number of seqs
fs=`expr $nb + 1` # line of first sequence
ls=`expr $nb + $ns` # line of last sequence
ab=`grep -n "*" $name.blc |head -1 |awk -F ":" '{print $1}'`
ae=`grep -n "*" $name.blc |tail -1 |awk -F ":" '{print $1}'`
loa=`expr $ae - $ab - 1` #Length of alignment
#nc defines the percentage of conservation
nc=`expr $ns \* 6 / 10`
#Generate Alscript Input
cat << end-als > temp.als
#Comments in ALscript command files start with a #
#Commands are free format - separated by blank, tab or comma characters
#But no blank lines. Blank lines must have a comment character #
#
BLOCK_FILE $name.blc
OUTPUT_FILE $name.ps
PORTRAIT
#LANDSCAPE
# MAX_SIDE 8.3
POINTSIZE 7
DEFINE_FONT 0 Helvetica DEFAULT
DEFINE_FONT 1 Helvetica-Bold DEFAULT
DEFINE_FONT 2 Helvetica REL .2
DEFINE_FONT 3 Symbol REL 1.2
DEFINE_FONT 4 Courier-Bold DEFAULT
IDENT_WIDTH $indent
ADD_SEQ 0 $nb
ADD_SEQ $ns $na
SINGLE_PAGE
bw#DEFINE_COLOUR 1 .2 .2 .2
bw#DEFINE_COLOUR 2 .4 .4 .4
bw#DEFINE_COLOUR 3 .8 .8 .8
col#DEFINE_COLOUR 1 1 0 0
col#DEFINE_COLOUR 2 0 0 1
col#DEFINE_COLOUR 3 0 1 0
col#DEFINE_COLOUR 4 0 1 1
col#DEFINE_COLOUR 5 1 0 1
col#DEFINE_COLOUR 6 1 .4 .4
col#DEFINE_COLOUR 7 .4 .4 1
col#DEFINE_COLOUR 8 .4 1 .4
# NUMBER_SEQS
DO_TICKS
# NO_NUMBERS
SETUP #Tell the program to get on with the formatting.
ID_FONT ALL 4
FONT_REGION ALL 1
FONT_REGION 1 $fs $loa $ls 0
RELATIVE_TO $fs 1 #assumes your sequence on top
#
#Mask for conservative substitution
#Calculate Mask
# Next line assumes your sequence is on top of the alignment
RELATIVE_TO 0
SUB_CHARS 1 $fs $loa $ls SPACE "$gap"
# Mask for conserved
calcons 1 $fs $loa $ls
#Draw Mask --
# Black text with green background
#Last number on next line is % conserved (times ten) for conservative sub
mask SETUP
mask CONSERVATION 1 $fs $loa $ls 6
mask CCOL 1 $fs $loa $ls 100
mask FONT 1 $fs $loa $ls 1
mask SCOL 1 $fs $loa $ls 3
mask RESET
#
#This mask is for X % IDENTICAL
# White text on blue background
# X is defined by nc above
#Last number on next line is #/total seqs for conserved
mask SETUP
mask ILLEGAL "$gap"
mask ID 1 $fs $loa $ls $nc
mask SCOL 1 $fs $loa $ls 2
mask CCOL 1 $fs $loa $ls 99
mask FONT 1 $fs $loa $ls 1
mask RESET
#Mask for total identity
mask CONSERVATION 1 $fs $loa $ls 10
col#mask SCOL 1 $fs $loa $ls 1
bw#mask SCOL 1 $fs $loa $ls 100
mask CCOL 1 $fs $loa $ls 99
# mask FONT 1 $fs $loa $ls 1
mask RESET
# End of Alscript input file
end-als
if [ $color == "yes" ] ; then grep -v "bw#" temp.als | sed 's/col#/ /g' > $name.als
else grep -v "col#" temp.als | sed 's/bw#/ /g' > $name.als
fi
alscript $name.als > $name.ps
kghostview $name.ps &
#gs -dBATCH -dNOPAUSE -sDEVICE=jpeg -sOutputFile=$name.jpg -r100 $name.ps