texlive[44764] Master/texmf-dist: gotoh (7jul17)

commits+karl at tug.org commits+karl at tug.org
Fri Jul 7 23:06:52 CEST 2017


Revision: 44764
          http://tug.org/svn/texlive?view=revision&revision=44764
Author:   karl
Date:     2017-07-07 23:06:52 +0200 (Fri, 07 Jul 2017)
Log Message:
-----------
gotoh (7jul17)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/gotoh/README.md
    trunk/Master/texmf-dist/source/latex/gotoh/gotoh.dtx
    trunk/Master/texmf-dist/tex/latex/gotoh/gotoh.sty

Added Paths:
-----------
    trunk/Master/texmf-dist/doc/latex/gotoh/gotoh.pdf

Modified: trunk/Master/texmf-dist/doc/latex/gotoh/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/gotoh/README.md	2017-07-07 00:21:03 UTC (rev 44763)
+++ trunk/Master/texmf-dist/doc/latex/gotoh/README.md	2017-07-07 21:06:52 UTC (rev 44764)
@@ -1,4 +1,4 @@
-# Package Gotoh (v1.0)
+# Package Gotoh (v1.1)
 
 
 LaTeX package: An implementation of the Gotoh sequence alignment algorithm.

Added: trunk/Master/texmf-dist/doc/latex/gotoh/gotoh.pdf
===================================================================
(Binary files differ)

Index: trunk/Master/texmf-dist/doc/latex/gotoh/gotoh.pdf
===================================================================
--- trunk/Master/texmf-dist/doc/latex/gotoh/gotoh.pdf	2017-07-07 00:21:03 UTC (rev 44763)
+++ trunk/Master/texmf-dist/doc/latex/gotoh/gotoh.pdf	2017-07-07 21:06:52 UTC (rev 44764)

Property changes on: trunk/Master/texmf-dist/doc/latex/gotoh/gotoh.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/pdf
\ No newline at end of property
Modified: trunk/Master/texmf-dist/source/latex/gotoh/gotoh.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/gotoh/gotoh.dtx	2017-07-07 00:21:03 UTC (rev 44763)
+++ trunk/Master/texmf-dist/source/latex/gotoh/gotoh.dtx	2017-07-07 21:06:52 UTC (rev 44764)
@@ -11,7 +11,7 @@
 % 
 % \fi
 %
-% \CheckSum{971}
+% \CheckSum{984}
 %
 % \changes{v1.0}{2017/05/05}{The first version}
 % 
@@ -18,7 +18,7 @@
 % \iffalse
 %<*package>
 \NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{gotoh}[2017/05/05 v1.0 Sequence alignment algorithm]
+\ProvidesPackage{gotoh}[2017/07/07 v1.1 Sequence alignment algorithm]
 %</package>
 %<*driver>
 \documentclass[draft]{ltxdoc}
@@ -105,16 +105,16 @@
 % \section{Calculating the Alignment}
 %
 % \DescribeMacro{\Gotoh}
-% The |\Gotoh| command simply takes two sequences as its arguments.
+% The syntax of |\Gotoh| is shown below.
 % \begin{quote}
-% |\Gotoh|\marg{sequence A}\marg{sequence B}
+% |\Gotoh|\oarg{key-value list}\marg{sequence A}\marg{sequence B}
 % \end{quote}
 % The command puts the optimal score of the alignment to specified control
 % sequence (default: |\GotohScore|) after executing the Gotoh algorithm, and
 % returns the alignment results to other control sequences (default:
 % |\GotohResultA| and |\GotohResultB|). Note that these assignments are done
-% globally. The control sequences to store the score and results can be changed
-% with |\GotohConfig| command.
+% globally. Using the optional argument, you can change the configuration
+% temporary with the same keys in |\GotohConfig| (see the next section).
 %
 % \section{Configuration}
 %
@@ -288,7 +288,7 @@
 % \begin{macro}{\gth at d}
 % \begin{macro}{\gth at e}
 % These are keys for setting the parameters of the algorithm. The default
-% values which are shown in equations~(\ref{eq:parameters}) are set here, and
+% values which are shown in Equations~(\ref{eq:parameters}) are set here, and
 % stored in the macros (\emph{not} count registers) respectively.
 %    \begin{macrocode}
 \define at cmdkeys[gth]{config}[gth@]{match, mismatch, d, e}
@@ -393,7 +393,7 @@
 % g(l) = -d - (l-1)e. \label{eq:gap}
 % \end{equation}
 % In this equation, $d$ and $e$ are parameters of the algorithm, which have
-% default values shown in equations~(\ref{eq:parameters}).
+% default values shown in Equations~(\ref{eq:parameters}).
 %    \begin{macrocode}
 \def\gth at gap@penalty#1{%
   \gth at calc#1\relax
@@ -403,10 +403,10 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \subsection{Printing Matrixes}
+% \subsection{Printing Matrices}
 %
 % \begin{macro}{\gth at print@matrix}
-% This command shows the matrixes $M$, $I_x$ or $I_y$ (See
+% This command shows the matrices $M$, $I^x$ or $I^y$ (See
 % section~\ref{sect:algorithm}). The argument of this macro specifies which
 % matrix to show, so you can detect |m|, |ix|, or |iy|. However, this macro is
 % currently only for the author of this package to debug.
@@ -419,7 +419,7 @@
     \mbox{\hbox to\gth at tempdima{\hss #1}}%
   \egroup}
 \def\gth at print@matrix#1{%
-  \bgroup\texttt
+  \bgroup\ttfamily
     #1:\\
     \gth at tempcnta\z@
     \@whilenum\gth at tempcnta<\gth at m\do{%
@@ -427,7 +427,7 @@
       \@whilenum\gth at tempcntb<\gth at n\do{%
         \gth at tab{%
           \gth at nameuse{\gth at sn @#1@\the\gth at tempcnta
-                    @\the\gth at tempcntb}}%
+                       @\the\gth at tempcntb}}%
       \advance\gth at tempcntb\@ne}\\
     \advance\gth at tempcnta\@ne}%
   \egroup}
@@ -437,21 +437,42 @@
 % \subsection{Executing the Gotoh Algorithm}\label{sect:algorithm}
 %
 % \begin{macro}{\Gotoh}
