# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem                  1.0
PortGroup                   github      1.0
PortGroup                   makefile    1.0

github.setup                BenLangmead bowtie2 2.5.1 v
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from         tarball
revision                    0

categories                  science biology
license                     GPL-3+
maintainers                 {mcalhoun @MarcusCalhoun-Lopez} openmaintainer

description                 Bowtie 2: Fast and sensitive read alignment
long_description            Bowtie 2 is an ultrafast and memory-efficient tool \
                            for aligning sequencing reads to long reference \
                            sequences. It is particularly good at aligning reads \
                            of about 50 up to 100s or 1,000s of characters, and \
                            particularly good at aligning to relatively long \
                            (e.g. mammalian) genomes. Bowtie 2 indexes the genome \
                            with an FM Index to keep its memory footprint small: \
                            for the human genome, its memory footprint is \
                            typically around 3.2 GB. Bowtie 2 supports gapped, \
                            local, and paired-end alignment modes.

homepage                    https://bowtie-bio.sourceforge.net/bowtie2/index.shtml

checksums                   rmd160  581f3b8f901722df829b9bbdf5d6fcaa8a3ba6c5 \
                            sha256  34da16406d190f05cd4cfd27de8fdaf3d3adfb5d41dc628e41e7c5ab5ce73e77 \
                            size    10598900

patchfiles                  patch-src-Makefile.diff

set python_branch           3.11
set python_version          [string map {. {}} ${python_branch}]

post-patch {
    reinplace               -W ${worksrcpath} \
                            "s|^#!/usr/bin/env python3\$|#!${prefix}/bin/python${python_branch}|" \
                            bowtie2-build \
                            bowtie2-inspect
}

supported_archs             arm64 x86_64
installs_libs               no
compiler.cxx_standard       2011

depends_lib-append          port:zlib
if {${configure.build_arch} eq "arm64"} {
    depends_build-append    port:simde
}

depends_run-append          port:python${python_version}

# Makefile sets optimizations flags
configure.optflags-delete   -Os

makefile.override-append    PREFIX

post-destroot {
    xinstall                -m 755 \
                            -d \
                            ${destroot}${prefix}/share/doc/${name}
    xinstall                -m 644 \
                            -W ${worksrcpath} \
                            TUTORIAL \
                            README.md \
                            NEWS \
                            MANUAL.markdown \
                            MANUAL \
                            LICENSE \
                            AUTHORS \
                            ${destroot}${prefix}/share/doc/${name}
}

# do not find _new or -beta software
github.livecheck.regex      {([^"_-]+)}
