Search in sources :

Example 6 with Residue

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

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

the class MolecularAssembly method getNodeList.

/**
 * <p>
 * getNodeList</p>
 *
 * @return a {@link java.util.ArrayList} object.
 */
public ArrayList<MSNode> getNodeList() {
    ArrayList<MSNode> 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(o);
                }
            }
        }
    }
    ArrayList<MSNode> list = ions.getChildList();
    for (MSNode node : list) {
        residues.add(node);
    }
    list = water.getChildList();
    for (MSNode node : list) {
        residues.add(node);
    }
    list = molecules.getChildList();
    for (MSNode node : list) {
        residues.add(node);
    }
    return residues;
}
Also used : MSNode(ffx.potential.bonded.MSNode) Residue(ffx.potential.bonded.Residue) ArrayList(java.util.ArrayList) Polymer(ffx.potential.bonded.Polymer)

Example 8 with Residue

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

the class Utilities method patternMatch.

// Check to see if a portion of the backbone matches that of a
// biological polymer, and if so determine the respective residue
private static Residue patternMatch(int start, List<Atom> backbone, PolymerType type) {
    int[] pattern;
    // Initialization
    if (type == PolymerType.AMINOACID) {
        pattern = AAPATTERN;
        if (backbone.size() < start + pattern.length) {
            return null;
        }
        // Check for correct Carbonyl placement
        Atom a = backbone.get(start + 1);
        if (formsBondsWith(a, 8)) {
            return null;
        }
        a = backbone.get(start + 2);
        if (!formsBondsWith(a, 8)) {
            return null;
        }
    } else if (type == PolymerType.NUCLEICACID) {
        pattern = NAPATTERN;
        if (backbone.size() < start + pattern.length) {
            return null;
        }
    } else {
        return null;
    }
    int length = pattern.length;
    List<Atom> atoms = getAtomListFromPool();
    List<Atom> sidePolymer = getAtomListFromPool();
    for (int i = 0; i < length; i++) {
        Atom a = backbone.get(start + i);
        // add backbone atoms to terminate sidePolymer search
        sidePolymer.add(a);
        if (a.getAtomicNumber() != pattern[i]) {
            return null;
        }
    }
    // terminate the search, then remove them
    if (start > 0) {
        atoms.add(backbone.get(start - 1));
    }
    if (start + length < backbone.size()) {
        atoms.add(backbone.get(start + length));
    }
    collectAtoms(backbone.get(start), atoms);
    if (start > 0) {
        atoms.remove(0);
    }
    if (start + length < backbone.size()) {
        atoms.remove(0);
    // Collect Just Side chain atoms, then remove backbone termination
    }
    if (type == PolymerType.AMINOACID) {
        collectAtoms(sidePolymer.get(1), sidePolymer);
    } else if (type == PolymerType.NUCLEICACID) {
        Atom seed = null;
        for (Atom a : atoms) {
            if (a.getAtomicNumber() == 7) {
                seed = a;
                break;
            }
        }
        if (seed != null && seed.getAtomicNumber() == 7) {
            sidePolymer.add(seed);
            collectAtoms(seed, sidePolymer);
        } else {
            return null;
        }
    }
    for (int i = 0; i <= length; i++) {
        sidePolymer.remove(0);
    }
    Residue res = assignResidue(backbone, start, atoms, sidePolymer);
    return res;
}
Also used : Residue(ffx.potential.bonded.Residue) Atom(ffx.potential.bonded.Atom)

Example 9 with Residue

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

the class Utilities method assignResidue.

