I'm developing a package which uses a GmapGenome in calling variants, and therefore am trying to create a small GmapGenome (out of a fasta file for just one chromosome) in my unit tests. The problem I run into, however, is that GmapGenome seems not to work for relative file paths.
I confirmed this for myself in the console by inputting a relative path as a fasta file:
faf <- FastaFile("./tests/testthat/test_data/ref_genome_fastas/chr5.fa")
GmapGenome(faf, name = "dan_rerio_chr5_test", create=TRUE)
Which yielded this error:
Can't open file ./tests/testthat/test_data/ref_genome_fastas/chr5.fa at /home/kylej13/R/x86_64-pc-linux-gnu-library/3.3/gmapR/usr/bin//fa_coords line 193. Opening file ./tests/testthat/test_data/ref_genome_fastas/chr5.fa /home/kylej13/R/x86_64-pc-linux-gnu-library/3.3/gmapR/usr/bin//fa_coords -o ./dan_rerio_chr5_test.coords "./tests/testthat/test_data/ref_genome_fastas/chr5.fa" failed with return code 512 at /home/kylej13/R/x86_64-pc-linux-gnu-library/3.3/gmapR/usr/bin/gmap_build line 179. Error in .gmap_build(db = genome(genome), dir = path(directory(genome)), : system call returned a non-0 status: /home/kylej13/R/x86_64-pc-linux-gnu-library/3.3/gmapR/usr/bin/gmap_build --db=dan_rerio_chr5_test --dir=/home/kylej13/.local/share/gmap --kmer=15 --sort=none -B /home/kylej13/R/x86_64-pc-linux-gnu-library/3.3/gmapR/usr/bin/ ./tests/testthat/test_data/ref_genome_fastas/chr5.fa
But when I used an absolute path
faf <- FastaFile("~/MMAPPR2/tests/testthat/test_data/ref_genome_fastas/chr5.fa"
it worked fine.
I think I can work around this by using normalizePath()
or something to get the absolute path, but it would be nice to fix this or to know if there's a reason GmapGenome doesn't take relative paths.
Does file.exists() return true for that path? Just making sure that e.g. the working directory is right.
Yes it does