<commit_before>package starbeast2;


import beast.core.BEASTInterface;
import beast.core.Description;
import beast.evolution.alignment.Taxon;
import beast.evolution.alignment.Sequence;
import beast.evolution.alignment.TaxonSet;

import java.util.*;


@Description("A TaxonSet is an ordered set of taxa. The order on the taxa is provided at the time of construction" +
        " either from a list of taxon objects or an alignment.")
public class StarBeastTaxonSet extends TaxonSet {

    @Override
    public void initAndValidate() {
        updateTaxaNames();
    }

    private void updateTaxaNames() {
        if (taxaNames == null) {
            taxaNames = new ArrayList<>();
        } else {
            taxaNames.clear();
        }

        if (taxonsetInput.get() == null && alignmentInput.get() == null) {
            throw new IllegalArgumentException("Need a taxonset and/or an alignment as input");
        }

        if (taxonsetInput.get() != null) {
            for (Taxon t : taxonsetInput.get()) {
                final String taxonName = t.getID();
                taxaNames.add(taxonName);
            }
        }

        // Add taxon names in morphology but not in molecular data
        if (alignmentInput.get() != null) {
            for (String taxonName : alignmentInput.get().getTaxaNames()) {
                if (!taxaNames.contains(taxonName)) taxaNames.add(taxonName);
            }
        }
    }

    // Hack to get tip dates to update correctly
    @Override
    public List<String> asStringList() {
        if (taxaNames == null) {
            return null;
        }

        if (taxaNames.size() == 1) { // probably running BEAUTi
            updateTaxaNames();
        }

        return Collections.unmodifiableList(taxaNames);
    }
}<commit_msg>Better handling of tip dates panel<commit_after>package starbeast2;


import beast.core.BEASTInterface;
import beast.core.Description;
import beast.evolution.alignment.Taxon;
import beast.evolution.alignment.Sequence;
import beast.evolution.alignment.TaxonSet;

import java.util.*;


@Description("A TaxonSet is an ordered set of taxa. The order on the taxa is provided at the time of construction" +
        " either from a list of taxon objects or an alignment.")
public class StarBeastTaxonSet extends TaxonSet {
    private boolean insideBeauti = false;

    @Override
    public void initAndValidate() {
        updateTaxaNames();
    }

    private void updateTaxaNames() {
        if (taxaNames == null) {
            taxaNames = new ArrayList<>();
        } else {
            taxaNames.clear();
        }

        if (taxonsetInput.get() == null && alignmentInput.get() == null) {
            throw new IllegalArgumentException("Need a taxonset and/or an alignment as input");
        }

        if (taxonsetInput.get() != null) {
            for (Taxon t : taxonsetInput.get()) {
                final String taxonName = t.getID();
                taxaNames.add(taxonName);
            }
        }

        // Add taxon names in morphology but not in molecular data
        if (alignmentInput.get() != null) {
            for (String taxonName : alignmentInput.get().getTaxaNames()) {
                if (!taxaNames.contains(taxonName)) taxaNames.add(taxonName);
            }
        }

        insideBeauti |= taxaNames.contains("Beauti2DummyTaxonSet");
    }

    // Hack to get tip dates to update correctly
    @Override
    public List<String> asStringList() {
        if (taxaNames == null) return null;
        if (insideBeauti) updateTaxaNames();

        return Collections.unmodifiableList(taxaNames);
    }
}
{'fraction_non_alphanumeric': 0.1004705231109881, 'fraction_numerical': 0.0011071132023249377, 'mean_word_length': 2.3095238095238093, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2749268', 'n_tokens_mistral': 1037, 'n_tokens_neox': 975, 'n_words': 283}