-% This is the user interface to execute the Gotoh algorithm.  If the boolean
-% switch |\if at gth@uppercase| is true, the arguments are processed by
-% |\uppercase| preamble before passing them to |\gth at gotoh| macro.
+% \changes{v1.1}{2017/07/07}{Add a new optional argument for changing
+% config temporary}
+% This is the user interface to execute the Gotoh algorithm.  First, the
+% `serial number' is incremented. The whole other process executed by this
+% macro contained in a group because a number of temporary macros are defined
+% during processing.
 %    \begin{macrocode}
-\newcommand{\Gotoh}[2]{%
+\newcommand{\Gotoh}{%
+  \gth at increment\gth at sn
+  \bgroup  % \egroup is in \gth at gotoh@pre
+  \@ifnextchar[{\gth at gotoh@setkeys}{\gth at gotoh@pre}}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\gth at gotoh@setkeys}
+% \begin{macro}{\gth at gotoh@pre}
+% These inner macros are for preparing: |\gth at gotoh@setkeys| process temporary
+% configuration specified with the optional argument of |\Gotoh|. In
+% |\gth at gotoh@pre|, if the boolean switch |\if at gth@uppercase| is true, the
+% arguments are processed by |\uppercase| preamble before passing them to
+% |\gth at gotoh| macro.
+%    \begin{macrocode}
+\def\gth at gotoh@setkeys[#1]{\setkeys[gth]{config}{#1}\gth at gotoh@pre}
+\def\gth at gotoh@pre#1#2{%
+  \edef\gth at tmpa{\noexpand\gth at gotoh{#1}{#2}}%
   \if at gth@uppercase
-    \uppercase{\gth at gotoh{#1}{#2}}%
+    \uppercase\expandafter{\gth at tmpa}%
   \else
-    \gth at gotoh{#1}{#2}%
-  \fi}
+    \gth at tmpa
+  \fi\egroup}
 %    \end{macrocode}
 % \end{macro}
+% \end{macro}
 %
 % \begin{macro}{\gth at gotoh}
-% This macro actually executes the Gotoh algorithm.~\cite{gotoh1982} The input
+% This macro actually executes the Gotoh algorithm~\cite{gotoh1982}. The input
 % of the algorithm is two biological sequences
 % \[
 % A \defeq a_1a_2a_3\dots a_m,\eqsep B \defeq b_1b_2b_3\dots b_n
@@ -462,19 +483,19 @@
 % calculation is done in $O(mn)$ time.} to get optimal score of the algorithm:
 % \begin{equation}
 % M_{i+1, j+1}
-%   = \max\left\{M_{ij}, {I_x}_{ij}, {I_y}_{ij}\right\} + c_{a_ib_j}
+%   = \max\left\{M_{ij}, I^x_{ij}, I^y_{ij}\right\} + c_{ij}
 % \label{eq:m}
 % \end{equation}
 % where
 % \begin{align}
-% {I_x}_{i+1, j} &= \max\left\{ M_{ij}-d, {I_x}_{ij}-e, {I_y}_{ij}-d \right\},
+% I^x_{i+1, j} &= \max\left\{ M_{ij}-d, I^x_{ij}-e, I^y_{ij}-d \right\},
 % \label{eq:ix} \\
-% {I_y}_{i, j+1} &= \max\left\{ M_{ij}-d, {I_y}_{ij}-e \right\},
+% I^y_{i, j+1} &= \max\left\{ M_{ij}-d, I^y_{ij}-e \right\},
 % \label{eq:iy}
 % \end{align}
-% and $c_{a_ib_j}$ is a score for a pair $(a_i, b_j)$, namely
+% and $c_{ij}$ is a score for a pair $(a_i, b_j)$, namely
 % \[
-% c_{a_ib_j} = \left\{
+% c_{ij} = \left\{
 %   \begin{array}{rll}
 %   1  & \text{if\enspace} a_i = b_j & \text{(match)} \\
 %   -1 & \text{otherwise} & \text{(mismatch)}. \\
@@ -481,21 +502,10 @@
 %   \end{array}
 % \right.
 % \]
+% Note that the Equations (\ref{eq:ix}) and (\ref{eq:iy}) have asymmetric form
+% because the order of inserting \emph{gaps} when alternating $A$ and $B$ does
+% not affect the optimal score.
 %
-%    \begin{macrocode}
-\def\gth at gotoh#1#2{%
-%    \end{macrocode}
-%
-% \subsubsection{Preparation}
-%
-% First, the `serial number' is incremented. The whole other part of this macro
-% contained in a group because a number of temporary macros are defined during
-% processing.
-%    \begin{macrocode}
-  \gth at increment\gth at sn
-  \bgroup
-%    \end{macrocode}
-%
 % \subsubsection{Getting sequences}
 %
 % \begin{macro}{\gth at m}
@@ -504,18 +514,19 @@
 % |\gth at seqa@|$a_i$ and |\gth at seqa@|$b_j$, and the lengthes of the sequences
 % $m, n$ are stored in |\gth at m| and |\gth at n| respectively.
 %    \begin{macrocode}
-    \gth at tempcnta\z@
-    \@tfor\gth at member:=#1\do{%
-      \gth at name@edef{seqa@\the\gth at tempcnta}{\gth at member}%
-      \advance\gth at tempcnta\@ne}%
-    \advance\gth at tempcnta\@ne
-    \edef\gth at m{\the\gth at tempcnta}%
-    \gth at tempcntb\z@
-    \@tfor\gth at member:=#2\do{%
-      \gth at name@edef{seqb@\the\gth at tempcntb}{\gth at member}%
-      \advance\gth at tempcntb\@ne}%
-    \advance\gth at tempcntb\@ne
-    \edef\gth at n{\the\gth at tempcntb}%
+\def\gth at gotoh#1#2{%
+  \gth at tempcnta\z@
+  \@tfor\gth at member:=#1\do{%
+    \gth at name@edef{seqa@\the\gth at tempcnta}{\gth at member}%
+    \advance\gth at tempcnta\@ne}%
+  \advance\gth at tempcnta\@ne
+  \edef\gth at m{\the\gth at tempcnta}%
+  \gth at tempcntb\z@
+  \@tfor\gth at member:=#2\do{%
+    \gth at name@edef{seqb@\the\gth at tempcntb}{\gth at member}%
+    \advance\gth at tempcntb\@ne}%
+  \advance\gth at tempcntb\@ne
+  \edef\gth at n{\the\gth at tempcntb}%
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
@@ -523,127 +534,127 @@
 % \subsubsection{Initialization}
 %
 % We have to be careful with initialization because many implementations of the
-% Gotoh algorithm have problems here.~\cite{flouri2015} Specifically, the
+% Gotoh algorithm have problems here~\cite{flouri2015}. Specifically, the
 % package initialzes the matrxes with following equations:
 % \begin{align*}
 % M_{i0} &= -\infty, M_{0j} = -\infty, M_{00} = 0, \\
-% {I_x}_{i0} &= -g(i), {I_x}_{0j} = -\infty, \\
-% {I_y}_{i0} &= -\infty, {I_y}_{0j} = -g(j).
+% I^x_{i0} &= -g(i), I^x_{0j} = -\infty, \\
+% I^y_{i0} &= -\infty, I^y_{0j} = -g(j).
 % \end{align*}
-% Note that function $g(l)$ is a gap penalty (shown in equation~(\ref{eq:gap}))
+% Note that function $g(l)$ is a gap penalty (shown in Equation~(\ref{eq:gap}))
 % and can be calculated with the macro |\gth at gap@penalty|.
 %
 %    \begin{macrocode}
-    \gth at tempcnta\z@
-    \@whilenum\gth at tempcnta<\gth at m\do{%
-      \gth at gap@penalty{\gth at tempcnta}%
-      \gth at name@xdef{\gth at sn @m@\the\gth at tempcnta @0}{\gth at min}%
-      \gth at name@xdef{\gth at sn @ix@\the\gth at tempcnta @0}{\the\gth at calc}%
-      \gth at name@xdef{\gth at sn @iy@\the\gth at tempcnta @0}{\gth at min}%
-      \advance\gth at tempcnta\@ne}%
-    \gth at tempcntb\z@
-    \@whilenum\gth at tempcntb<\gth at n\do{%
-      \gth at gap@penalty{\gth at tempcntb}%
-      \gth at name@xdef{\gth at sn @m at 0@\the\gth at tempcntb}{\gth at min}%
-      \gth at name@xdef{\gth at sn @ix at 0@\the\gth at tempcntb}{\gth at min}%
-      \gth at name@xdef{\gth at sn @iy at 0@\the\gth at tempcntb}{\the\gth at calc}%
-      \advance\gth at tempcntb\@ne}%
-    \gth at name@xdef{\gth at sn @m at 0@0}{\number\z@}%
+  \gth at tempcnta\z@
+  \@whilenum\gth at tempcnta<\gth at m\do{%
+    \gth at gap@penalty{\gth at tempcnta}%
+    \gth at name@xdef{\gth at sn @m@\the\gth at tempcnta @0}{\gth at min}%
+    \gth at name@xdef{\gth at sn @ix@\the\gth at tempcnta @0}{\the\gth at calc}%
+    \gth at name@xdef{\gth at sn @iy@\the\gth at tempcnta @0}{\gth at min}%
+    \advance\gth at tempcnta\@ne}%
+  \gth at tempcntb\z@
+  \@whilenum\gth at tempcntb<\gth at n\do{%
+    \gth at gap@penalty{\gth at tempcntb}%
+    \gth at name@xdef{\gth at sn @m at 0@\the\gth at tempcntb}{\gth at min}%
+    \gth at name@xdef{\gth at sn @ix at 0@\the\gth at tempcntb}{\gth at min}%
+    \gth at name@xdef{\gth at sn @iy at 0@\the\gth at tempcntb}{\the\gth at calc}%
+    \advance\gth at tempcntb\@ne}%
+  \gth at name@xdef{\gth at sn @m at 0@0}{\number\z@}%
 %    \end{macrocode}
 %
 % \subsubsection{Memoization}
 %
 % If the switch |\if at gth@memoization| is true, memoization functions (See
-% section~\ref{sect:memofunc}) are called recursively.
+% section~\ref{sect:memofunc}) are called recursively. 
 %    \begin{macrocode}
