use of ffx.potential.bonded.Residue in project ffx by mjschnie.
the class XRayEnergy method setOccupancies.
/**
* set atom occupancies based on current position
*
* @param x current parameters to set occupancies with
*/
public void setOccupancies(double[] x) {
double occ = 0.0;
int index = nXYZ + nB;
for (ArrayList<Residue> list : refinementModel.getAltResidues()) {
for (Residue r : list) {
occ = x[index++];
for (Atom a : r.getAtomList()) {
if (a.getOccupancy() < 1.0) {
a.setOccupancy(occ);
}
}
}
}
for (ArrayList<Molecule> list : refinementModel.getAltMolecules()) {
for (Molecule m : list) {
occ = x[index++];
for (Atom a : m.getAtomList()) {
if (a.getOccupancy() < 1.0) {
a.setOccupancy(occ);
}
}
}
}
}
use of ffx.potential.bonded.Residue in project ffx by mjschnie.
the class PDBFilter method numberAtoms.
/**
* <p>
* numberAtoms</p>
*/
private void numberAtoms() {
int index = 1;
for (Atom a : activeMolecularAssembly.getAtomArray()) {
a.setXyzIndex(index++);
}
index--;
if (logger.isLoggable(Level.INFO)) {
logger.info(String.format(" Total number of atoms: %d\n", index));
}
Polymer[] polymers = activeMolecularAssembly.getChains();
if (polymers != null) {
for (Polymer p : polymers) {
List<Residue> residues = p.getResidues();
for (Residue r : residues) {
r.reOrderAtoms();
}
}
}
List<Molecule> molecules = activeMolecularAssembly.getMolecules();
for (Molecule n : molecules) {
n.reOrderAtoms();
}
List<MSNode> waters = activeMolecularAssembly.getWaters();
for (MSNode n : waters) {
MSGroup m = (MSGroup) n;
m.reOrderAtoms();
}
List<MSNode> ions = activeMolecularAssembly.getIons();
for (MSNode n : ions) {
MSGroup m = (MSGroup) n;
m.reOrderAtoms();
}
}
use of ffx.potential.bonded.Residue in project ffx by mjschnie.
the class PDBFilter method findChainBreaks.
private List<List<Residue>> findChainBreaks(List<Residue> residues, double cutoff) {
List<List<Residue>> subChains = new ArrayList<List<Residue>>();
List<Residue> subChain = null;
Residue previousResidue = null;
Atom pC = null;
StringBuilder sb = new StringBuilder(" Chain Breaks:");
for (Residue residue : residues) {
List<Atom> resAtoms = residue.getAtomList();
if (pC == null) {
/**
* Initialization.
*/
subChain = new ArrayList<Residue>();
subChain.add(residue);
subChains.add(subChain);
} else {
/**
* Find the Nitrogen of the current residue.
*/
Atom N = null;
for (Atom a : resAtoms) {
if (a.getName().equalsIgnoreCase("N")) {
N = a;
break;
}
}
if (N == null) {
subChain.add(residue);
continue;
}
/**
* Compute the distance between the previous carbonyl carbon and
* the current nitrogen.
*/
double r = VectorMath.dist(pC.getXYZ(null), N.getXYZ(null));
if (r > cutoff) {
/**
* Start a new chain.
*/
subChain = new ArrayList<Residue>();
subChain.add(residue);
subChains.add(subChain);
char ch1 = previousResidue.getChainID();
char ch2 = residue.getChainID();
sb.append(format("\n C-N distance of %6.2f A for %c-%s and %c-%s.", r, ch1, previousResidue.toString(), ch2, residue.toString()));
} else {
/**
* Continue the current chain.
*/
subChain.add(residue);
}
}
/**
* Save the carbonyl carbon.
*/
for (Atom a : resAtoms) {
if (a.getName().equalsIgnoreCase("C")) {
pC = a;
break;
}
}
previousResidue = residue;
}
if (subChains.size() > 1) {
logger.info(sb.toString());
}
return subChains;
}
use of ffx.potential.bonded.Residue in project ffx by mjschnie.
the class PDBFilter method buildMissingResidues.
/**
* Currently builds missing internal loops based on information in DBREF and
* SEQRES records.
*
* Known limitations include: 1) No building n- and c-terminal loops. 2) No
* support for DBREF1 or DBREF2 records. 3) Incomplete optimization scheme
* to position the loops.
*
* @param xyzIndex
*
* @return xyzIndex updated based on built atoms.
*/
private int buildMissingResidues(int xyzIndex) {
/**
* Only build loops if the buildLoops flag is true.
*/
if (!properties.getBoolean("buildLoops", false)) {
return xyzIndex;
}
Polymer[] polymers = activeMolecularAssembly.getChains();
for (Polymer polymer : polymers) {
Character chainID = polymer.getChainID();
String[] resNames = seqres.get(chainID);
int[] seqRange = dbref.get(chainID);
if (resNames == null || seqRange == null) {
continue;
}
int seqBegin = seqRange[0];
int seqEnd = seqRange[1];
logger.info(format("\n Checking for missing residues in chain %s between residues %d and %d.", polymer.toString(), seqBegin, seqEnd));
int firstResID = polymer.getFirstResidue().getResidueNumber();
for (int i = 0; i < resNames.length; i++) {
int currentID = seqBegin + i;
Residue currentResidue = polymer.getResidue(currentID);
if (currentResidue != null) {
continue;
}
if (currentID <= firstResID) {
logger.info(format(" Residue %d is missing, but is at the beginning of the chain.", currentID));
continue;
}
Residue previousResidue = polymer.getResidue(currentID - 1);
if (previousResidue == null) {
logger.info(format(" Residue %d is missing, but could not be build (previous residue missing).", currentID));
continue;
}
Residue nextResidue = null;
for (int j = currentID + 1; j <= seqEnd; j++) {
nextResidue = polymer.getResidue(j);
if (nextResidue != null) {
break;
}
}
/**
* Residues at the end of the chain are not currently built.
*/
if (nextResidue == null) {
logger.info(format(" Residue %d is missing, but is at the end of the chain.", currentID));
break;
}
/**
* Find the previous carbonyl carbon and next nitrogen.
*/
Atom C = (Atom) previousResidue.getAtomNode("C");
Atom N = (Atom) nextResidue.getAtomNode("N");
if (C == null || N == null) {
logger.info(format(" Residue %d is missing, but bonding atoms are missing (C or N).", currentID));
continue;
}
/**
* Build the missing residue.
*/
currentResidue = polymer.getResidue(resNames[i], currentID, true);
double[] vector = new double[3];
int count = 3 * (nextResidue.getResidueNumber() - previousResidue.getResidueNumber());
VectorMath.diff(N.getXYZ(null), C.getXYZ(null), vector);
VectorMath.scalar(vector, 1.0 / count, vector);
double[] nXYZ = new double[3];
VectorMath.sum(C.getXYZ(null), vector, nXYZ);
nXYZ[0] += Math.random() - 0.5;
nXYZ[1] += Math.random() - 0.5;
nXYZ[2] += Math.random() - 0.5;
Atom newN = new Atom(xyzIndex++, "N", C.getAltLoc(), nXYZ, resNames[i], currentID, chainID, 1.0, C.getTempFactor(), C.getSegID(), true);
currentResidue.addMSNode(newN);
double[] caXYZ = new double[3];
VectorMath.scalar(vector, 2.0, vector);
VectorMath.sum(C.getXYZ(null), vector, caXYZ);
caXYZ[0] += Math.random() - 0.5;
caXYZ[1] += Math.random() - 0.5;
caXYZ[2] += Math.random() - 0.5;
Atom newCA = new Atom(xyzIndex++, "CA", C.getAltLoc(), caXYZ, resNames[i], currentID, chainID, 1.0, C.getTempFactor(), C.getSegID(), true);
currentResidue.addMSNode(newCA);
double[] cXYZ = new double[3];
VectorMath.scalar(vector, 1.5, vector);
VectorMath.sum(C.getXYZ(null), vector, cXYZ);
cXYZ[0] += Math.random() - 0.5;
cXYZ[1] += Math.random() - 0.5;
cXYZ[2] += Math.random() - 0.5;
Atom newC = new Atom(xyzIndex++, "C", C.getAltLoc(), cXYZ, resNames[i], currentID, chainID, 1.0, C.getTempFactor(), C.getSegID(), true);
currentResidue.addMSNode(newC);
double[] oXYZ = new double[3];
vector[0] = Math.random() - 0.5;
vector[1] = Math.random() - 0.5;
vector[2] = Math.random() - 0.5;
VectorMath.sum(cXYZ, vector, oXYZ);
Atom newO = new Atom(xyzIndex++, "O", C.getAltLoc(), oXYZ, resNames[i], currentID, chainID, 1.0, C.getTempFactor(), C.getSegID(), true);
currentResidue.addMSNode(newO);
logger.info(String.format(" Building residue %8s.", currentResidue.toString()));
}
}
return xyzIndex;
}
use of ffx.potential.bonded.Residue in project ffx by mjschnie.
the class PDBFilter method assignAminoAcidAtomTypes.
/**
* Assign atom types to an amino acid polymer.
*
* @param residues The residues to assign atom types to.
*
* @throws ffx.potential.parsers.PDBFilter.MissingHeavyAtomException
*
* @since 1.0
*/
private void assignAminoAcidAtomTypes(List<Residue> residues) throws MissingHeavyAtomException, MissingAtomTypeException {
/**
* Loop over amino acid residues.
*/
int numberOfResidues = residues.size();
for (int residueNumber = 0; residueNumber < numberOfResidues; residueNumber++) {
Residue residue = residues.get(residueNumber);
Residue previousResidue = null;
Residue nextResidue = null;
if (residueNumber > 0) {
previousResidue = residues.get(residueNumber - 1);
}
if (residueNumber < numberOfResidues - 1) {
nextResidue = residues.get(residueNumber + 1);
}
AminoAcidUtils.assignAminoAcidAtomTypes(residue, previousResidue, nextResidue, forceField, bondList);
}
}
Aggregations