annotate FCSKeyword.R @ 1:1d5e530c8a5e draft default tip

"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
author azomics
date Mon, 22 Jun 2020 17:22:21 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
1 #!/usr/bin/env Rscript
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
2 # ImmPort FCSKeywords
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
3 ######################################################################
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
4 # Copyright (c) 2016 Northrop Grumman.
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
5 # All rights reserved.
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
6 ######################################################################
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
7 #
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
8 # Converts the FCS file to text without transformaton
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
9 # To run in R
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
10 # 1) library(flowCore)
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
11 # 2) source("FCSKeyword.R")
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
12 # 3) transformFCS("filename")
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
13 #
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
14 # Version 1.4.1
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
15 # March 2016 -- added lines to run directly from command line
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
16 #
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
17
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
18 library(flowCore)
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
19
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
20 #
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
21 # Starting function for processing a FCS file
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
22 #
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
23 extractKeywords <- function(input_file, keyword_file="", debug=FALSE) {
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
24 #
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
25 # Generate the file names for the output_file and keyword_file
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
26 #
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
27 pieces <- unlist(strsplit(input_file, .Platform$file.sep))
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
28 filename <- pieces[length(pieces)]
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
29
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
30 if (keyword_file == "") {
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
31 filepieces <- unlist(strsplit(filename, '\\.'))
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
32 #replace .fcs with .keyword; append .keyword if not ending in .fcs
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
33 if (filepieces[length(filepieces)] == 'fcs') {
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
34 filepieces[length(filepieces)] = 'keyword'
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
35 } else {
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
36 filepieces[length(filepieces)+1] = 'keyword'
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
37 }
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
38 keyword_file <- paste(filepieces, collapse = '.')
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
39 }
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
40
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
41 if (debug) {
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
42 print (paste("Converting file: ", input_file))
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
43 print (paste("Original file name: ", filename))
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
44 print (paste("Output file name: ", output_file))
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
45 print (paste("Keyword file name: ", keyword_file))
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
46 }
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
47 fcs <- read.FCS(input_file, transformation=F)
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
48 keywords <- keyword(fcs)
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
49 write.table(as.matrix(keywords), file=keyword_file, quote=F,
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
50 row.names=T, col.names=F, sep='=', append=F)
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
51 }
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
52
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
53 # Extract Keywords
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
54 # @param input_file FCS file to be transformed
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
55 # @param keyword_file FCS file keywords ".keywords" extension"
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
56 transformFCS <- function(input_file, keyword_file="", debug=FALSE) {
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
57 isValid <- F
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
58 # Check file beginning matches FCS standard
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
59 tryCatch({
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
60 isValid = isFCSfile(input_file)
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
61 }, error = function(ex) {
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
62 print (paste(" ! Error in isFCSfile", ex))
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
63 })
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
64
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
65 if (isValid) {
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
66 extractKeywords(input_file, keyword_file, debug)
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
67 } else {
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
68 print (paste(input_file, "does not meet FCS standard"))
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
69 }
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
70 }
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
71
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
72 args <- commandArgs(TRUE)
1d5e530c8a5e "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/extract_fcs_keywords commit f0a40d58aec0a657b60df338c79dc1ee8e510aa0"
azomics
parents:
diff changeset
73 transformFCS(args[1], args[2])