-    \if at gth@memoization
-      \gth at decrement\gth at m \gth at decrement\gth at n
-        \gth at memo@ix{\gth at m}{\gth at n}%
-        \gth at memo@iy{\gth at m}{\gth at n}%
-        \gth at memo@m{\gth at m}{\gth at n}%
-      \gth at increment\gth at m \gth at increment\gth at n
+  \if at gth@memoization
+    \gth at decrement\gth at m \gth at decrement\gth at n
+      \gth at memo@ix{\gth at m}{\gth at n}%
+      \gth at memo@iy{\gth at m}{\gth at n}%
+      \gth at memo@m{\gth at m}{\gth at n}%
+    \gth at increment\gth at m \gth at increment\gth at n
 %    \end{macrocode}
 %
 % \subsubsection{Dynamic Programming}
 %
-% To fill matrxes $M$, $I_x$ and $I_y$ the package use the recurrence formula
+% To fill matrxes $M$, $I^x$, and $I^y$ the package use the recurrence formula
 %
 %    \begin{macrocode}
-    \else
-      \gth at tempcnta\@ne
-      \@whilenum\gth at tempcnta<\gth at m\do{%
-        \gth at tempcntb\@ne
-        \@whilenum\gth at tempcntb<\gth at n\do{%
+  \else
+    \gth at tempcnta\@ne
+    \@whilenum\gth at tempcnta<\gth at m\do{%
+      \gth at tempcntb\@ne
+      \@whilenum\gth at tempcntb<\gth at n\do{%
 %    \end{macrocode}
-% First, $I_x$ is calculated with equation (\ref{eq:ix}).
+% First, $I^x$ is calculated with Equation (\ref{eq:ix}).
 %    \begin{macrocode}
-          \advance\gth at tempcnta\m at ne
-            \gth at max{%
-              \gth at nameuse{\gth at sn @m@\the\gth at tempcnta
-                        @\the\gth at tempcntb},%
-              \gth at nameuse{\gth at sn @iy@\the\gth at tempcnta
-                        @\the\gth at tempcntb}}%
-            \gth at tempcntc\gth at calc
-            \gth at tempcntd
-              \gth at nameuse{\gth at sn @ix@\the\gth at tempcnta
-                        @\the\gth at tempcntb}%
-            \advance\gth at tempcntc-\gth at d\advance\gth at tempcntd-\gth at e
-          \advance\gth at tempcnta\@ne
-          \gth at max{\gth at tempcntc,\gth at tempcntd}%
-          \gth at name@xdef{\gth at sn @ix@\the\gth at tempcnta
-                         @\the\gth at tempcntb}{%
-            \the\gth at calc}%
+        \advance\gth at tempcnta\m at ne
+          \gth at max{%
+            \gth at nameuse{\gth at sn @m@\the\gth at tempcnta
+                         @\the\gth at tempcntb},%
+            \gth at nameuse{\gth at sn @iy@\the\gth at tempcnta
+                         @\the\gth at tempcntb}}%
+          \gth at tempcntc\gth at calc
+          \gth at tempcntd
+            \gth at nameuse{\gth at sn @ix@\the\gth at tempcnta
+                         @\the\gth at tempcntb}%
+          \advance\gth at tempcntc-\gth at d\advance\gth at tempcntd-\gth at e
+        \advance\gth at tempcnta\@ne
+        \gth at max{\gth at tempcntc,\gth at tempcntd}%
+        \gth at name@xdef{\gth at sn @ix@\the\gth at tempcnta
+                       @\the\gth at tempcntb}{%
+          \the\gth at calc}%
 %    \end{macrocode}
-% Secondly, $I_y$ is calculated with equation (\ref{eq:iy}).
+% Secondly, $I^y$ is calculated with Equation (\ref{eq:iy}).
 %    \begin{macrocode}
-          \advance\gth at tempcntb\m at ne
-            \gth at tempcntc
-              \gth at nameuse{\gth at sn @m@\the\gth at tempcnta
-                        @\the\gth at tempcntb}%
-            \gth at tempcntd
-              \gth at nameuse{\gth at sn @iy@\the\gth at tempcnta
-                        @\the\gth at tempcntb}%
-            \advance\gth at tempcntc-\gth at d\advance\gth at tempcntd-\gth at e
-          \advance\gth at tempcntb\@ne
-          \gth at max{\gth at tempcntc,\gth at tempcntd}%
-          \gth at name@xdef{\gth at sn @iy@\the\gth at tempcnta
-                         @\the\gth at tempcntb}{%
-            \the\gth at calc}%
+        \advance\gth at tempcntb\m at ne
+          \gth at tempcntc
+            \gth at nameuse{\gth at sn @m@\the\gth at tempcnta
+                         @\the\gth at tempcntb}%
+          \gth at tempcntd
+            \gth at nameuse{\gth at sn @iy@\the\gth at tempcnta
+                         @\the\gth at tempcntb}%
+          \advance\gth at tempcntc-\gth at d\advance\gth at tempcntd-\gth at e
+        \advance\gth at tempcntb\@ne
+        \gth at max{\gth at tempcntc,\gth at tempcntd}%
+        \gth at name@xdef{\gth at sn @iy@\the\gth at tempcnta
+                       @\the\gth at tempcntb}{%
+          \the\gth at calc}%
 %    \end{macrocode}
-% Finally, $M$ is calculated with equation (\ref{eq:m}) and a loop is completed.
+% Finally, $M$ is calculated with Equation (\ref{eq:m}) and a loop is completed.
 %    \begin{macrocode}
-          \advance\gth at tempcnta\m at ne\advance\gth at tempcntb\m at ne
-            \gth at max{%
-              \gth at nameuse{\gth at sn @m@\the\gth at tempcnta
-                        @\the\gth at tempcntb},%
-              \gth at nameuse{\gth at sn @ix@\the\gth at tempcnta
-                        @\the\gth at tempcntb},%
-              \gth at nameuse{\gth at sn @iy@\the\gth at tempcnta
-                        @\the\gth at tempcntb}}%
-            \edef\gth at tmpa{\gth at nameuse{seqa@\the\gth at tempcnta}}%
-            \edef\gth at tmpb{\gth at nameuse{seqb@\the\gth at tempcntb}}%
-          \advance\gth at tempcnta\@ne\advance\gth at tempcntb\@ne
-          \ifx\gth at tmpa\gth at tmpb
-            \advance\gth at calc\gth at match
-          \else
-            \advance\gth at calc\gth at mismatch
-          \fi
-          \gth at name@xdef{\gth at sn @m@\the\gth at tempcnta
-                         @\the\gth at tempcntb}{%
-            \the\gth at calc}%
-          \advance\gth at tempcntb\@ne}%
-        \advance\gth at tempcnta\@ne}%
-    \fi
+        \advance\gth at tempcnta\m at ne\advance\gth at tempcntb\m at ne
+          \gth at max{%
+            \gth at nameuse{\gth at sn @m@\the\gth at tempcnta
+                         @\the\gth at tempcntb},%
+            \gth at nameuse{\gth at sn @ix@\the\gth at tempcnta
+                         @\the\gth at tempcntb},%
+            \gth at nameuse{\gth at sn @iy@\the\gth at tempcnta
+                         @\the\gth at tempcntb}}%
+          \edef\gth at tmpa{\gth at nameuse{seqa@\the\gth at tempcnta}}%
+          \edef\gth at tmpb{\gth at nameuse{seqb@\the\gth at tempcntb}}%
+        \advance\gth at tempcnta\@ne\advance\gth at tempcntb\@ne
+        \ifx\gth at tmpa\gth at tmpb
+          \advance\gth at calc\gth at match
+        \else
+          \advance\gth at calc\gth at mismatch
+        \fi
+        \gth at name@xdef{\gth at sn @m@\the\gth at tempcnta
+                       @\the\gth at tempcntb}{%
+          \the\gth at calc}%
+        \advance\gth at tempcntb\@ne}%
+      \advance\gth at tempcnta\@ne}%
+  \fi
 %    \end{macrocode}
 %
