aboutsummaryrefslogtreecommitdiff
blob: a0992b76beb84ff31e5b25760559f28ed44ace2e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7

inherit fortran-2 perl-module toolchain-funcs

DESCRIPTION="Prediction of coding regions in DNA/RNA sequences"
HOMEPAGE="https://sourceforge.net/projects/estscan/"
SRC_URI="
	https://downloads.sourceforge.net/${PN}/${P}.tar.gz
	https://downloads.sourceforge.net/${PN}/At.smat.gz
	https://downloads.sourceforge.net/${PN}/Dm.smat.gz
	https://downloads.sourceforge.net/${PN}/Dr.smat.gz
	https://downloads.sourceforge.net/${PN}/Hs.smat.gz
	https://downloads.sourceforge.net/${PN}/Mm.smat.gz
	https://downloads.sourceforge.net/${PN}/Rn.smat.gz
	https://downloads.sourceforge.net/${PN}/user_guide_fev_07.pdf
	https://downloads.sourceforge.net/${PN}/BTLib-0.19.tar.gz"

SLOT="0"
LICENSE="estscan"
KEYWORDS="~amd64 ~x86"
IUSE="icc ifc"

DEPEND="
	dev-perl/BTLib
	icc? ( dev-lang/icc )
	ifc? ( dev-lang/ifc )"
RDEPEND="${DEPEND}"

S="${WORKDIR}"

src_prepare() {
	default
	sed \
		-e 's/\\rm -f/rm -rf/' \
		-e 's/^ LDFLAGS = -lm/LDFLAGS = -lm/' \
		-i "${P}"/Makefile || die "failed to edit Makefile"

	# fix hard-coded paths
	sed -e 's+/usr/molbio/share/ESTScan+/usr/share/ESTscan+' -i "${P}"/${PN}.c || die
	sed -e 's+/usr/molbio/share/ESTScan+/usr/share/ESTscan+' -i "${P}"/${PN}.spec || die

	if ! use icc; then
		sed \
			-e 's/^ CFLAGS = -O2/#CFLAGS = ${CFLAGS}/' -i "${P}"/Makefile || die
	fi

	if ! use ifc; then
		sed \
			-e 's/^ FFLAGS = -O2/#FFLAGS = ${FFLAGS}/' \
			-e "s/^ F77 = g77/F77 = $(tc-getF77)/" -i "${P}"/Makefile \
			|| die
	fi

	if use icc; then
		# FIXME: I would use $(tc-getCC) instead of hard-coded icc but it gives
		# me gcc instead, same for $(tc-getF77)
		# Moreover, the if/else logic here should separate users having only icc
		# while not ifort (and vice-versa) from those having only
		# gcc/gfortran/g77
		#
		# FIXME: below as a dirty hack I force gfortran instead of ifort for
		# my testing purposes. Didn't ebuild contain "PROVIDES" line?
		# Same for FFLAGS.
		sed \
			-e "s:^# CC = icc:CC = icc:" \
			-e "s:^# CFLAGS = -O3 -ipo -axP:#CFLAGS = -O3 -ipo -axP:" \
			-e "s/^ CFLAGS = -O2/#CFLAGS = -O2/" \
			-e "s/^ CC = gcc/# CC = gcc/" \
			-i "${P}"/Makefile || die "sed failed to fix CFLAGS and CC"

	fi

	if use ifc; then
		sed \
			-e "s:^# FFLAGS = -O3 -ipo -axP:#FFLAGS = -O3 -ipo -axP:" \
			-e "s/^# F77 = ifort/F77 = gfortran/" \
			-e "s/^ FFLAGS = -O2/#FFLAGS = -O2/" \
			-e "s/^ F77 = g77/# F77 = g77/" \
			-i "${P}"/Makefile || die "sed failed to fix FFLAGS and F77"
	fi
}

src_compile() {
	emake -C ${P}
}

src_install() {
	# FIXME: Some kind of documentation is in {P}/${PN}.spec
	cd ${P} || die "Failed to chdir to ${P}"
	dobin \
		build_model ${PN} evaluate_model extract_EST extract_UG_EST \
		extract_mRNA makesmat maskred prepare_data winsegshuffle
	# the file build_model_utils.pl should go into some PERL site-packages dir
	# see {P}/${PN}.spec

	# install the doc (but is not in ${WORKDIR} because src_unpack() failed on it as it has .pdf extension
	insinto /usr/share/doc/${PN}
	# grab the file directly from ../distdir/
	doins "${DISTDIR}"/user_guide_fev_07.pdf

	# install the default precomputed matrices
	cd "${WORKDIR}" || die "Failed to chdir to ${WORKDIR}"
	insinto /usr/share/${PN}
	doins *.smat

	# install BTlib (in perl)
	# dobin fetch indexer netfetch
	insinto /usr/share/${PN}/
	# install the config file which is packed inside the BTLib tarball while is not
	# being installed by dev-perl/BTLib
	doins "${WORKDIR}"/BTLib-0.19/fetch.conf

	# FIXME: install the *.pm files from BTLib-0.19
	# cd "${WORKDIR}"/BTLib-0.19 || die "Failed to chdir to "${WORKDIR}"/BTLib-0.19
	# myinst="DESTDIR=${D}"
	# perl-module_src_install

	einfo "Please edit /usr/share/${PN}/fetch.conf to fit your local database layout."
	einfo "Also create your own scoring matrices and place them into /usr/share/${PN}/."
	einfo "You may follow the hints from http://${PN}.sourceforge.net/"
}