code: public void writeOntTxt(PrintWriter pw) {
          for (String id : terms.keySet()) {
              OntologyTerm term = terms.get(id);
              Set<String> synSet = new HashSet<String>();
              synSet.add(term.getName());
              for (Synonym s : term.getSynonyms()) {
                  String st = s.getType();
                  if (id.startsWith("PTCO")
                          || (st != null && !st
                                  .matches(".*(InChI|SMILES|FORMULA).*"))) {
                      String synonym = s.getSyn();
                      if (!synonym.matches("\\S")) {// reject ontology terms
                                                    // consisting of a single
                                                    // letter as these produce too
                                                    // many false positives
                          synSet.add(synonym);
                      }
                  }
              }
  
              pw.println("[" + id + "]");
              for (String syn : synSet)
                  pw.println(syn);
              pw.println();
          }
          pw.flush();
      }
docs: Writes a file suitable for use as onotology.txt.
  
  @param pw
  The PrintWriter to write to.