diff mykrobe_parser.R @ 4:8529045f0fdf draft

planemo upload for repository https://github.com/phac-nml/mykrobe-parser commit 34d9c47b9451e5f7843028dba22b96d125fb09f5
author nml
date Thu, 25 Apr 2019 10:13:46 -0400
parents f2608dccd3e0
children deebc6410d13
line wrap: on
line diff
--- a/mykrobe_parser.R	Fri Oct 26 16:57:34 2018 -0400
+++ b/mykrobe_parser.R	Thu Apr 25 10:13:46 2019 -0400
@@ -152,7 +152,7 @@
             opt$depth,  # Mykrobe_min_depth_default_5
             opt$conf,  # Mykrobe_min_conf_default_10
             "",                             # LIMS_file - empty as it's an upload field in LIMS
-            opt$name)  # LIMS_filename
+            opt$name)  # Mutation_set_version
 
 names(params) <- c("Lims_Comment", 
                    "Lims_INTComment",
@@ -160,7 +160,7 @@
                    "Mykrobe_min_depth_default_5",
                    "Mykrobe_min_conf_default_10", 
                    "LIMS_file", 
-                   "LIMS_filename")
+                   "Mutation_set_version")
 
 
 # A default report in the order our LIMS requires
@@ -185,9 +185,12 @@
              "Mykrobe_rpsA",
              "Pyrazinamide_R_mutations",
              "Pyrazinamide_Prediction",
-             "Mykrobe_gyrA",
-             "Quinolones_R_mutations",
-             "Quinolones_Prediction",
+             "Mykrobe_Ofloxacin_gyrA",
+             "Ofloxacin_R_mutations",
+             "Ofloxacin_Prediction",
+             "Mykrobe_Moxifloxacin_gyrA",
+             "Moxifloxacin_R_mutations",
+             "Moxifloxacin_Prediction",
              "Mykrobe_rpsL",
              "Mykrobe_Streptomycin_rrs",
              "Mykrobe_Streptomycin_gid",
@@ -212,7 +215,7 @@
              "Mykrobe_min_depth_default_5",
              "Mykrobe_min_conf_default_10",
              "LIMS_file",
-             "LIMS_filename")
+             "Mutation_set_version")
 
 report <- setNames(data.frame(matrix("", ncol = length(columns), nrow = 1), stringsAsFactors = F), columns)
 
@@ -222,7 +225,8 @@
                "Rifampicin", 
                "Ethambutol", 
                "Pyrazinamide", 
-               "Moxifloxacin_Ofloxacin", 
+               "Moxifloxacin",
+               "Ofloxacin", 
                "Streptomycin",
                "Amikacin",
                "Capreomycin",
@@ -287,7 +291,7 @@
         mutate(variants = strsplit(variants, "__")) %>% # Split the mutations across rows (list first then split across rows)
         unnest(variants) %>% 
         separate(variants, c("gene", "mutation"), "_") %>% 
-        mutate(columnname = ifelse(gene %in% c("tlyA", "rrs", "gid"), # Check for columns that include the drug name or not and paste accordingly
+        mutate(columnname = ifelse(gene %in% c("tlyA", "rrs", "eis", "gid"), # Check for columns that include the drug name or not and paste accordingly
                                    paste("Mykrobe", drug, gene, sep = "_"),
                                    paste("Mykrobe", gene, sep = "_"))) %>% 
         # Extract out the mutation information with a regex that covers all potential genes
@@ -332,9 +336,7 @@
   filter_at(vars(ends_with("_Prediction")), any_vars(. != "failed")) %>% 
   mutate_at(vars(starts_with("Mykrobe_")), funs(replace(., is.na(.), "No Mutation"))) %>% 
   full_join(anti_join(report, ., by = "file")) %>% 
-  select(columns) %>% 
-  rename(Moxifloxacin_Ofloxacin_R_mutations = Quinolones_R_mutations,
-         Moxifloxacin_Ofloxacin_Prediction = Quinolones_Prediction)
+  select(columns) 
   
 
 # Add in the parameters fed from Galaxy using named character vector
@@ -347,7 +349,7 @@
     Mykrobe_min_depth_default_5 = params["Mykrobe_min_depth_default_5"],
     Mykrobe_min_conf_default_10 = params["Mykrobe_min_conf_default_10"],
     LIMS_file = params["LIMS_file"],
-    LIMS_filename = params["LIMS_filename"]
+    Mutation_set_version = params["Mutation_set_version"]
   )
   
 
@@ -375,4 +377,4 @@
 print("Writing JSON data to CSV as output-jsondata.csv")
 sink(NULL, type="message") # close the sink
 
-quit()
\ No newline at end of file
+quit()