# Adapting the GACT-X Aligner to Accelerate Minimap2 in an FPGA Cloud Instance
## 2 Materials and Methods
### GACT-X in Minimap2: Performance Assessment and Optimization  
In the first series of experiments, the cloud FPGA implementation of GACT-X was evaluated and optimized. Sub-sequences were generated from Minimap2 installed in the server of the f1.2 xlarge instance, through its chaining step, and used as input to the GACT-X module installed in the FPGA board. Alternatively, Minimap2 also runs its original version with the _ksw_ function, which is used as a comparison reference. The three datasets described in Section 2.2.2 were assembled in Minimap2, in a single thread execution, to collect the intermediate results after chaining. All three read sets were mapped to the primary assembly of the GRCh38 reference. Minimap2 was executed to output the alignment in the \".sam\" format. Figure 6 shows the adapted flowchart for transferring data to the FPGA with the tile algorithm. The input sub-sequences were collected from Minimap2 after the seeding and chaining steps (left of the figure). Each sub-sequence is transferred once to the cloud FPGA, and, during its tile processing, the parameters and results are transferred back and forth to the host. In the figure, the loop cycles 5 times, since five tiles are considered for this example. The alignment parameters of GACT-X were changed to have the same proportions as the default in Minimap2 (Table 2) through the file \"params.cfg\". The alignment parameters directly influence the alignment scores and the alignment paths resulting from the SWG algorithm. The match, mismatch, and gap scores are \(2,\ -4,\ -4,\ -2\) for Minimap2, so they were set as \(10,\ -20,\ -30,\ -10\) for the adapted GACT-X. The difference in the gap opening score is due to different interpretations of whether an extension occurs when opening a gap, but the resulting alignment is the same. GACT-X only supports one gap function, so only Minimap2's affine gap function with a higher slope and lower translocation was used in GACT-X since it picks the more frequent short indels (insertion/deletions). The X-drop value was adjusted proportionally to the new match score. The first 100,000 simulated long reads were aligned with Minimap2 to the GRCh38 genome reference. This quantity was enough for the initial evaluation and displayed a similar length distribution to the entire dataset. The simulated dataset was chosen because it was confirmed to present a good mapping accuracy in Minimap2. The ksw function's input lengths and the function's processing time were measured in the \"ksw2_extd2_sse.c\" file. Time was measured using the function \"time\". Minimap2's method of breaking reads into sub-sequences separated by anchors in a chain reduced the query and target lengths from thousands of bases to mostly 200-300 bases. The same inputs for ksw were written in a \".txt\" file and aligned with GACT-X, with the processing time measured in the host using the \"high_resolution_clock:now()\" function. GACT-X performed considerably worse than the ksw function from Minimap2, as presented in Figure 7. The performances for ksw and GACT-X meet only for sequences larger than 1000 bases. This is because GACT-X's processing time has a shifted constant of about 500 us that corresponds to the data transfer time from the host to FPGA and back throughout the PCIe line. This creates a heavy \begin{table}
\begin{tabular}{c c c c c c c c} \hline \hline  & \multirow{2}{*}{**Match Score**} & \multirow{2}{*}{**Mismatch Score**} & \multicolumn{3}{c}{**1 st Affine Function**} & \multicolumn{3}{c}{**2 nd Affine Function**} & \multirow{2}{*}{**X-Drop**} \\ \cline{3-4} \cline{6-7}  & & & **Gap Open** & & **Gap Extend** & & **Gap Open** & **Gap Extend** \\ \hline \hline
**Minimap2** & 2 & \(-4\) & \(-4\) & \(-2\) & \(-24\) & \(-1\) & - \\ \hline \multirow{2}{*}{**GACT-X**} & **Original** & \(91\) to \(100\) & \(-31\) to \(-125\) & \(-430\) & \(-30\) & - & - & 9430 \\ \cline{2-7}  & **Adapted** & \(10\) & \(-20\) & \(-30\) & \(-10\) & - & - & 943 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Minimap2 and GACT-X’s alignment parameters.