Sign inSign up

jysgro/reseek

By jysgro

Updated 11 months ago

"reseek" protein structure search and alignment algorithm within Ubuntu 22:04

Image
Data science
0

285

jysgro/reseek repository overview

Source code is at: https://github.com/rcedgar/reseek

Compilation = today 2025/11/03 for AMD X86

Run and share local DIR with container mapped onto, and opened in working dir /data:

docker run -it --rm -v ${PWD}:/data -w /data jysgro/reseek:ub2204

Check with:

reseek --help

See source code for details.

Compilation for ARM (Silicon) chip

This took many hours of working with Copilot, and in the end still runs within the container over qemu-i386 after a compilation possible through SIMDe (SIMD Everywhere), but in the end the resulting binary is still in AMD-style rather than ARM. Also, since the code ended up being 32 bit a cross compilation was necessary.

I wrote more details in a Blog on this process here: Compiling arm64 version of amd64 code in 32 bit in a container – with Copilot help

The more complicated Dockerfile is further below.

To run this version:

ocker run -it --rm -v ${PWD}:/data -w /data jysgro/reseek:ub2204_arm64_qemu32

In the end it may be easier to use the AMD64 container with the added --platform=linux/amd64, but THIS DOES NOT WORK and will simply give error Illegal instruction.

# WILL NOT WORK on ARM
docker run -it --rm --platform=linux/amd64 -v ${PWD}:/data -w /data jysgro/reseek:ub2204

AMD64 Dockerfile used: (for tag=ub2204)

Created in part with help by Copilot.

# Official Ubuntu base image
FROM ubuntu:22.04

# Set environment variables to avoid interactive prompts during package installation
ENV DEBIAN_FRONTEND=noninteractive