private static Residue assignResidue(List<Atom> backbone, int start, List<Atom> atoms, List<Atom> sidePolymer) {
    Atom a;
    int atomicnum;
    // 0 = S, 1 = P, 2 = O, 3 = N, 4 = C
    int[] bins = new int[5];
    char[] chars = { 'S', 'P', 'O', 'N', 'C' };
    for (ListIterator li = sidePolymer.listIterator(); li.hasNext(); ) {
        a = (Atom) li.next();
        atomicnum = a.getAtomicNumber();
        switch(atomicnum) {
            case 1:
                // ignore hydrogens
                break;
            case 6:
                // Carbon
                bins[4]++;
                break;
            case 7:
                // Nitrogen
                bins[3]++;
                break;
            case 8:
                // Oxygen
                bins[2]++;
                break;
            case 15:
                // Phosphorus
                bins[1]++;
                break;
            case 16:
                // Sulfur
                bins[0]++;
                break;
            default:
                return null;
        }
    }
    StringBuilder key = new StringBuilder();
    int atomCount = 0;
    for (int i = 0; i < 5; i++) {
        if (bins[i] != 0) {
            atomCount += bins[i];
            key.append(chars[i]);
            key.append(Integer.toString(bins[i]));
        }
    }
    if (atomCount == 0) {
        // Glycine
        key.append("H");
    }
    String resname = sidechainStoichiometry.get(key.toString());
    if (resname == null) {
        resname = "Unknown";
    } else {
        resname = resname.intern();
    }
    if (resname.equals("1") || resname.equals("2")) {
        // Special case where atom string keys aren't unique
        Atom alpha = backbone.get(start + 1);
        Atom carbonyl = backbone.get(start + 2);
        Atom beta = null;
        List alphabonds = alpha.getBonds();
        Bond abond;
        for (ListIterator li = alphabonds.listIterator(); li.hasNext(); ) {
            abond = (Bond) li.next();
            beta = abond.get1_2(alpha);
            // carbon
            if (beta.getAtomicNumber() != 7 && beta.getAtomicNumber() != 1 && beta != carbonyl) {
                break;
            }
            beta = null;
        }
        if (beta == null) {
            return null;
        }
        List<Bond> betabonds = beta.getBonds();
        Atom gamma;
        int carboncount = 0;
        for (ListIterator<Bond> li = betabonds.listIterator(); li.hasNext(); ) {
            abond = li.next();
            gamma = abond.get1_2(beta);
            if (gamma.getAtomicNumber() == 6) {
                carboncount++;
            }
        }
        if (resname.equals("1")) {
            if (carboncount == 2) {
                resname = "PRO";
            } else {
                resname = "VAL";
            }
        } else {
            if (carboncount == 2) {
                resname = "LEU";
            } else {
                resname = "ILE";
            }
        }
    } else if (resname.equals("3")) {
        Atom c3 = backbone.get(start + 3);
        int num = countCO(c3);
        if (num == 2) {
            resname = "A";
        } else {
            resname = "DG";
        }
    }
    Residue residue = null;
    try {
        Residue.NA3.valueOf(resname.toUpperCase());
        residue = new Residue(resname, Residue.ResidueType.NA);
    } catch (Exception e) {
    }
    if (residue == null) {
        try {
            Residue.AA3.valueOf(resname.toUpperCase());
            residue = new Residue(resname, Residue.ResidueType.AA);
        } catch (Exception e) {
        }
    }
    if (residue == null) {
        residue = new Residue(resname, Residue.ResidueType.UNK);
    }
    // Create the Residue group
    for (ListIterator li = atoms.listIterator(); li.hasNext(); ) {
        a = (Atom) li.next();
        residue.addMSNode(a);
    }
    return residue;
}
Also used : ListIterator(java.util.ListIterator) Atom(ffx.potential.bonded.Atom) Residue(ffx.potential.bonded.Residue) List(java.util.List) ArrayList(java.util.ArrayList) Bond(ffx.potential.bonded.Bond)

Example 10 with Residue

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

the class RotamerOptimization method testTripleEnergyElimination.

/**
 * Test the elimination criteria by setting self and 2-body interactions to
 * zero. Two residues are at fixed rotamers and all rotamer interactions
 * with those two residues are calculated.
 *
 * @param residues
 * @param resID1 The residue number for one of two fixed residues.
 * @param resID2 The second residue number for one of two fixed residues.
 */
public void testTripleEnergyElimination(Residue[] residues, int resID1, int resID2) {
    int nRes = residues.length;
    if (resID1 >= nRes) {
        return;
    }
    if (resID2 >= nRes) {
        return;
    }
    if (resID1 == resID2) {
        return;
    }
    for (int i = 0; i < nRes; i++) {
        Residue resI = residues[i];
        Rotamer[] rotI = resI.getRotamers(library);
        int nI = rotI.length;
        for (int ri = 0; ri < nI; ri++) {
            try {
                selfEnergy[i][ri] = 0.0;
            } catch (Exception e) {
            // catch NPE.
            }
            for (int j = i + 1; j < nRes; j++) {
                Residue resJ = residues[j];
                Rotamer[] rotJ = resJ.getRotamers(library);
                int nJ = rotJ.length;
                for (int rj = 0; rj < nJ; rj++) {
                    /**
                     * if (i != resID1 && j != resID1) { try {
                     * twoBodyEnergy[i][ri][j][rj] = 0.0; } catch (Exception
                     * e) { // catch NPE. } }
                     */
                    try {
                        twoBodyEnergy[i][ri][j][rj] = 0.0;
                    } catch (Exception e) {
                    // catch NPE.
                    }
                    if (threeBodyTerm) {
                        for (int k = j + 1; k < nRes; k++) {
                            Residue resK = residues[k];
                            Rotamer[] rotK = resK.getRotamers(library);
                            int nK = rotK.length;
                            for (int rk = 0; rk < nK; rk++) {
                                if (i != resID1 && j != resID1 && k != resID1) {
                                    try {
                                        threeBodyEnergy[i][ri][j][rj][k][rk] = 0.0;
                                    } catch (Exception e) {
                                    // catch NPE.
                                    }
                                }
                                if (i != resID2 && j != resID2 && k != resID2) {
                                    try {
                                        threeBodyEnergy[i][ri][j][rj][k][rk] = 0.0;
                                    } catch (Exception e) {
                                    // catch NPE.
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : Residue(ffx.potential.bonded.Residue) MultiResidue(ffx.potential.bonded.MultiResidue) RotamerLibrary.applyRotamer(ffx.potential.bonded.RotamerLibrary.applyRotamer) Rotamer(ffx.potential.bonded.Rotamer) IOException(java.io.IOException) NACorrectionException(ffx.potential.bonded.NACorrectionException)

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