Search in sources :

Example 41 with Atom

use of ffx.potential.bonded.Atom 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 42 with Atom

use of ffx.potential.bonded.Atom 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 43 with Atom

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

the class MolecularAssembly method getResidue.

private Atom getResidue(Atom atom, boolean create, Residue.ResidueType defaultRT) {
    Character chainID = atom.getChainID();
    String resName = atom.getResidueName();
    int resNum = atom.getResidueNumber();
    String segID = atom.getSegID();
    // Find/Create the chain
    Polymer polymer = getPolymer(chainID, segID, create);
    if (polymer == null) {
        return null;
    }
    Residue res = polymer.getResidue(resName, resNum, create, defaultRT);
    if (create && res != null) {
        return (Atom) res.addMSNode(atom);
    }
    return null;
}
Also used : Residue(ffx.potential.bonded.Residue) Polymer(ffx.potential.bonded.Polymer) Atom(ffx.potential.bonded.Atom)

Example 44 with Atom

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

the class MolecularAssembly method getActiveAtomArray.

/**
 * <p>
 * getActiveAtomArray</p>
 *
 * @return an array of active {@link ffx.potential.bonded.Atom} objects.
 */
public Atom[] getActiveAtomArray() {
    ArrayList<Atom> atoms = getAtomList();
    ArrayList<Atom> activeAtoms = new ArrayList<>();
    for (Atom a : atoms) {
        if (a.isActive()) {
            activeAtoms.add(a);
        }
    }
    Atom[] atomArray = activeAtoms.toArray(new Atom[activeAtoms.size()]);
    Arrays.sort(atomArray);
    return atomArray;
}
Also used : ArrayList(java.util.ArrayList) Atom(ffx.potential.bonded.Atom)

Example 45 with Atom

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

the class Utilities method addPhosphate.

/**
 * Add a phosphate and its bonded oxygens that are not bonded to a carbon to
 * the specified residue.
 *
 * @param phosphate Atom
 * @param residue Residue
 */
public static void addPhosphate(Atom phosphate, Residue residue) {
    if (phosphate == null) {
        return;
    }
    residue.addMSNode(phosphate);
    for (Bond b : phosphate.getBonds()) {
        Atom oxygen = b.get1_2(phosphate);
        // Add oxygens not bonded to a Carbon
        if (numberOfBondsWith(oxygen, 6) == 0) {
            residue.addMSNode(oxygen);
            // Add hydrogens atoms for protonated oxygen groups
            Atom hydrogen = findBondWith(oxygen, 1);
            if (hydrogen != null) {
                residue.addMSNode(hydrogen);
            }
        }
    }
}
Also used : Bond(ffx.potential.bonded.Bond) Atom(ffx.potential.bonded.Atom)

Aggregations

Atom (ffx.potential.bonded.Atom)206 Residue (ffx.potential.bonded.Residue)42 Bond (ffx.potential.bonded.Bond)37 CoordRestraint (ffx.potential.nonbonded.CoordRestraint)34 ArrayList (java.util.ArrayList)33 OpenMM_System_addConstraint (simtk.openmm.OpenMMLibrary.OpenMM_System_addConstraint)23 Polymer (ffx.potential.bonded.Polymer)22 IOException (java.io.IOException)22 MSNode (ffx.potential.bonded.MSNode)21 Crystal (ffx.crystal.Crystal)20 Molecule (ffx.potential.bonded.Molecule)19 File (java.io.File)19 MultiResidue (ffx.potential.bonded.MultiResidue)17 MultipoleType (ffx.potential.parameters.MultipoleType)13 MissingHeavyAtomException (ffx.potential.bonded.BondedUtils.MissingHeavyAtomException)12 PointerByReference (com.sun.jna.ptr.PointerByReference)11 MissingAtomTypeException (ffx.potential.bonded.BondedUtils.MissingAtomTypeException)11 AtomType (ffx.potential.parameters.AtomType)11 List (java.util.List)11 MolecularAssembly (ffx.potential.MolecularAssembly)10