File: .r-install.sh

package info (click to toggle)
shogun 0.6.3-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 8,688 kB
  • ctags: 6,563
  • sloc: cpp: 61,677; python: 5,233; sh: 2,767; makefile: 555; objc: 37
file content (177 lines) | stat: -rwxr-xr-x 5,706 bytes parent folder | download
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#!/bin/bash

VERSION=`head -n 3 NEWS | tail -n 1| awk '{ print $5 }'`
DATE=`head -n 1 NEWS | cut -f 1 -d ' '`
RVERSION="`echo 'version; quit()' | R  --no-save 2>&1 | grep version\.string | cut -f 4 -d ' '`"
PLATFORM=`echo 'R.version$platform' | R --no-save 2>/dev/null | grep '\[1\]' | cut -f 2 -d '"'`
DATE="`date '+%Y-%m-%d %H:%M:%S'`"
OSTYPE=`echo '.Platform[1]' | R --no-save 2>/dev/null | grep '\[1\]' | cut -f 2 -d '"'`
#OSTYPE="`uname -o`"
PKGFILE="$1/$2/Meta/package.rds"

cat >"$1/$2/DESCRIPTION" <<EOF
Package: $2
Version: $VERSION
Date: $DATE
Title: The SHOGUN Machine Learning Toolbox
Author: Soeren Sonnenburg, Gunnar Raetsch
Maintainer: Soeren Sonnenburg <Soeren.Sonnenburg@first.fraunhofer.de>
Depends: R (>= 2.1.0)
Suggests:
Description: SHOGUN - is a new machine learning toolbox with focus on large
        scale kernel methods and especially on Support Vector Machines (SVM) with focus
        to bioinformatics. It provides a generic SVM object interfacing to several
        different SVM implementations. Each of the SVMs can be combined with a variety
        of the many kernels implemented. It can deal with weighted linear combination
        of a number of sub-kernels, each of which not necessarily working on the same
        domain, where  an optimal sub-kernel weighting can be learned using Multiple
        Kernel Learning.  Apart from SVM 2-class classification and regression
        problems, a number of linear methods like Linear Discriminant Analysis (LDA),
        Linear Programming Machine (LPM), (Kernel) Perceptrons and also algorithms to
        train hidden markov models are implemented. The input feature-objects can be
        dense, sparse or strings and of type int/short/double/char and can be converted
        into different feature types. Chains of preprocessors (e.g.  substracting the
        mean) can be attached to each feature object allowing for on-the-fly
        pre-processing.
License: GPL Version 3 or later.
URL: http://www.shogun-toolbox.org
Built: $RVERSION; $PLATFORM; $OSTYPE;
EOF

echo "x=structure(list(DESCRIPTION = c(Package='$2',\
		Version=\"$VERSION\",\
		Date=\"$DATE\",\
		Title=\"The SHOGUN Machine Learning Toolbox\",\
		Author=\"Soeren Sonnenburg, Gunnar Raetsch\",\
		Maintainer=\"Soeren.Sonnenburg@first.fraunhofer.de\",\
		Depends=\"R (>= $RVERSION)\"),\
		Built = list(R=\"$RVERSION\", Platform=\"$PLATFORM\", Date=\"$DATE\", OStype=\"$OSTYPE\"),\
		Rdepends = list(name='R', op='>=', version='2.1.0'),\
		Rdepends2 = list(list(name='R', op='>=', version='2.1.0')),\
		Depends = list(),\
		Suggests = list(),\
		Imports = list()),\
		class = 'packageDescription2');\
		.saveRDS(x, \"$PKGFILE\")" | R --no-save

# R STATIC
if [ "$2" = "sg" ]
then
echo "Installing static sg interface for R"
cat >"$1/$2/R/$2" <<EOF
.packageName <- "$2"
# The purpose of this file is to supply no functionality
# except easier access functions in R for external C 
# function calls. 
#
# For example instead of typing
#
#     > .External("$2", "send_command", "blah")
#
# one can simply type
#
#     > send_command(blah)
#
# where > is the R prompt.

# interface $2(arg1,arg2,...) as w/ matlab/octave/python
#
$2 <- function(...) .External("$2",...,PACKAGE="$2")


# R specific interface

# Generic functions
#
send_command <- function(x) .External("$2","send_command",x,PACKAGE="$2")
set_features <- function(x,y) .External("$2","set_features",x,y,PACKAGE="$2")
add_features <- function(x,y) .External("$2","add_features",x,y,PACKAGE="$2")
set_labels <- function(x,y) .External("$2","set_labels", x,y,PACKAGE="$2")
get_kernel_matrix <- function() .External("$2","get_kernel_matrix",PACKAGE="$2")

# SVM functions
#
svm_classify <- function() .External("$2","svm_classify",PACKAGE="$2")
get_svm <- function() .External("$2","get_svm",PACKAGE="$2")
get_subkernel_weights <- function() .External("$2","get_subkernel_weights",PACKAGE="$2") 

# HMM functions
#
get_hmm <- function() .External("$2","get_hmm",PACKAGE="$2")

# Load the shogun dynamic library at startup.
#
.First.lib <- function(lib,pkg)
{
	cat(paste("\nWelcome! This is SHOGUN version $VERSION\n"))
	library.dynam("$2",pkg,lib)
}

# Unload the library.
#
.Last.lib <- function(lib) library.dynam.unload("$2", libpath=lib) 

# Because in packages with namespaces .First.lib will not be loaded
# one needs another functions called .onLoad resp. .onUnload
#

.onLoad <- function(lib, pkg) .First.lib(lib,pkg)
.onUnload <- function(lib) .Last.lib(lib)

# a nice banner
#
.onAttach <- function(lib, pkg) cat(paste("\nWelcome! This is SHOGUN version $VERSION\n"))
EOF

# R-MODULAR
else
echo "Installing modular shogun interface for R"

cat >"$1/$2/R/$2" <<EOF
.packageName <- "$2"
#$2 <- function(...) .External("$2",...,PACKAGE="$2")

# Load the shogun dynamic library at startup.
#
.First.lib <- function(lib,pkg)
{
	cat(paste("\nWelcome! This is SHOGUN version $VERSION\n"))
EOF

for f in */*.so
do
	echo "library.dynam(\"`basename $f`\", pkg, lib)" >> "$1/$2/R/$2"
done

for f in */*.RData
do
	echo "load(paste(lib, \"/\", \"$2\", \"/R/\", \"`basename $f`\", sep=''), envir=.GlobalEnv)" >> "$1/$2/R/$2"
	echo "cacheMetaData(1)" >> "$1/$2/R/$2"
done
cat >>"$1/$2/R/$2" <<EOF
}
# Unload the library.
#
.Last.lib <- function(lib)
{
EOF

for f in */*.so
do
	echo "library.dynam.unload(\"$f\", lib)" >> "$1/$2/R/$2"
done

cat >>"$1/$2/R/$2" <<EOF
}

# Because in packages with namespaces .First.lib will not be loaded
# one needs another functions called .onLoad resp. .onUnload
#
.onLoad <- function(lib, pkg) .First.lib(lib,pkg)
.onUnload <- function(lib) .Last.lib(lib)

# a nice banner
#
.onAttach <- function() cat(paste("\nWelcome! This is SHOGUN version $VERSION\n"))
EOF
fi