Search in sources :

Example 11 with MSNode

use of ffx.potential.bonded.MSNode in project ffx by mjschnie.

the class MolecularAssembly method findAtom.

/**
 * <p>
 * findAtom</p>
 *
 * @param atom a {@link ffx.potential.bonded.Atom} object.
 * @return a {@link ffx.potential.bonded.Atom} object.
 */
public Atom findAtom(Atom atom) {
    if (!atom.isHetero() || atom.isModRes()) {
        Polymer polymer = getPolymer(atom.getChainID(), atom.getSegID(), false);
        if (polymer != null) {
            Residue res = polymer.getResidue(atom.getResidueName(), atom.getResidueNumber(), false);
            if (res != null) {
                MSNode node = res.getAtomNode();
                Atom root = (Atom) node.contains(atom);
                return root;
            }
        }
        return null;
    } else {
        ArrayList<Molecule> list = getMolecules();
        for (MSNode node : list) {
            Molecule m = (Molecule) node;
            if (m.getSegID().equalsIgnoreCase(atom.getSegID()) && m.getResidueName().equalsIgnoreCase(atom.getResidueName()) && m.getResidueNumber() == atom.getResidueNumber()) {
                Atom root = (Atom) node.contains(atom);
                return root;
            }
        }
        ArrayList<MSNode> ionList = getIons();
        for (MSNode node : ionList) {
            Molecule m = (Molecule) node;
            if (m.getSegID().equalsIgnoreCase(atom.getSegID()) && m.getResidueName().equalsIgnoreCase(atom.getResidueName()) && m.getResidueNumber() == atom.getResidueNumber()) {
                Atom root = (Atom) node.contains(atom);
                return root;
            }
        }
        ArrayList<MSNode> waterList = getWaters();
        for (MSNode node : waterList) {
            Molecule m = (Molecule) node;
            if (m.getSegID().equalsIgnoreCase(atom.getSegID()) && m.getResidueName().equalsIgnoreCase(atom.getResidueName()) && m.getResidueNumber() == atom.getResidueNumber()) {
                Atom root = (Atom) node.contains(atom);
                return root;
            }
        }
        return null;
    }
}
Also used : Molecule(ffx.potential.bonded.Molecule) MSNode(ffx.potential.bonded.MSNode) Residue(ffx.potential.bonded.Residue) Polymer(ffx.potential.bonded.Polymer) Atom(ffx.potential.bonded.Atom)

Example 12 with MSNode

use of ffx.potential.bonded.MSNode in project ffx by mjschnie.

the class MolecularAssembly method getResidueList.

/**
 * <p>
 * getResidueList</p>
 *
 * @return a {@link java.util.ArrayList} object.
 */
public ArrayList<Residue> getResidueList() {
    ArrayList<Residue> residues = new ArrayList<>();
    ListIterator<MSNode> li, lj;
    MSNode o;
    Polymer c;
    for (li = getAtomNodeList().listIterator(); li.hasNext(); ) {
        o = li.next();
        if (o instanceof Polymer) {
            c = (Polymer) o;
            for (lj = c.getAtomNodeList().listIterator(); lj.hasNext(); ) {
                o = lj.next();
                if (o instanceof Residue) {
                    residues.add((Residue) o);
                }
            }
        }
    }
    return residues;
}
Also used : MSNode(ffx.potential.bonded.MSNode) Residue(ffx.potential.bonded.Residue) ArrayList(java.util.ArrayList) Polymer(ffx.potential.bonded.Polymer)

Example 13 with MSNode

use of ffx.potential.bonded.MSNode in project ffx by mjschnie.

the class MolecularAssembly method getCharge.

/**
 * Sums up charge of the system, checking nonstandard residues for
 * non-unitary charges.
 *
 * @param alwaysLog Log non-unitary charge warnings for all nodes
 * @return System charge
 */
public double getCharge(boolean alwaysLog) {
    double totalCharge = 0;
    for (MSNode node : getNodeList()) {
        double charge = 0;
        boolean isNonstandard = false;
        for (Atom atom : node.getAtomList()) {
            charge += atom.getMultipoleType().getCharge();
            if (atom.isModRes()) {
                isNonstandard = true;
            }
        }
        if ((alwaysLog || isNonstandard) && (Math.abs(Math.round(charge) - charge) > 1.0E-5)) {
            logger.warning(String.format(" Node %s has non-unitary charge %12.8f", node.toString(), charge));
        }
        totalCharge += charge;
    }
    return totalCharge;
}
Also used : MSNode(ffx.potential.bonded.MSNode) Atom(ffx.potential.bonded.Atom)

