Changeset 4511


Ignore:
Timestamp:
Aug 15, 2013, 5:08:09 PM (10 years ago)
Author:
Fredrik Levander
Message:

Refs #808. Refs #807. Updated converter to output as many digits as in input file, which also avoid local decimal/comma problems.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/plugin/src/org/proteios/plugins/MgfToMzDataPlugin.java

    r4499 r4511  
    573573    int percent = 0;
    574574    String title = "";
    575     Float rtInSeconds = 0f;
     575    String rtInSeconds = "0";
    576576    float basePeakIntensity = 0;
    577577    float totalIntensity = 0;
    578     Float massToChargeRatio = 0f;
    579     Float intensity = 0f;
     578    String massToChargeRatio = "0";
     579    String intensity = "0";
    580580    Integer chargeState = 0;
    581581    /*
     
    595595          // New spectrum, reset peaklist data
    596596          title = "";
    597           rtInSeconds = 0f;
     597          rtInSeconds = "0";
    598598          basePeakIntensity = 0;
    599599          totalIntensity = 0;
    600           massToChargeRatio = 0f;
    601           intensity = 0f;
     600          massToChargeRatio = "0";
     601          intensity = "0";
    602602          chargeState = 0;
    603603          dataLength = 0;
     
    634634          if (restLine != null)
    635635          {
    636             rtInSeconds = Float.valueOf(restLine);
     636            rtInSeconds = restLine;
    637637          }
    638638        }
     
    645645          {
    646646            StringTokenizer st = new StringTokenizer(restLine);
    647             massToChargeRatio = Float.valueOf(st.nextToken());
     647            massToChargeRatio = st.nextToken();
    648648            try
    649649            {
    650               intensity = Float.valueOf(st.nextToken());
     650              intensity = st.nextToken();
    651651            }
    652652            catch (NoSuchElementException e)
    653653            {
    654               intensity = 0f;
     654              intensity = "0";
    655655            }
    656656          }
     
    12051205   */
    12061206  private void writeMzDataSpectrumDescBlock(XMLCrudeWriter2 xmlCWriter,
    1207       Float massToChargeRatio, Float intensity, Integer chargeState,
    1208       Float rtInSeconds, String title)
     1207      String massToChargeRatio, String intensity, Integer chargeState,
     1208      String rtInSeconds, String title)
    12091209      throws XMLStreamException
    12101210  {
     
    12411241   * @param rtInSeconds Float
    12421242   */
    1243   private void writeMzDataSpectrumSettingsBlock(XMLCrudeWriter2 xmlCWriter, Float rtInSeconds)
     1243  private void writeMzDataSpectrumSettingsBlock(XMLCrudeWriter2 xmlCWriter, String rtInSeconds)
    12441244      throws XMLStreamException
    12451245  {
     
    12671267   * @param rtInSeconds Float
    12681268   */
    1269   private void writeMzDataSpectrumInstrumentBlock(XMLCrudeWriter2 xmlCWriter, Float rtInSeconds)
     1269  private void writeMzDataSpectrumInstrumentBlock(XMLCrudeWriter2 xmlCWriter, String rtInSeconds)
    12701270      throws XMLStreamException
    12711271  {
     
    12981298     */
    12991299    XMLExportUtil.writeCvParamBlock(xmlCWriter, "psi", "PSI:1000039",
    1300       "TimeInSeconds", Float.toString(rtInSeconds));
     1300      "TimeInSeconds", rtInSeconds);
    13011301    /*
    13021302     * Write spectrumInstrument block end
     
    13161316   */
    13171317  private void writeMzDataPrecursorListBlock(XMLCrudeWriter2 xmlCWriter,
    1318       Float massToChargeRatio, Float intensity, Integer chargeState)
     1318      String massToChargeRatio, String intensity, Integer chargeState)
    13191319      throws XMLStreamException
    13201320  {
     
    13461346   */
    13471347  private void writeMzDataPrecursorBlock(XMLCrudeWriter2 xmlCWriter,
    1348       Float massToChargeRatio, Float intensity, Integer chargeState)
     1348      String massToChargeRatio, String intensity, Integer chargeState)
    13491349      throws XMLStreamException
    13501350  {
     
    13871387   */
    13881388  private void writeMzDataIonSelectionBlock(XMLCrudeWriter2 xmlCWriter,
    1389       Float massToChargeRatio, Float intensity, Integer chargeState)
     1389      String massToChargeRatio, String intensity, Integer chargeState)
    13901390      throws XMLStreamException
    13911391  {
     
    13981398     * Write cvParam tag
    13991399     */
    1400     /*
    1401      * We want massToChargeRatio to be displayed with 2 decimals, even if
    1402      * the last ones are zeros. GroupingUsed is set to 'false' to avoid e.g.
    1403      * "2000.000000" being displayed as "2,000.000000". NumberFormat
    1404      * requires "import java.text.NumberFormat" to work.
    1405      */
    1406     NumberFormat massToChargeRatioFormat = NumberFormat.getInstance();
    1407     massToChargeRatioFormat.setMinimumFractionDigits(2);
    1408     massToChargeRatioFormat.setMaximumFractionDigits(2);
    1409     massToChargeRatioFormat.setGroupingUsed(false);
    14101400    XMLExportUtil.writeCvParamBlock(xmlCWriter, "psi", "PSI:1000040",
    1411       "MassToChargeRatio", massToChargeRatioFormat.format(
    1412         massToChargeRatio).toString());
     1401      "MassToChargeRatio", massToChargeRatio);
    14131402    /*
    14141403     * Write cvParam tag
     
    14201409     */
    14211410    XMLExportUtil.writeCvParamBlock(xmlCWriter, "psi", "PSI:1000042",
    1422       "Intensity", Float.toString(intensity));
     1411      "Intensity", intensity);
    14231412    /*
    14241413     * Write ionSelection block end
Note: See TracChangeset for help on using the changeset viewer.