예제 #1
0
  /**
   * Marshalls the mgf file object to a file. If the file already exists it will be overwritten.
   *
   * @param file The file to marshall the mgf file to.
   */
  public void marshallToFile(File file) throws JMzReaderException {
    try {
      // create the object to write the file
      BufferedWriter writer = new BufferedWriter(new FileWriter(file));

      // process all additional parameters
      String parameters = marshallAdditionalParameters();

      // write the parameters
      writer.write(parameters);

      // process the pmf spectra
      for (PmfQuery q : pmfQueries) writer.write(q.toString() + "\n");

      writer.write("\n");

      // write the spectra
      for (Integer index = 0; index < 1000000; index++) {
        if (!ms2Queries.containsKey(index)) continue;

        writer.write(ms2Queries.get(index).toString() + "\n");
      }

      writer.close();

    } catch (IOException e) {
      throw new JMzReaderException("Failed to write output file", e);
    }
  }
예제 #2
0
  @Override
  public String toString() {
    // add the parameters
    String string = marshallAdditionalParameters();

    // process the pmf spectra
    for (PmfQuery q : pmfQueries) string += (q.toString() + "\n");

    if (pmfQueries.size() > 0) string += "\n";

    // write the spectra
    for (Integer index = 0; index < 1000000; index++) {
      if (!ms2Queries.containsKey(index)) continue;

      string += ms2Queries.get(index).toString() + "\n";
    }

    return string;
  }