コード例 #1
0
ファイル: NexusExporter.java プロジェクト: 4ment/beast-mcmc
  public Map<String, Integer> writeNexusHeader(Tree tree) {
    int taxonCount = tree.getTaxonCount();
    List<String> names = new ArrayList<String>();

    for (int i = 0; i < tree.getTaxonCount(); i++) {
      names.add(tree.getTaxonId(i));
    }

    if (sorted) Collections.sort(names);

    out.println("#NEXUS");
    out.println();
    out.println("Begin taxa;");
    out.println("\tDimensions ntax=" + taxonCount + ";");
    out.println("\tTaxlabels");
    for (String name : names) {
      if (name.matches(SPECIAL_CHARACTERS_REGEX)) {
        name = "'" + name + "'";
      }
      out.println("\t\t" + name);
    }
    out.println("\t\t;");
    out.println("End;");
    out.println("");
    out.println("Begin trees;");

    // This is needed if the trees use numerical taxon labels
    out.println("\tTranslate");
    Map<String, Integer> idMap = new HashMap<String, Integer>();

    int k = 1;
    for (String name : names) {
      idMap.put(name, k);
      if (name.matches(SPECIAL_CHARACTERS_REGEX)) {
        name = "'" + name + "'";
      }
      if (k < names.size()) {
        out.println("\t\t" + k + " " + name + ",");
      } else {
        out.println("\t\t" + k + " " + name);
      }
      k += 1;
    }
    return idMap;
  }
コード例 #2
0
ファイル: PathogenFrame.java プロジェクト: stevenhwu/ABI
  private void setStatusMessage() {
    Tree tree = treesPanel.getTree();
    if (tree != null) {
      String message = "";
      message += "Tree loaded, " + tree.getTaxonCount() + " taxa";

      TemporalRooting tr = treesPanel.getTemporalRooting();
      if (tr.isContemporaneous()) {
        message += ", contemporaneous tips";
      } else {
        NumberFormatter nf = new NumberFormatter(3);
        message += ", dated tips with range " + nf.format(tr.getDateRange());
      }
      statusLabel.setText(message);
    }
  }