# -*- 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           makefile 1.0

name                theseus
version             3.3.0
revision            4

categories          science
platforms           darwin
license             GPL-2+
maintainers         {reneeotten @reneeotten} openmaintainer

description         A program for maximum likelihood superpositioning and analysis of macromolecular structures
long_description    {*}${description}

homepage            https://theobald.brandeis.edu/theseus
master_sites        ${homepage}/src/
distname            theseus_${version}

checksums           rmd160  33c23525cbc0dc1ae805766492d29e16844d311b \
                    sha256  3cfd4f906717f9cb8e77f689fc97059b32df355c0696077034ea99a485e3f2fe \
                    size    22548124

depends_build       port:cctools

depends_lib         port:gsl

extract.rename      yes

patchfiles          patch-make.inc.diff

variant muscle description {Use MUSCLE for multiple sequence alignment} {
    depends_run-append \
                    port:muscle

    patchfiles-append \
                    patch-theseus_align-muscle.diff

    notes-append "**  MUSCLE will be used as alignment program by 'theseus_align'  **"
}

variant mafft description {Use MAFFT for multiple sequence alignment} {
    depends_run-append \
                    port:mafft

    patchfiles-append \
                    patch-theseus_align-mafft.diff

    notes-append "**  MAFFT will be used as alignment program by 'theseus_align'  **"
}

if {![variant_isset mafft]} {
    default_variants +muscle
}

post-patch {
    reinplace "s|@@PREFIX@@|${prefix}|g" ${worksrcpath}/make.inc
    reinplace "s|@@PREFIX@@|${prefix}|g" ${worksrcpath}/theseus_align
    reinplace "s|error.h|Error.h|g" ${worksrcpath}/NWfill.c
}

post-destroot {
    xinstall -m 0755 -W ${worksrcpath} theseus theseus_align ${destroot}${prefix}/bin
    xinstall -m 0644 -W ${worksrcpath} theseus.1 ${destroot}${prefix}/share/man/man1

    set docdir ${prefix}/share/doc/${name}
    xinstall -d ${destroot}${docdir}
    xinstall -m 0644 -W ${worksrcpath} AUTHORS COPYING \
       INSTALL.txt LICENSE README theseus_man.pdf ${destroot}${docdir}
}

livecheck.type      regex
livecheck.url       ${homepage}
livecheck.regex     Version (\[0-9.\]+)

notes   "The provided wrapper script 'theseus_align', runs THESEUS on multiple PDB files.\
        This script transparently extracts the proper sequences from the PDB files, aligns\
        them, and then performs the ML superposition based on that alignment.\
        \n\nIt can use different alignment programs: MUSCLE and MAFFT are currently present\
        in MacPorts; others (PROBCONS, CLUSTALW, CLUSTAL-OMEGA, T_COFFEE, KALIGN, DIALIGN2)\
        can be utilized as well, but will require editing of the script located in:\
        ${prefix}/bin/theseus_align"
