Tuesday, July 21, 2026

The Step-by-Step Guide to Compiling LASTZ for Windows 64-bit

 

Step 1: Install the MSYS2 Environment

  1. Download and run the official 64-bit installer from MSYS2.org.

  2. Once installed, launch the MSYS2 MinGW 64-bit terminal from your Start Menu. (Crucial: Do not use the default MSYS terminal; use the blue-coded MinGW 64-bit shell). "msys2-x86_64-20260611.exe"


Then run

Step 2: Install the Compiler Toolchain

Update your package database and install the native Windows 64-bit GCC compiler and Git by running the following command in the MSYS2 terminal: pacman -Syu

pacman -S --needed mingw-w64-x86_64-toolchain git make




Press enter on "all" then Y



Then add the the path to the C++ compiler to your windows path:

C:\msys64\mingw64\bin

Step 3: Install the Windows mman Library

The MSYS2 community has built a direct translation library called mman-win32 that bridges this exact Unix-to-Windows gap.

Open your MSYS2 MinGW 64-bit terminal and run this command to download and install the missing header file: pacman -S mingw-w64-x86_64-mman-win32


We can tell the GCC compiler to physically embed the mman library directly inside lastz.exe instead of just pointing to it. This is called static linking, and it ensures your .exe will run on any Windows machine without needing extra files.

Step 4: Clone the LASTZ Source Code

Clone the repository and jump into the directory or download : https://github.com/lastz/lastz





Extract into a folder:


















Now you need to make some changes to the Makefile to allow it to build on Windows 64 bit:


On line:






Change:

Line 58:


definedForAll = -Wall -Wextra -Werror -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE


to:


definedForAll = -Wall -Wextra -Werror -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -DNO_GZCOMPRESS -D__MINGW32__ -D__MSVCRT__



Change:

Line 58:


definedForAll = -Wall -Wextra -Werror -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE


to:


definedForAll = -Wall -Wextra -Werror -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -DNO_GZCOMPRESS -D__MINGW32__ -D__MSVCRT__






Change:

Line 108:


lastz: $(foreach part,${srcFiles},${part}.o) ${CC} ${LDFLAGS} $(foreach part,${srcFiles},${part}.o) -lm -o $@ lastz_D: $(foreach part,${srcFiles},${part}_D.o) ${CC} ${LDFLAGS} $(foreach part,${srcFiles},${part}_D.o) -lm -o $@ lastz_32: $(foreach part,${srcFiles},${part}_32.o) ${CC} ${LDFLAGS} $(foreach part,${srcFiles},${part}_32.o) -lm -o $@ lastz_40: $(foreach part,${srcFiles},${part}_40.o) ${CC} ${LDFLAGS} $(foreach part,${srcFiles},${part}_40.o) -lm -o $@


to:


lastz: $(foreach part,${srcFiles},${part}.o) ${CC} ${LDFLAGS} $(foreach part,${srcFiles},${part}.o) -static -lm -lmman -o $@ lastz_D: $(foreach part,${srcFiles},${part}_D.o) ${CC} ${LDFLAGS} $(foreach part,${srcFiles},${part}_D.o) -static -lm -lmman -o $@ lastz_32: $(foreach part,${srcFiles},${part}_32.o) ${CC} ${LDFLAGS} $(foreach part,${srcFiles},${part}_32.o) -static -lm -lmman -o $@ lastz_40: $(foreach part,${srcFiles},${part}_40.o) ${CC} ${LDFLAGS} $(foreach part,${srcFiles},${part}_40.o) -static -lm -lmman -o $@



Step 5: Re-open MSYS2 MINGW64 (To allow it to pick up the path changes)


Now change the folder in the terminal to where the source code is: (The first part is the drive name)


$ cd /c/tools/lastz-master/src

Step 6: Compile and build:


Type:

make clean

make
















Step 7: You should now find the file in the folder:




















Then open a windows CMD terminal and test: C:\Tools\lastz-master\src>lastz.exe You must specify a target file lastz-- Local Alignment Search Tool, blastZ-like (version 1.04.58 released 20260507) usage: lastz target [query] [options] (common options; use --help for a more extensive list) target, query specifiers or files, containing sequences to align (use --help=files for more details) --seed=<pattern> set seed pattern (12of19, 14of22, or general pattern) (default is 1110100110010101111) --[no]transition allow (or don't) one transition in a seed hit (by default a transition is allowed) --[no]chain perform chaining (by default no chaining is performed) --[no]gapped perform gapped alignment (instead of gap-free) (by default gapped alignment is performed) --step=<length> set step length (default is 1) --strand=both search both strands --strand=plus search + strand only (matching strand of query spec) (by default both strands are searched) --scores=<file> read substitution and gap scores from a file --xdrop=<score> set x-drop threshold (default is 10sub[A][A]) --ydrop=<score> set y-drop threshold (default is open+300extend) --infer[=<control>] infer scores from the sequences, then use them all inference options are read from the control file --hspthresh=<score> set threshold for high scoring pairs (default is 3000) ungapped extensions scoring lower are discarded <score> can also be a percentage or base count --gappedthresh=<score> set threshold for gapped alignments gapped extensions scoring lower are discarded <score> can also be a percentage or base count (default is to use same value as --hspthresh) --include=<file> read command line arguments from a text file --help list "all" options (but the online documentation is more complete) --help=files list information about file specifiers --help=shortcuts list blastz-compatible shortcuts --help=defaults list scoring defaults for your current settings --help=yasra list yasra-specific shortcuts See the online documentation at http://www.bx.psu.edu/~rsharris/lastz for the most up-to-date information.


I then did a LastZ alignment between the Silk moth mitochondrial genome and the Human mitochondrial genome and this was the result:


It is more sensitive than Minimap2, which is faster, but does not show significant similarities.


 

Then when I used TBlastX to do the same, I can see much more similarity due to the fact that tBlastX works on the protein level.















No comments:

Post a Comment

Please leave me a comment