# Update and install dependencies
RUN apt-get update && apt-get install -y \
    git \
    build-essential \
    libboost-all-dev \
    libeigen3-dev \
    libopencv-dev \
    python3 \
    python3-pip \
    && rm -rf /var/lib/apt/lists/*

# Clone reseek repository
RUN git clone https://github.com/rcedgar/reseek.git /opt/reseek

# Set working directory
WORKDIR /opt/reseek

# Add a few things after the fact:
RUN apt-get update && apt-get install -y nano curl wget

RUN cd src/; chmod +x build_linux_x86.bash ; ./build_linux_x86.bash \
    && rm -rf /var/lib/apt/lists/*

# Clean up compilation objects
RUN rm /opt/reseek/src/o/*.o

# Add Path to reseek
ENV PATH="${PATH}:/opt/reseek/bin"

# Variable required to run correctly:
ENV reseek=/opt/reseek/bin/reseek

# Default command
CMD ["/bin/bash"]

ARM Docker file - for tag ub2204_arm64_qemu32

FROM ubuntu:22.04

ENV DEBIAN_FRONTEND=noninteractive

# Install dependencies and cross-toolchain for i686
RUN apt-get update && apt-get install -y \
    git \
    build-essential \
    gcc-i686-linux-gnu \
    g++-i686-linux-gnu \
    binutils-i686-linux-gnu \
    libc6-dev-i386-amd64-cross \
    libboost-all-dev \
    libeigen3-dev \
    libopencv-dev \
    python3 \
    python3-pip \
    nano \
    curl \
    wget \
    cmake \
    patch \
    qemu-user \
    qemu-user-static \
    binfmt-support \
    && rm -rf /var/lib/apt/lists/*

# Register QEMU for i386 emulation
RUN update-binfmts --enable qemu-i386

# Clone SIMDe
RUN git clone https://github.com/simd-everywhere/simde.git /opt/simde

# Clone reseek repository
RUN git clone https://github.com/rcedgar/reseek.git /opt/reseek
RUN sed -i '/#include "dss.h"/a #include <iostream>' /opt/reseek/src/dss.cpp
RUN sed -i 's/asserta(ScaledValue >= 0 && ScaledValue <= 1);/if (ScaledValue < 0 || ScaledValue > 1) { std::cerr << "Warning: ScaledValue out of bounds: " << ScaledValue << " (Value=" << Value << ", Min=" << MinValue << ", Max=" << MaxValue << ", Range=" << Range << ")" << std::endl; ScaledValue = std::min(1.0, std::max(0.0, ScaledValue)); }/' /opt/reseek/src/dss.cpp

# Patch parasail.h with SIMDe
RUN sed -i 's|#include <immintrin.h>|#define SIMDE_ENABLE_NATIVE_ALIASES\n#include "/opt/simde/simde/x86/avx2.h"|' /opt/reseek/src/parasail.h && \
    sed -i 's/\b__m256i\b/simde__m256i/g' /opt/reseek/src/parasail.h && \
    sed -i 's/\b_mm256_/simde_mm256_/g' /opt/reseek/src/parasail.h && \
    sed -i 's/\b_MM_SHUFFLE\b/SIMDE_MM_SHUFFLE/g' /opt/reseek/src/parasail.h && \
    sed -i 's/simde__m256i_8_8/simde__m256i/g' /opt/reseek/src/parasail.h && \
    sed -i 's|return.*parasail_memalign(alignment, size.*);|return (simde__m256i *) parasail_memalign(alignment, size*sizeof(simde__m256i));|' /opt/reseek/src/parasail.h

# Patch parasail.cpp (only intrinsic and type replacements, no function renaming)
RUN sed -i 's/_mm256_slli_si256_rpl/simde_mm256_slli_si256/g' /opt/reseek/src/parasail.cpp && \
    sed -i 's/_mm256_hmax_epi8_rpl/simde_mm256_hmax_epi8_rpl/g' /opt/reseek/src/parasail.cpp && \
    sed -i 's/_mm256_insert_epi8_rpl/simde_mm256_insert_epi8/g' /opt/reseek/src/parasail.cpp && \
    sed -i '/_mm256_store_si256(&vProfile\[index\], t.m);/c\            simde_mm256_store_si256(&vProfile[index], simde_mm256_setzero_si256());' /opt/reseek/src/parasail.cpp

# Patch getticks.h to avoid x86-only asm on ARM
RUN sed -i '/__asm__ __volatile__ ("rdtsc"/i #if defined(__x86_64__) || defined(__i386__)' /opt/reseek/src/getticks.h && \
    sed -i '/__asm__ __volatile__ ("rdtsc"/a #else\n lo = hi = 0;\n#endif' /opt/reseek/src/getticks.h

# Set working directory
WORKDIR /opt/reseek/src

# Disable last line of build_linux_x86.bash
RUN sed -i '$d' build_linux_x86.bash

# Run the script to generate vcxproj_make.py
RUN chmod +x build_linux_x86.bash && ./build_linux_x86.bash

# Compile using vcxproj_make.py with cross-compilers
RUN python3 ./vcxproj_make.py --cppcompiler="i686-linux-gnu-g++" --ccompiler="i686-linux-gnu-gcc" --nonative --nostrip

# Replace strip with i686-linux-gnu-strip in Makefile
RUN sed -i 's/\bstrip\b/i686-linux-gnu-strip/g' /opt/reseek/src/Makefile

# Clean up compilation objects
RUN rm -f /opt/reseek/src/o/*.o

# Add reseek to PATH
# ENV PATH="${PATH}:/opt/reseek/bin"
# ENV reseek=/opt/reseek/bin/reseek

# Create a wrapper to call qemu-i386 internally in the container
# to avoid Exec format error.
# While the compilationn was successful for ARM chip it is not
# an ARM binary fully.


# Create a wrapper script for reseek using qemu-i386
RUN echo '#!/bin/bash\nqemu-i386 /opt/reseek/bin/reseek "$@"' > /usr/local/bin/reseek && \
    chmod +x /usr/local/bin/reseek

CMD ["/bin/bash"]

Tag summary

Content type

Image

Digest

sha256:5eac51ed4

Size

829 MB

Last updated

11 months ago

docker pull jysgro/reseek:ub2204_arm64_qemu32