Browse code

Removed support for CSI files because Rsamtools does not support it

shians authored on 05/03/2024 03:43:24
Showing 1 changed files
... ...
@@ -15,16 +15,15 @@ assert_readable <- function(x) {
15 15
 
16 16
 #' @importFrom purrr map_lgl
17 17
 assert_has_index <- function(x) {
18
-    has_index <- purrr::map_lgl(paste0(x, ".bai"), fs::file_exists) |
19
-                 purrr::map_lgl(paste0(x, ".csi"), fs::file_exists)
18
+    has_index <- purrr::map_lgl(paste0(x, ".bai"), fs::file_exists)
20 19
 
21 20
     if (any(!has_index)) {
22 21
         no_index <- x[!has_index]
23 22
         if (length(no_index) == 1) {
24
-            stop(glue::glue("files '{no_index}' does not have bam index, this can be fixed by running `samtools index` in the command line."))
23
+            stop(glue::glue("file '{no_index}' does not have bam index (.bai), this can be fixed by running `samtools index` in the command line."))
25 24
         } else {
26 25
             no_index <- paste(glue::glue("'{no_index}'"), collapse = ", ")
27
-            stop(glue::glue("files {no_index} do not have bam index, this can be fixed by running `samtools index` in the command line."))
26
+            stop(glue::glue("files {no_index} do not have bam index (.bai), this can be fixed by running `samtools index` in the command line."))
28 27
         }
29 28
     }
30 29
 }
Browse code

Added handling of csi indices for BAM files

shians authored on 04/03/2024 23:51:25
Showing 1 changed files
... ...
@@ -15,7 +15,8 @@ assert_readable <- function(x) {
15 15
 
16 16
 #' @importFrom purrr map_lgl
17 17
 assert_has_index <- function(x) {
18
-    has_index <- purrr::map_lgl(paste0(x, ".bai"), fs::file_exists)
18
+    has_index <- purrr::map_lgl(paste0(x, ".bai"), fs::file_exists) |
19
+                 purrr::map_lgl(paste0(x, ".csi"), fs::file_exists)
19 20
 
20 21
     if (any(!has_index)) {
21 22
         no_index <- x[!has_index]
Browse code

Updated assertions

Shians authored on 05/06/2023 05:00:37
Showing 1 changed files
... ...
@@ -8,7 +8,7 @@ assert_readable <- function(x) {
8 8
             stop(glue::glue("Path '{unreadables}' does not exist"))
9 9
         } else {
10 10
             unreadables <- paste(glue::glue("'{unreadables}'"), collapse = ", ")
11
-            stop(glue::glue("Paths {unreadables} do not exist"))
11
+            stop(glue::glue("paths {unreadables} do not exist"))
12 12
         }
13 13
     }
14 14
 }
... ...
@@ -20,10 +20,10 @@ assert_has_index <- function(x) {
20 20
     if (any(!has_index)) {
21 21
         no_index <- x[!has_index]
22 22
         if (length(no_index) == 1) {
23
-            stop(glue::glue("files '{no_index}' does not have bam index"))
23
+            stop(glue::glue("files '{no_index}' does not have bam index, this can be fixed by running `samtools index` in the command line."))
24 24
         } else {
25 25
             no_index <- paste(glue::glue("'{no_index}'"), collapse = ", ")
26
-            stop(glue::glue("files {no_index} do not have bam index"))
26
+            stop(glue::glue("files {no_index} do not have bam index, this can be fixed by running `samtools index` in the command line."))
27 27
         }
28 28
     }
29 29
 }
Browse code

Added check for BAM indices

Shians authored on 31/05/2023 03:09:33
Showing 1 changed files
... ...
@@ -12,3 +12,18 @@ assert_readable <- function(x) {
12 12
         }
13 13
     }
14 14
 }
15
+
16
+#' @importFrom purrr map_lgl
17
+assert_has_index <- function(x) {
18
+    has_index <- purrr::map_lgl(paste0(x, ".bai"), fs::file_exists)
19
+
20
+    if (any(!has_index)) {
21
+        no_index <- x[!has_index]
22
+        if (length(no_index) == 1) {
23
+            stop(glue::glue("files '{no_index}' does not have bam index"))
24
+        } else {
25
+            no_index <- paste(glue::glue("'{no_index}'"), collapse = ", ")
26
+            stop(glue::glue("files {no_index} do not have bam index"))
27
+        }
28
+    }
29
+}
Browse code

Fixed readability assertions

Shians authored on 11/04/2023 01:17:24
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,14 @@
1
+#' @importFrom purrr map_lgl
2
+assert_readable <- function(x) {
3
+    readable <- purrr::map_lgl(x, fs::file_exists)
4
+
5
+    if (any(!readable)) {
6
+        unreadables <- x[!readable]
7
+        if (length(unreadables) == 1) {
8
+            stop(glue::glue("Path '{unreadables}' does not exist"))
9
+        } else {
10
+            unreadables <- paste(glue::glue("'{unreadables}'"), collapse = ", ")
11
+            stop(glue::glue("Paths {unreadables} do not exist"))
12
+        }
13
+    }
14
+}