Fixed GNPS library json generator (mz formatting was to string)
double needed
package net.sf.mzmine.modules.peaklistmethods.io.spectraldbsubmit.formats;
-import java.text.DecimalFormat;
-import java.text.NumberFormat;
import javax.json.Json;
import javax.json.JsonArray;
import javax.json.JsonArrayBuilder;
@@ -123,12 +121,11 @@ public class GnpsJsonGenerator {
* @return
*/
private static JsonArray genJSONData(DataPoint[] dps) {
- NumberFormat mzForm = new DecimalFormat("0.######");
JsonArrayBuilder data = Json.createArrayBuilder();
JsonArrayBuilder signal = Json.createArrayBuilder();
for (DataPoint dp : dps) {
// round to five digits. thats more than enough
- signal.add(mzForm.format(dp.getMZ()));
+ signal.add(((int) (dp.getMZ() * 1000000)) / 1000000.0);
signal.add(dp.getIntensity());
data.add(signal.build());
}