-% \subsubsection{Printing Matrixes}
+% \subsubsection{Printing Matrices}
 %
 % This is piece of code for debugging the package (so usually commented out).
 %
 %    \begin{macrocode}
-    %\gth at print@matrix{m}%
-    %\gth at print@matrix{ix}%
-    %\gth at print@matrix{iy}%
+  %\gth at print@matrix{m}%
+  %\gth at print@matrix{ix}%
+  %\gth at print@matrix{iy}%
 %    \end{macrocode}
 %
 % \subsubsection{Returning the Optimal Score}
@@ -651,20 +662,90 @@
 % The calculated optimal score of the alignment stored here to the control
 % sequences which stored in |\gth at score|.
 %    \begin{macrocode}
-    \bgroup
-      \gth at decrement\gth at m \gth at decrement\gth at n
-      \expandafter\xdef\gth at score{%
-        \gth at nameuse{\gth at sn @m@\gth at m @\gth at n}}%
-    \egroup
+  \bgroup
+    \gth at decrement\gth at m \gth at decrement\gth at n
+    \expandafter\xdef\gth at score{%
+      \gth at nameuse{\gth at sn @m@\gth at m @\gth at n}}%
+  \egroup
 %    \end{macrocode}
 %
 % \subsubsection{Trace Back}
 %
+% After processing dynamic programming (or memoization functions), matrices
+% $M$, $I^x$, and $I^y$ are all filled. Using these matrices, we can determine
+% the `trace' from the optimal score $M_{m,n}$ to the start $M_{0,0}$ and get
+% the result of alignment $(x, y)$.
+%
+% Considering the form of Equation (\ref{eq:m})--(\ref{eq:iy}), the calculation
+% formulae of the former values depend on which matrix the `current position'
+% exists. In order to take into account these differences, trace back process
+% is calculated while switching three modes: default, gap x, and gap y.
+%
+% First, make sure to empty |\gth at rseq@x| and |\gth at rseq@y| which is going to
+% store result alignment sequences $x$ and $y$ respectively. Note that this is
+% the trace \emph{back} process, so new characters are prepended to the
+% existing sequences in each loop. In the next line, the switches
+% |\if at gth@gapx@| and |\if at gth@gapy@| are both turned off (which means
+% processing starts from the default mode).
 %    \begin{macrocode}
-    \let\gth at rseq@x\@empty\let\gth at rseq@y\@empty\let\gth at mode@seq\@empty
-    \@gth at remain@true\@gth at gapx@false\@gth at gapy@false
-    \@whilesw\if at gth@remain@\fi{%
-      \ifnum\gth at m=\z@
+  \let\gth at rseq@x\@empty\let\gth at rseq@y\@empty
+  \@gth at remain@true\@gth at gapx@false\@gth at gapy@false
+%    \end{macrocode}
+% In the main loop of trace back, process the condition either $x$ or $y$ is
+% already completed first. In this situation, the other sequence should be
+% filled all the remaining with \emph{gaps}.
+%    \begin{macrocode}
+  \@whilesw\if at gth@remain@\fi{%
+    \ifnum\gth at m=\z@
+      \gth at decrement\gth at n
+      \expandafter\expandafter\expandafter
+      \ifx\gth at nameuse{seqb@\gth at n}\relax\else
+        \edef\gth at rseq@x{\gth at gap@char\gth at rseq@x}%
+        \edef\gth at rseq@y{\gth at nameuse{seqb@\gth at n}%
+                         \gth at rseq@y}%
+      \fi
+    \else\ifnum\gth at n=\z@
+      \gth at decrement\gth at m
+      \expandafter\expandafter\expandafter
+      \ifx\gth at nameuse{seqa@\gth at m}\relax\else
+        \edef\gth at rseq@x{\gth at nameuse{seqa@\gth at m}%
+                         \gth at rseq@x}%
+        \edef\gth at rseq@y{\gth at gap@char\gth at rseq@y}%
+      \fi
+    \else
+%    \end{macrocode}
+% \paragraph{mode: gap x}
+% Prepend former base to $x$ and a \emph{gap} to $y$. If
+% $M_{m-1,n}-d>I^x_{m-1,n}-e$ back to default mode. Else if
+% $I^x_{m-1,n}-e<I^y_{m-1,n}-d$ switch to mode gap y and otherwise stay in mode
+% gap x.
+%    \begin{macrocode}
+      \if at gth@gapx@
+        \gth at decrement\gth at m
+        \expandafter\expandafter\expandafter
+        \ifx\gth at nameuse{seqa@\gth at m}\relax\else
+          \edef\gth at rseq@x{\gth at nameuse{seqa@\gth at m}%
+                           \gth at rseq@x}%
+          \edef\gth at rseq@y{\gth at gap@char\gth at rseq@y}%
+        \fi
+        \gth at tempcnta\gth at nameuse{\gth at sn @m@\gth at m @\gth at n}%
+        \gth at tempcntb\gth at nameuse{\gth at sn @ix@\gth at m @\gth at n}%
+        \gth at tempcntc\gth at nameuse{\gth at sn @iy@\gth at m @\gth at n}%
+        \advance\gth at tempcnta-\gth at d
+        \advance\gth at tempcntb-\gth at e
+        \advance\gth at tempcntc-\gth at d
+        \ifnum\gth at tempcnta>\gth at tempcntb
+          \@gth at gapx@false
+        \else\ifnum\gth at tempcntb<\gth at tempcntc
+          \@gth at gapx@false\@gth at gapy@true
+        \fi\fi
+%    \end{macrocode}
+% \paragraph{mode: gap y}
+% Prepend a \emph{gap} to $x$ and former base to $y$. If
+% $M_{m,n-1}-d>I^y_{m,n-1}-e$ back to default mode and otherwise stay in mode
+% gap y.
+%    \begin{macrocode}
+      \else\if at gth@gapy@
         \gth at decrement\gth at n
         \expandafter\expandafter\expandafter
         \ifx\gth at nameuse{seqb@\gth at n}\relax\else
@@ -672,83 +753,54 @@
           \edef\gth at rseq@y{\gth at nameuse{seqb@\gth at n}%
                            \gth at rseq@y}%
         \fi
-      \else\ifnum\gth at n=\z@
+        \gth at tempcnta\gth at nameuse{\gth at sn @m@\gth at m @\gth at n}%
+        \gth at tempcntb\gth at nameuse{\gth at sn @iy@\gth at m @\gth at n}%
+        \advance\gth at tempcnta-\gth at d\advance\gth at tempcntb-\gth at e
+        \ifnum\gth at tempcnta>\gth at tempcntb
+          \@gth at gapy@false
+        \fi
+%    \end{macrocode}
+% \paragraph{mode: default}
+% Prepend former base to $x$ and $y$ respectively. Only if
+% $M_{m-1,n-1}>I^x_{m-1,n-1}$ and $M_{m-1,n-1}>I^y_{m-1,n-1}$ stay on default
+% mode, and else if $I^x_{m-1,n-1}>I^y_{n-1,m-1}$ go to gap x otherwise go to
+% gap y.
+%    \begin{macrocode}
+      \else
         \gth at decrement\gth at m
+        \gth at decrement\gth at n
         \expandafter\expandafter\expandafter
         \ifx\gth at nameuse{seqa@\gth at m}\relax\else
-          \edef\gth at rseq@x{\gth at nameuse{seqa@\gth at m}%
-                           \gth at rseq@x}%
-          \edef\gth at rseq@y{\gth at gap@char\gth at rseq@y}%
-        \fi
-      \else
-        \if at gth@gapx@
-          % mode: gap x
-          \gth at decrement\gth at m
           \expandafter\expandafter\expandafter
-          \ifx\gth at nameuse{seqa@\gth at m}\relax\else
+          \ifx\gth at nameuse{seqb@\gth at n}\relax\else
             \edef\gth at rseq@x{\gth at nameuse{seqa@\gth at m}%
                              \gth at rseq@x}%
-            \edef\gth at rseq@y{\gth at gap@char\gth at rseq@y}%
-          \fi
-          \gth at tempcnta\gth at nameuse{\gth at sn @m@\gth at m @\gth at n}%
-          \gth at tempcntb\gth at nameuse{\gth at sn @ix@\gth at m @\gth at n}%
-          \gth at tempcntc\gth at nameuse{\gth at sn @iy@\gth at m @\gth at n}%
-          \advance\gth at tempcnta-\gth at d
-          \advance\gth at tempcntb-\gth at e
-          \advance\gth at tempcntc-\gth at d
-          \ifnum\gth at tempcnta>\gth at tempcntb
-            \@gth at gapx@false
-          \else\ifnum\gth at tempcntb<\gth at tempcntc
-            \@gth at gapx@false\@gth at gapy@true
-          \fi\fi
-        \else\if at gth@gapy@
-          % mode: gap y
-          \gth at decrement\gth at n
-          \expandafter\expandafter\expandafter
-          \ifx\gth at nameuse{seqb@\gth at n}\relax\else
-            \edef\gth at rseq@x{\gth at gap@char\gth at rseq@x}%
             \edef\gth at rseq@y{\gth at nameuse{seqb@\gth at n}%
                              \gth at rseq@y}%
           \fi
-          \gth at tempcnta\gth at nameuse{\gth at sn @m@\gth at m @\gth at n}%
-          \gth at tempcntb\gth at nameuse{\gth at sn @iy@\gth at m @\gth at n}%
-          \advance\gth at tempcnta-\gth at d\advance\gth at tempcntb-\gth at e
-          \ifnum\gth at tempcnta>\gth at tempcntb
-            \@gth at gapy@false
+        \fi
+        \gth at tempcnta\gth at nameuse{\gth at sn @m@\gth at m @\gth at n}%
+        \gth at tempcntb\gth at nameuse{\gth at sn @ix@\gth at m @\gth at n}%
+        \gth at tempcntc\gth at nameuse{\gth at sn @iy@\gth at m @\gth at n}%
+        \@gth at gap@false
+        \ifnum\gth at tempcnta<\gth at tempcntb\@gth at gap@true\fi
+        \ifnum\gth at tempcnta<\gth at tempcntc\@gth at gap@true\fi
+        \if at gth@gap@
+          \ifnum\gth at tempcntb>\gth at tempcntc
+            \@gth at gapx@true
+          \else
+            \@gth at gapy@true
           \fi
-        \else
-          % mode: default
-          \gth at decrement\gth at m
-          \gth at decrement\gth at n
-          \expandafter\expandafter\expandafter
-          \ifx\gth at nameuse{seqa@\gth at m}\relax\else
-            \expandafter\expandafter\expandafter
-            \ifx\gth at nameuse{seqb@\gth at n}\relax\else
-              \edef\gth at rseq@x{\gth at nameuse{seqa@\gth at m}%
-                               \gth at rseq@x}%
-              \edef\gth at rseq@y{\gth at nameuse{seqb@\gth at n}%
-                               \gth at rseq@y}%
-            \fi
-          \fi
-          \gth at tempcnta\gth at nameuse{\gth at sn @m@\gth at m @\gth at n}%
-          \gth at tempcntb\gth at nameuse{\gth at sn @ix@\gth at m @\gth at n}%
-          \gth at tempcntc\gth at nameuse{\gth at sn @iy@\gth at m @\gth at n}%
-          \@gth at gap@false
-          \ifnum\gth at tempcnta<\gth at tempcntb\@gth at gap@true\fi
-          \ifnum\gth at tempcnta<\gth at tempcntc\@gth at gap@true\fi
-          \if at gth@gap@
-            \ifnum\gth at tempcntb>\gth at tempcntc
-              \@gth at gapx@true
-            \else
-              \@gth at gapy@true
-            \fi
-          \fi
-        \fi\fi
+        \fi
       \fi\fi
-      \ifnum\gth at m<\@ne\ifnum\gth at n<\@ne
-        \@gth at remain@false
-      \fi\fi}%
+    \fi\fi
 %    \end{macrocode}
+% Finally, if we achieve to $M_{0,0}$, exit from the main loop.
+%    \begin{macrocode}
+    \ifnum\gth at m<\@ne\ifnum\gth at n<\@ne
+      \@gth at remain@false
+    \fi\fi}%
+%    \end{macrocode}
 %
 % \subsubsection{Returning Results}
 %
