Search in sources :

Example 1 with Residue

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

the class XRayEnergy method getCoordinates.

/**
 * {@inheritDoc}
 */
@Override
public double[] getCoordinates(double[] x) {
    assert (x != null);
    double[] xyz = new double[3];
    int index = 0;
    fill(x, 0.0);
    if (refineXYZ) {
        for (Atom a : activeAtomArray) {
            a.getXYZ(xyz);
            x[index++] = xyz[0];
            x[index++] = xyz[1];
            x[index++] = xyz[2];
        }
    }
    if (refineB) {
        double[] anisou = null;
        int resnum = -1;
        int nat = 0;
        int nres = diffractionData.getnResidueBFactor() + 1;
        for (Atom a : activeAtomArray) {
            // ignore hydrogens!!!
            if (a.getAtomicNumber() == 1) {
                continue;
            }
            if (a.getAnisou(null) != null) {
                anisou = a.getAnisou(anisou);
                x[index++] = anisou[0];
                x[index++] = anisou[1];
                x[index++] = anisou[2];
                x[index++] = anisou[3];
                x[index++] = anisou[4];
                x[index++] = anisou[5];
            } else if (diffractionData.isResidueBFactor()) {
                if (resnum != a.getResidueNumber()) {
                    if (nres >= diffractionData.getnResidueBFactor()) {
                        if (resnum > -1 && index < nXYZ + nB - 1) {
                            x[index] /= nat;
                            index++;
                        }
                        nat = 1;
                        nres = 1;
                    } else {
                        nres++;
                        nat++;
                    }
                    x[index] += a.getTempFactor();
                    resnum = a.getResidueNumber();
                } else {
                    x[index] += a.getTempFactor();
                    nat++;
                }
            } else {
                x[index++] = a.getTempFactor();
            }
        }
        if (diffractionData.isResidueBFactor()) {
            if (nat > 1) {
                x[index] /= nat;
            }
        }
    }
    if (refineOCC) {
        for (ArrayList<Residue> list : refinementModel.getAltResidues()) {
            for (Residue r : list) {
                for (Atom a : r.getAtomList()) {
                    if (a.getOccupancy() < 1.0) {
                        x[index++] = a.getOccupancy();
                        break;
                    }
                }
            }
        }
        for (ArrayList<Molecule> list : refinementModel.getAltMolecules()) {
            for (Molecule m : list) {
                for (Atom a : m.getAtomList()) {
                    if (a.getOccupancy() < 1.0) {
                        x[index++] = a.getOccupancy();
                        break;
                    }
                }
            }
        }
    }
    return x;
}
Also used : Molecule(ffx.potential.bonded.Molecule) Residue(ffx.potential.bonded.Residue) Atom(ffx.potential.bonded.Atom)

Example 2 with Residue

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

the class XRayEnergy method getOccupancyGradients.

/**
 * Fill gradient array with occupancy gradients.
 * Note: this also acts to constrain the occupancies
 * by moving the gradient vector COM to zero
 *
 * @param g array to add gradients to
 */
public void getOccupancyGradients(double[] g) {
    double ave;
    int index = nXYZ + nB;
    // First: Alternate Residues
    for (ArrayList<Residue> list : refinementModel.getAltResidues()) {
        ave = 0.0;
        for (Residue r : list) {
            for (Atom a : r.getAtomList()) {
                if (a.getOccupancy() < 1.0) {
                    ave += a.getOccupancyGradient();
                }
            }
        }
        /*
             * should this be normalized with respect
             * to number of atoms in residue in addition
             * to the number of conformers?
             */
        ave /= list.size();
        for (Residue r : list) {
            for (Atom a : r.getAtomList()) {
                if (a.getOccupancy() < 1.0) {
                    g[index] += a.getOccupancyGradient();
                }
            }
            if (list.size() > 1) {
                // subtract average to move COM to zero
                g[index] -= ave;
            }
            index++;
        }
    }
    // Now the molecules (HETATMs).
    for (ArrayList<Molecule> list : refinementModel.getAltMolecules()) {
        ave = 0.0;
        for (Molecule m : list) {
            for (Atom a : m.getAtomList()) {
                if (a.getOccupancy() < 1.0) {
                    ave += a.getOccupancyGradient();
                }
            }
        }
        ave /= list.size();
        for (Molecule m : list) {
            for (Atom a : m.getAtomList()) {
                if (a.getOccupancy() < 1.0) {
                    g[index] += a.getOccupancyGradient();
                }
            }
            if (list.size() > 1) {
                g[index] -= ave;
            }
            index++;
        }
    }
}
Also used : Molecule(ffx.potential.bonded.Molecule) Residue(ffx.potential.bonded.Residue) Atom(ffx.potential.bonded.Atom)

Example 3 with Residue

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

the class MolecularAssembly method sidePolymerCOM.

/**
 * <p>
 * sidePolymerCOM</p>
 */
public void sidePolymerCOM() {
    ArrayList<Residue> residues = getResidueList();
    Residue r;
    ListIterator<Residue> li;
    for (li = residues.listIterator(); li.hasNext(); ) {
        r = li.next();
        r.logSideChainCOM();
    }
}
Also used : Residue(ffx.potential.bonded.Residue)

Example 4 with Residue

use of ffx.potential.bonded.Residue 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 5 with Residue

use of ffx.potential.bonded.Residue 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)

Aggregations

Residue (ffx.potential.bonded.Residue)102 MultiResidue (ffx.potential.bonded.MultiResidue)66 Rotamer (ffx.potential.bonded.Rotamer)44 Atom (ffx.potential.bonded.Atom)41 RotamerLibrary.applyRotamer (ffx.potential.bonded.RotamerLibrary.applyRotamer)39 ArrayList (java.util.ArrayList)30 Polymer (ffx.potential.bonded.Polymer)29 IOException (java.io.IOException)20 Molecule (ffx.potential.bonded.Molecule)13 NACorrectionException (ffx.potential.bonded.NACorrectionException)13 MSNode (ffx.potential.bonded.MSNode)12 ResidueState (ffx.potential.bonded.ResidueState)11 Bond (ffx.potential.bonded.Bond)10 Crystal (ffx.crystal.Crystal)8 MissingAtomTypeException (ffx.potential.bonded.BondedUtils.MissingAtomTypeException)8 MissingHeavyAtomException (ffx.potential.bonded.BondedUtils.MissingHeavyAtomException)8 File (java.io.File)8 AminoAcid3 (ffx.potential.bonded.ResidueEnumerations.AminoAcid3)7 TitrationUtils.inactivateResidue (ffx.potential.extended.TitrationUtils.inactivateResidue)6 BufferedWriter (java.io.BufferedWriter)6