HenrikBengtsson / aroma.seq

🔬 R package: aroma.seq: High-Throughput Sequence Analysis using the Aroma Framework
https://github.com/HenrikBengtsson/aroma.seq
0 stars 1 forks source link

print() on a "missing" BamDataFile gives "Error in Rsamtools::BamFile(pathname, ..." #24

Closed HenrikBengtsson closed 8 years ago

HenrikBengtsson commented 9 years ago
> class(bam)[1]
[1] "BamDataFile"

> getPathname(bam)
[1] NA

> print(bam)
Error in Rsamtools::BamFile(pathname, index = character(0L)) :
  'file' must be character(1) and not NA
> traceback()
16: stop("'file' must be character(1) and not NA")
15: Rsamtools::BamFile(pathname, index = character(0L))
14: readHeader.BamDataFile(this, ...)
13: readHeader(this, ...)
12: getHeader.BamDataFile(this, ...)
11: getHeader(this, ...)
10: getPrograms.BamDataFile(this, ...)
9: getPrograms(this, ...)
8: getProgramString.BamDataFile(this)
7: getProgramString(this)
6: sprintf("Generated by: %s", getProgramString(this))
5: as.character.BamDataFile(x)
4: as.character(x)
3: print(as.character(x))
2: print.Object(x)
1: print(x)

This boils down to:

> getHeader(bam)
Error in Rsamtools::BamFile(pathname, index = character(0L)) :
  'file' must be character(1) and not NA

> readHeader(bam)
Error in Rsamtools::BamFile(pathname, index = character(0L)) :
  'file' must be character(1) and not NA

As a start, readHeader() should not try to read a non-existing file. At least it should throw an error that the file does not exist, e.g.

> Arguments$getReadablePathname(getPathname(bam))
[2015-05-28 17:31:27] Exception: No such file/directory because argument 'file' is NA.
HenrikBengtsson commented 8 years ago

Solved;

> bam <- BamDataFile("non-existing.bam", mustExist=FALSE)
> bam
BamDataFile:
Name: NA
Full name: NA
Pathname: non-existing.bam
File size: NA
RAM: 0.00 MB