# -*- 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
# $Id: Portfile 119367 2014-04-23 19:52:12Z mf2k@macports.org $

PortSystem              1.0

name                    arb
epoch                   1
version                 6.0-rc1
categories              science
maintainers             mac.com:matt.cottrell
platforms               darwin

description             ARB graphical DNA, RNA and amino acid sequence analysis tool

homepage                http://www.arb-home.de/

long_description        ARB is an application for genetic sequence analysis that includes tools for editing and aligning \
                        nucleotide and amino acid sequences.  Features include routines for designing fluorescence in situ \
                        hybridization (FISH) probes and PCR and sequencing primers.  Phylogenetic trees can be generated and \
                        sequences can be added to existing trees.  ARB maintains links between the phylogenetic trees and sequences \
                        for database search and query.  The Silva Comprehensive Ribosomal RNA Database (http://www.arb-silva.de/) \
                        maintains up-to-date databases.  An active community of scientists exchanges tips on the ARB Yahoo! discussion group \
                        (http://tech.groups.yahoo.com/group/arb_users/). Citation: Wolfgang Ludwig, et al. (2004) ARB: a software environment \
                        for sequence data. Nucleic Acids Research. 32:1363-1371.

license                 Restrictive/Distributable

master_sites            http://download.arb-home.de/build/$name-${version}/
distname                arb-${version}-source-hotfix1
extract.suffix          .tgz
worksrcdir              arbsrc_11977

checksums               rmd160  9ef6edf8e2e386794cfc204519bb00f4394549ee \
                        sha256  cb9bcbd999d6f8b3c06bde70a1d1e5a61ca564e80c16da4bb01bb7820f396e10

depends_build           port:imake \
                        port:makedepend

depends_lib             port:openmotif \
                        port:lynx \
                        port:gsed \
                        port:sablotron \
                        port:glw \
                        port:glew \
                        port:xfig \
                        port:gv \
                        port:xorg-libXaw \
                        port:gtime \
                        path:lib/pkgconfig/glib-2.0.pc:glib2 \
                        port:coreutils



patchfiles              patch-ARB-config.makefile.diff \
                        patch-ARB-intro.fig.diff \
                        patch-ARB-arb.diff \
                        patch-ARB-ARBDB.diff

configure               {
                        if {${build_arch} eq "ppc" || ${build_arch} eq "i386"} {
                            set is64bit 0
                        } else {
                            set is64bit 1
                        }

                        file copy ${worksrcpath}/config.makefile.template ${worksrcpath}/config.makefile
                        reinplace "s|@@64BIT@@|${is64bit}|g" ${worksrcpath}/config.makefile
                        reinplace "s|@@PREFIX@@|${prefix}|g" ${worksrcpath}/SH/arb_macsetup
}

build.env-append        PREFIX=${prefix} \
                        ARBHOME=${worksrcpath} \
                        PATH=${worksrcpath}/bin:$env(PATH)

compiler.blacklist *llvm-gcc-4.2
                        
build.args              GCC=${configure.cc} \
                        GPP=${configure.cxx}

destroot.keepdirs       ${destroot}${prefix}/share/arb/lib/pts

destroot                {
                        # Give the default settings a recognizable name ending in .default
                        file rename ${worksrcpath}/lib/arb_tcp.dat ${worksrcpath}/lib/arb_tcp.dat.default
                        file rename ${worksrcpath}/lib/macros ${worksrcpath}/lib/macros.default

                        eval xinstall -m 0755 [glob ${worksrcpath}/bin/*] ${destroot}${prefix}/bin

                        file mkdir ${destroot}${prefix}/share/arb/bin
                        file copy ${worksrcpath}/PERL_SCRIPTS ${destroot}${prefix}/share/arb/PERL_SCRIPTS
                        file copy ${worksrcpath}/GDEHELP ${destroot}${prefix}/share/arb/GDEHELP
                        file copy ${worksrcpath}/lib ${destroot}${prefix}/share/arb/lib
                        file copy ${worksrcpath}/SH ${destroot}${prefix}/share/arb/SH
                        file copy ${worksrcpath}/demo.arb ${destroot}${prefix}/share/arb

                        file mkdir ${destroot}${prefix}/lib/help
                        file copy ${worksrcpath}/HELP_SOURCE/oldhelp ${destroot}${prefix}/lib/help

                        ln -s ${prefix}/bin/arb_pt_server ${destroot}${prefix}/share/arb/bin/arb_pt_server
                        ln -s ${prefix}/bin/arb_name_server ${destroot}${prefix}/share/arb/bin/arb_name_server

                        xinstall -m 777 -d ${destroot}${prefix}/share/arb/lib/pts
}

# to be investigated later
universal_variant       no

post-activate           {
                        # Provide users with copies of the default configuration and macros
                        # if the user doesn't already have them.
                        if {![file exists ${prefix}/share/arb/lib/arb_tcp.dat]} {
                            xinstall -m 777 ${prefix}/share/arb/lib/arb_tcp.dat.default \
                                ${prefix}/share/arb/lib/arb_tcp.dat
                        }
                        if {![file exists ${prefix}/share/arb/lib/macros]} {
                            file copy ${prefix}/share/arb/lib/macros.default \
                                ${prefix}/share/arb/lib/macros
                            fs-traverse item ${prefix}/share/arb/lib/macros {
                                file attributes ${item} -permissions a+w
                            }
                        }
}

notes "
****************************************************************
Before running ARB you must set ARBHOME and add ARB to your PATH
****************************************************************

You have two options (A is easier, B is more difficult):

A) Easy - open a new terminal window and type arb_macsetup to set the necessary environment variables automatically.  This script also enables keyboard shortcuts used in the sequence editor.

or
	
B) More difficult - follow the steps below:

1)
bash users add the following lines to your ~/.profile or to your ~/.bashrc

      ARBHOME=${prefix}/share/arb;export ARBHOME
      PATH=${prefix}/share/arb/bin:\$PATH
      export PATH

      enter the following command:
      . ~/.profile
2)
tcsh users add the following lines to your ~/.cshrc
      
      setenv ARBHOME ${prefix}/share/arb
      setenv PATH ${prefix}/share/arb\:\$PATH

      enter the following command:
      source ~/.cshrc

C) to set up ARB for another user on this computer log into their account and type ${prefix}/bin/arb_macsetup

************************************************************************************************************************************
You can set up keyboard shortcuts manually by creating a text file in your home folder called .xmodmap that contains the text below:
************************************************************************************************************************************

clear Mod1
clear Mod2
keycode 63 = Mode_switch
keycode 66 = Meta_L
keycode 69 = Meta_R
add Mod1 = Meta_L Meta_R
add Mod2 = Mode_switch

*******************************************************************
Use keys Control+Command Arrow Key to jump over bases
Use Keys Option Arrow Key to pull in bases across alignment gaps
Use the right Command Key plus a letter key to activate a menu item
*******************************************************************

*****************************
Type 'arb' to start using ARB
*****************************

A demo data base is located at ${prefix}/share/arb/demo.arb

User generated macros, arb_tcp.dat and pt_servers have been preserved,
but you should keep backups of these just in case.  They are located at:

${prefix}/share/arb/lib/macros/
${prefix}/share/arb/lib/arb_tcp.dat
${prefix}/share/arb/lib/pts/

Default settings are maintained at:

${prefix}/share/arb/lib/macros.default/
${prefix}/share/arb/lib/arb_tcp.dat.default

These notes can be viewed at any time by typing 'port notes arb'

Please cite: Wolfgang Ludwig, et al. (2004) ARB: a software environment for sequence data. Nucleic Acids Research. 32:1363-1371
"

livecheck.type          regex
livecheck.url           http://download.arb-home.de/build/
livecheck.regex         ${name}-(\[0-9.\]+)-rc1-source/${extract.suffix}
