# -*- 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 92165 2012-04-20 20:58:04Z ryandesign@macports.org $

PortSystem              1.0

name                    arb
epoch                   1
version                 5.3
revision                4
categories              science
maintainers             me.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.

master_sites            http://download.arb-home.de/release/arb_${version}/
distname                arbsrc
extract.suffix          .tgz
dist_subdir             ${name}/${version}
worksrcdir              arbsrc_8210

checksums               sha1    535b72bfbf99f498deee17824c1f167228ad2088 \
                        rmd160  d4b240da693f903d0e8bd59f4b1f1043b6935508

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

patchfiles              patch-ARB-config.makefile.diff \
                        patch-ARB-makefile.diff \
                        patch-ARB-RNA3D_GlobalHeader.hxx.diff \
                        patch-ARB-DARWIN.pl.diff \
                        patch-ARB-intro.fig.diff \
                        patch-GDEHELP-Makefile.diff
                       
configure               {
                        reinplace "s| sed | gsed |g" ${worksrcpath}/GDEHELP/MENUS/align.menu \
                                                     ${worksrcpath}/util/arb_check_build_env.pl \
                                                     ${worksrcpath}/arb_install.sh \
                                                     ${worksrcpath}/WINDOW/AW_status.cxx \
                                                     ${worksrcpath}/SH/example_batch_probe_match.sh \
                                                     ${worksrcpath}/GDEHELP/GDEmenus \
                                                     ${worksrcpath}/GDEHELP/genhelp.sh \
                                                     ${worksrcpath}/GDEHELP/genhelptree.sh \
                                                     ${worksrcpath}/SOURCE_TOOLS/make_java_dependencies.sh \
                                                     ${worksrcpath}/HELP_SOURCE/Makefile \
                                                     ${worksrcpath}/AISC_COM/AISC/Makefile \
                                                     ${worksrcpath}/GDEHELP/Makefile \
                                                     ${worksrcpath}/HELP_SOURCE/genhelp/Makefile \
                                                     ${worksrcpath}/GDEHELP/Makefile.helpfiles
                        file copy ${worksrcpath}/config.makefile.template ${worksrcpath}/config.makefile
                        file copy ${filespath}/arb_macsetup ${worksrcpath}/bin
                        reinplace "s|@@LIBPERLDIR@@|[exec ${prefix}/bin/perl -e "use Config; print \$Config{archlib};"]/CORE|g" ${worksrcpath}/PERL2ARB/DARWIN.PL
                        reinplace "s|@@PREFIX@@|${prefix}|g" ${worksrcpath}/bin/arb_macsetup

                        if {${build_arch} == "ppc" || ${build_arch} == "i386"} {
                            set is64bit 0
                        } else {
                            set is64bit 1
                        }
                        reinplace "s|@@64BIT@@|${is64bit}|g" ${worksrcpath}/config.makefile
}

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

# https://trac.macports.org/ticket/33756
if {${configure.compiler} == "clang"} {
    configure.compiler 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}/lib ${destroot}${prefix}/share/arb/lib
                        file copy ${worksrcpath}/GDEHELP ${destroot}${prefix}/share/arb/GDEHELP
                        file mkdir ${destroot}${prefix}/lib/help
                        file copy ${worksrcpath}/HELP_SOURCE/oldhelp ${destroot}${prefix}/lib/help
                        file copy ${worksrcpath}/PERL_SCRIPTS ${destroot}${prefix}/share/arb/PERL_SCRIPTS
                        file copy ${worksrcpath}/SH ${destroot}${prefix}/share/arb/SH
                        file copy ${worksrcpath}/demo.arb ${destroot}${prefix}/share/arb
                        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
3)
create 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

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

D)
type arb to start 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

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

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/release/
livecheck.regex         ${name}_(\[0-9.\]+)/