@@ -756,9 +808,8 @@
 % |\gth at resq@y| are copied globally to the control sequences which stored in
 % |\gth at resulta| and |\gth at resultb|.
 %    \begin{macrocode}
-    \expandafter\gth at glet\gth at resulta\gth at rseq@x
-    \expandafter\gth at glet\gth at resultb\gth at rseq@y
-  \egroup}
+  \expandafter\gth at glet\gth at resulta\gth at rseq@x
+  \expandafter\gth at glet\gth at resultb\gth at rseq@y}
 %    \end{macrocode}
 % \end{macro}
 %
@@ -767,7 +818,10 @@
 % \begin{macro}{\gth at memo@ix}
 % \begin{macro}{\gth at memo@iy}
 % \begin{macro}{\gth at memo@m}
-% These are memoization functions for calculating $I_x, I_y, M$ respectively.
+% These are memoization functions for calculating $I^x, I^y, M$ respectively.
+% Since these functions change many `temporary' values, all of the processes
+% are wrapped in a group and only the return values and components of matrices
+% are assigned globally.
 %    \begin{macrocode}
 \def\gth at memo@ix#1#2{%
   \bgroup
@@ -774,7 +828,7 @@
     \gth at tempcnta#1\gth at tempcntb#2\relax
     \expandafter\expandafter\expandafter
     \ifx\gth at nameuse{\gth at sn @ix@\the\gth at tempcnta
-                  @\the\gth at tempcntb}\relax
+                     @\the\gth at tempcntb}\relax
       \advance\gth at tempcnta\m at ne
         \gth at memo@ix{\gth at tempcnta}{\gth at tempcntb}%
         \edef\gth at tmp@ix at return{\gth at ix@return}%
@@ -800,7 +854,7 @@
     \gth at tempcnta#1\gth at tempcntb#2\relax
     \expandafter\expandafter\expandafter
     \ifx\gth at nameuse{\gth at sn @iy@\the\gth at tempcnta
-                  @\the\gth at tempcntb}\relax
+                     @\the\gth at tempcntb}\relax
       \advance\gth at tempcntb\m at ne
         \gth at memo@iy{\gth at tempcnta}{\gth at tempcntb}%
         \edef\gth at tmp@iy at return{\gth at iy@return}%
@@ -823,7 +877,7 @@
     \gth at tempcnta#1\gth at tempcntb#2\relax
     \expandafter\expandafter\expandafter
     \ifx\gth at nameuse{\gth at sn @m@\the\gth at tempcnta
-                  @\the\gth at tempcntb}\relax
+                     @\the\gth at tempcntb}\relax
       \advance\gth at tempcnta\m at ne\advance\gth at tempcntb\m at ne
         \gth at memo@ix{\gth at tempcnta}{\gth at tempcntb}%
         \edef\gth at tmp@ix at return{\gth at ix@return}%

Modified: trunk/Master/texmf-dist/tex/latex/gotoh/gotoh.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/gotoh/gotoh.sty	2017-07-07 00:21:03 UTC (rev 44763)
+++ trunk/Master/texmf-dist/tex/latex/gotoh/gotoh.sty	2017-07-07 21:06:52 UTC (rev 44764)
@@ -13,7 +13,7 @@
 %% This package is distributed under the MIT License.
 %% 
 \NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{gotoh}[2017/05/05 v1.0 Sequence alignment algorithm]
+\ProvidesPackage{gotoh}[2017/07/07 v1.1 Sequence alignment algorithm]
 \RequirePackage{xkeyval}
 \def\gth at pkgname{gotoh}
 \def\gth at warn{\PackageWarningNoLine\gth at pkgname}
@@ -74,7 +74,7 @@
     \mbox{\hbox to\gth at tempdima{\hss #1}}%
   \egroup}
 \def\gth at print@matrix#1{%
-  \bgroup\texttt
+  \bgroup\ttfamily
     #1:\\
     \gth at tempcnta\z@
     \@whilenum\gth at tempcnta<\gth at m\do{%
@@ -82,120 +82,160 @@
       \@whilenum\gth at tempcntb<\gth at n\do{%
         \gth at tab{%
           \gth at nameuse{\gth at sn @#1@\the\gth at tempcnta
-                    @\the\gth at tempcntb}}%
+                       @\the\gth at tempcntb}}%
       \advance\gth at tempcntb\@ne}\\
     \advance\gth at tempcnta\@ne}%
   \egroup}
-\newcommand{\Gotoh}[2]{%
+\newcommand{\Gotoh}{%
+  \gth at increment\gth at sn
+  \bgroup  % \egroup is in \gth at gotoh@pre
+  \@ifnextchar[{\gth at gotoh@setkeys}{\gth at gotoh@pre}}
+\def\gth at gotoh@setkeys[#1]{\setkeys[gth]{config}{#1}\gth at gotoh@pre}
+\def\gth at gotoh@pre#1#2{%
+  \edef\gth at tmpa{\noexpand\gth at gotoh{#1}{#2}}%
   \if at gth@uppercase
-    \uppercase{\gth at gotoh{#1}{#2}}%
+    \uppercase\expandafter{\gth at tmpa}%
   \else
-    \gth at gotoh{#1}{#2}%
-  \fi}
+    \gth at tmpa
+  \fi\egroup}
 \def\gth at gotoh#1#2{%
-  \gth at increment\gth at sn
-  \bgroup
-    \gth at tempcnta\z@
-    \@tfor\gth at member:=#1\do{%
-      \gth at name@edef{seqa@\the\gth at tempcnta}{\gth at member}%
-      \advance\gth at tempcnta\@ne}%
-    \advance\gth at tempcnta\@ne
-    \edef\gth at m{\the\gth at tempcnta}%
-    \gth at tempcntb\z@
-    \@tfor\gth at member:=#2\do{%
-      \gth at name@edef{seqb@\the\gth at tempcntb}{\gth at member}%
-      \advance\gth at tempcntb\@ne}%
-    \advance\gth at tempcntb\@ne
-    \edef\gth at n{\the\gth at tempcntb}%
-    \gth at tempcnta\z@
+  \gth at tempcnta\z@
+  \@tfor\gth at member:=#1\do{%
+    \gth at name@edef{seqa@\the\gth at tempcnta}{\gth at member}%
+    \advance\gth at tempcnta\@ne}%
+  \advance\gth at tempcnta\@ne
+  \edef\gth at m{\the\gth at tempcnta}%
+  \gth at tempcntb\z@
+  \@tfor\gth at member:=#2\do{%
+    \gth at name@edef{seqb@\the\gth at tempcntb}{\gth at member}%
+    \advance\gth at tempcntb\@ne}%
+  \advance\gth at tempcntb\@ne
+  \edef\gth at n{\the\gth at tempcntb}%
+  \gth at tempcnta\z@
+  \@whilenum\gth at tempcnta<\gth at m\do{%
+    \gth at gap@penalty{\gth at tempcnta}%
+    \gth at name@xdef{\gth at sn @m@\the\gth at tempcnta @0}{\gth at min}%
+    \gth at name@xdef{\gth at sn @ix@\the\gth at tempcnta @0}{\the\gth at calc}%
+    \gth at name@xdef{\gth at sn @iy@\the\gth at tempcnta @0}{\gth at min}%
+    \advance\gth at tempcnta\@ne}%
+  \gth at tempcntb\z@
+  \@whilenum\gth at tempcntb<\gth at n\do{%
+    \gth at gap@penalty{\gth at tempcntb}%
+    \gth at name@xdef{\gth at sn @m at 0@\the\gth at tempcntb}{\gth at min}%
+    \gth at name@xdef{\gth at sn @ix at 0@\the\gth at tempcntb}{\gth at min}%
+    \gth at name@xdef{\gth at sn @iy at 0@\the\gth at tempcntb}{\the\gth at calc}%
+    \advance\gth at tempcntb\@ne}%
+  \gth at name@xdef{\gth at sn @m at 0@0}{\number\z@}%
+  \if at gth@memoization
+    \gth at decrement\gth at m \gth at decrement\gth at n
+      \gth at memo@ix{\gth at m}{\gth at n}%
+      \gth at memo@iy{\gth at m}{\gth at n}%
+      \gth at memo@m{\gth at m}{\gth at n}%
+    \gth at increment\gth at m \gth at increment\gth at n
+  \else
+    \gth at tempcnta\@ne
     \@whilenum\gth at tempcnta<\gth at m\do{%
-      \gth at gap@penalty{\gth at tempcnta}%
-      \gth at name@xdef{\gth at sn @m@\the\gth at tempcnta @0}{\gth at min}%
-      \gth at name@xdef{\gth at sn @ix@\the\gth at tempcnta @0}{\the\gth at calc}%
-      \gth at name@xdef{\gth at sn @iy@\the\gth at tempcnta @0}{\gth at min}%
+      \gth at tempcntb\@ne
+      \@whilenum\gth at tempcntb<\gth at n\do{%
+        \advance\gth at tempcnta\m at ne
+          \gth at max{%
+            \gth at nameuse{\gth at sn @m@\the\gth at tempcnta
+                         @\the\gth at tempcntb},%
+            \gth at nameuse{\gth at sn @iy@\the\gth at tempcnta
+                         @\the\gth at tempcntb}}%
+          \gth at tempcntc\gth at calc
+          \gth at tempcntd
+            \gth at nameuse{\gth at sn @ix@\the\gth at tempcnta
+                         @\the\gth at tempcntb}%
+          \advance\gth at tempcntc-\gth at d\advance\gth at tempcntd-\gth at e
+        \advance\gth at tempcnta\@ne
+        \gth at max{\gth at tempcntc,\gth at tempcntd}%
+        \gth at name@xdef{\gth at sn @ix@\the\gth at tempcnta
+                       @\the\gth at tempcntb}{%
+          \the\gth at calc}%
+        \advance\gth at tempcntb\m at ne
+          \gth at tempcntc
+            \gth at nameuse{\gth at sn @m@\the\gth at tempcnta
+                         @\the\gth at tempcntb}%
+          \gth at tempcntd
+            \gth at nameuse{\gth at sn @iy@\the\gth at tempcnta
+                         @\the\gth at tempcntb}%
+          \advance\gth at tempcntc-\gth at d\advance\gth at tempcntd-\gth at e
+        \advance\gth at tempcntb\@ne
+        \gth at max{\gth at tempcntc,\gth at tempcntd}%
+        \gth at name@xdef{\gth at sn @iy@\the\gth at tempcnta
+                       @\the\gth at tempcntb}{%
+          \the\gth at calc}%
+        \advance\gth at tempcnta\m at ne\advance\gth at tempcntb\m at ne
+          \gth at max{%
+            \gth at nameuse{\gth at sn @m@\the\gth at tempcnta
+                         @\the\gth at tempcntb},%
+            \gth at nameuse{\gth at sn @ix@\the\gth at tempcnta
+                         @\the\gth at tempcntb},%
+            \gth at nameuse{\gth at sn @iy@\the\gth at tempcnta
+                         @\the\gth at tempcntb}}%
+          \edef\gth at tmpa{\gth at nameuse{seqa@\the\gth at tempcnta}}%
+          \edef\gth at tmpb{\gth at nameuse{seqb@\the\gth at tempcntb}}%
+        \advance\gth at tempcnta\@ne\advance\gth at tempcntb\@ne
+        \ifx\gth at tmpa\gth at tmpb
+          \advance\gth at calc\gth at match
+        \else
+          \advance\gth at calc\gth at mismatch
+        \fi
+        \gth at name@xdef{\gth at sn @m@\the\gth at tempcnta
+                       @\the\gth at tempcntb}{%
+          \the\gth at calc}%
+        \advance\gth at tempcntb\@ne}%
       \advance\gth at tempcnta\@ne}%
-    \gth at tempcntb\z@
-    \@whilenum\gth at tempcntb<\gth at n\do{%
-      \gth at gap@penalty{\gth at tempcntb}%
-      \gth at name@xdef{\gth at sn @m at 0@\the\gth at tempcntb}{\gth at min}%
-      \gth at name@xdef{\gth at sn @ix at 0@\the\gth at tempcntb}{\gth at min}%
-      \gth at name@xdef{\gth at sn @iy at 0@\the\gth at tempcntb}{\the\gth at calc}%
-      \advance\gth at tempcntb\@ne}%
-    \gth at name@xdef{\gth at sn @m at 0@0}{\number\z@}%
-    \if at gth@memoization
-      \gth at decrement\gth at m \gth at decrement\gth at n
-        \gth at memo@ix{\gth at m}{\gth at n}%
-        \gth at memo@iy{\gth at m}{\gth at n}%
-        \gth at memo@m{\gth at m}{\gth at n}%
-      \gth at increment\gth at m \gth at increment\gth at n
+  \fi
+  %\gth at print@matrix{m}%
+  %\gth at print@matrix{ix}%
+  %\gth at print@matrix{iy}%
+  \bgroup
+    \gth at decrement\gth at m \gth at decrement\gth at n
+    \expandafter\xdef\gth at score{%
+      \gth at nameuse{\gth at sn @m@\gth at m @\gth at n}}%
+  \egroup
+  \let\gth at rseq@x\@empty\let\gth at rseq@y\@empty
+  \@gth at remain@true\@gth at gapx@false\@gth at gapy@false
+  \@whilesw\if at gth@remain@\fi{%
+    \ifnum\gth at m=\z@
+      \gth at decrement\gth at n
+      \expandafter\expandafter\expandafter
+      \ifx\gth at nameuse{seqb@\gth at n}\relax\else
+        \edef\gth at rseq@x{\gth at gap@char\gth at rseq@x}%
+        \edef\gth at rseq@y{\gth at nameuse{seqb@\gth at n}%
+                         \gth at rseq@y}%
+      \fi
+    \else\ifnum\gth at n=\z@
+      \gth at decrement\gth at m
+      \expandafter\expandafter\expandafter
+      \ifx\gth at nameuse{seqa@\gth at m}\relax\else
+        \edef\gth at rseq@x{\gth at nameuse{seqa@\gth at m}%
+                         \gth at rseq@x}%
+        \edef\gth at rseq@y{\gth at gap@char\gth at rseq@y}%
+      \fi
     \else
-      \gth at tempcnta\@ne
-      \@whilenum\gth at tempcnta<\gth at m\do{%
-        \gth at tempcntb\@ne
-        \@whilenum\gth at tempcntb<\gth at n\do{%
-          \advance\gth at tempcnta\m at ne
-            \gth at max{%
-              \gth at nameuse{\gth at sn @m@\the\gth at tempcnta
-                        @\the\gth at tempcntb},%
-              \gth at nameuse{\gth at sn @iy@\the\gth at tempcnta
-                        @\the\gth at tempcntb}}%
-            \gth at tempcntc\gth at calc
-            \gth at tempcntd
-              \gth at nameuse{\gth at sn @ix@\the\gth at tempcnta
-                        @\the\gth at tempcntb}%
-            \advance\gth at tempcntc-\gth at d\advance\gth at tempcntd-\gth at e
-          \advance\gth at tempcnta\@ne
-          \gth at max{\gth at tempcntc,\gth at tempcntd}%
-          \gth at name@xdef{\gth at sn @ix@\the\gth at tempcnta
-                         @\the\gth at tempcntb}{%
-            \the\gth at calc}%
-          \advance\gth at tempcntb\m at ne
-            \gth at tempcntc
-              \gth at nameuse{\gth at sn @m@\the\gth at tempcnta
-                        @\the\gth at tempcntb}%
-            \gth at tempcntd
-              \gth at nameuse{\gth at sn @iy@\the\gth at tempcnta
-                        @\the\gth at tempcntb}%
-            \advance\gth at tempcntc-\gth at d\advance\gth at tempcntd-\gth at e
-          \advance\gth at tempcntb\@ne
-          \gth at max{\gth at tempcntc,\gth at tempcntd}%
-          \gth at name@xdef{\gth at sn @iy@\the\gth at tempcnta
-                         @\the\gth at tempcntb}{%
-            \the\gth at calc}%
-          \advance\gth at tempcnta\m at ne\advance\gth at tempcntb\m at ne
-            \gth at max{%
-              \gth at nameuse{\gth at sn @m@\the\gth at tempcnta
-                        @\the\gth at tempcntb},%
-              \gth at nameuse{\gth at sn @ix@\the\gth at tempcnta
-                        @\the\gth at tempcntb},%
-              \gth at nameuse{\gth at sn @iy@\the\gth at tempcnta
-                        @\the\gth at tempcntb}}%
-            \edef\gth at tmpa{\gth at nameuse{seqa@\the\gth at tempcnta}}%
-            \edef\gth at tmpb{\gth at nameuse{seqb@\the\gth at tempcntb}}%
-          \advance\gth at tempcnta\@ne\advance\gth at tempcntb\@ne
-          \ifx\gth at tmpa\gth at tmpb
-            \advance\gth at calc\gth at match
-          \else
-            \advance\gth at calc\gth at mismatch
-          \fi
-          \gth at name@xdef{\gth at sn @m@\the\gth at tempcnta
-                         @\the\gth at tempcntb}{%
-            \the\gth at calc}%
-          \advance\gth at tempcntb\@ne}%
-        \advance\gth at tempcnta\@ne}%
-    \fi
-    %\gth at print@matrix{m}%
-    %\gth at print@matrix{ix}%
-    %\gth at print@matrix{iy}%
-    \bgroup
-      \gth at decrement\gth at m \gth at decrement\gth at n
-      \expandafter\xdef\gth at score{%
-        \gth at nameuse{\gth at sn @m@\gth at m @\gth at n}}%
-    \egroup
-    \let\gth at rseq@x\@empty\let\gth at rseq@y\@empty\let\gth at mode@seq\@empty
-    \@gth at remain@true\@gth at gapx@false\@gth at gapy@false
-    \@whilesw\if at gth@remain@\fi{%
-      \ifnum\gth at m=\z@
+      \if at gth@gapx@
+        \gth at decrement\gth at m
+        \expandafter\expandafter\expandafter
+        \ifx\gth at nameuse{seqa@\gth at m}\relax\else
+          \edef\gth at rseq@x{\gth at nameuse{seqa@\gth at m}%
+                           \gth at rseq@x}%
+          \edef\gth at rseq@y{\gth at gap@char\gth at rseq@y}%
+        \fi
+        \gth at tempcnta\gth at nameuse{\gth at sn @m@\gth at m @\gth at n}%
+        \gth at tempcntb\gth at nameuse{\gth at sn @ix@\gth at m @\gth at n}%
+        \gth at tempcntc\gth at nameuse{\gth at sn @iy@\gth at m @\gth at n}%
+        \advance\gth at tempcnta-\gth at d
+        \advance\gth at tempcntb-\gth at e
+        \advance\gth at tempcntc-\gth at d
+        \ifnum\gth at tempcnta>\gth at tempcntb
+          \@gth at gapx@false
+        \else\ifnum\gth at tempcntb<\gth at tempcntc
+          \@gth at gapx@false\@gth at gapy@true
+        \fi\fi
+      \else\if at gth@gapy@
         \gth at decrement\gth at n
         \expandafter\expandafter\expandafter
         \ifx\gth at nameuse{seqb@\gth at n}\relax\else
@@ -203,91 +243,51 @@
           \edef\gth at rseq@y{\gth at nameuse{seqb@\gth at n}%
                            \gth at rseq@y}%
         \fi
-      \else\ifnum\gth at n=\z@
+        \gth at tempcnta\gth at nameuse{\gth at sn @m@\gth at m @\gth at n}%
+        \gth at tempcntb\gth at nameuse{\gth at sn @iy@\gth at m @\gth at n}%
+        \advance\gth at tempcnta-\gth at d\advance\gth at tempcntb-\gth at e
+        \ifnum\gth at tempcnta>\gth at tempcntb
+          \@gth at gapy@false
+        \fi
+      \else
         \gth at decrement\gth at m
+        \gth at decrement\gth at n
         \expandafter\expandafter\expandafter
         \ifx\gth at nameuse{seqa@\gth at m}\relax\else
-          \edef\gth at rseq@x{\gth at nameuse{seqa@\gth at m}%
-                           \gth at rseq@x}%
-          \edef\gth at rseq@y{\gth at gap@char\gth at rseq@y}%
-        \fi
-      \else
-        \if at gth@gapx@
-          % mode: gap x
-          \gth at decrement\gth at m
           \expandafter\expandafter\expandafter
-          \ifx\gth at nameuse{seqa@\gth at m}\relax\else
+          \ifx\gth at nameuse{seqb@\gth at n}\relax\else
             \edef\gth at rseq@x{\gth at nameuse{seqa@\gth at m}%
                              \gth at rseq@x}%
-            \edef\gth at rseq@y{\gth at gap@char\gth at rseq@y}%
-          \fi
-          \gth at tempcnta\gth at nameuse{\gth at sn @m@\gth at m @\gth at n}%
-          \gth at tempcntb\gth at nameuse{\gth at sn @ix@\gth at m @\gth at n}%
-          \gth at tempcntc\gth at nameuse{\gth at sn @iy@\gth at m @\gth at n}%
-          \advance\gth at tempcnta-\gth at d
-          \advance\gth at tempcntb-\gth at e
-          \advance\gth at tempcntc-\gth at d
-          \ifnum\gth at tempcnta>\gth at tempcntb
-            \@gth at gapx@false
-          \else\ifnum\gth at tempcntb<\gth at tempcntc
-            \@gth at gapx@false\@gth at gapy@true
-          \fi\fi
-        \else\if at gth@gapy@
-          % mode: gap y
-          \gth at decrement\gth at n
-          \expandafter\expandafter\expandafter
-          \ifx\gth at nameuse{seqb@\gth at n}\relax\else
-            \edef\gth at rseq@x{\gth at gap@char\gth at rseq@x}%
             \edef\gth at rseq@y{\gth at nameuse{seqb@\gth at n}%
                              \gth at rseq@y}%
           \fi
-          \gth at tempcnta\gth at nameuse{\gth at sn @m@\gth at m @\gth at n}%
-          \gth at tempcntb\gth at nameuse{\gth at sn @iy@\gth at m @\gth at n}%
-          \advance\gth at tempcnta-\gth at d\advance\gth at tempcntb-\gth at e
-          \ifnum\gth at tempcnta>\gth at tempcntb
-            \@gth at gapy@false
+        \fi
+        \gth at tempcnta\gth at nameuse{\gth at sn @m@\gth at m @\gth at n}%
+        \gth at tempcntb\gth at nameuse{\gth at sn @ix@\gth at m @\gth at n}%
+        \gth at tempcntc\gth at nameuse{\gth at sn @iy@\gth at m @\gth at n}%
+        \@gth at gap@false
+        \ifnum\gth at tempcnta<\gth at tempcntb\@gth at gap@true\fi
+        \ifnum\gth at tempcnta<\gth at tempcntc\@gth at gap@true\fi
+        \if at gth@gap@
+          \ifnum\gth at tempcntb>\gth at tempcntc
+            \@gth at gapx@true
+          \else
+            \@gth at gapy@true
           \fi
-        \else
-          % mode: default
-          \gth at decrement\gth at m
-          \gth at decrement\gth at n
-          \expandafter\expandafter\expandafter
-          \ifx\gth at nameuse{seqa@\gth at m}\relax\else
-            \expandafter\expandafter\expandafter
-            \ifx\gth at nameuse{seqb@\gth at n}\relax\else
-              \edef\gth at rseq@x{\gth at nameuse{seqa@\gth at m}%
-                               \gth at rseq@x}%
-              \edef\gth at rseq@y{\gth at nameuse{seqb@\gth at n}%
-                               \gth at rseq@y}%
-            \fi
-          \fi
-          \gth at tempcnta\gth at nameuse{\gth at sn @m@\gth at m @\gth at n}%
-          \gth at tempcntb\gth at nameuse{\gth at sn @ix@\gth at m @\gth at n}%
-          \gth at tempcntc\gth at nameuse{\gth at sn @iy@\gth at m @\gth at n}%
-          \@gth at gap@false
-          \ifnum\gth at tempcnta<\gth at tempcntb\@gth at gap@true\fi
-          \ifnum\gth at tempcnta<\gth at tempcntc\@gth at gap@true\fi
-          \if at gth@gap@
-            \ifnum\gth at tempcntb>\gth at tempcntc
-              \@gth at gapx@true
-            \else
-              \@gth at gapy@true
-            \fi
-          \fi
-        \fi\fi
+        \fi
       \fi\fi
-      \ifnum\gth at m<\@ne\ifnum\gth at n<\@ne
-        \@gth at remain@false
-      \fi\fi}%
-    \expandafter\gth at glet\gth at resulta\gth at rseq@x
-    \expandafter\gth at glet\gth at resultb\gth at rseq@y
-  \egroup}
+    \fi\fi
+    \ifnum\gth at m<\@ne\ifnum\gth at n<\@ne
+      \@gth at remain@false
+    \fi\fi}%
+  \expandafter\gth at glet\gth at resulta\gth at rseq@x
+  \expandafter\gth at glet\gth at resultb\gth at rseq@y}
 \def\gth at memo@ix#1#2{%
   \bgroup
     \gth at tempcnta#1\gth at tempcntb#2\relax
     \expandafter\expandafter\expandafter
     \ifx\gth at nameuse{\gth at sn @ix@\the\gth at tempcnta
-                  @\the\gth at tempcntb}\relax
+                     @\the\gth at tempcntb}\relax
       \advance\gth at tempcnta\m at ne
         \gth at memo@ix{\gth at tempcnta}{\gth at tempcntb}%
         \edef\gth at tmp@ix at return{\gth at ix@return}%
@@ -313,7 +313,7 @@
     \gth at tempcnta#1\gth at tempcntb#2\relax
     \expandafter\expandafter\expandafter
     \ifx\gth at nameuse{\gth at sn @iy@\the\gth at tempcnta
-                  @\the\gth at tempcntb}\relax
+                     @\the\gth at tempcntb}\relax
       \advance\gth at tempcntb\m at ne
         \gth at memo@iy{\gth at tempcnta}{\gth at tempcntb}%
         \edef\gth at tmp@iy at return{\gth at iy@return}%
@@ -336,7 +336,7 @@
     \gth at tempcnta#1\gth at tempcntb#2\relax
     \expandafter\expandafter\expandafter
     \ifx\gth at nameuse{\gth at sn @m@\the\gth at tempcnta
-                  @\the\gth at tempcntb}\relax
+                     @\the\gth at tempcntb}\relax
       \advance\gth at tempcnta\m at ne\advance\gth at tempcntb\m at ne
         \gth at memo@ix{\gth at tempcnta}{\gth at tempcntb}%
         \edef\gth at tmp@ix at return{\gth at ix@return}%



More information about the tex-live-commits mailing list