annotate w4mkmeans_wrapper.R @ 2:c415b7dc6f37 draft default tip

planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 3e916537da6bb37e6f3927d7a11e98e0ab6ef5ec
author eschen42
date Mon, 05 Mar 2018 12:40:17 -0500
parents 02cafb660b72
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
1 #!/usr/bin/env Rscript
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
2
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
3 # references:
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
4 # what this does:
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
5 # - [stats::kmeans](https://stat.ethz.ch/R-manual/R-devel/library/stats/html/kmeans.html)
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
6 # - [stats::p.adjust](https://stat.ethz.ch/R-manual/R-devel/library/stats/html/p.adjust.html)
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
7 # how this does what it does:
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
8 # - [parallel::clusterApply](https://stat.ethz.ch/R-manual/R-devel/library/parallel/html/clusterApply.html)
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
9
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
10 # invocation:
1
02cafb660b72 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit f600ce8a783df16e49272341dce0fc6bbc299b0a
eschen42
parents: 0
diff changeset
11 # Rscript w4mkmeans_wrapper.R \
02cafb660b72 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit f600ce8a783df16e49272341dce0fc6bbc299b0a
eschen42
parents: 0
diff changeset
12 # algorithm "$algorithm" \
02cafb660b72 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit f600ce8a783df16e49272341dce0fc6bbc299b0a
eschen42
parents: 0
diff changeset
13 # categorical_prefix "$categorical_prefix" \
02cafb660b72 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit f600ce8a783df16e49272341dce0fc6bbc299b0a
eschen42
parents: 0
diff changeset
14 # data_matrix_path "$dataMatrix_in" \
02cafb660b72 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit f600ce8a783df16e49272341dce0fc6bbc299b0a
eschen42
parents: 0
diff changeset
15 # iter_max "$iter_max" \
02cafb660b72 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit f600ce8a783df16e49272341dce0fc6bbc299b0a
eschen42
parents: 0
diff changeset
16 # kfeatures "$kfeatures" \
02cafb660b72 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit f600ce8a783df16e49272341dce0fc6bbc299b0a
eschen42
parents: 0
diff changeset
17 # ksamples "$ksamples" \
02cafb660b72 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit f600ce8a783df16e49272341dce0fc6bbc299b0a
eschen42
parents: 0
diff changeset
18 # nstart "$nstart" \
02cafb660b72 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit f600ce8a783df16e49272341dce0fc6bbc299b0a
eschen42
parents: 0
diff changeset
19 # sampleMetadata_out "$sampleMetadata_out" \
02cafb660b72 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit f600ce8a783df16e49272341dce0fc6bbc299b0a
eschen42
parents: 0
diff changeset
20 # sample_metadata_path "$sampleMetadata_in" \
02cafb660b72 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit f600ce8a783df16e49272341dce0fc6bbc299b0a
eschen42
parents: 0
diff changeset
21 # scores_out "$scores_out" \
02cafb660b72 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit f600ce8a783df16e49272341dce0fc6bbc299b0a
eschen42
parents: 0
diff changeset
22 # slots "${GALAXY_SLOTS:-1}" \
02cafb660b72 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit f600ce8a783df16e49272341dce0fc6bbc299b0a
eschen42
parents: 0
diff changeset
23 # variableMetadata_out "$variableMetadata_out" \
02cafb660b72 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit f600ce8a783df16e49272341dce0fc6bbc299b0a
eschen42
parents: 0
diff changeset
24 # variable_metadata_path "$variableMetadata_in"
2
c415b7dc6f37 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 3e916537da6bb37e6f3927d7a11e98e0ab6ef5ec
eschen42
parents: 1
diff changeset
25 #
0
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
26 # <inputs>
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
27 # <param name="dataMatrix_in" label="Data matrix file" type="data" format="tabular" help="variable x sample, decimal: '.', missing: NA, mode: numerical, separator: tab" />
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
28 # <param name="sampleMetadata_in" label="Sample metadata file" type="data" format="tabular" help="sample x metadata columns, separator: tab" />
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
29 # <param name="variableMetadata_in" label="Variable metadata file" type="data" format="tabular" help="variable x metadata columns, separator: tab" />
1
02cafb660b72 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit f600ce8a783df16e49272341dce0fc6bbc299b0a
eschen42
parents: 0
diff changeset
30 # <param name="categoricalPrefix" label="prefix for cluster names " type="text" value="k" help="Some tools require non-numeric values to discern categorical; e.g., enter 'k' here to prepend 'k' to cluster numbers in the output; default 'k'." />
0
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
31 # <param name="kfeatures" label="K value(s) for features" type="text" value="0" help="Single or min,max value(s) for K for features (variables), or 0 for none." />
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
32 # <param name="ksamples" label="K value(s) for samples" type="text" value="0" help="Single or min,max value(s) for K for samples, or 0 for none." />
2
c415b7dc6f37 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 3e916537da6bb37e6f3927d7a11e98e0ab6ef5ec
eschen42
parents: 1
diff changeset
33 # <param name="iter_max" label="Max number of iterations" type="text" value="20" help="The maximum number of iterations allowed; default 20." />
c415b7dc6f37 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 3e916537da6bb37e6f3927d7a11e98e0ab6ef5ec
eschen42
parents: 1
diff changeset
34 # <param name="nstart" label="Number of random sets" type="text" value="20" help="How many random sets should be chosen; default 20." />
0
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
35 # <param name="algorithm" label="Algorithm for clustering" type="select" value = "Hartigan-Wong" help="K-means clustering algorithm, default 'Hartigan-Wong'; alternatives 'Lloyd', 'MacQueen'; 'Forgy' is a synonym for 'Lloyd', see stats::kmeans reference for further info and references.">
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
36 # <option value="Hartigan-Wong" selected="TRUE">Hartigan-Wong</option>
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
37 # <option value="Lloyd">Lloyd</option>
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
38 # <option value="MacQueen">MacQueen</option>
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
39 # <option value="Forgy">Forgy</option>
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
40 # </param>
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
41 # </inputs>
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
42 # <outputs>
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
43 # <data name="sampleMetadata_out" label="${tool.name}_${sampleMetadata_in.name}" format="tabular" ></data>
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
44 # <data name="variableMetadata_out" label="${tool.name}_${variableMetadata_in.name}" format="tabular" ></data>
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
45 # </outputs>
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
46
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
47 ##------------------------
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
48 ## libraries for this file
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
49 ##------------------------
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
50
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
51 library(batch) ## for 'parseCommandArgs'
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
52
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
53 ##-------------------
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
54 ## Pre-initialization
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
55 ##-------------------
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
56
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
57 argVc <- unlist(parseCommandArgs(evaluate=FALSE))
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
58 if ( Reduce( `|`, grepl("tool_directory",names(argVc)) ) ) {
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
59 tool_directory <- as.character(argVc["tool_directory"])
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
60 } else {
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
61 tool_directory <- "."
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
62 }
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
63 r_path <- function(f) paste( tool_directory, f, sep = "/" )
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
64
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
65 ##----------------------------------------------------------
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
66 ## Computation - source general and module-specific routines
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
67 ##----------------------------------------------------------
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
68
2
c415b7dc6f37 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 3e916537da6bb37e6f3927d7a11e98e0ab6ef5ec
eschen42
parents: 1
diff changeset
69 log_print <- function(x, ...) {
0
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
70 cat(
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
71 format(Sys.time(), "%Y-%m-%dT%H:%M:%S%z")
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
72 , " "
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
73 , c(x, ...)
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
74 , "\n"
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
75 , sep=""
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
76 , file=stderr()
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
77 )
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
78 }
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
79
2
c415b7dc6f37 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 3e916537da6bb37e6f3927d7a11e98e0ab6ef5ec
eschen42
parents: 1
diff changeset
80 log_cat <- function(x, ...) {
c415b7dc6f37 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 3e916537da6bb37e6f3927d7a11e98e0ab6ef5ec
eschen42
parents: 1
diff changeset
81 cat(
c415b7dc6f37 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 3e916537da6bb37e6f3927d7a11e98e0ab6ef5ec
eschen42
parents: 1
diff changeset
82 c(x, ...)
c415b7dc6f37 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 3e916537da6bb37e6f3927d7a11e98e0ab6ef5ec
eschen42
parents: 1
diff changeset
83 , "\n"
c415b7dc6f37 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 3e916537da6bb37e6f3927d7a11e98e0ab6ef5ec
eschen42
parents: 1
diff changeset
84 , sep=""
c415b7dc6f37 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 3e916537da6bb37e6f3927d7a11e98e0ab6ef5ec
eschen42
parents: 1
diff changeset
85 , file=stderr()
c415b7dc6f37 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 3e916537da6bb37e6f3927d7a11e98e0ab6ef5ec
eschen42
parents: 1
diff changeset
86 )
c415b7dc6f37 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 3e916537da6bb37e6f3927d7a11e98e0ab6ef5ec
eschen42
parents: 1
diff changeset
87 }
c415b7dc6f37 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 3e916537da6bb37e6f3927d7a11e98e0ab6ef5ec
eschen42
parents: 1
diff changeset
88
0
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
89 # log_print(sprintf("tool_directory is %s", tool_directory))
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
90
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
91 w4m_general_purpose_routines_path <- r_path("w4m_general_purpose_routines.R")
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
92 # log_print(sprintf("w4m_general_purpose_routines_path is %s", w4m_general_purpose_routines_path))
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
93 if ( ! file.exists(w4m_general_purpose_routines_path) ) {
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
94 log_print("cannot find file w4m_general_purpose_routines.R")
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
95 q(save = "no", status = 1, runLast = TRUE)
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
96 }
2
c415b7dc6f37 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 3e916537da6bb37e6f3927d7a11e98e0ab6ef5ec
eschen42
parents: 1
diff changeset
97 log_print("sourcing ",w4m_general_purpose_routines_path)
0
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
98 source(w4m_general_purpose_routines_path)
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
99 if ( ! exists("prepare.data.matrix") ) {
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
100 log_print("'prepare.data.matrix' was not read from file w4m_general_purpose_routines.R")
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
101 q(save = "no", status = 1, runLast = TRUE)
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
102 }
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
103
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
104 w4mkmeans_routines_path <- r_path("w4mkmeans_routines.R")
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
105 # log_print(sprintf("w4mkmeans_routines_path is %s", w4mkmeans_routines_path))
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
106 if ( ! file.exists(w4mkmeans_routines_path) ) {
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
107 log_print("cannot find file w4mkmeans_routines.R")
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
108 q(save = "no", status = 1, runLast = TRUE)
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
109 }
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
110 # log_print("sourcing ",w4mkmeans_routines_path)
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
111 source(w4mkmeans_routines_path)
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
112 if ( ! exists("w4mkmeans") ) {
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
113 log_print("'w4mkmeans' was not read from file w4mkmeans_routines.R")
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
114 q(save = "no", status = 1, runLast = TRUE)
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
115 }
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
116
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
117 ##-----------------------------------------
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
118 ## Computation - W4m data-suppport routines
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
119 ##-----------------------------------------
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
120
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
121 # read_data_frame - read a w4m data frame from a tsv, with error handling
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
122 # e.g., data_matrix_input_env <- read_data_frame(dataMatrix_in, "data matrix input")
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
123 read_data_frame <- function(file_path, kind_string, failure_action = log_print) {
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
124 my.env <- new.env()
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
125 my.env$success <- FALSE
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
126 my.env$msg <- sprintf("no message reading %s", kind_string)
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
127 tryCatch(
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
128 expr = {
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
129 my.env$data <- utils::read.delim( fill = FALSE, file = file_path )
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
130 my.env$success <- TRUE
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
131 }
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
132 , error = function(e) {
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
133 my.env$msg <<- sprintf("%s read failed", kind_string)
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
134 }
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
135 )
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
136 if (!my.env$success) {
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
137 failure_action(my.env$msg)
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
138 }
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
139 return (my.env)
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
140 }
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
141
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
142 # write_result - write a w4m data frame to a tsv
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
143 write_result <- function(result, file_path, kind_string, failure_action = log_print) {
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
144 my.env <- new.env()
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
145 my.env$success <- FALSE
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
146 my.env$msg <- sprintf("no message writing %s", kind_string)
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
147 tryCatch(
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
148 expr = {
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
149 write.table(
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
150 x = result
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
151 , sep = "\t"
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
152 , file = file_path
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
153 , quote = FALSE
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
154 , row.names = FALSE
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
155 )
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
156 my.env$success <- TRUE
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
157 }
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
158 , error = function(e) {
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
159 my.env$msg <<- sprintf("%s write failed", kind_string)
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
160 }
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
161 )
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
162 if (!my.env$success) {
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
163 failure_action(my.env$msg)
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
164 return (my.env)
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
165 }
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
166 return (my.env)
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
167 }
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
168
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
169 # read the three input files
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
170 read_input_data <- function(env, failure_action = log_print) {
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
171 kind_string <- "none"
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
172 tryCatch(
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
173 expr = {
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
174 # read in the sample metadata
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
175 kind_string <- "sample metadata input"
2
c415b7dc6f37 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 3e916537da6bb37e6f3927d7a11e98e0ab6ef5ec
eschen42
parents: 1
diff changeset
176 smpl_metadata_input_env <-
0
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
177 read_data_frame(
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
178 file_path = env$sample_metadata_path
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
179 , kind_string = kind_string
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
180 , failure_action = failure_action
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
181 )
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
182 if (!smpl_metadata_input_env$success) {
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
183 failure_action(smpl_metadata_input_env$msg)
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
184 return ( FALSE )
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
185 }
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
186 env$sampleMetadata <- smpl_metadata_input_env$data
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
187
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
188 # read in the variable metadata
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
189 kind_string <- "variable metadata input"
2
c415b7dc6f37 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 3e916537da6bb37e6f3927d7a11e98e0ab6ef5ec
eschen42
parents: 1
diff changeset
190 vrbl_metadata_input_env <-
0
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
191 read_data_frame(
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
192 file_path = env$variable_metadata_path
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
193 , kind_string = kind_string
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
194 , failure_action = failure_action
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
195 )
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
196 if (!vrbl_metadata_input_env$success) {
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
197 failure_action(vrbl_metadata_input_env$msg)
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
198 return ( FALSE )
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
199 }
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
200 env$variableMetadata <- vrbl_metadata_input_env$data
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
201
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
202 # read in the data matrix
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
203 kind_string <- "data matrix input"
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
204 data_matrix_input_env <-
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
205 read_data_frame(
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
206 file_path = env$data_matrix_path
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
207 , kind_string = kind_string
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
208 , failure_action = failure_action
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
209 )
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
210 if (!data_matrix_input_env$success) {
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
211 failure_action(data_matrix_input_env$msg)
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
212 return ( FALSE )
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
213 }
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
214 # data frame for dataMatrix has rownames in first column
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
215 data_matrix_df <- data_matrix_input_env$data
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
216 rownames(data_matrix_df) <- data_matrix_df[,1]
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
217 data_matrix <- data_matrix_df[,2:ncol(data_matrix_df)]
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
218 env$dataMatrix <- as.matrix(data_matrix)
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
219
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
220 }
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
221 , error = function(e) {
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
222 failure_action( sprintf("read_input_data failed for '%s' - %s", kind_string, format_error(e)) )
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
223 return ( FALSE )
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
224 }
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
225 )
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
226 return ( TRUE )
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
227 }
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
228
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
229
2
c415b7dc6f37 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 3e916537da6bb37e6f3927d7a11e98e0ab6ef5ec
eschen42
parents: 1
diff changeset
230 read_input_failure_action <- function(x, ...) {
0
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
231 log_print("Failure reading input for '", modNamC, "' Galaxy module call")
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
232 log_print(x, ...)
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
233 }
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
234
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
235 ##--------------------------
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
236 ## Computation - Entry Point
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
237 ##--------------------------
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
238
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
239 ##----------
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
240 ## Constants
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
241 ##----------
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
242
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
243 modNamC <- "w4mkmeans" ## module name
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
244
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
245 ## options
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
246 ##--------
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
247
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
248 # Set the handler for R error-handling
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
249 options( show.error.messages = F
2
c415b7dc6f37 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 3e916537da6bb37e6f3927d7a11e98e0ab6ef5ec
eschen42
parents: 1
diff changeset
250 , error = function () {
0
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
251 log_print( "Fatal error in '", modNamC, "': ", geterrmessage() )
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
252 q( "no", 1, F )
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
253 }
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
254 , warn = -1
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
255 )
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
256
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
257 # strings as factors? - not by default!
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
258 # save old value
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
259 strAsFacL <- options()$stringsAsFactors
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
260 options(stringsAsFactors = FALSE)
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
261
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
262
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
263 ## log file
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
264 ##---------
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
265
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
266 log_print("Start of the '", modNamC, "' Galaxy module call")
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
267
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
268 ## arguments
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
269 ##----------
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
270
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
271 args_env <- new.env()
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
272
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
273 # files
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
274
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
275 log_print("PARAMETERS (raw):")
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
276 invisible(
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
277 lapply(
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
278 X = 1:length(argVc)
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
279 , FUN = function(i) {
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
280 log_print(sprintf(" - %s: %s", names(argVc)[i], argVc[i]))
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
281 }
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
282 )
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
283 )
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
284
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
285 # write.table(as.matrix(argVc), col.names=F, quote=F, sep='\t')
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
286
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
287 ## output files
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
288 sampleMetadata_out <- as.character(argVc["sampleMetadata_out"])
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
289 variableMetadata_out <- as.character(argVc["variableMetadata_out"])
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
290 scores_out <- as.character(argVc["scores_out"])
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
291 ## input files
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
292 args_env$data_matrix_path <- as.character(argVc["data_matrix_path"])
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
293 args_env$variable_metadata_path <- as.character(argVc["variable_metadata_path"])
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
294 args_env$sample_metadata_path <- as.character(argVc["sample_metadata_path"])
2
c415b7dc6f37 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 3e916537da6bb37e6f3927d7a11e98e0ab6ef5ec
eschen42
parents: 1
diff changeset
295
0
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
296 # other parameters
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
297
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
298 # multi-string args - split csv: "1,2,3" -> c("1","2","3")
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
299 args_env$kfeatures <- strsplit(x = as.character(argVc['kfeatures']), split = ",", fixed = TRUE)[[1]]
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
300 args_env$ksamples <- strsplit(x = as.character(argVc['ksamples' ]), split = ",", fixed = TRUE)[[1]]
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
301 # numeric args
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
302 args_env$iter_max <- as.numeric( argVc['iter_max' ])
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
303 args_env$nstart <- as.numeric( argVc['nstart' ])
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
304 args_env$slots <- as.numeric( argVc['slots' ])
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
305 # string args
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
306 args_env$algorithm <- as.character( argVc['algorithm'])
1
02cafb660b72 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit f600ce8a783df16e49272341dce0fc6bbc299b0a
eschen42
parents: 0
diff changeset
307 args_env$categorical_prefix <- as.character( argVc['categorical_prefix'])
02cafb660b72 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit f600ce8a783df16e49272341dce0fc6bbc299b0a
eschen42
parents: 0
diff changeset
308
02cafb660b72 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit f600ce8a783df16e49272341dce0fc6bbc299b0a
eschen42
parents: 0
diff changeset
309
02cafb660b72 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit f600ce8a783df16e49272341dce0fc6bbc299b0a
eschen42
parents: 0
diff changeset
310 # make local 'log_print' function available through 'env'
0
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
311 args_env$log_print <- log_print
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
312
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
313 log_print("PARAMETERS (parsed):")
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
314 for (member in ls(args_env)) {
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
315 value <- get(member, args_env)
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
316 value <- ifelse(length(value) == 1, value, sprintf("c(%s)", paste(value, collapse=", ")))
2
c415b7dc6f37 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 3e916537da6bb37e6f3927d7a11e98e0ab6ef5ec
eschen42
parents: 1
diff changeset
317
0
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
318 log_print(sprintf(" - %s: %s", member, ifelse( !is.function(value) , value, "function" )))
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
319 }
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
320 log_print("")
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
321
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
322 ##---------------------------------------------------------
2
c415b7dc6f37 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 3e916537da6bb37e6f3927d7a11e98e0ab6ef5ec
eschen42
parents: 1
diff changeset
323 ## Computation - attempt to read input data and process
0
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
324 ##---------------------------------------------------------
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
325 if ( ! read_input_data(args_env, failure_action = read_input_failure_action) ) {
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
326 result <- -1
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
327 } else {
2
c415b7dc6f37 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 3e916537da6bb37e6f3927d7a11e98e0ab6ef5ec
eschen42
parents: 1
diff changeset
328 log_print("Input data was read.")
c415b7dc6f37 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 3e916537da6bb37e6f3927d7a11e98e0ab6ef5ec
eschen42
parents: 1
diff changeset
329 # attempt to process the data
0
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
330 result <- w4mkmeans(env = args_env)
2
c415b7dc6f37 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 3e916537da6bb37e6f3927d7a11e98e0ab6ef5ec
eschen42
parents: 1
diff changeset
331 log_print("Returned from call to w4mkmeans.")
0
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
332 }
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
333
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
334 if ( length(result) == 0 ) {
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
335 log_print("no results were produced")
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
336 # exit with status code non-zero to indicate error
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
337 q(save = "no", status = 1, runLast = FALSE)
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
338 } else if ( ! setequal(names(result),c("variableMetadata","sampleMetadata","scores")) ) {
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
339 log_print(sprintf("unexpected result keys %s", names(result)))
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
340 # exit with status code non-zero to indicate error
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
341 q(save = "no", status = 1, runLast = FALSE)
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
342 } else if ( ! write_result(result = result$variableMetadata, file_path = variableMetadata_out, kind_string = "clustered variableMetadata")$success ) {
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
343 log_print("failed to write output file for clustered variableMetadata")
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
344 # exit with status code non-zero to indicate error
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
345 q(save = "no", status = 1, runLast = FALSE)
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
346 } else if ( ! write_result(result = result$sampleMetadata, file_path = sampleMetadata_out, kind_string = "clustered sampleMetadata")$success ) {
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
347 log_print("failed to write output file for clustered sampleMetadata")
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
348 # exit with status code non-zero to indicate error
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
349 q(save = "no", status = 1, runLast = FALSE)
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
350 } else {
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
351 tryCatch(
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
352 expr = {
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
353 fileConn<-file(scores_out)
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
354 writeLines(result$scores, fileConn)
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
355 close(fileConn)
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
356 }
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
357 , error = function(e) {
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
358 log_print(sprintf("failed to write output file for cluster scores - %s", format_error(e)))
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
359 # exit with status code non-zero to indicate error
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
360 q(save = "no", status = 1, runLast = FALSE)
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
361 }
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
362 )
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
363 }
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
364
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
365 ##--------
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
366 ## Closing
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
367 ##--------
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
368
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
369 if (!file.exists(sampleMetadata_out)) {
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
370 log_print(sprintf("ERROR %s::w4m_kmeans_wrapper - file '%s' was not created", modNamC, sampleMetadata_out))
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
371 }
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
372
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
373 if (!file.exists(variableMetadata_out)) {
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
374 log_print(sprintf("ERROR %s::w4m_kmeans_wrapper - file '%s' was not created", modNamC, variableMetadata_out))
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
375 }
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
376
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
377 if (!file.exists(scores_out)) {
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
378 log_print(sprintf("ERROR %s::w4m_kmeans_wrapper - file '%s' was not created", modNamC, scores_out))
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
379 }
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
380
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
381 log_print("Normal termination of '", modNamC, "' Galaxy module call")
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
382
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
383 # exit with status code zero
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
384 q(save = "no", status = 0, runLast = FALSE)