5 myself=`dirname "$0"`/`basename "$0"`; export myself
6 version="v6.857b (2011/05/30)"; export version
9 progname=`basename "$0"`
10 if [ `echo $os | grep -i cygwin` ]; then
12 elif [ `echo $os | grep -i darwin` ]; then
14 elif [ `echo $os | grep -i sunos` ]; then
16 elif [ `echo $os | grep -i linux` ]; then
23 if [ "$MAFFT_BINARIES" ]; then
24 prefix="$MAFFT_BINARIES"
31 if [ "$1" = "--man" ]; then
37 if [ ! -x "$prefix/tbfast" ]; then
39 echo "correctly installed?" 1>&2
40 echo "mafft binaries have to be installed in \$MAFFT_BINARIES" 1>&2
41 echo "or the $prefix directory". 1>&2
56 defaultdistance="sixtuples"
57 #defaultdistance="local"
65 defaultsbstmodel=" -b 62 "
68 if [ $progname = "xinsi" -o $progname = "mafft-xinsi" ]; then
72 defaultdistance="scarna"
79 defaultalgoptit=" -AB " ## chui
81 defaultsbstmodel=" -b 62 "
84 elif [ $progname = "qinsi" -o $progname = "mafft-qinsi" ]; then
88 defaultdistance="global"
95 defaultalgoptit=" -AB " ## chui
97 defaultsbstmodel=" -b 62 "
100 elif [ $progname = "linsi" -o $progname = "mafft-linsi" ]; then
104 defaultdistance="local"
105 elif [ $progname = "ginsi" -o $progname = "mafft-ginsi" ]; then
109 defaultdistance="global"
110 elif [ $progname = "einsi" -o $progname = "mafft-einsi" ]; then
114 defaultdistance="localgenaf"
115 elif [ $progname = "fftns" -o $progname = "mafft-fftns" ]; then
118 defaultdistance="sixtuples"
119 elif [ $progname = "fftnsi" -o $progname = "mafft-fftnsi" ]; then
123 defaultdistance="sixtuples"
124 elif [ $progname = "nwns" -o $progname = "mafft-nwns" ]; then
127 defaultdistance="sixtuples"
128 elif [ $progname = "nwnsi" -o $progname = "mafft-nwnsi" ]; then
132 defaultdistance="sixtuples"
137 parallelizationstrategy="BAATARI2"
139 sbstmodel=$defaultsbstmodel
140 fmodel=$defaultfmodel
144 iterate=$defaultiterate
147 distance=$defaultdistance
164 weighti=$defaultweighti
165 weightr=$defaultweightr
166 weightm=$defaultweightm
168 mccaskill=$defaultmccaskill
169 contrafold=$defaultcontrafold
173 algopt=$defaultalgopt
174 algoptit=$defaultalgoptit
194 seedfiles="/dev/null"
195 seedtablefile="/dev/null"
197 treeinfile="/dev/null"
199 laraparams="/dev/null"
208 if [ $# -gt 0 ]; then
211 if [ "$1" = "--auto" ]; then
213 elif [ "$1" = "--anysymbol" ]; then
215 elif [ "$1" = "--preservecase" ]; then
217 elif [ "$1" = "--clustalout" ]; then
218 outputformat="clustal"
219 elif [ "$1" = "--phylipout" ]; then
220 outputformat="phylip"
221 elif [ "$1" = "--reorder" ]; then
224 elif [ "$1" = "--inputorder" ]; then
227 elif [ "$1" = "--unweight" ]; then
229 elif [ "$1" = "--algq" ]; then
232 elif [ "$1" = "--namelength" ]; then
234 namelength=`expr "$1" - 0`
235 elif [ "$1" = "--groupsize" ]; then
237 groupsize=`expr "$1" - 0`
238 elif [ "$1" = "--partsize" ]; then
240 partsize=`expr "$1" - 0`
241 elif [ "$1" = "--parttree" ]; then
244 elif [ "$1" = "--dpparttree" ]; then
246 partdist="localalign"
247 elif [ "$1" = "--fastaparttree" ]; then
250 elif [ "$1" = "--treeout" ]; then
252 elif [ "$1" = "--distout" ]; then
254 elif [ "$1" = "--fastswpair" ]; then
257 elif [ "$1" = "--fastapair" ]; then
260 elif [ "$1" = "--averagelinkage" ]; then
262 elif [ "$1" = "--minimumlinkage" ]; then
264 elif [ "$1" = "--noscore" ]; then
266 elif [ "$1" = "--6merpair" ]; then
268 elif [ "$1" = "--blastpair" ]; then
270 elif [ "$1" = "--globalpair" ]; then
272 elif [ "$1" = "--localpair" ]; then
274 elif [ "$1" = "--scarnapair" ]; then
276 elif [ "$1" = "--larapair" ]; then
278 elif [ "$1" = "--slarapair" ]; then
280 elif [ "$1" = "--foldalignpair" ]; then
281 distance="foldalignlocal"
282 elif [ "$1" = "--foldalignlocalpair" ]; then
283 distance="foldalignlocal"
284 elif [ "$1" = "--foldalignglobalpair" ]; then
285 distance="foldalignglobal"
286 elif [ "$1" = "--globalgenafpair" ]; then
287 distance="globalgenaf"
288 elif [ "$1" = "--localgenafpair" ]; then
289 distance="localgenaf"
290 elif [ "$1" = "--genafpair" ]; then
291 distance="localgenaf"
292 elif [ "$1" = "--memsave" ]; then
293 memopt=" -M -B " # -B (bunkatsunashi no riyu ga omoidasenai)
294 elif [ "$1" = "--nomemsave" ]; then
296 elif [ "$1" = "--nuc" ]; then
298 elif [ "$1" = "--amino" ]; then
300 elif [ "$1" = "--fft" ]; then
303 elif [ "$1" = "--nofft" ]; then
305 elif [ "$1" = "--quiet" ]; then
307 elif [ "$1" = "--debug" ]; then
309 elif [ "$1" = "--coreext" ]; then
311 elif [ "$1" = "--core" ]; then
313 elif [ "$1" = "--out" ]; then
316 elif [ "$1" = "--thread" ]; then
318 numthreads=`expr "$1" - 0`
319 elif [ "$1" = "--randomseed" ]; then
321 randomseed=`expr "$1" - 0`
322 elif [ "$1" = "--bestfirst" ]; then
323 parallelizationstrategy="BESTFIRST"
324 elif [ "$1" = "--adhoc0" ]; then
325 parallelizationstrategy="BAATARI0"
326 elif [ "$1" = "--adhoc1" ]; then
327 parallelizationstrategy="BAATARI1"
328 elif [ "$1" = "--adhoc2" ]; then
329 parallelizationstrategy="BAATARI2"
330 elif [ "$1" = "--simplehillclimbing" ]; then
331 parallelizationstrategy="BAATARI2"
332 elif [ "$1" = "--scoreout" ]; then
334 elif [ "$1" = "--outnum" ]; then
336 elif [ "$1" = "--addprofile" ]; then
340 elif [ "$1" = "--add" ]; then
344 elif [ "$1" = "--maxiterate" ]; then
346 iterate=`expr "$1" - 0`
347 elif [ "$1" = "--retree" ]; then
349 cycle=`expr "$1" - 0`
350 elif [ "$1" = "--aamatrix" ]; then
354 elif [ "$1" = "--treein" ]; then
359 elif [ "$1" = "--topin" ]; then
364 echo "The --topin option has been disabled." 1>&2
365 echo "There was a bug in version < 6.530." 1>&2
366 echo "This bug has not yet been fixed." 1>&2
368 elif [ "$1" = "--kappa" ]; then
371 elif [ "$1" = "--fmodel" ]; then
373 elif [ "$1" = "--jtt" ]; then
376 elif [ "$1" = "--kimura" ]; then
379 elif [ "$1" = "--tm" ]; then
382 elif [ "$1" = "--bl" ]; then
385 elif [ "$1" = "--weighti" ]; then
388 elif [ "$1" = "--weightr" ]; then
391 elif [ "$1" = "--weightm" ]; then
394 elif [ "$1" = "--rnaalifold" ]; then
396 elif [ "$1" = "--mccaskill" ]; then
399 elif [ "$1" = "--contrafold" ]; then
402 elif [ "$1" = "--ribosum" ]; then
404 elif [ "$1" = "--op" ]; then
407 elif [ "$1" = "--ep" ]; then
410 elif [ "$1" = "--rop" ]; then
413 elif [ "$1" = "--rep" ]; then
416 elif [ "$1" = "--lop" ]; then
419 elif [ "$1" = "--LOP" ]; then
422 elif [ "$1" = "--lep" ]; then
425 elif [ "$1" = "--lexp" ]; then
428 elif [ "$1" = "--LEXP" ]; then
431 elif [ "$1" = "--GEXP" ]; then
434 elif [ "$1" = "--GOP" ]; then
437 elif [ "$1" = "--gop" ]; then
440 elif [ "$1" = "--gep" ]; then
443 elif [ "$1" = "--gexp" ]; then
446 elif [ "$1" = "--laraparams" ]; then
449 elif [ "$1" = "--corethr" ]; then
452 elif [ "$1" = "--corewin" ]; then
455 elif [ "$1" = "--seedtable" ]; then
459 elif [ "$1" = "--seed" ]; then
462 seedfiles="$seedfiles $1"
463 elif [ $progname = "fftns" -o $progname = "nwns" ]; then
464 if [ "$1" -gt 0 ]; then
465 cycle=`expr "$1" - 0`
468 echo "Unknown option: $1" 1>&2
476 # TMPFILE=/tmp/$progname.$$
477 TMPFILE=`mktemp -dt $progname.XXXXXXXXXX`
478 if [ $? -ne 0 ]; then
479 echo "mktemp seems to be obsolete. Re-trying without -t" 1>&2
480 TMPFILE=`mktemp -d /tmp/$progname.XXXXXXXXXX`
483 # mkdir $TMPFILE || er=1
484 if [ $debug -eq 1 ]; then
485 trap "tar cfvz debuginfo.tgz $TMPFILE; rm -rf $TMPFILE " 0
487 trap "rm -rf $TMPFILE " 0
489 if [ $# -eq 1 ]; then
490 if [ -r "$1" -o "$1" = - ]; then
492 if [ -r "$addfile" ]; then
495 echo "$0": Cannot open "$addfile". 1>&2
499 cat "$1" | tr "\r" "\n" > $TMPFILE/infile
500 echo "" >> $TMPFILE/infile
501 cat "$addfile" | tr "\r" "\n" | grep -v "^$" >> $TMPFILE/infile
502 cat "$addfile" | tr "\r" "\n" | grep -v "^$" > $TMPFILE/_addfile
503 cat "$aamatrix" | tr "\r" "\n" | grep -v "^$" > $TMPFILE/_aamtx
504 cat "$treeinfile" | tr "\r" "\n" | grep -v "^$" > $TMPFILE/_guidetree
505 cat "$seedtablefile" | tr "\r" "\n" | grep -v "^$" > $TMPFILE/_seedtablefile
506 cat "$laraparams" | tr "\r" "\n" | grep -v "^$" > $TMPFILE/_lara.params
509 seedfilesintmp="/dev/null"
511 set $seedfiles > /dev/null
516 cat "$1" | tr "\r" "\n" > $TMPFILE/seed$#
518 echo "$0": Cannot open "$1". 1>&2
521 seednseq=$seednseq" "`grep -c '^[>|=]' $TMPFILE/seed$#`
522 seedfilesintmp=$seedfilesintmp" "seed$#
525 # echo $seedfilesintmp
530 echo "$0": Cannot open "$1". 1>&2
540 if [ $os != "linux" ]; then
544 if [ $numthreads -eq 0 -a $parallelizationstrategy = "BESTFIRST" ]; then
545 echo 'Impossible' 1>&2;
549 if [ $auto -eq 1 ]; then
550 "$prefix/countlen" < $TMPFILE/infile > $TMPFILE/size
551 nseq=`awk '{print $1}' $TMPFILE/size`
552 nlen=`awk '{print $3}' $TMPFILE/size`
553 if [ $nlen -lt 2000 -a $nseq -lt 100 ]; then
556 elif [ $nlen -lt 10000 -a $nseq -lt 500 ]; then
563 if [ $quiet -eq 0 ]; then
564 echo "nseq = " $nseq 1>&2
565 echo "nlen = " $nlen 1>&2
566 echo "distance = " $distance 1>&2
567 echo "iterate = " $iterate 1>&2
571 if [ $parallelizationstrategy = "BESTFIRST" -o $parallelizationstrategy = "BAATARI0" ]; then
576 if [ $iterate -gt $iteratelimit ]; then #??
577 iterate=$iteratelimit
580 if [ $rnaalifold -eq 1 ]; then
581 rnaopt=" -e $rgep -o $rgop -c $weightm -r $weightr -R $rnascoremtx "
582 # rnaoptit=" -o $rgop -BT -c $weightm -r $weightr -R "
583 rnaoptit=" -o $rgop -F -c $weightm -r $weightr -R "
584 elif [ $mccaskill -eq 1 -o $contrafold -eq 1 ]; then
585 rnaopt=" -o $rgop -c $weightm -r $weightr "
586 # rnaoptit=" -e $rgep -o $rgop -BT -c $weightm -r $weightr $rnascoremtx "
587 rnaoptit=" -e $rgep -o $rgop -F -c $weightm -r $weightr $rnascoremtx "
593 model="$sbstmodel $kappa $fmodel"
595 if [ $er -eq 1 ]; then
596 echo "------------------------------------------------------------------------------" 1>&2
597 echo " MAFFT" $version 1>&2
599 # echo " Input format: fasta" 1>&2
601 # echo " Usage: `basename $0` [options] inputfile > outputfile" 1>&2
602 echo " http://mafft.cbrc.jp/alignment/software/" 1>&2
603 echo " NAR 30:3059-3066 (2002), Briefings in Bioinformatics 9:286-298 (2008)" 1>&2
604 # echo "------------------------------------------------------------------------------" 1>&2
605 # echo " % mafft in > out" 1>&2
606 echo "------------------------------------------------------------------------------" 1>&2
608 echo "High speed:" 1>&2
609 echo " % mafft in > out" 1>&2
610 echo " % mafft --retree 1 in > out (fast)" 1>&2
612 echo "High accuracy (for <~200 sequences x <~2,000 aa/nt):" 1>&2
613 echo " % mafft --maxiterate 1000 --localpair in > out (% linsi in > out is also ok)" 1>&2
614 echo " % mafft --maxiterate 1000 --genafpair in > out (% einsi in > out)" 1>&2
615 echo " % mafft --maxiterate 1000 --globalpair in > out (% ginsi in > out)" 1>&2
617 echo "If unsure which option to use:" 1>&2
618 echo " % mafft --auto in > out" 1>&2
620 # echo "Other options:" 1>&2
621 echo "--op # : Gap opening penalty, default: 1.53" 1>&2
622 echo "--ep # : Offset (works like gap extension penalty), default: 0.0" 1>&2
623 echo "--maxiterate # : Maximum number of iterative refinement, default: 0" 1>&2
624 echo "--clustalout : Output: clustal format, default: fasta" 1>&2
625 echo "--reorder : Outorder: aligned, default: input order" 1>&2
626 echo "--quiet : Do not report progress" 1>&2
627 echo "--thread # : Number of threads. (# must be <= number of physical cores - 1)" 1>&2
629 # echo " % mafft --maxiterate 1000 --localpair in > out (L-INS-i)" 1>&2
630 # echo " most accurate in many cases, assumes only one alignable domain" 1>&2
632 # echo " % mafft --maxiterate 1000 --genafpair in > out (E-INS-i)" 1>&2
633 # echo " works well if many unalignable residues exist between alignable domains" 1>&2
635 # echo " % mafft --maxiterate 1000 --globalpair in > out (G-INS-i)" 1>&2
636 # echo " suitable for globally alignable sequences " 1>&2
638 # echo " % mafft --maxiterate 1000 in > out (FFT-NS-i)" 1>&2
639 # echo " accurate and slow, iterative refinement method " 1>&2
641 # echo "If the input sequences are long (~1,000,000nt)," 1>&2
642 # echo " % mafft --retree 1 --memsave --fft in > out (FFT-NS-1-memsave, new in v5.8)" 1>&2
644 # echo "If many (~5,000) sequences are to be aligned," 1>&2
646 # echo " % mafft --retree 1 [--memsave] --nofft in > out (NW-NS-1, new in v5.8)" 1>&2
648 # echo " --localpair : All pairwise local alignment information is included" 1>&2
649 # echo " to the objective function, default: off" 1>&2
650 # echo " --globalpair : All pairwise global alignment information is included" 1>&2
651 # echo " to the objective function, default: off" 1>&2
652 # echo " --op # : Gap opening penalty, default: $defaultgop " 1>&2
653 # echo " --ep # : Offset (works like gap extension penalty), default: $defaultaof " 1>&2
654 # echo " --bl #, --jtt # : Scoring matrix, default: BLOSUM62" 1>&2
655 # echo " Alternatives are BLOSUM (--bl) 30, 45, 62, 80, " 1>&2
656 # echo " or JTT (--jtt) # PAM. " 1>&2
657 # echo " --nuc or --amino : Sequence type, default: auto" 1>&2
658 # echo " --retree # : The number of tree building in progressive method " 1>&2
659 # echo " (see the paper for detail), default: $defaultcycle " 1>&2
660 # echo " --maxiterate # : Maximum number of iterative refinement, default: $defaultiterate " 1>&2
661 # if [ $defaultfft -eq 1 ]; then
662 # echo " --fft or --nofft: FFT is enabled or disabled, default: enabled" 1>&2
664 # echo " --fft or --nofft: FFT is enabled or disabled, default: disabled" 1>&2
666 # echo " --memsave: Memory saving mode" 1>&2
667 # echo " (for long genomic sequences), default: off" 1>&2
668 # echo " --clustalout : Output: clustal format, default: fasta" 1>&2
669 # echo " --reorder : Outorder: aligned, default: input order" 1>&2
670 # echo " --quiet : Do not report progress" 1>&2
671 # echo "-----------------------------------------------------------------------------" 1>&2
674 if [ $sw -eq 1 ]; then
680 if [ $distance = "fasta" -o $partdist = "fasta" ]; then
681 if [ ! "$FASTA_4_MAFFT" ]; then
682 FASTA_4_MAFFT=`which fasta34`
685 if [ ! -x "$FASTA_4_MAFFT" ]; then
687 echo "== Install FASTA ========================================================" 1>&2
688 echo "This option requires the fasta34 program (FASTA version x.xx or higher)" 1>&2
689 echo "installed in your PATH. If you have the fasta34 program but have renamed" 1>&2
690 echo "(like /usr/local/bin/myfasta), set the FASTA_4_MAFFT environment variable" 1>&2
691 echo "to point your fasta34 (like setenv FASTA_4_MAFFT /usr/local/bin/myfasta)." 1>&2
692 echo "=========================================================================" 1>&2
697 if [ $distance = "lara" -o $distance = "slara" ]; then
698 if [ ! -x "$prefix/mafft_lara" ]; then
700 echo "== Install LaRA =========================================================" 1>&2
701 echo "This option requires LaRA (Bauer et al. http://www.planet-lisa.net/)." 1>&2
702 echo "The executable have to be renamed to 'mafft_lara' and installed into " 1>&2
703 echo "the $prefix directory. " 1>&2
704 echo "A configuration file of LaRA also have to be given" 1>&2
705 echo "mafft-xinsi --larapair --laraparams parameter_file" 1>&2
706 echo "mafft-xinsi --slarapair --laraparams parameter_file" 1>&2
707 echo "=========================================================================" 1>&2
711 if [ ! -s "$laraparams" ]; then
713 echo "== Configure LaRA =======================================================" 1>&2
714 echo "A configuration file of LaRA have to be given" 1>&2
715 echo "mafft-xinsi --larapair --laraparams parameter_file" 1>&2
716 echo "mafft-xinsi --slarapair --laraparams parameter_file" 1>&2
717 echo "=========================================================================" 1>&2
722 if [ $distance = "foldalignlocal" -o $distance = "foldalignglobal" ]; then
723 if [ ! -x "$prefix/foldalign210" ]; then
725 echo "== Install FOLDALIGN ====================================================" 1>&2
726 echo "This option requires FOLDALIGN (Havgaard et al. http://foldalign.ku.dk/)." 1>&2
727 echo "The executable have to be renamed to 'foldalign210' and installed into " 1>&2
728 echo "the $prefix directory. " 1>&2
729 echo "=========================================================================" 1>&2
734 if [ $distance = "scarna" ]; then
735 if [ ! -x "$prefix/mxscarnamod" ]; then
737 echo "== Install MXSCARNA ======================================================" 1>&2
738 echo "MXSCARNA (Tabei et al. BMC Bioinformatics 2008 9:33) is required." 1>&2
739 echo "Please 'make' at the 'extensions' directory of the MAFFT source package," 1>&2
740 echo "which contains the modified version of MXSCARNA." 1>&2
741 echo "http://align.bmr.kyushu-u.ac.jp/mafft/software/source.html " 1>&2
742 echo "==========================================================================" 1>&2
747 if [ $mccaskill -eq 1 ]; then
748 if [ ! -x "$prefix/mxscarnamod" ]; then
750 echo "== Install MXSCARNA ======================================================" 1>&2
751 echo "MXSCARNA (Tabei et al. BMC Bioinformatics 2008 9:33) is required." 1>&2
752 echo "Please 'make' at the 'extensions' directory of the MAFFT source package," 1>&2
753 echo "which contains the modified version of MXSCARNA." 1>&2
754 echo "http://align.bmr.kyushu-u.ac.jp/mafft/software/source.html " 1>&2
755 echo "==========================================================================" 1>&2
760 if [ $contrafold -eq 1 ]; then
761 if [ ! -x "$prefix/contrafold" ]; then
763 echo "== Install CONTRAfold ===================================================" 1>&2
764 echo "This option requires CONTRAfold" 1>&2
765 echo "(Do et al. http://contra.stanford.edu/contrafold/)." 1>&2
766 echo "The executable 'contrafold' have to be installed into " 1>&2
767 echo "the $prefix directory. " 1>&2
768 echo "=========================================================================" 1>&2
775 # if [ $treeout -eq 1 ]; then
776 # parttreeoutopt="-t"
777 # if [ $cycle -eq 0 ]; then
781 # if [ $distance = "global" -o $distance = "local" -o $distance = "localgenaf" -o $distance = "globalgenaf" ]; then
782 # distance="distonly"
789 # if [ $cycle -eq 0 ]; then
792 # if [ $distance = "global" -o $distance = "local" -o $distance = "localgenaf" -o $distance = "globalgenaf" ]; then
793 # distance="distonly"
801 if [ $cycle -eq 0 ]; then
804 if [ $distance = "global" -o $distance = "local" -o $distance = "localgenaf" -o $distance = "globalgenaf" ]; then
807 if [ $treeout -eq 1 ]; then
813 if [ $distout -eq 1 ]; then
817 if [ $treeout -eq 1 ]; then
824 if [ $distout -eq 1 ]; then
830 formatcheck=`grep -c '^[[:blank:]]\+>' $TMPFILE/infile | head -1 `
831 if [ $formatcheck -gt 0 ]; then
832 echo "The first character of a description line must be " 1>&2
833 echo "the greater-than (>) symbol, not a blank." 1>&2
834 echo "Please check the format around the following line(s):" 1>&2
835 grep -n '^[[:blank:]]\+>' $TMPFILE/infile 1>&2
839 nseq=`grep -c '^[>|=]' $TMPFILE/infile | head -1 `
840 if [ $nseq -eq 2 ]; then
843 if [ $cycle -gt 3 ]; then
847 if [ $nseq -gt 4000 -a $iterate -gt 1 ]; then
848 echo "Too many sequences to perform iterative refinement!" 1>&2
849 echo "Please use a progressive method." 1>&2
854 if [ $distance = "sixtuples" -a \( $seed = "x" -a $seedtable = "x" \) ]; then
856 elif [ $distance = "sixtuples" -a \( $seed != "x" -o $seedtable != "x" \) ]; then
857 if [ $cycle -lt 2 ]; then
860 if [ $iterate -lt 2 ]; then
861 echo "############################################################################" 1>&2
862 echo "# Warning:" 1>&2
863 echo "# Progressive alignment method is incompatible with the --seed option." 1>&2
864 echo "# Automatically switched to the iterative refinement method." 1>&2
866 echo "# Also consider using the '--add' option, which is compatible with" 1>&2
867 echo "# the progressive method and FASTER than the '--seed' option." 1>&2
868 echo "# Usage is:" 1>&2
869 echo "# % mafft --add newSequences existingAlignment > output" 1>&2
870 echo "############################################################################" 1>&2
873 localparam="-l "$weighti
874 elif [ $distance = "parttree" ]; then
876 if [ $groupsize -gt -1 ]; then
880 localparam=" -l "$weighti
881 if [ $cycle -gt 1 ]; then # 09/01/08
886 if [ $distance = "localgenaf" -o $distance = "globalgenaf" ]; then
890 if [ "$memopt" = " -M -B " -a "$distance" != "sixtuples" ]; then
891 echo "Impossible" 1>&2
896 if [ $distance = "parttree" ]; then
897 if [ $seed != "x" -o $seedtable != "x" ]; then
898 echo "Impossible" 1>&2
901 if [ $iterate -gt 1 ]; then
902 echo "Impossible" 1>&2
905 if [ $outorder = "aligned" ]; then
908 outorder="input" # partorder ga kiku
909 if [ $partdist = "localalign" ]; then
910 splitopt=" -L " # -L -l -> fast
911 elif [ $partdist = "fasta" ]; then
919 # if [ $nseq -gt 5000 ]; then
922 if [ $forcefft -eq 1 ]; then
925 elif [ $fft -eq 1 ]; then
931 if [ $seed != "x" -a $seedtable != "x" ]; then
932 echo 'Use either one of seedtable and seed. Not both.' 1>&2
935 # if [ $seedtable != "x" -a $anysymbol -gt 0 ]; then
936 # echo 'The combination of --seedtable and --anysymbol is not supported.' 1>&2
940 if [ $treein -eq 1 ]; then
941 # if [ $iterate -gt 0 ]; then
942 # echo 'Not supported yet.' 1>&2
948 if [ "$addarg0" != " " ]; then
949 "$prefix/countlen" < $TMPFILE/_addfile > $TMPFILE/addsize
950 nadd=`awk '{print $1}' $TMPFILE/addsize`
951 if [ $nadd -eq "0" ]; then
952 echo Check $addfile 1>&2
955 addarg="$addarg0 $nadd"
958 if [ $seed != "x" -o $seedtable != "x" ]; then
959 echo 'Impossible' 1>&2;
960 echo 'Use either ONE of --seed, --seedtable, --addprofile and --add.' 1>&2
965 if [ $mccaskill -eq 1 -o $rnaalifold -eq 1 -o $contrafold -eq 1 ]; then
966 if [ $distance = "sixtuples" ]; then
967 echo 'Not supported.' 1>&2
968 echo 'Please add --globalpair, --localpair, --scarnapair,' 1>&2
969 echo '--larapair, --slarapair, --foldalignlocalpair or --foldalignglobalpair' 1>&2
974 if [ $mccaskill -eq 1 -o $rnaalifold -eq 1 -o $contrafold -eq 1 ]; then
975 if [ $distance = "scarna" -o $distance = "lara" -o $distance = "slara" -o $distance = "foldalignlocal" -o $distance = "foldalignglobal" ]; then
977 elif [ $distance = "global" -o $distance = "local" -o $distance = "localgenaf" -o "globalgenaf" ]; then
980 elif [ $distance = "fasta" -a $sw -eq 0 ]; then
982 elif [ $distance = "fasta" -a $sw -eq 1 ]; then
984 elif [ $distance = "blast" ]; then
986 elif [ $distance = "global" -o $distance = "distonly" ]; then
988 elif [ $distance = "local" ]; then
990 elif [ $distance = "localgenaf" ]; then
992 elif [ $distance = "globalgenaf" ]; then
994 elif [ $fft -eq 1 ]; then
999 strategy=$strategy"NS-"
1000 if [ $iterate -gt 0 ]; then
1001 strategy=$strategy"i"
1002 elif [ $distance = "parttree" ]; then
1003 if [ $partdist = "fasta" ]; then
1004 strategy=$strategy"FastaPartTree-"$cycle
1005 elif [ $partdist = "localalign" ]; then
1006 strategy=$strategy"DPPartTree-"$cycle
1008 strategy=$strategy"PartTree-"$cycle
1011 strategy=$strategy$cycle
1015 performance='Not tested.'
1016 if [ $strategy = "F-INS-i" ]; then
1017 explanation='Iterative refinement method (<'$iterate') with LOCAL pairwise alignment information'
1018 performance='Most accurate, but very slow'
1019 elif [ $strategy = "L-INS-i" ]; then
1020 explanation='Iterative refinement method (<'$iterate') with LOCAL pairwise alignment information'
1021 performance='Probably most accurate, very slow'
1022 elif [ $strategy = "E-INS-i" ]; then
1023 explanation='Iterative refinement method (<'$iterate') with LOCAL pairwise alignment with generalized affine gap costs (Altschul 1998)'
1024 performance='Suitable for sequences with long unalignable regions, very slow'
1025 elif [ $strategy = "G-INS-i" ]; then
1026 explanation='Iterative refinement method (<'$iterate') with GLOBAL pairwise alignment information'
1027 performance='Suitable for sequences of similar lengths, very slow'
1028 elif [ $strategy = "X-INS-i" ]; then
1029 explanation='RNA secondary structure information is taken into account.'
1030 performance='For short RNA sequences only, extremely slow'
1031 elif [ $strategy = "F-INS-1" ]; then
1032 explanation='Progressive method incorporating LOCAL pairwise alignment information'
1033 elif [ $strategy = "L-INS-1" ]; then
1034 explanation='Progressive method incorporating LOCAL pairwise alignment information'
1035 elif [ $strategy = "G-INS-1" ]; then
1036 explanation='Progressive method incorporating GLOBAL pairwise alignment information'
1037 elif [ $strategy = "FFT-NS-i" -o $strategy = "NW-NS-i" ]; then
1038 explanation='Iterative refinement method (max. '$iterate' iterations)'
1039 if [ $iterate -gt 2 ]; then
1040 performance='Accurate but slow'
1042 performance='Standard'
1044 elif [ $strategy = "FFT-NS-2" -o $strategy = "NW-NS-2" ]; then
1045 explanation='Progressive method (guide trees were built '$cycle' times.)'
1046 performance='Fast but rough'
1047 elif [ $strategy = "FFT-NS-1" -o $strategy = "NW-NS-1" ]; then
1048 explanation='Progressive method (rough guide tree was used.)'
1049 performance='Very fast but very rough'
1052 if [ $outputformat = "clustal" -a $outorder = "aligned" ]; then
1053 outputopt=" -c $strategy -r $TMPFILE/order "
1054 elif [ $outputformat = "clustal" -a $outorder = "input" ]; then
1055 outputopt=" -c $strategy "
1056 elif [ $outputformat = "phylip" -a $outorder = "aligned" ]; then
1057 outputopt=" -y -r $TMPFILE/order "
1058 elif [ $outputformat = "phylip" -a $outorder = "input" ]; then
1060 elif [ $outputformat = "pir" -a $outorder = "aligned" ]; then
1061 outputopt=" -f -r $TMPFILE/order "
1069 if [ $quiet -gt 0 ]; then
1071 if [ $anysymbol -eq 1 ]; then
1073 "$prefix/replaceu" -i orig > infile 2>/dev/null || exit 1
1076 if [ $seed != "x" ]; then
1078 if [ $anysymbol -eq 1 ]; then
1080 cat /dev/null > orig
1082 cat /dev/null > infile
1083 cat /dev/null > hat3.seed
1085 # echo "seednseq="$seednseq
1086 # echo "seedoffset="$seedoffset
1087 set $seednseq > /dev/null
1094 if [ $anysymbol -eq 1 ]; then
1096 "$prefix/replaceu" -i seed$# -o $seedoffset > clean 2>/dev/null || exit 1
1099 "$prefix/multi2hat3s" -t $nseq -o $seedoffset -i seed$# >> infile 2>/dev/null || exit 1
1100 cat hat3 >> hat3.seed
1102 seedoffset=`expr $seedoffset + $1`
1104 # echo "seedoffset="$seedoffset
1106 # echo "seedoffset="$seedoffset
1107 if [ $anysymbol -eq 1 ]; then
1108 "$prefix/replaceu" -i orig2 -o $seedoffset >> infile 2>/dev/null || exit 1 # yarinaoshi
1111 cat infile2 >> infile
1113 elif [ $seedtable != "x" ]; then
1114 cat _seedtablefile > hat3.seed
1116 cat /dev/null > hat3.seed
1121 if [ $mccaskill -eq 1 ]; then
1122 "$prefix/mccaskillwrap" -C $numthreads -d "$prefix" -i infile > hat4 2>/dev/null || exit 1
1123 elif [ $contrafold -eq 1 ]; then
1124 "$prefix/contrafoldwrap" -d "$prefix" -i infile > hat4 2>/dev/null || exit 1
1126 if [ $distance = "fasta" ]; then
1127 "$prefix/dndfast7" $swopt < infile > /dev/null 2>&1 || exit 1
1128 cat hat3.seed hat3 > hatx
1130 "$prefix/tbfast" $outnum $addarg -C $numthreads $rnaopt $weightopt $treeinopt $treeoutopt $distoutopt $seqtype $model -f "-"$gop -h "-"$aof $param_fft $localparam $algopt $treealg $scoreoutarg < infile > /dev/null 2>&1 || exit 1
1131 elif [ $distance = "blast" ]; then
1132 "$prefix/dndblast" < infile > /dev/null 2>&1 || exit 1
1133 cat hat3.seed hat3 > hatx
1135 "$prefix/tbfast" $outnum $addarg -C $numthreads $rnaopt $weightopt $treeinopt $treeoutopt $distoutopt $seqtype $model -f "-"$gop -h "-"$aof $param_fft $localparam $algopt $treealg $scoreoutarg < infile > /dev/null 2>&1 || exit 1
1136 elif [ $distance = "foldalignlocal" ]; then
1137 "$prefix/pairlocalalign" -C $numthreads $seqtype $foldalignopt $model -g $lexp -f $lgop -h $laof -H -d "$prefix" < infile > /dev/null 2>&1 || exit 1
1138 cat hat3.seed hat3 > hatx
1140 "$prefix/tbfast" $outnum $addarg -C $numthreads $rnaopt $weightopt $treeinopt $treeoutopt $distoutopt $seqtype $model -f "-"$gop -h "-"$aof $param_fft $localparam $algopt $treealg $scoreoutarg < infile > /dev/null 2>&1 || exit 1
1141 elif [ $distance = "foldalignglobal" ]; then
1142 "$prefix/pairlocalalign" -C $numthreads $seqtype $foldalignopt $model -g $pgexp -f $pggop -h $pgaof -H -o -global -d "$prefix" < infile > /dev/null 2>&1 || exit 1
1143 cat hat3.seed hat3 > hatx
1145 "$prefix/tbfast" $outnum $addarg -C $numthreads $rnaopt $weightopt $treeinopt $treeoutopt $distoutopt $seqtype $model -f "-"$gop -h "-"$aof $param_fft $localparam $algopt $treealg $scoreoutarg < infile > /dev/null 2>&1 || exit 1
1146 elif [ $distance = "slara" ]; then
1147 "$prefix/pairlocalalign" -C $numthreads -p $laraparams $seqtype $model -f $lgop -T -d "$prefix" < infile > /dev/null 2>&1 || exit 1
1148 cat hat3.seed hat3 > hatx
1150 "$prefix/tbfast" $outnum $addarg -C $numthreads $rnaopt $weightopt $treeinopt $treeoutopt $distoutopt $seqtype $model -f "-"$gop -h "-"$aof $param_fft $localparam $algopt $treealg $scoreoutarg < infile > /dev/null 2>&1 || exit 1
1151 elif [ $distance = "lara" ]; then
1152 "$prefix/pairlocalalign" -C $numthreads -p $laraparams $seqtype $model -f $lgop -B -d "$prefix" < infile > /dev/null 2>&1 || exit 1
1153 cat hat3.seed hat3 > hatx
1155 "$prefix/tbfast" $outnum $addarg -C $numthreads $rnaopt $weightopt $treeinopt $treeoutopt $distoutopt $seqtype $model -f "-"$gop -h "-"$aof $param_fft $localparam $algopt $treealg $scoreoutarg < infile > /dev/null 2>&1 || exit 1
1156 elif [ $distance = "scarna" ]; then
1157 "$prefix/pairlocalalign" -C $numthreads $seqtype $model -f $pggop -s -d "$prefix" < infile > /dev/null 2>&1 || exit 1
1158 cat hat3.seed hat3 > hatx
1160 "$prefix/tbfast" $outnum $addarg -C $numthreads $rnaopt $weightopt $treeinopt $treeoutopt $distoutopt $seqtype $model -f "-"$gop -h "-"$aof $param_fft $localparam $algopt $treealg $scoreoutarg < infile > /dev/null 2>&1 || exit 1
1161 elif [ $distance = "global" ]; then
1162 "$prefix/pairlocalalign" -C $numthreads $seqtype $model -g $pgexp -f $pggop -h $pgaof -F < infile > /dev/null 2>&1 || exit 1
1163 cat hat3.seed hat3 > hatx
1165 "$prefix/tbfast" $outnum $addarg -C $numthreads $rnaopt $weightopt $treeinopt $treeoutopt $distoutopt $seqtype $model -f "-"$gop -h "-"$aof $param_fft $localparam $algopt $treealg $scoreoutarg < infile > /dev/null 2>&1 || exit 1
1166 elif [ $distance = "local" ]; then
1167 "$prefix/pairlocalalign" -C $numthreads $seqtype $model -g $lexp -f $lgop -h $laof -L < infile > /dev/null 2>&1 || exit 1
1168 cat hat3.seed hat3 > hatx
1170 "$prefix/tbfast" $outnum $addarg -C $numthreads $rnaopt $weightopt $treeinopt $treeoutopt $distoutopt $seqtype $model -f "-"$gop -h "-"$aof $param_fft $localparam $algopt $treealg $scoreoutarg < infile > /dev/null 2>&1 || exit 1
1171 elif [ $distance = "globalgenaf" ]; then
1172 "$prefix/pairlocalalign" -C $numthreads $seqtype $model -g $pgexp -f $pggop -h $pgaof -O $GGOP -E $GEXP -K < infile > /dev/null 2>&1 || exit 1
1173 cat hat3.seed hat3 > hatx
1175 "$prefix/tbfast" $outnum $addarg -C $numthreads $rnaopt $weightopt $treeinopt $treeoutopt $distoutopt $seqtype $model -f "-"$gop -h "-"$aof $param_fft $localparam $algopt $treealg $scoreoutarg < infile > /dev/null 2>&1 || exit 1
1176 elif [ $distance = "localgenaf" ]; then
1177 "$prefix/pairlocalalign" -C $numthreads $seqtype $model -g $lexp -f $lgop -h $laof -O $LGOP -E $LEXP -N < infile > /dev/null 2>&1 || exit 1
1178 cat hat3.seed hat3 > hatx
1180 "$prefix/tbfast" $outnum $addarg -C $numthreads $rnaopt $weightopt $treeinopt $treeoutopt $distoutopt $seqtype $model -f "-"$gop -h "-"$aof $param_fft $localparam $algopt $treealg $scoreoutarg < infile > /dev/null 2>&1 || exit 1
1181 elif [ $distance = "distonly" ]; then
1182 "$prefix/pairlocalalign" -C $numthreads $seqtype $model -g $pgexp -f $pggop -h $pgaof -t < infile > /dev/null 2>&1 || exit 1
1183 "$prefix/tbfast" $outnum $addarg -C $numthreads $rnaopt $weightopt $treeinopt $treeoutopt $distoutopt $seqtype $model -f "-"$gop -h "-"$aof $param_fft $localparam $algopt $treealg $scoreoutarg < infile > /dev/null 2>&1 || exit 1
1184 elif [ $distance = "parttree" ]; then
1185 "$prefix/splittbfast" -Q $splitopt $partorderopt $parttreeoutopt $seqtype $model -f "-"$gop -h "-"$aof $param_fft -p $partsize -s $groupsize $treealg -i infile > pre 2>/dev/null || exit 1
1188 "$prefix/disttbfast" -O $outnum $addarg -C $numthreads $memopt $weightopt $treeinopt $treeoutopt $distoutopt $seqtype $model -f "-"$gop -h "-"$aof $param_fft $algopt $treealg $scoreoutarg < infile > pre 2>/dev/null || exit 1
1191 while [ $cycle -gt 1 ]
1193 if [ $distance = "parttree" ]; then
1195 "$prefix/splittbfast" -Z -Q $splitopt $partorderopt $parttreeoutopt $memopt $seqtype $model -f "-"$gop -h "-"$aof $param_fft -p $partsize -s $groupsize $treealg -i infile > pre 2>/dev/null || exit 1
1197 "$prefix/tbfast" -O $outnum -C $numthreads $rnaopt $weightopt $treeoutopt $distoutopt $memopt $seqtype $model -f "-"$gop -h "-"$aof $param_fft $localparam $algopt -J $treealg $scoreoutarg < pre > /dev/null 2>&1 || exit 1
1199 cycle=`expr $cycle - 1`
1201 if [ $iterate -gt 0 ]; then
1202 if [ $distance = "sixtuples" ]; then
1203 "$prefix/dndpre" -C $numthreads < pre > /dev/null 2>&1 || exit 1
1205 "$prefix/dvtditr" -C $numthreads -t $randomseed $rnaoptit $memopt $scorecalcopt $localparam -z 50 $seqtype $model -f "-"$gop -h "-"$aof -I $iterate $weightopt $treeinopt $algoptit $treealg -p $parallelizationstrategy $scoreoutarg < pre > /dev/null 2>&1 || exit 1
1209 if [ $anysymbol -eq 1 ]; then
1211 "$prefix/replaceu" -i orig > infile || exit 1
1214 if [ $seed != "x" ]; then
1216 if [ $anysymbol -eq 1 ]; then
1218 cat /dev/null > orig
1220 cat /dev/null > infile
1221 cat /dev/null > hat3.seed
1223 # echo "seednseq="$seednseq
1224 # echo "seedoffset="$seedoffset
1225 set $seednseq > /dev/null
1232 if [ $anysymbol -eq 1 ]; then
1234 "$prefix/replaceu" -i seed$# -o $seedoffset > clean || exit 1
1237 "$prefix/multi2hat3s" -t $nseq -o $seedoffset -i seed$# >> infile || exit 1
1238 cat hat3 >> hat3.seed
1240 seedoffset=`expr $seedoffset + $1`
1242 # echo "seedoffset="$seedoffset
1244 # echo "seedoffset="$seedoffset
1245 if [ $anysymbol -eq 1 ]; then
1246 "$prefix/replaceu" -i orig2 -o $seedoffset >> infile || exit 1 # yarinaoshi
1249 cat infile2 >> infile
1251 elif [ $seedtable != "x" ]; then
1252 cat _seedtablefile > hat3.seed
1254 cat /dev/null > hat3.seed
1258 if [ $mccaskill -eq 1 ]; then
1259 "$prefix/mccaskillwrap" -C $numthreads -d "$prefix" -i infile > hat4 || exit 1
1260 elif [ $contrafold -eq 1 ]; then
1261 "$prefix/contrafoldwrap" -d "$prefix" -i infile > hat4 || exit 1
1263 if [ $distance = "fasta" ]; then
1264 "$prefix/dndfast7" $swopt < infile > /dev/null || exit 1
1265 cat hat3.seed hat3 > hatx
1267 "$prefix/tbfast" $outnum $addarg -C $numthreads $rnaopt $weightopt $treeinopt $treeoutopt $distoutopt $seqtype $model -f "-"$gop -h "-"$aof $param_fft $localparam $algopt $treealg $scoreoutarg < infile > /dev/null || exit 1
1268 elif [ $distance = "blast" ]; then
1269 "$prefix/dndblast" < infile > /dev/null || exit 1
1270 cat hat3.seed hat3 > hatx
1272 "$prefix/tbfast" $outnum $addarg -C $numthreads $rnaopt $weightopt $treeinopt $treeoutopt $distoutopt $seqtype $model -f "-"$gop -h "-"$aof $param_fft $localparam $algopt $treealg $scoreoutarg < infile > /dev/null || exit 1
1273 elif [ $distance = "foldalignlocal" ]; then
1274 "$prefix/pairlocalalign" -C $numthreads $seqtype $foldalignopt $model -g $lexp -f $lgop -h $laof -H -d "$prefix" < infile > /dev/null || exit 1
1275 cat hat3.seed hat3 > hatx
1277 "$prefix/tbfast" $outnum $addarg -C $numthreads $rnaopt $weightopt $treeinopt $treeoutopt $distoutopt $seqtype $model -f "-"$gop -h "-"$aof $param_fft $localparam $algopt $treealg $scoreoutarg < infile > /dev/null 2>&1 || exit 1
1278 elif [ $distance = "foldalignglobal" ]; then
1279 "$prefix/pairlocalalign" -C $numthreads $seqtype $foldalignopt $model -g $pgexp -f $pggop -h $pgaof -H -o -global -d "$prefix" < infile > /dev/null || exit 1
1280 cat hat3.seed hat3 > hatx
1282 "$prefix/tbfast" $outnum $addarg -C $numthreads $rnaopt $weightopt $treeinopt $treeoutopt $distoutopt $seqtype $model -f "-"$gop -h "-"$aof $param_fft $localparam $algopt $treealg $scoreoutarg < infile > /dev/null 2>&1 || exit 1
1283 elif [ $distance = "slara" ]; then
1284 "$prefix/pairlocalalign" -C $numthreads -p $laraparams $seqtype $model -f $lgop -T -d "$prefix" < infile > /dev/null || exit 1
1285 cat hat3.seed hat3 > hatx
1287 "$prefix/tbfast" $outnum $addarg -C $numthreads $rnaopt $weightopt $treeinopt $treeoutopt $distoutopt $seqtype $model -f "-"$gop -h "-"$aof $param_fft $localparam $algopt $treealg $scoreoutarg < infile > /dev/null 2>&1 || exit 1
1288 elif [ $distance = "lara" ]; then
1289 "$prefix/pairlocalalign" -C $numthreads -p $laraparams $seqtype $model -f $lgop -B -d "$prefix" < infile > /dev/null || exit 1
1290 cat hat3.seed hat3 > hatx
1292 "$prefix/tbfast" $outnum $addarg -C $numthreads $rnaopt $weightopt $treeinopt $treeoutopt $distoutopt $seqtype $model -f "-"$gop -h "-"$aof $param_fft $localparam $algopt $treealg $scoreoutarg < infile > /dev/null 2>&1 || exit 1
1293 elif [ $distance = "scarna" ]; then
1294 "$prefix/pairlocalalign" -C $numthreads $seqtype $model -f $pggop -s -d "$prefix" < infile > /dev/null || exit 1
1295 cat hat3.seed hat3 > hatx
1297 "$prefix/tbfast" $outnum $addarg -C $numthreads $rnaopt $weightopt $treeinopt $treeoutopt $distoutopt $seqtype $model -f "-"$gop -h "-"$aof $param_fft $localparam $algopt $treealg $scoreoutarg < infile > /dev/null 2>&1 || exit 1
1298 elif [ $distance = "global" ]; then
1299 "$prefix/pairlocalalign" -C $numthreads $seqtype $model -g $pgexp -f $pggop -h $pgaof -F < infile > /dev/null || exit 1
1300 cat hat3.seed hat3 > hatx
1302 "$prefix/tbfast" $outnum $addarg -C $numthreads $rnaopt $weightopt $treeinopt $treeoutopt $distoutopt $seqtype $model -f "-"$gop -h "-"$aof $param_fft $localparam $algopt $treealg $scoreoutarg < infile > /dev/null || exit 1
1303 elif [ $distance = "local" ]; then
1304 "$prefix/pairlocalalign" -C $numthreads $seqtype $model -g $lexp -f $lgop -h $laof -L < infile > /dev/null || exit 1
1305 cat hat3.seed hat3 > hatx
1307 "$prefix/tbfast" $outnum $addarg -C $numthreads $rnaopt $weightopt $treeinopt $treeoutopt $distoutopt $seqtype $model -f "-"$gop -h "-"$aof $param_fft $localparam $algopt $treealg $scoreoutarg < infile > /dev/null || exit 1
1308 elif [ $distance = "globalgenaf" ]; then
1309 "$prefix/pairlocalalign" -C $numthreads $seqtype $model -g $pgexp -f $pggop -h $pgaof -O $GGOP -E $GEXP -K < infile > /dev/null || exit 1
1310 cat hat3.seed hat3 > hatx
1312 "$prefix/tbfast" $outnum $addarg -C $numthreads $rnaopt $weightopt $treeinopt $treeoutopt $distoutopt $seqtype $model -f "-"$gop -h "-"$aof $param_fft $localparam $algopt $treealg $scoreoutarg < infile > /dev/null || exit 1
1313 elif [ $distance = "localgenaf" ]; then
1314 "$prefix/pairlocalalign" -C $numthreads $seqtype $model -g $lexp -f $lgop -h $laof -O $LGOP -E $LEXP -N < infile > /dev/null || exit 1
1315 cat hat3.seed hat3 > hatx
1317 "$prefix/tbfast" $outnum $addarg -C $numthreads $rnaopt $weightopt $treeinopt $treeoutopt $distoutopt $seqtype $model -f "-"$gop -h "-"$aof $param_fft $localparam $algopt $treealg $scoreoutarg < infile > /dev/null || exit 1
1318 elif [ $distance = "distonly" ]; then
1319 "$prefix/pairlocalalign" -C $numthreads $seqtype $model -g $pgexp -f $pggop -h $pgaof -t < infile > /dev/null || exit 1
1320 "$prefix/tbfast" $outnum $addarg -C $numthreads $rnaopt $weightopt $treeinopt $treeoutopt $distoutopt $seqtype $model -f "-"$gop -h "-"$aof $param_fft $localparam $algopt $treealg $scoreoutarg < infile > /dev/null || exit 1
1321 elif [ $distance = "parttree" ]; then
1322 "$prefix/splittbfast" -Q $splitopt $partorderopt $parttreeoutopt $memopt $seqtype $model -f "-"$gop -h "-"$aof $param_fft -p $partsize -s $groupsize $treealg -i infile > pre || exit 1
1325 "$prefix/disttbfast" -O $outnum $addarg -C $numthreads $memopt $weightopt $treeinopt $treeoutopt $distoutopt $seqtype $model -f "-"$gop -h "-"$aof $param_fft $algopt $treealg $scoreoutarg < infile > pre || exit 1
1329 while [ $cycle -gt 1 ]
1331 if [ $distance = "parttree" ]; then
1333 "$prefix/splittbfast" -Z -Q $splitopt $partorderopt $parttreeoutopt $memopt $seqtype $model -f "-"$gop -h "-"$aof $param_fft -p $partsize -s $groupsize $treealg -i infile > pre || exit 1
1335 "$prefix/tbfast" -O $outnum -C $numthreads $rnaopt $weightopt $treeoutopt $distoutopt $memopt $seqtype $model -f "-"$gop -h "-"$aof $param_fft $localparam $algopt -J $treealg $scoreoutarg < pre > /dev/null || exit 1
1337 cycle=`expr $cycle - 1`
1339 if [ $iterate -gt 0 ]; then
1340 if [ $distance = "sixtuples" ]; then
1341 "$prefix/dndpre" -C $numthreads < pre > /dev/null 2>&1 || exit 1
1343 "$prefix/dvtditr" -C $numthreads -t $randomseed $rnaoptit $memopt $scorecalcopt $localparam -z 50 $seqtype $model -f "-"$gop -h "-"$aof -I $iterate $weightopt $treeinopt $algoptit $treealg -p $parallelizationstrategy $scoreoutarg < pre > /dev/null || exit 1
1347 if [ $coreout -eq 1 ]; then
1348 "$prefix/setcore" -w $corewin -i $corethr $coreext < pre > pre2
1350 elif [ $anysymbol -eq 1 ]; then
1351 "$prefix/restoreu" -a pre -i orig > restored || exit 1
1355 if [ $quiet -eq 0 ]; then
1357 if [ $mccaskill -eq 1 ]; then
1358 echo "RNA base pairing probaility was calculated by the McCaskill algorithm (1)" 1>&2
1359 echo "implemented in Vienna RNA package (2) and MXSCARNA (3), and then" 1>&2
1360 echo "incorporated in the iterative alignment process (4)." 1>&2
1361 echo "(1) McCaskill, 1990, Biopolymers 29:1105-1119" 1>&2
1362 echo "(2) Hofacker et al., 2002, J. Mol. Biol. 319:3724-3732" 1>&2
1363 echo "(3) Tabei et al., 2008, BMC Bioinformatics 9:33" 1>&2
1364 echo "(4) Katoh and Toh, 2008, BMC Bioinformatics 9:212" 1>&2
1366 elif [ $contrafold -eq 1 ]; then
1367 echo "RNA base pairing probaility was calculated by the CONTRAfold algorithm (1)" 1>&2
1368 echo "and then incorporated in the iterative alignment process (4)." 1>&2
1369 echo "(1) Do et al., 2006, Bioinformatics 22:e90-98" 1>&2
1370 echo "(2) Katoh and Toh, 2008, BMC Bioinformatics 9:212" 1>&2
1373 if [ $distance = "fasta" -o $partdist = "fasta" ]; then
1374 echo "Pairwise alignments were computed by FASTA" 1>&2
1375 echo "(Pearson & Lipman, 1988, PNAS 85:2444-2448)" 1>&2
1377 if [ $distance = "blast" ]; then
1378 echo "Pairwise alignments were computed by BLAST" 1>&2
1379 echo "(Altschul et al., 1997, NAR 25:3389-3402)" 1>&2
1381 if [ $distance = "scarna" ]; then
1382 echo "Pairwise alignments were computed by MXSCARNA" 1>&2
1383 echo "(Tabei et al., 2008, BMC Bioinformatics 9:33)." 1>&2
1385 if [ $distance = "lara" -o $distance = "slara" ]; then
1386 echo "Pairwise alignments were computed by LaRA" 1>&2
1387 echo "(Bauer et al., 2007, BMC Bioinformatics 8:271)." 1>&2
1389 if [ $distance = "foldalignlocal" ]; then
1390 echo "Pairwise alignments were computed by FOLDALIGN (local)" 1>&2
1391 echo "(Havgaard et al., 2007, PLoS Computational Biology 3:e193)." 1>&2
1393 if [ $distance = "foldalignglobal" ]; then
1394 echo "Pairwise alignments were computed by FOLDALIGN (global)" 1>&2
1395 echo "(Havgaard et al., 2007, PLoS Computational Biology 3:e193)." 1>&2
1398 echo 'Strategy:' 1>&2
1399 printf ' '$strategy 1>&2
1400 echo ' ('$performance')' 1>&2
1401 echo ' '$explanation 1>&2
1403 echo "If unsure which option to use, try 'mafft --auto input > output'." 1>&2
1404 # echo "If long gaps are expected, try 'mafft --ep 0.0 --auto input > output'." 1>&2
1405 echo "If the possibility of long gaps can be excluded, add '--ep 0.123'." 1>&2
1406 echo "For more information, see 'mafft --help', 'mafft --man' and the mafft page." 1>&2
1411 if [ "$outputfile" = "" ]; then
1412 if [ "$outputopt" = "null" ]; then
1413 cat < $TMPFILE/pre || exit 1
1415 "$prefix/f2cl" -n $namelength $outputopt < $TMPFILE/pre || exit 1
1418 if [ "$outputopt" = "null" ]; then
1419 cat < $TMPFILE/pre > "$outputfile" || exit 1
1421 "$prefix/f2cl" -n $namelength $outputopt < $TMPFILE/pre > "$outputfile" || exit 1
1425 if [ $treeout -eq 1 ]; then
1426 cp $TMPFILE/infile.tree "$infilename.tree"
1429 if [ $distout -eq 1 ]; then
1430 cp $TMPFILE/hat2 "$infilename.hat2"
1438 tmpawk=`which nawk 2>/dev/null | awk '{print $1}'`
1439 if [ -x "$tmpawk" ]; then
1443 tmpawk=`which gawk 2>/dev/null | awk '{print $1}'`
1444 if [ -x "$tmpawk" ]; then
1448 #echo "prog="$prog 1>&2
1454 prefix = ENVIRON["prefix"];
1455 version = ENVIRON["version"];
1456 myself = ENVIRON["myself"];
1460 printf( "\n" ) > "/dev/tty";
1461 printf( "---------------------------------------------------------------------\n" ) > "/dev/tty";
1462 printf( "\n" ) > "/dev/tty";
1463 printf( " MAFFT %s\n", version ) > "/dev/tty";
1464 printf( "\n" ) > "/dev/tty";
1465 printf( " Copyright (c) 2011 Kazutaka Katoh\n" ) > "/dev/tty";
1466 printf( " NAR 30:3059-3066, NAR 33:511-518\n" ) > "/dev/tty";
1467 printf( " http://mafft.cbrc.jp/alignment/software/\n" ) > "/dev/tty";
1468 printf( "---------------------------------------------------------------------\n" ) > "/dev/tty";
1469 printf( "\n" ) > "/dev/tty";
1473 printf( "\n" ) > "/dev/tty";
1474 printf( "Input file? (fasta format)\n@ " ) > "/dev/tty";
1475 res = getline < "/dev/tty";
1477 if( res == 0 || NF == 0 )
1479 infile = sprintf( "%s", $0 );
1481 res = getline < infile;
1485 printf( "%s: No such file.\n\n", infile ) > "/dev/tty";
1486 printf( "Filename extension (eg., .txt) must be typed, if any.\n\n" ) > "/dev/tty";
1489 printf( "%s: Empty.\n", infile ) > "/dev/tty";
1492 printf( "OK. infile = %s\n\n", infile ) > "/dev/tty";
1500 printf( "\n" ) > "/dev/tty";
1501 printf( "Output file?\n" ) > "/dev/tty";
1502 printf( "@ " ) > "/dev/tty";
1503 res = getline < "/dev/tty";
1504 close( "/dev/tty" );
1505 if( res == 0 || NF == 0 )
1509 outfile = sprintf( "%s", $0 );
1510 printf( "OK. outfile = %s\n\n", outfile ) > "/dev/tty";
1518 printf( "\n" ) > "/dev/tty";
1519 printf( "Output format?\n" ) > "/dev/tty";
1520 printf( " 1. Clustal format / Sorted\n" ) > "/dev/tty";
1521 printf( " 2. Clustal format / Input order\n" ) > "/dev/tty";
1522 printf( " 3. Fasta format / Sorted\n" ) > "/dev/tty";
1523 printf( " 4. Fasta format / Input order\n" ) > "/dev/tty";
1524 printf( " 5. Phylip format / Sorted\n" ) > "/dev/tty";
1525 printf( " 6. Phylip format / Input order\n" ) > "/dev/tty";
1526 printf( "@ " ) > "/dev/tty";
1527 res = getline < "/dev/tty";
1528 close( "/dev/tty" );
1529 # printf( "res=%d, NF=%d\n", res, NF );
1532 # printf( "resnum=%d\n", resnum );
1534 if( resnum < 1 || 6 < resnum )
1539 outargs = "--clustalout --reorder";
1540 else if( resnum == 2 )
1541 outargs = "--clustalout --inputorder";
1542 else if( resnum == 3 )
1543 outargs = "--reorder";
1544 else if( resnum == 4 )
1545 outargs = "--inputorder";
1546 else if( resnum == 5 )
1547 outargs = "--phylipout --reorder";
1548 else if( resnum == 6 )
1549 outargs = "--phylipout --inputorder";
1552 printf( "OK. arguments = %s\n\n", outargs ) > "/dev/tty";
1560 printf( "\n" ) > "/dev/tty";
1561 printf( "Strategy?\n" ) > "/dev/tty";
1562 printf( " 1. --auto\n" ) > "/dev/tty";
1563 printf( " 2. FFT-NS-1 (fast)\n" ) > "/dev/tty";
1564 printf( " 3. FFT-NS-2 (default)\n" ) > "/dev/tty";
1565 printf( " 4. G-INS-i (accurate)\n" ) > "/dev/tty";
1566 printf( " 5. L-INS-i (accurate)\n" ) > "/dev/tty";
1567 printf( " 6. E-INS-i (accurate)\n" ) > "/dev/tty";
1568 printf( "@ " ) > "/dev/tty";
1569 res = getline < "/dev/tty";
1570 close( "/dev/tty" );
1571 # printf( "res=%d, NF=%d\n", res, NF );
1574 # printf( "resnum=%d\n", resnum );
1576 if( resnum < 1 || 6 < resnum )
1581 arguments = "--auto";
1582 else if( resnum == 2 )
1583 arguments = "--retree 1";
1584 else if( resnum == 3 )
1585 arguments = "--retree 2";
1586 else if( resnum == 4 )
1587 arguments = "--globalpair --maxiterate 16";
1588 else if( resnum == 5 )
1589 arguments = "--localpair --maxiterate 16";
1590 else if( resnum == 6 )
1591 arguments = "--genafpair --maxiterate 16";
1593 arguments = sprintf( "%s", $0 );
1594 printf( "OK. arguments = %s %s\n\n", arguments, outargs ) > "/dev/tty";
1602 printf( "\n" ) > "/dev/tty";
1603 printf( "Additional arguments? (--ep #, --op #, --kappa #, etc)\n" ) > "/dev/tty";
1604 printf( "@ " ) > "/dev/tty";
1605 res = getline < "/dev/tty";
1606 close( "/dev/tty" );
1607 if( res == 0 || NF == 0 )
1613 addargs = sprintf( "%s", $0 );
1614 printf( "OK. arguments = %s %s %s\n\n", addargs, arguments, outargs ) > "/dev/tty";
1619 arguments = sprintf( "%s %s %s", addargs, arguments, outargs );
1622 command = sprintf( "\"%s\" %s \"%s\" > \"%s\"", myself, arguments, infile, outfile );
1623 gsub( /\\/, "/", command );
1626 printf( "command=\n%s\n", command ) > "/dev/tty";
1632 printf( "OK?\n" ) > "/dev/tty";
1633 printf( "@ [Y] " ) > "/dev/tty";
1634 res = getline < "/dev/tty";
1635 close( "/dev/tty" );
1638 else if( NF == 0 || $0 ~ /^[Yy]/ )
1647 printf( "\n" ) > "/dev/tty";
1648 printf( "\n" ) > "/dev/tty";
1651 command = sprintf( "less \"%s\"", outfile );
1653 printf( "Press Enter to exit." ) > "/dev/tty";
1654 res = getline < "/dev/tty";