Browse code

Rename list_gff3 to is_gff3 function and made it robust

Aspasia Orfanou authored on 01/02/2022 12:27:21
Showing 4 changed files

... ...
@@ -1,9 +1,9 @@
1 1
 # Generated by roxygen2: do not edit by hand
2 2
 
3 3
 export(get_lineage_report)
4
+export(is_gff3)
4 5
 export(lineagespot)
5 6
 export(lineagespot_hits)
6
-export(list_gff3)
7 7
 export(list_input)
8 8
 export(list_vcf)
9 9
 export(merge_vcf)
... ...
@@ -66,7 +66,7 @@ list_vcf <- function(vcf_fls = NULL,
66 66
 }
67 67
 
68 68
 
69
-#' list_gff3
69
+#' is_gff3
70 70
 #'
71 71
 #' @description
72 72
 #' Identify whether a file is in GFF3 format.
... ...
@@ -84,8 +84,8 @@ list_vcf <- function(vcf_fls = NULL,
84 84
 #' gff3_path <- system.file("extdata", "NC_045512.2_annot.gff3",
85 85
 #'   package = "lineagespot"
86 86
 #' )
87
-#' list_gff3(gff3_path)
88
-list_gff3 <- function(file) {
87
+#' is_gff3(gff3_path)
88
+is_gff3 <- function(file) {
89 89
   if (is.null(file)) {
90 90
     stop(c(
91 91
       "Please provide a valid GFF3 file",
... ...
@@ -101,7 +101,7 @@ list_gff3 <- function(file) {
101 101
     stop("Please give path of only one GFF3 file.")
102 102
   }
103 103
 
104
-  res <- str_detect(file, "gff3")
104
+  res <- str_detect(file, ".gff3$")
105 105
 
106 106
   return(res)
107 107
 }
... ...
@@ -149,10 +149,12 @@ list_input <- function(vcf_fls = NULL,
149 149
     stop("No VCF is found. Please insert valid input files.")
150 150
   }
151 151
 
152
-  if (list_gff3(gff3_path) == FALSE) {
152
+  if (is_gff3(gff3_path) == FALSE) {
153 153
     stop("No valid gff3 was given. Please insert path of valid gff3.")
154 154
   }
155 155
 
156 156
 
157 157
   return(vcf_fls)
158 158
 }
159
+
160
+
159 161
similarity index 81%
160 162
rename from man/list_gff3.Rd
161 163
rename to man/is_gff3.Rd
... ...
@@ -1,10 +1,10 @@
1 1
 % Generated by roxygen2: do not edit by hand
2 2
 % Please edit documentation in R/input_checking.R
3
-\name{list_gff3}
4
-\alias{list_gff3}
5
-\title{list_gff3}
3
+\name{is_gff3}
4
+\alias{is_gff3}
5
+\title{is_gff3}
6 6
 \usage{
7
-list_gff3(file)
7
+is_gff3(file)
8 8
 }
9 9
 \arguments{
10 10
 \item{file}{Path to GFF3 file.}
... ...
@@ -20,5 +20,5 @@ Identify whether a file is in GFF3 format.
20 20
 gff3_path <- system.file("extdata", "NC_045512.2_annot.gff3",
21 21
   package = "lineagespot"
22 22
 )
23
-list_gff3(gff3_path)
23
+is_gff3(gff3_path)
24 24
 }
... ...
@@ -30,9 +30,9 @@ test_that('Input file is vcf',{
30 30
 })
31 31
 
32 32
 test_that('Input file is gff3',{
33
-    expect_true(list_gff3(system.file("extdata","NC_045512.2_annot.gff3",
33
+    expect_true(is_gff3(system.file("extdata","NC_045512.2_annot.gff3",
34 34
                                     package = "lineagespot")))
35
-    expect_false(list_gff3(system.file("extdata","vcf-files",
35
+    expect_false(is_gff3(system.file("extdata","vcf-files",
36 36
                                     "SampleA_freebayes_ann.vcf",
37 37
                                     package = "lineagespot")))
38 38
 })