generate.formula gets an error if the specified element list has only one element specified. Inserting a dummy element with max count of zero circumvents the issue. Of course, I don't know if the actual root cause has anything to to with list length.
generate.formula(120, window = 0.0036, list(c("C", "0", "12")))
# Error in .jcall(mfTool, "Lorg/openscience/cdk/interfaces/IMolecularFormulaSet;", :
# java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
generate.formula(120, window = 0.0036, list(c("C", "0", "12"), c("H", "0", "0")))
# [[1]] cdkFormula: C10 , mass = 120 , charge = 0
generate.formula(120, window = 0.0036, list(c("H", "0", "200")))
# Error in .jcall(mfTool, "Lorg/openscience/cdk/interfaces/IMolecularFormulaSet;", :
# java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
list(c("C", "0", "12")) is in fact a list of length one, so the issue isn't that it got converted to a list of length 3:
generate.formula
gets an error if the specified element list has only one element specified. Inserting a dummy element with max count of zero circumvents the issue. Of course, I don't know if the actual root cause has anything to to with list length.list(c("C", "0", "12"))
is in fact a list of length one, so the issue isn't that it got converted to a list of length 3:(I am aware that the doc specifies
c("C", 0, 50)
but of course 0 and 50 get converted to character anyway.)System (please complete the following information):