Browse code

normalize path to fasta file for gmap_build

Needed because we are running it inside a temporary directory. That
logic is now passed down to gmap_build() from referenceSequence<-().


git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/gmapR@129717 bc3139a8-67e5-0310-9ffc-ced21a209358

Michael Lawrence authored on 18/05/2017 22:47:22
Showing2 changed files

... ...
@@ -121,16 +121,7 @@ setReplaceMethod("referenceSequence",
121 121
                  signature(x = "GmapGenome", value = "ANY"),
122 122
                  function(x, name, ..., value)
123 123
                  {
124
-                   gmap_db_tmp_dir <- file.path(tempdir(), "gmap_db_tmp_dir")
125
-                   dir.create(gmap_db_tmp_dir, recursive=TRUE)
126
-                   cur_wd <- getwd()
127
-                   on.exit({unlink(gmap_db_tmp_dir, recursive=TRUE)
128
-                            setwd(cur_wd)})
129
-                   setwd(gmap_db_tmp_dir)
130
-
131
-                   db <- gmap_build(value, x, ...)
132
-                   
133
-                   db
124
+                   gmap_build(value, x, ...)
134 125
                  })
135 126
 
136 127
 setGeneric("snps<-", function(x, name, ..., value) standardGeneric("snps<-"))
... ...
@@ -45,7 +45,15 @@ setMethod("gmap_build", c("DNAStringSet", "GmapGenome"),
45 45
 
46 46
 setMethod("gmap_build", c("character", "GmapGenome"),
47 47
           function(x, genome, kmer = 15L, ...) {
48
+            gmap_db_tmp_dir <- file.path(tempdir(), "gmap_db_tmp_dir")
49
+            dir.create(gmap_db_tmp_dir, recursive=TRUE)
50
+            cur_wd <- getwd()
51
+            on.exit({unlink(gmap_db_tmp_dir, recursive=TRUE)
52
+                setwd(cur_wd)})
53
+            setwd(gmap_db_tmp_dir)
54
+
48 55
             gz <- file_ext(x) == "gz"
56
+            x <- normalizePath(x, mustWork=TRUE)
49 57
             .gmap_build(db = genome(genome), dir = path(directory(genome)),
50 58
                         kmer = kmer, sort = "none", gunzip = gz, .fasta = x, ...)
51 59
             genome