File ncbi.spec of Package ncbi

# spec file for package ncbi
# Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany.
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via

Name:           ncbi
Summary:        NCBI Software Development Toolkit
License:        SUSE-Public-Domain
Group:          Productivity/Scientific/Other
Version:        6.1
Release:        0
BuildRequires:  fdupes
BuildRequires:  gcc
BuildRequires:  openmotif-devel
BuildRequires:  tcsh
%if 0%{?suse_version} > 1140
BuildRequires:  libjpeg-devel
BuildRequires:  pkgconfig(libpng)
BuildRequires:  pkgconfig(xmuu) 
BuildRequires:  pkgconfig(xp)
Source:         %{name}.tar.gz
Patch0:         ncbi-6.1-link-to-shared-motif.patch
Patch1:         ncbi-6.1-optflags.patch
Patch2:         ncbi-6.1-strncat-overflow.patch
Patch3:         ncbi-6.1-math-meaning.patch
Patch4:         ncbi-6.1-null-pointer.patch
Patch5:         ncbi-6.1-no-return.patch
Patch6:         ncbi-6.1-sequence-point.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%define wwwblastdir /var/lib/wwwblast

The NCBI Software Development Toolkit was developed for the production and
 distribution of GenBank, Entrez, BLAST, and related services by NCBI.

%package blast
Summary:        Basic Local Alignment and Search Tool
Group:          Productivity/Scientific/Other
Requires:       ncbi-data

%description blast
The NCBI Basic Local Alignment Search Tool (BLAST) finds regions of
local similarity between sequences. The program compares nucleotide or
protein sequences to sequence databases and calculates the statistical
significance of matches. BLAST can be used to infer functional and
evolutionary relationships between sequences as well as help identify
members of gene families.

%package tools
Summary:        Utilities from the NCBI toolkit
Group:          Productivity/Scientific/Other
Requires:       ncbi-data

%description tools
This packages includes the binaries excluding the blast programs. 
Also contains documentation and man pages.

%package wwwblast
Summary:        Web-interface to the NCBI BLAST set of programs
Group:          Productivity/Scientific/Other
Requires:       apache2

%description wwwblast
The wwwblast package contains a suite of standalone programs that perform 
various similarity searches using the BLAST heuristic algorithm. Similar to 
the NCBI BLAST server wwwblast provides
a graphic user interface (GUI) through the use of web forms. Individual 
program takes the user inputs from the web form and returns the search result 
to a browser window. There are different web forms for different BLAST 

%package data
Summary:        NCBI toolkit data files
Group:          Productivity/Scientific/Other

%description data
Data files used by programs in the NCBI toolkit.

%package devel
Summary:        NCBI toolkit header files needed for development
Group:          Development/Libraries/C and C++

%description devel
This package contains the header files required for development of software 
using the NCBI toolkit.

%setup -q -c %{name}

# fix __DATE and __TIME  this causes the package to rebuild when not needed
BUILDTIME=$(LC_ALL=C date -ur %{_sourcedir}/%{name}.changes +'%H:%M')
BUILDDATE=$(LC_ALL=C date -ur %{_sourcedir}/%{name}.changes +'%b %d %Y')
sed -i "s/__TIME__/\"$BUILDTIME\"/" $(grep -rl '__TIME__' ncbi)
sed -i "s/__DATE__/\"$BUILDDATE\"/" $(grep -rl '__DATE__' ncbi)
sed -i 's/datetime/\dati/g' $(grep -rl 'datetime' ncbi)

#remove executable permissions
chmod -x ncbi/doc/blast/
chmod -x ncbi/doc/
chmod -x ncbi/doc/fa2htgs/updateHtgsDoc

#remove zero-length files
cd ncbi/network/wwwblast
rm wwwblast.log psiblast.log rpsblast.log
sed -i 's:/usr/local/bin/perl:/usr/bin/perl:'


