Bioconductor / Biostrings

Efficient manipulation of biological strings
https://bioconductor.org/packages/Biostrings
54 stars 16 forks source link

consensusString and consensusMatrix error for legth-0 input #101

Open jan-glx opened 1 year ago

jan-glx commented 1 year ago

Currently, consensusString fails for length-0 inputs:

Biostrings::consensusString(character(0))
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'consensusString': 'x' has no element and 'width' is NULL

Created on 2023-07-29 by the reprex package (v2.0.1)

I believe it should return character(0) instead and at most warn.

Maybe, replacing error("'x' has no element and 'width' is NULL"); with return allocMatrix(INTSXP, 0, 0); is all that's needed?

ahl27 commented 3 months ago

Thanks for the callout, and apologies for the slow turnaround--this is fixed in #111.

The return values in the new version should be consistent with inputs of length > 0:

I'll merge this sometime this month once I've double checked that it's not causing any other weird bugs.