<commit_before>package beast.evolution.tree;

import beast.core.Description;
import beast.core.Input;
import beast.core.StateNode;
import beast.evolution.alignment.TaxonSet;
import beast.util.TreeParser;

import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;


@Description("Tree (the T in BEAST) representing gene beast.tree, species"
        + " beast.tree, language history, or other time-beast.tree"
        + " relationships among sequence data.")
public class Tree extends StateNode implements TreeInterface {
    public Input<Tree> m_initial = new Input<Tree>("initial", "tree to start with");
    public Input<List<TraitSet>> m_traitList = new Input<List<TraitSet>>("trait",
            "trait information for initializing traits (like node dates) in the tree",
            new ArrayList<TraitSet>());
    public Input<TaxonSet> m_taxonset = new Input<TaxonSet>("taxonset",
            "set of taxa that correspond to the leafs in the tree");
    public Input<String> nodeTypeInput = new Input<String>("nodetype",
            "type of the nodes in the beast.tree", Node.class.getName());

    /**
     * state of dirtiness of a node in the tree
     * DIRTY means a property on the node has changed, but not the topology
     * FILTHY means the nodes' parent or child has changed.
     */
    public static final int IS_CLEAN = 0, IS_DIRTY = 1, IS_FILTHY = 2;

    /**
     * counters of number of nodes, nodeCount = internalNodeCount + leafNodeCount *
     */
    protected int nodeCount = -1;
    protected int internalNodeCount = -1;
    protected int leafNodeCount = -1;

    /**
     * node representation of the beast.tree *
     */
    protected beast.evolution.tree.Node root;
    protected beast.evolution.tree.Node storedRoot;

    /**
     * array of all nodes in the tree *
     */
    protected Node[] m_nodes = null;
    protected Node[] m_storedNodes = null;

    /**
     * array of taxa names for the nodes in the tree
     * such that m_sTaxaNames[node.getNr()] == node.getID()*
     */
    String[] m_sTaxaNames = null;

    /**
     * Trait set which specifies leaf node times.
     */
    protected TraitSet timeTraitSet = null;

    /*
     * Whether or not TraitSets have been processed.
     */
    protected boolean traitsProcessed = false;

    @Override
    public void initAndValidate() throws Exception {
//        if (m_initial.get() != null && !(this instanceof StateNodeInitialiser)) {
//            final Tree other = m_initial.get();
//            root = other.root.copy();
//            nodeCount = other.nodeCount;
//            internalNodeCount = other.internalNodeCount;
//            leafNodeCount = other.leafNodeCount;
//        }<commit_msg>Issue 64: do not allow initial to be specified when a tree is not a StateNodeInitialiser, since the input will be ignored and the nodetype (if any) is not adjusted to that of the initial input tree.<commit_after>package beast.evolution.tree;

import beast.core.Description;
import beast.core.Input;
import beast.core.StateNode;
import beast.core.StateNodeInitialiser;
import beast.evolution.alignment.TaxonSet;
import beast.util.TreeParser;

import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;


@Description("Tree (the T in BEAST) representing gene beast.tree, species"
        + " beast.tree, language history, or other time-beast.tree"
        + " relationships among sequence data.")
public class Tree extends StateNode implements TreeInterface {
    public Input<Tree> m_initial = new Input<Tree>("initial", "tree to start with");
    public Input<List<TraitSet>> m_traitList = new Input<List<TraitSet>>("trait",
            "trait information for initializing traits (like node dates) in the tree",
            new ArrayList<TraitSet>());
    public Input<TaxonSet> m_taxonset = new Input<TaxonSet>("taxonset",
            "set of taxa that correspond to the leafs in the tree");
    public Input<String> nodeTypeInput = new Input<String>("nodetype",
            "type of the nodes in the beast.tree", Node.class.getName());

    /**
     * state of dirtiness of a node in the tree
     * DIRTY means a property on the node has changed, but not the topology
     * FILTHY means the nodes' parent or child has changed.
     */
    public static final int IS_CLEAN = 0, IS_DIRTY = 1, IS_FILTHY = 2;

    /**
     * counters of number of nodes, nodeCount = internalNodeCount + leafNodeCount *
     */
    protected int nodeCount = -1;
    protected int internalNodeCount = -1;
    protected int leafNodeCount = -1;

    /**
     * node representation of the beast.tree *
     */
    protected beast.evolution.tree.Node root;
    protected beast.evolution.tree.Node storedRoot;

    /**
     * array of all nodes in the tree *
     */
    protected Node[] m_nodes = null;
    protected Node[] m_storedNodes = null;

    /**
     * array of taxa names for the nodes in the tree
     * such that m_sTaxaNames[node.getNr()] == node.getID()*
     */
    String[] m_sTaxaNames = null;

    /**
     * Trait set which specifies leaf node times.
     */
    protected TraitSet timeTraitSet = null;

    /*
     * Whether or not TraitSets have been processed.
     */
    protected boolean traitsProcessed = false;

    @Override
    public void initAndValidate() throws Exception {
        if (m_initial.get() != null && !(this instanceof StateNodeInitialiser)) {
        	throw new RuntimeException("initial-input should be specified for tree that is not a StateNodeInitialiser");
//            final Tree other = m_initial.get();
//            root = other.root.copy();
//            nodeCount = other.nodeCount;
//            internalNodeCount = other.internalNodeCount;
//            leafNodeCount = other.leafNodeCount;
        }
{'fraction_non_alphanumeric': 0.09874849991428082, 'fraction_numerical': 0.002400137150694325, 'mean_word_length': 2.8712674187126743, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, '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': '1061489', 'n_tokens_mistral': 1651, 'n_tokens_neox': 1611, 'n_words': 555}