I'm not sure why I get two extra characters at the end of the for loop. Looking at other answers on StackExchange indicates I'm not suppose to use both algorithm and algorithmic and that its better to stick to one.
However, removing either does not produce the results I want.
Here is the code.
\usepackage{setspace}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{multicol}
\usepackage{algorithm}
\usepackage{algorithmic}
\usepackage{subcaption}
\usepackage{colortbl}
\usepackage{xparse}
\usepackage{caption}
\usepackage{fancyhdr}
\usepackage{algpseudocode}
\begin{center}
\begin{minipage}{1\textwidth}
\begin{algorithm}[H]
\caption{Forward calculation for pair HMMs}
\begin{algorithmic}
\REQUIRE Set $f^{\mathrm{M}}(0,0)=1 f^{\mathrm{X}}(0,0)=f^{\mathrm{Y}}(0,0)= f^{}(i,-1) = f^{}(-1, j) = 0$
\FOR{$i=0, \ldots, n, j=0, \ldots, m \text { except }(0,0)$}
\begin{aligned}
f^{\mathrm{M}}(i, j) & = p_{I_{i} O_{j}}\left[a_{MM} (f^{\mathrm{M}}(i-1, j-1))+\
& \quad \quad \left.a_{XM}\left(f^{\mathrm{X}}(i-1, j-1)\right)+a_{YM}(f^{\mathrm{Y}}(i-1, j-1)\right)\right] \
f^{\mathrm{X}}(i, j) & = q_{I_{i}}\left[a_{MX} f^{\mathrm{M}}(i-1, j)+a_{XX} f^{\mathrm{X}}(i-1, j)\right] \
f^{\mathrm{Y}}(i, j) & = q_{O_{j}}\left[a_{MY} f^{\mathrm{M}}(i, j-1)+a_{YY} f^{\mathrm{Y}}(i, j-1)\right]\
\end{aligned}
\ENDFOR
\end{algorithmic}
\end{algorithm}
\end{minipage}
\end{center}
