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;
}
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;
}
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;
}
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);
}
}
}
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);
}
}
}
}
Aggregations