annotate w4mkmeans_wrapper.R @ 1:02cafb660b72 draft

planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit f600ce8a783df16e49272341dce0fc6bbc299b0a
author eschen42
date Wed, 09 Aug 2017 18:06:55 -0400
parents 6ccbe18131a6
children c415b7dc6f37
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"
0
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
25 #
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." />
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
33 # <param name="iter_max" label="Max number of iterations" type="text" value="10" help="The maximum number of iterations allowed; default 10." />
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
34 # <param name="nstart" label="Number of random sets" type="text" value="1" help="How many random sets should be chosen; default 1." />
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
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
69 log_print <- function(x, ...) {
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
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
80 # 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
81
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
82 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
83 # 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
84 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
85 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
86 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
87 }
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
88 # log_print("sourcing ",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
89 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
90 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
91 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
92 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
93 }
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
94
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
95 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
96 # 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
97 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
98 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
99 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
100 }
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
101 # 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
102 source(w4mkmeans_routines_path)
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
103 if ( ! exists("w4mkmeans") ) {
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
104 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
105 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
106 }
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
107
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
108 ##-----------------------------------------
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
109 ## 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
110 ##-----------------------------------------
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
111
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
112 # 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
113 # 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
114 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
115 my.env <- new.env()
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
116 my.env$success <- FALSE
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
117 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
118 tryCatch(
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
119 expr = {
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
120 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
121 my.env$success <- TRUE
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
122 }
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
123 , error = function(e) {
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
124 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
125 }
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
126 )
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
127 if (!my.env$success) {
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
128 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
129 }
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
130 return (my.env)
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
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
133 # 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
134 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
135 my.env <- new.env()
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
136 my.env$success <- FALSE
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
137 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
138 tryCatch(
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
139 expr = {
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
140 write.table(
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
141 x = result
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
142 , sep = "\t"
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
143 , file = file_path
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
144 , quote = FALSE
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
145 , row.names = FALSE
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
146 )
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
147 my.env$success <- TRUE
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
148 }
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
149 , error = function(e) {
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
150 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
151 }
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
152 )
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
153 if (!my.env$success) {
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
154 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
155 return (my.env)
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
156 }
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
157 return (my.env)
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
158 }
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
159
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
160 # 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
161 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
162 kind_string <- "none"
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
163 tryCatch(
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
164 expr = {
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
165 # 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
166 kind_string <- "sample metadata input"
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
167 smpl_metadata_input_env <-
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
168 read_data_frame(
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
169 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
170 , kind_string = kind_string
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
171 , failure_action = failure_action
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
172 )
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
173 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
174 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
175 return ( FALSE )
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
176 }
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
177 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
178
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
179 # 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
180 kind_string <- "variable metadata input"
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
181 vrbl_metadata_input_env <-
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
182 read_data_frame(
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
183 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
184 , kind_string = kind_string
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
185 , failure_action = failure_action
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
186 )
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
187 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
188 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
189 return ( FALSE )
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
190 }
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
191 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
192
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
193 # 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
194 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
195 data_matrix_input_env <-
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
196 read_data_frame(
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
197 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
198 , kind_string = kind_string
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
199 , failure_action = failure_action
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
200 )
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
201 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
202 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
203 return ( FALSE )
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
204 }
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
205 # 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
206 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
207 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
208 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
209 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
210
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
211 }
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
212 , error = function(e) {
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
213 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
214 return ( FALSE )
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
215 }
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
216 )
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
217 return ( TRUE )
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
218 }
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 read_input_failure_action <- function(x, ...) {
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
222 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
223 log_print(x, ...)
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 ##--------------------------
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
227 ## Computation - Entry Point
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
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
230 ##----------
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
231 ## Constants
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
232 ##----------
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 modNamC <- "w4mkmeans" ## module name
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 ## options
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 # 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
240 options( show.error.messages = F
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
241 , error = function () {
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
242 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
243 q( "no", 1, F )
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 , warn = -1
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 # 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
249 # save old value
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
250 strAsFacL <- options()$stringsAsFactors
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
251 options(stringsAsFactors = FALSE)
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
252
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 ## log file
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 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
258
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
259 ## arguments
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
260 ##----------
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 args_env <- new.env()
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
263
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
264 # files
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("PARAMETERS (raw):")
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
267 invisible(
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
268 lapply(
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
269 X = 1:length(argVc)
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
270 , FUN = function(i) {
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
271 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
272 }
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
273 )
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
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
276 # 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
277
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
278 ## output files
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
279 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
280 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
281 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
282 ## input files
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
283 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
284 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
285 args_env$sample_metadata_path <- as.character(argVc["sample_metadata_path"])
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 # other parameters
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
288
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
289 # 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
290 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
291 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
292 # numeric args
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
293 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
294 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
295 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
296 # string args
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
297 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
298 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
299
02cafb660b72 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit f600ce8a783df16e49272341dce0fc6bbc299b0a
eschen42
parents: 0
diff changeset
300
02cafb660b72 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit f600ce8a783df16e49272341dce0fc6bbc299b0a
eschen42
parents: 0
diff changeset
301 # 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
302 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
303
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
304 log_print("PARAMETERS (parsed):")
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
305 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
306 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
307 value <- ifelse(length(value) == 1, value, sprintf("c(%s)", paste(value, collapse=", ")))
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
308
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
309 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
310 }
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
311 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 ##---------------------------------------------------------
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
314 ## Computation - attempt to read input data
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
315 ##---------------------------------------------------------
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
316 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
317 result <- -1
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
318 } else {
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
319 log_print("Input data was read successfully.")
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
320 result <- w4mkmeans(env = args_env)
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
321 log_print("returned from call to w4mkmeans.")
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
322 }
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
323
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
324 if ( length(result) == 0 ) {
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
325 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
326 # 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
327 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
328 } 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
329 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
330 # 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
331 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
332 } 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
333 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
334 # 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
335 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
336 } 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
337 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
338 # 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
339 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
340 } else {
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
341 tryCatch(
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
342 expr = {
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
343 fileConn<-file(scores_out)
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
344 writeLines(result$scores, fileConn)
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
345 close(fileConn)
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
346 }
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
347 , error = function(e) {
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
348 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
349 # 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
350 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
351 }
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
352 )
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
353 }
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
354
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
355 ##--------
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
356 ## Closing
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
357 ##--------
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
358
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
359
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
360 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
361 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
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 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
365 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
366 }
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 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
369 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
370 }
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 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
373
6ccbe18131a6 planemo upload for repository https://github.com/HegemanLab/w4mkmeans_galaxy_wrapper/tree/master commit 299e5c7fdb0d6eb0773f3660009f6d63c2082a8d
eschen42
parents:
diff changeset
374 # 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
375 q(save = "no", status = 0, runLast = FALSE)