Search in sources :

Example 6 with Polymer

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

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

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

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

the class Utilities method biochemistry.

/**
 * This routine sub-divides a system into groups of ions, water, hetero
 * molecules, and polynucleotides/polypeptides.
 *
 * @param molecularAssembly a {@link ffx.potential.MolecularAssembly}
 * object.
 * @param atoms a {@link java.util.List} object.
 */
public static void biochemistry(MolecularAssembly molecularAssembly, List<Atom> atoms) {
    Atom atom, seed = null;
    int num = 0;
    int waterNum = 0;
    int ionNum = 0;
    int moleculeNum = 0;
    List<String> segIDs = new ArrayList<>();
    while (atoms.size() > 0) {
        /**
         * Nitrogen is used to "seed" a backbone search because carbon can
         * be separated from the backbone by a sulfur (ie. MET).
         */
        for (Atom a : atoms) {
            seed = a;
            if (seed.getAtomicNumber() == 7) {
                break;
            }
        }
        /**
         * If no nitrogen atoms remain, there are no nucleic or amino acids.
         */
        if (seed.getAtomicNumber() != 7) {
            List<Atom> moleculeAtoms;
            while (atoms.size() > 0) {
                atom = atoms.get(0);
                // Check for a metal ion or noble gas
                if (atom.getNumBonds() == 0) {
                    ionNum++;
                    Molecule ion = new Molecule(atom.getName() + "-" + ionNum);
                    ion.addMSNode(atom);
                    atoms.remove(0);
                    molecularAssembly.addMSNode(ion);
                    continue;
                } else // Check for water
                if (atom.getAtomicNumber() == 8 && isWaterOxygen(atom)) {
                    waterNum++;
                    Molecule water = new Molecule("Water-" + waterNum);
                    water.addMSNode(atom);
                    atoms.remove(0);
                    List<Bond> bonds = atom.getBonds();
                    for (Bond b : bonds) {
                        Atom hydrogen = b.get1_2(atom);
                        water.addMSNode(hydrogen);
                        atoms.remove(hydrogen);
                    }
                    molecularAssembly.addMSNode(water);
                    continue;
                }
                // Otherwise classify the molecule as a hetero
                moleculeNum++;
                Molecule molecule = new Molecule("Molecule-" + moleculeNum);
                moleculeAtoms = getAtomListFromPool();
                collectAtoms(atoms.get(0), moleculeAtoms);
                while (moleculeAtoms.size() > 0) {
                    atom = moleculeAtoms.get(0);
                    moleculeAtoms.remove(0);
                    molecule.addMSNode(atom);
                    atoms.remove(atom);
                }
                molecularAssembly.addMSNode(molecule);
            }
            seed = null;
            break;
        }
        List<Atom> backbone = findPolymer(atoms, seed, null);
        if (backbone.size() > 0) {
            for (ListIterator li = backbone.listIterator(backbone.size()); li.hasPrevious(); ) {
                seed = (Atom) li.previous();
                if (seed.getAtomicNumber() == 7) {
                    break;
                }
            }
            backbone = findPolymer(atoms, seed, null);
        }
        Character chainID = getChainID(num);
        String segID = getSegID(chainID, segIDs);
        Polymer c = new Polymer(chainID, segID, true);
        if (backbone.size() > 2 && divideBackbone(backbone, c)) {
            for (Atom a : c.getAtomList()) {
                atoms.remove(a);
            }
            logger.fine(" Sequenced chain: " + c.getName());
            molecularAssembly.addMSNode(c);
            num++;
        } else {
            moleculeNum++;
            Molecule hetero = new Molecule("" + moleculeNum + "-Hetero");
            atom = backbone.get(0);
            List<Atom> heteroAtomList = getAtomListFromPool();
            collectAtoms(atom, heteroAtomList);
            for (Atom a : heteroAtomList) {
                hetero.addMSNode(a);
            }
            for (Atom a : hetero.getAtomList()) {
                atoms.remove(a);
            }
            molecularAssembly.addMSNode(hetero);
        }
    }
}
Also used : Molecule(ffx.potential.bonded.Molecule) ArrayList(java.util.ArrayList) Polymer(ffx.potential.bonded.Polymer) List(java.util.List) ArrayList(java.util.ArrayList) Bond(ffx.potential.bonded.Bond) ListIterator(java.util.ListIterator) Atom(ffx.potential.bonded.Atom)

Example 10 with Polymer

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

the class RotamerOptimization method setResidues.

/**
 * Set a contiguous block of residues to optimize.
 *
 * @param startResID
 * @param finalResID
 */
public void setResidues(int startResID, int finalResID) {
    Polymer polymer;
    if (chain != null) {
        polymer = molecularAssembly.getChain(chain);
    } else {
        polymers = molecularAssembly.getChains();
        polymer = polymers[0];
    }
    residueList = new ArrayList<>();
    for (int i = startResID; i <= finalResID; i++) {
        Residue residue = polymer.getResidue(i);
        if (residue != null) {
            Rotamer[] rotamers = residue.getRotamers(library);
            if (rotamers != null) {
                if (rotamers.length == 1) {
                    switch(residue.getResidueType()) {
                        case NA:
                            residue.initializeDefaultAtomicCoordinates();
                            break;
                        case AA:
                        default:
                            RotamerLibrary.applyRotamer(residue, rotamers[0]);
                            break;
                    }
                    if (addOrigRot) {
                        residueList.add(residue);
                    }
                } else {
                    residueList.add(residue);
                }
            } else if (useForcedResidues && checkIfForced(i)) {
                residueList.add(residue);
            }
        }
    }
}
Also used : Residue(ffx.potential.bonded.Residue) MultiResidue(ffx.potential.bonded.MultiResidue) Polymer(ffx.potential.bonded.Polymer) RotamerLibrary.applyRotamer(ffx.potential.bonded.RotamerLibrary.applyRotamer) Rotamer(ffx.potential.bonded.Rotamer)

Aggregations

Polymer (ffx.potential.bonded.Polymer)38 Residue (ffx.potential.bonded.Residue)29 Atom (ffx.potential.bonded.Atom)21 MSNode (ffx.potential.bonded.MSNode)19 ArrayList (java.util.ArrayList)14 Molecule (ffx.potential.bonded.Molecule)13 Bond (ffx.potential.bonded.Bond)10 MultiResidue (ffx.potential.bonded.MultiResidue)9 MissingAtomTypeException (ffx.potential.bonded.BondedUtils.MissingAtomTypeException)7 MissingHeavyAtomException (ffx.potential.bonded.BondedUtils.MissingHeavyAtomException)7 IOException (java.io.IOException)7 Crystal (ffx.crystal.Crystal)4 MolecularAssembly (ffx.potential.MolecularAssembly)4 BufferedWriter (java.io.BufferedWriter)4 File (java.io.File)4 FileWriter (java.io.FileWriter)4 SSBond (org.biojava.bio.structure.SSBond)4 MSGroup (ffx.potential.bonded.MSGroup)3 AminoAcid3 (ffx.potential.bonded.ResidueEnumerations.AminoAcid3)3 Rotamer (ffx.potential.bonded.Rotamer)3