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

github.setup        infphilo tophat 2.1.2 v
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
revision            3
categories          science biology
license             Boost-1
maintainers         {mcalhoun @MarcusCalhoun-Lopez} openmaintainer

description         a fast splice junction mapper for RNA-Seq reads

long_description    TopHat is {*}${description}. It aligns RNA-Seq reads to \
                    mammalian-sized genomes using the ultra high-throughput \
                    short read aligner Bowtie, and then analyzes the mapping \
                    results to identify splice junctions between exons.

homepage            https://ccb.jhu.edu/software/tophat/

checksums           rmd160  5a5525f810a38efd5d95303224477d62eb2bd110 \
                    sha256  ec4c522a1caa6cc7c52e2ed7d60f8cdfb21d010523de93d60c64cd5c1b0f352a \
                    size    4538707

use_autoconf        yes
autoconf.cmd        ./bootstrap
autoconf.args

patchfiles          patch-cflags.diff \
                    patch-macports_libs.diff \
                    patch-cxx14.diff

post-patch {
    reinplace -W ${worksrcpath}/src \
        "s|^#!/usr/bin/env python|#!${prefix}/bin/python2.7|" \
        bed_to_juncs \
        contig_to_chr_coords \
        generate_chromosome.py \
        sra_to_solid \
        tophat-fusion-post \
        tophat.py
}

# replicate default optimization level
configure.optflags      -O3

configure.cppflags-prepend  -I${prefix}/include/seqan-1 \
                            -I${prefix}/include/bam-0.1

# find correct Boost library
# allow MacPort to set optimization level
# avoid conflict with boehmgc
configure.args-append   --with-boost-thread=-mt \
                        --enable-optim=no \
                        --libdir=${prefix}/libexec/${name}/lib

# need for autoconf
depends_build-append    port:autoconf \
                        port:automake \
                        port:libtool

depends_lib-append      port:python27 \
                        port:zlib \
                        port:samtools-0.1 \
                        port:seqan-1

# TopHat attempts to install its own versions
depends_run-append       port:py27-intervaltree2 \
                         port:py27-sortedcontainers
post-destroot {
    delete \
        ${destroot}${prefix}/bin/intervaltree \
        ${destroot}${prefix}/bin/sortedcontainers
}

# TopHat uses BowTie 2 by default, so make it a runtime dependency
depends_run-append       port:bowtie2

notes {
    By default, TopHat uses BowTie version 2, so the port bowtie2 was installed as a dependency.
    To use BowTie version 1 as well, please install the port bowtie manually.
}
