<commit_before>package etomica.atom;

public class Molecule extends Atom implements IMolecule {

    public Molecule(AtomType type) {
        super(type);
        childList = new AtomArrayList();
        assignChildOrdinals();
    }
    
    /**
     * Returns a string of digits that uniquely identifies this atom.  String is
     * formed by concatenating the ordinal of this atom to the signature
     * given by the parent of this atom.  If atom has no parent, forms a string
     * from only the ordinal.
     */
    public String signature() {
        return Integer.toString(getIndex());
    }
    
    /**
     * Assigns ordinals to all child atoms, numbering them sequentially
     * according to their position in the childList.
     */
    private void assignChildOrdinals() {
        for (int i = 0; i < childList.getAtomCount(); i++) {
            childList.getAtom(i).setIndex(i);
        }
    }

    /**
     * Adds the given Atom as a child of this Atom.  The given child Atom
     * should be parentless when this method is called.
     * @throws IllegalArgumentException if the given atom already has a parent.
     */
    public void addChildAtom(IAtomLeaf newChildAtom) {
        if(newChildAtom.getParentGroup() != null) {//new parent is null
            throw new IllegalArgumentException(newChildAtom+" is already the child of "+newChildAtom.getParentGroup());
        }

        newChildAtom.setParent(this);

        newChildAtom.setIndex(childList.getAtomCount());
        childList.add(newChildAtom);
    }
    
    /**
     * Removes the given child Atom from this AtomGroup.
     * @throws IllegalArgumentException if the given atom is not a child.
     */<commit_msg>give Molecule a useful toString<commit_after>package etomica.atom;

public class Molecule extends Atom implements IMolecule {

    public Molecule(AtomType type) {
        super(type);
        childList = new AtomArrayList();
        assignChildOrdinals();
    }
    
    /**
     * Returns a string of digits that uniquely identifies this atom.  String is
     * formed by concatenating the ordinal of this atom to the signature
     * given by the parent of this atom.  If atom has no parent, forms a string
     * from only the ordinal.
     */
    public String signature() {
        return Integer.toString(index);
    }

    /**
     * Returns a string formed by concatenating the signature of this atom
     * to a string that identifies it as a molecule.
     */
    public final String toString() {
//        return Integer.toBinaryString(node.index());
        return "Molecule(" + index + ")";
    }

    /**
     * Assigns ordinals to all child atoms, numbering them sequentially
     * according to their position in the childList.
     */
    private void assignChildOrdinals() {
        for (int i = 0; i < childList.getAtomCount(); i++) {
            childList.getAtom(i).setIndex(i);
        }
    }

    /**
     * Adds the given Atom as a child of this Atom.  The given child Atom
     * should be parentless when this method is called.
     * @throws IllegalArgumentException if the given atom already has a parent.
     */
    public void addChildAtom(IAtomLeaf newChildAtom) {
        if(newChildAtom.getParentGroup() != null) {//new parent is null
            throw new IllegalArgumentException(newChildAtom+" is already the child of "+newChildAtom.getParentGroup());
        }

        newChildAtom.setParent(this);

        newChildAtom.setIndex(childList.getAtomCount());
        childList.add(newChildAtom);
    }
    
    /**
     * Removes the given child Atom from this AtomGroup.
     * @throws IllegalArgumentException if the given atom is not a child.
     */
{'fraction_non_alphanumeric': 0.08238482384823849, 'fraction_numerical': 0.0005420054200542005, 'mean_word_length': 2.482075471698113, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '6687942', 'n_tokens_mistral': 1034, 'n_tokens_neox': 997, 'n_words': 359}