#install wwwblast *.cgi and *.REAL binaries
mkdir -p %{buildroot}/%{wwwblastdir}
cd ncbi
install -m 755 bin/*.REAL %{buildroot}/%{wwwblastdir}/
install -m 755 bin/*.cgi %{buildroot}/%{wwwblastdir}/
rm -rf bin/*.REAL
rm -rf bin/*.cgi

#all other binaries
mkdir -p %{buildroot}/%{_bindir}
install -m 755 bin/* %{buildroot}/%{_bindir}/
#rename rpsblast as rpsblast-legacy (avoid conflict with blast+)
mv %{buildroot}/%{_bindir}/rpsblast %{buildroot}/%{_bindir}/rpsblast-legacy

#devel files
mkdir -p %{buildroot}/%{_includedir}/ncbi

cd include
for m in `find . -type d`; do
	install -d -m 755 $m %{buildroot}/%{_includedir}/ncbi/$m

for n in `find . -type f`; do
	install -m 644 $n %{buildroot}/%{_includedir}/ncbi/$n
cd ..

mkdir -p %{buildroot}/%{_mandir}/man1
install -m 644 doc/man/*.1 %{buildroot}/%{_mandir}/man1/
rm -rf doc/man

mkdir -p %{buildroot}/%{_docdir}/ncbi-blast
install -m 644 doc/blast/* %{buildroot}/%{_docdir}/ncbi-blast/
rm -rf doc/blast

#data files
mkdir -p %{buildroot}/%{_datadir}/ncbi/data
install -m 644 data/* %{buildroot}/%{_datadir}/ncbi/data

cd network/wwwblast
for j in `find . -type d`; do
    install -d -m 755 %{buildroot}/%{wwwblastdir}/$j

mkdir -p %{buildroot}/%{wwwblastdir}/TmpGifs

for k in `find . -type f`; do
    install -m 644 $k %{buildroot}/%{wwwblastdir}/$k;

cd %{buildroot}/%{wwwblastdir}/
for m in `find . -name '*.cgi'`; do 
    chmod 755 $m; 

chmod 755 %{buildroot}/%{wwwblastdir}/db/CDD/rpsfdb.csh
chmod 755 %{buildroot}/%{wwwblastdir}/db/CDD/make_cdd.csh
chmod 755 %{buildroot}/%{wwwblastdir}/

mkdir -p %{buildroot}/%{_sysconfdir}/apache2/conf.d

cat << __EOF__ >> %{buildroot}/%{_sysconfdir}/apache2/conf.d/wwwblast.conf
Alias /blast "/var/lib/wwwblast/"

<Directory "/var/lib/wwwblast">
    Options ExecCGI
    AllowOverride None
    AddHandler cgi-script .cgi .REAL
    Order allow,deny
    Allow from all

# create a dummy target for /etc/alternatives/rpsblast (avoid conflict with blast+)
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
ln -s -f %{_sysconfdir}/alternatives/rpsblast %{buildroot}%{_bindir}/rpsblast

%fdupes -s %{buildroot}

%post blast
update-alternatives --install \
   %{_bindir}/rpsblast rpsblast %{_bindir}/rpsblast-legacy 15

%postun blast
if [ ! -f %{_bindir}/rpsblast-legacy ] ; then
   update-alternatives --remove rpsblast %{_bindir}/rpsblast-legacy


%files blast
%ghost %_sysconfdir/alternatives/rpsblast

%files tools
%exclude %{_bindir}/bl2seq
%exclude %{_bindir}/blastall
%exclude %{_bindir}/blastclust
%exclude %{_bindir}/blastpgp
%exclude %{_bindir}/copymat
%exclude %{_bindir}/fastacmd
%exclude %{_bindir}/formatdb
%exclude %{_bindir}/formatrpsdb
%exclude %{_bindir}/impala
%exclude %{_bindir}/makemat
%exclude %{_bindir}/megablast
%exclude %{_bindir}/rpsblast
%exclude %{_bindir}/rpsblast-legacy
%exclude %{_bindir}/seedtop
%doc ncbi/doc/*

%files wwwblast
%dir %attr(-,root,root) /etc/apache2
%dir %attr(-,root,root) /etc/apache2/conf.d
%config(noreplace) %attr(-,root,root) %{_sysconfdir}/apache2/conf.d/wwwblast.conf
%dir /var/lib/wwwblast
%config(noreplace) /var/lib/wwwblast/*.rc
%exclude /var/lib/wwwblast/Src

%files data

%files devel

openSUSE Build Service is sponsored by