Example 14 with MSNode

use of ffx.potential.bonded.MSNode in project ffx by mjschnie.

the class MolecularAssembly method getMoleculeNumbers.

/**
 * This method assigns a unique integer to every molecule in the
 * MolecularAssembly beginning at 0. An integer array with these values for
 * each atom is returned.
 *
 * @return an array of molecule numbers for each atom.
 */
public int[] getMoleculeNumbers() {
    int[] moleculeNumber = new int[getAtomList().size()];
    int current = 0;
    // Loop over polymers together
    Polymer[] polymers = getChains();
    if (polymers != null && polymers.length > 0) {
        for (Polymer polymer : polymers) {
            List<Atom> atomList = polymer.getAtomList();
            for (Atom atom : atomList) {
                moleculeNumber[atom.getXyzIndex() - 1] = current;
            }
            current++;
        }
    }
    // Loop over each molecule
    for (MSNode molecule : molecules.getChildList()) {
        List<Atom> atomList = molecule.getAtomList();
        for (Atom atom : atomList) {
            moleculeNumber[atom.getXyzIndex() - 1] = current;
            atom.setMoleculeNumber(current);
        }
        current++;
    }
    // Loop over each water
    for (MSNode wat : water.getChildList()) {
        List<Atom> atomList = wat.getAtomList();
        for (Atom atom : atomList) {
            moleculeNumber[atom.getXyzIndex() - 1] = current;
        }
        current++;
    }
    // Loop over each ion
    for (MSNode ion : ions.getChildList()) {
        List<Atom> atomList = ion.getAtomList();
        for (Atom atom : atomList) {
            moleculeNumber[atom.getXyzIndex() - 1] = current;
        }
        current++;
    }
    return moleculeNumber;
}
Also used : MSNode(ffx.potential.bonded.MSNode) Polymer(ffx.potential.bonded.Polymer) Atom(ffx.potential.bonded.Atom)

Example 15 with MSNode

use of ffx.potential.bonded.MSNode in project ffx by mjschnie.

the class MolecularAssembly method setColor.

/**
 * {@inheritDoc}
 */
@Override
public void setColor(RendererCache.ColorModel newColorModel, Color3f color, Material mat) {
    for (ListIterator<MSNode> li = getAtomNodeList().listIterator(); li.hasNext(); ) {
        MSGroup group = (MSGroup) li.next();
        group.setColor(newColorModel, color, mat);
    }
    for (MSNode m : molecules.getChildList()) {
        m.setColor(newColorModel, color, mat);
    }
    for (MSNode m : water.getChildList()) {
        m.setColor(newColorModel, color, mat);
    }
    for (MSNode m : ions.getChildList()) {
        m.setColor(newColorModel, color, mat);
    }
}
Also used : MSNode(ffx.potential.bonded.MSNode) MSGroup(ffx.potential.bonded.MSGroup)

Aggregations

MSNode (ffx.potential.bonded.MSNode)39 Atom (ffx.potential.bonded.Atom)21 Polymer (ffx.potential.bonded.Polymer)20 Molecule (ffx.potential.bonded.Molecule)16 Residue (ffx.potential.bonded.Residue)13 ArrayList (java.util.ArrayList)9 MolecularAssembly (ffx.potential.MolecularAssembly)7 Bond (ffx.potential.bonded.Bond)7 MissingAtomTypeException (ffx.potential.bonded.BondedUtils.MissingAtomTypeException)6 MissingHeavyAtomException (ffx.potential.bonded.BondedUtils.MissingHeavyAtomException)6 IOException (java.io.IOException)6 Crystal (ffx.crystal.Crystal)5 File (java.io.File)5 MSGroup (ffx.potential.bonded.MSGroup)4 BufferedWriter (java.io.BufferedWriter)4 FileWriter (java.io.FileWriter)4 HashMap (java.util.HashMap)3 List (java.util.List)3 MSRoot (ffx.potential.bonded.MSRoot)2 ROLS (ffx.potential.bonded.ROLS)2