Browse code

add FULL() param to extract from GRangeslist

Simone authored on 27/03/2021 14:45:15
Showing2 changed files

... ...
@@ -61,8 +61,8 @@ Collate:
61 61
     'S3Aggregates.R'
62 62
     'S3Cover-Param.R'
63 63
     'S3Distal.R'
64
-    'S3filter_extract_param.R'
65 64
     'S3Operator.R'
65
+    'S3filter_extract_param.R'
66 66
     'Utils.R'
67 67
     'evaluation-functions.R'
68 68
     'filter-extract-function.R'
... ...
@@ -68,6 +68,10 @@
68 68
 #' sorted_grl_full <- sort(grl)
69 69
 #' filter_and_extract(sorted_grl, region_attributes = FULL())
70 70
 #' 
71
+#' grl <- import_gmql(test_path, TRUE)
72
+#' sorted_grl <- sort(grl)
73
+#' filter_and_extract(sorted_grl, region_attributes = FULL())
74
+#' 
71 75
 #' ## Also, we can inlcude a list of region attribute inside the FULL() 
72 76
 #' ## function to exlucde that regions
73 77
 #' 
... ...
@@ -225,6 +229,21 @@ filter_and_extract <- function(
225 229
   }
226 230
   
227 231
   g1 <- region_list[[1]]
232
+
233
+  if(is.object(regions) && ("FULL" %in% class(regions))) {
234
+    all_values <- names(elementMetadata(g1))
235
+    except_values <- regions$values
236
+    regions <- if (is.null(except_values))
237
+      all_values
238
+    else
239
+      all_values[!all_values %in% except_values]
240
+    names(regions) <- NULL
241
+    # since import convert this value from GMQL schema to GTF format
242
+    # we need to convert it back
243
+    regions <- replace(regions, regions == "feature", "type")
244
+    regions <- replace(regions, regions == "frame", "phase")
245
+  }
246
+  
228 247
   elementMetadata(g1) <- NULL
229 248
   if (!is.null(regions)) {
230 249
     DF_list <- mapply(function(g_x, h) {