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