use of ffx.potential.bonded.Atom in project ffx by mjschnie.
the class BiojavaFilter method renameNonstandardHydrogens.
/**
* Ensures proper naming of hydrogens according to latest PDB format.
* Presently mostly guesses at which hydrogens to re-assign, which may cause
* chirality errors for prochiral hydrogens. If necessary, we will implement
* more specific mapping.
*
* @param residue
*/
private void renameNonstandardHydrogens(Residue residue) {
switch(fileStandard) {
case VERSION3_3:
return;
case VERSION3_2:
default:
break;
}
// May have to get position.
String residueType = residue.getName().toUpperCase();
ArrayList<Atom> resAtoms = residue.getAtomList();
for (Atom atom : resAtoms) {
if (atom == null) {
continue;
}
String atomName = atom.getName().toUpperCase();
// Handles situations such as 1H where it should be NA_H1, etc.
if (atomName.contains("H")) {
try {
String firstChar = atomName.substring(0, 1);
Integer.parseInt(firstChar);
atomName = atomName.substring(1);
atomName = atomName.concat(firstChar);
atom.setName(atomName);
} catch (NumberFormatException e) {
// Do nothing.
}
}
}
// Ensures proper hydrogen assignment; for example, Gln should have HB2,
// HB3 instead of HB1, HB2.
ArrayList<Atom> betas;
ArrayList<Atom> gammas;
ArrayList<Atom> deltas;
ArrayList<Atom> epsilons;
ArrayList<Atom> zetas;
String atomName;
Atom OH;
Atom HH;
Atom HG;
Atom HD2;
switch(getAminoAcid(residueType)) {
case GLY:
ArrayList<Atom> alphas = new ArrayList<>();
for (Atom atom : resAtoms) {
if (atom.getName().toUpperCase().contains("HA")) {
alphas.add(atom);
}
}
renameGlycineAlphaHydrogens(residue, alphas);
break;
case ALA:
// No known errors with alanine
break;
case VAL:
// No known errors with valine
break;
case LEU:
betas = new ArrayList<>();
for (Atom atom : resAtoms) {
if (atom.getName().toUpperCase().contains("HB")) {
betas.add(atom);
}
}
renameBetaHydrogens(residue, betas, 23);
break;
case ILE:
ArrayList<Atom> ileAtoms = new ArrayList<>();
for (Atom atom : resAtoms) {
if (atom.getName().toUpperCase().contains("HG1")) {
ileAtoms.add(atom);
}
}
renameIsoleucineHydrogens(residue, ileAtoms);
break;
case SER:
betas = new ArrayList<>();
for (Atom atom : resAtoms) {
if (atom.getName().toUpperCase().contains("HB")) {
betas.add(atom);
}
}
renameBetaHydrogens(residue, betas, 23);
break;
case THR:
Atom HG1 = (Atom) residue.getAtomNode("HG1");
if (HG1 == null) {
for (Atom atom : resAtoms) {
atomName = atom.getName().toUpperCase();
// Length < 4 avoids bringing in HG21, HG22, or HG23.
if (atomName.length() < 4 && atomName.contains("HG")) {
atom.setName("HG1");
break;
}
}
}
break;
case CYS:
betas = new ArrayList<>();
HG = (Atom) residue.getAtomNode("HG");
for (Atom atom : resAtoms) {
atomName = atom.getName().toUpperCase();
if (atomName.contains("HB")) {
betas.add(atom);
} else if (HG == null && atomName.contains("HG")) {
HG = atom;
HG.setName("HG");
}
}
renameBetaHydrogens(residue, betas, 23);
break;
case CYX:
// I pray this is never important, because I don't have an example CYX to work from.
break;
case CYD:
betas = new ArrayList<>();
for (Atom atom : resAtoms) {
if (atom.getName().toUpperCase().contains("HB")) {
betas.add(atom);
}
}
renameBetaHydrogens(residue, betas, 23);
break;
case PRO:
betas = new ArrayList<>();
gammas = new ArrayList<>();
deltas = new ArrayList<>();
for (Atom atom : resAtoms) {
atomName = atom.getName().toUpperCase();
if (atomName.contains("HB")) {
betas.add(atom);
} else if (atomName.contains("HG")) {
gammas.add(atom);
} else if (atomName.contains("HD")) {
deltas.add(atom);
}
}
renameBetaHydrogens(residue, betas, 23);
renameGammaHydrogens(residue, gammas, 23);
renameDeltaHydrogens(residue, deltas, 23);
break;
case PHE:
betas = new ArrayList<>();
deltas = new ArrayList<>();
epsilons = new ArrayList<>();
Atom HZ = (Atom) residue.getAtomNode("HZ");
for (Atom atom : resAtoms) {
atomName = atom.getName().toUpperCase();
if (atomName.contains("HB")) {
betas.add(atom);
} else if (atomName.contains("HD")) {
deltas.add(atom);
} else if (atomName.contains("HE")) {
epsilons.add(atom);
} else if (HZ == null && atomName.contains("HZ")) {
HZ = atom;
HZ.setName("HZ");
}
}
renameBetaHydrogens(residue, betas, 23);
renameDeltaHydrogens(residue, deltas, 12);
renameEpsilonHydrogens(residue, epsilons, 12);
break;
case TYR:
betas = new ArrayList<>();
deltas = new ArrayList<>();
epsilons = new ArrayList<>();
HH = (Atom) residue.getAtomNode("HH");
OH = (Atom) residue.getAtomNode("OH");
for (Atom atom : resAtoms) {
atomName = atom.getName().toUpperCase();
if (atomName.contains("HB")) {
betas.add(atom);
} else if (atomName.contains("HD")) {
deltas.add(atom);
} else if (atomName.contains("HE")) {
epsilons.add(atom);
} else if (HH == null && atomName.contains("HH")) {
HH = atom;
HH.setName("HH");
} else if (OH == null && atomName.contains("O") && atomName.contains("H")) {
OH = atom;
OH.setName("OH");
}
}
renameBetaHydrogens(residue, betas, 23);
renameDeltaHydrogens(residue, deltas, 12);
renameEpsilonHydrogens(residue, epsilons, 12);
break;
case TYD:
betas = new ArrayList<>();
deltas = new ArrayList<>();
epsilons = new ArrayList<>();
OH = (Atom) residue.getAtomNode("OH");
for (Atom atom : resAtoms) {
atomName = atom.getName().toUpperCase();
if (atomName.contains("HB")) {
betas.add(atom);
} else if (atomName.contains("HD")) {
deltas.add(atom);
} else if (atomName.contains("HE")) {
epsilons.add(atom);
} else if (OH == null && atomName.contains("O") && atomName.contains("H")) {
OH = atom;
OH.setName("OH");
}
}
renameBetaHydrogens(residue, betas, 23);
renameDeltaHydrogens(residue, deltas, 12);
renameEpsilonHydrogens(residue, epsilons, 12);
break;
case TRP:
betas = new ArrayList<>();
epsilons = new ArrayList<>();
zetas = new ArrayList<>();
Atom HD1 = (Atom) residue.getAtomNode("HD1");
Atom HH2 = (Atom) residue.getAtomNode("HH2");
for (Atom atom : resAtoms) {
atomName = atom.getName().toUpperCase();
if (atomName.contains("HB")) {
betas.add(atom);
} else if (atomName.contains("HE")) {
epsilons.add(atom);
} else if (atomName.contains("HZ")) {
zetas.add(atom);
} else if (HD1 == null && atomName.contains("HD")) {
HD1 = atom;
HD1.setName("HD1");
} else if (HH2 == null && atomName.contains("HH")) {
HH2 = atom;
HH2.setName("HH2");
}
}
renameBetaHydrogens(residue, betas, 23);
renameEpsilonHydrogens(residue, epsilons, 13);
renameZetaHydrogens(residue, zetas, 23);
break;
case HIS:
betas = new ArrayList<>();
deltas = new ArrayList<>();
epsilons = new ArrayList<>();
for (Atom atom : resAtoms) {
atomName = atom.getName().toUpperCase();
if (atomName.contains("HB")) {
betas.add(atom);
} else if (atomName.contains("HD")) {
deltas.add(atom);
} else if (atomName.contains("HE")) {
epsilons.add(atom);
}
}
renameBetaHydrogens(residue, betas, 23);
renameDeltaHydrogens(residue, deltas, 12);
renameEpsilonHydrogens(residue, epsilons, 12);
break;
case HID:
betas = new ArrayList<>();
deltas = new ArrayList<>();
Atom HE1 = (Atom) residue.getAtomNode("HE1");
for (Atom atom : resAtoms) {
atomName = atom.getName().toUpperCase();
if (atomName.contains("HB")) {
betas.add(atom);
} else if (atomName.contains("HD")) {
deltas.add(atom);
} else if (HE1 == null && atomName.contains("HE")) {
HE1 = atom;
HE1.setName("HE1");
}
}
renameBetaHydrogens(residue, betas, 23);
renameDeltaHydrogens(residue, deltas, 12);
break;
case HIE:
betas = new ArrayList<>();
epsilons = new ArrayList<>();
HD2 = (Atom) residue.getAtomNode("HD2");
for (Atom atom : resAtoms) {
atomName = atom.getName().toUpperCase();
if (atomName.contains("HB")) {
betas.add(atom);
} else if (atomName.contains("HE")) {
epsilons.add(atom);
} else if (HD2 == null && atomName.contains("HD")) {
HD2 = atom;
HD2.setName("HD2");
}
}
renameBetaHydrogens(residue, betas, 23);
renameEpsilonHydrogens(residue, epsilons, 12);
break;
case ASP:
betas = new ArrayList<>();
for (Atom atom : resAtoms) {
if (atom.getName().toUpperCase().contains("HB")) {
betas.add(atom);
}
}
renameBetaHydrogens(residue, betas, 23);
break;
case ASH:
betas = new ArrayList<>();
HD2 = (Atom) residue.getAtomNode("HD2");
for (Atom atom : resAtoms) {
atomName = atom.getName().toUpperCase();
if (atomName.contains("HB")) {
betas.add(atom);
} else if (HD2 == null && atomName.contains("HD")) {
HD2 = atom;
HD2.setName("HD2");
}
}
renameBetaHydrogens(residue, betas, 23);
break;
case ASN:
betas = new ArrayList<>();
ArrayList<Atom> HD2s = new ArrayList<>();
for (Atom atom : resAtoms) {
atomName = atom.getName().toUpperCase();
if (atomName.contains("HB")) {
betas.add(atom);
} else if (atomName.contains("HD")) {
HD2s.add(atom);
}
}
renameBetaHydrogens(residue, betas, 23);
renameAsparagineHydrogens(residue, HD2s);
break;
case GLU:
betas = new ArrayList<>();
gammas = new ArrayList<>();
for (Atom atom : resAtoms) {
atomName = atom.getName().toUpperCase();
if (atomName.contains("HB")) {
betas.add(atom);
} else if (atomName.contains("HG")) {
gammas.add(atom);
}
}
renameBetaHydrogens(residue, betas, 23);
renameGammaHydrogens(residue, gammas, 23);
break;
case GLH:
betas = new ArrayList<>();
gammas = new ArrayList<>();
Atom HE2 = (Atom) residue.getAtomNode("HE2");
for (Atom atom : resAtoms) {
atomName = atom.getName().toUpperCase();
if (atomName.contains("HB")) {
betas.add(atom);
} else if (atomName.contains("HG")) {
gammas.add(atom);
} else if (HE2 == null && atomName.contains("HE")) {
HE2 = atom;
HE2.setName("HE2");
}
}
renameBetaHydrogens(residue, betas, 23);
renameGammaHydrogens(residue, gammas, 23);
break;
case GLN:
betas = new ArrayList<>();
gammas = new ArrayList<>();
epsilons = new ArrayList<>();
for (Atom atom : resAtoms) {
atomName = atom.getName().toUpperCase();
if (atomName.contains("HB")) {
betas.add(atom);
} else if (atomName.contains("HG")) {
gammas.add(atom);
} else if (atomName.contains("HE")) {
epsilons.add(atom);
}
}
renameBetaHydrogens(residue, betas, 23);
renameGammaHydrogens(residue, gammas, 23);
renameGlutamineHydrogens(residue, epsilons);
break;
case MET:
betas = new ArrayList<>();
gammas = new ArrayList<>();
// Epsilons should not break, as they are 1-3.
for (Atom atom : resAtoms) {
atomName = atom.getName().toUpperCase();
if (atomName.contains("HB")) {
betas.add(atom);
} else if (atomName.contains("HG")) {
gammas.add(atom);
}
}
renameBetaHydrogens(residue, betas, 23);
renameGammaHydrogens(residue, gammas, 23);
break;
case LYS:
betas = new ArrayList<>();
gammas = new ArrayList<>();
deltas = new ArrayList<>();
epsilons = new ArrayList<>();
// Zetas are 1-3, should not break.
for (Atom atom : resAtoms) {
atomName = atom.getName().toUpperCase();
if (atomName.contains("HB")) {
betas.add(atom);
} else if (atomName.contains("HG")) {
gammas.add(atom);
} else if (atomName.contains("HD")) {
deltas.add(atom);
} else if (atomName.contains("HE")) {
epsilons.add(atom);
}
}
renameBetaHydrogens(residue, betas, 23);
renameGammaHydrogens(residue, gammas, 23);
renameDeltaHydrogens(residue, deltas, 23);
renameEpsilonHydrogens(residue, epsilons, 23);
break;
case LYD:
betas = new ArrayList<>();
gammas = new ArrayList<>();
deltas = new ArrayList<>();
epsilons = new ArrayList<>();
zetas = new ArrayList<>();
for (Atom atom : resAtoms) {
atomName = atom.getName().toUpperCase();
if (atomName.contains("HB")) {
betas.add(atom);
} else if (atomName.contains("HG")) {
gammas.add(atom);
} else if (atomName.contains("HD")) {
deltas.add(atom);
} else if (atomName.contains("HE")) {
epsilons.add(atom);
} else if (atomName.contains("HZ")) {
zetas.add(atom);
}
}
renameBetaHydrogens(residue, betas, 23);
renameGammaHydrogens(residue, gammas, 23);
renameDeltaHydrogens(residue, deltas, 23);
renameEpsilonHydrogens(residue, epsilons, 23);
renameZetaHydrogens(residue, zetas, 12);
break;
case ARG:
betas = new ArrayList<>();
gammas = new ArrayList<>();
deltas = new ArrayList<>();
Atom HE = (Atom) residue.getAtomNode("HE");
ArrayList<Atom> HHn = new ArrayList<>();
for (Atom atom : resAtoms) {
atomName = atom.getName().toUpperCase();
if (atomName.contains("HB")) {
betas.add(atom);
} else if (atomName.contains("HG")) {
gammas.add(atom);
} else if (atomName.contains("HD")) {
deltas.add(atom);
} else if (HE == null && atomName.contains("HE")) {
HE = atom;
HE.setName("HE");
} else if (atomName.contains("HH")) {
HHn.add(atom);
}
}
renameBetaHydrogens(residue, betas, 23);
renameGammaHydrogens(residue, gammas, 23);
renameDeltaHydrogens(residue, deltas, 23);
renameArginineHydrogens(residue, HHn);
break;
case ORN:
case AIB:
case PCA:
case UNK:
default:
// Pray, for I have no examples to work from.
break;
}
}
use of ffx.potential.bonded.Atom in project ffx by mjschnie.
the class CrystalEnergyTest method testSoftCore.
public void testSoftCore() {
logger.info(String.format(" Testing crystal softcore unity of %s with %s.", filename, pmeName));
boolean gradient = false;
boolean print = true;
double e = forceFieldEnergy.energy(gradient, print);
Atom[] atoms = molecularAssembly.getAtomArray();
int n = atoms.length;
// Make the 3 atoms soft
for (int i = n; i > n - 3; i--) {
Atom ai = atoms[i - 1];
ai.setApplyLambda(true);
}
// Compute the energy with Lambda = 1.0;
double lambda = 1.0;
forceFieldEnergy.setLambda(lambda);
double e2 = forceFieldEnergy.energy(gradient, print);
assertEquals(e, e2, tolerance);
}
use of ffx.potential.bonded.Atom in project ffx by mjschnie.
the class OPLSCrystalEnergyTest method testSoftCore.
public void testSoftCore() {
boolean gradient = false;
boolean print = true;
double e = forceFieldEnergy.energy(gradient, print);
Atom[] atoms = molecularAssembly.getAtomArray();
int n = atoms.length;
// Make the 3 atoms soft
for (int i = n; i > n - 3; i--) {
Atom ai = atoms[i - 1];
ai.setApplyLambda(true);
}
// Compute the energy with Lambda = 1.0;
double lambda = 1.0;
forceFieldEnergy.setLambda(lambda);
double e2 = forceFieldEnergy.energy(gradient, print);
assertEquals(e, e2, tolerance);
}
use of ffx.potential.bonded.Atom in project ffx by mjschnie.
the class SimulationFilter method readFile.
/**
* {@inheritDoc}
*/
@Override
public boolean readFile() {
// information
for (int i = 0; i < system.numatoms; i++) {
AtomType atomType = atomTypes.get(system.types[i]);
if (atomType == null) {
atomType = new AtomType(system.types[i], -1, system.name[i], system.story[i], system.atomic[i], system.mass[i], 0);
atomTypes.put(system.types[i], atomType);
}
}
atomList = new ArrayList<Atom>();
Vector<Integer> bonds1 = new Vector<Integer>();
Vector<Integer> bonds2 = new Vector<Integer>();
double[] d = new double[3];
int[] b = new int[4];
for (int i = 0; i < system.numatoms; i++) {
d[0] = system.coordinates[0][i];
d[1] = system.coordinates[1][i];
d[2] = system.coordinates[2][i];
String s = new String("" + system.types[i]);
AtomType atomType = atomTypes.get(s);
Atom a = new Atom(i + 1, new String("" + atomType.type), atomType, d);
atomList.add(a);
int b1 = i + 1;
b[0] = system.connectivity[0][i];
b[1] = system.connectivity[1][i];
b[2] = system.connectivity[2][i];
b[3] = system.connectivity[3][i];
int j = 0;
while (j < 4 && b[j] != 0) {
int b2 = b[j];
bonds1.add(b1);
bonds2.add(b2);
j++;
}
}
bondList = new ArrayList<Bond>();
for (int i = 0; i < bonds1.size(); i++) {
int a1 = bonds1.get(i);
int a2 = bonds2.get(i);
if (a1 < a2) {
Atom atom1 = atomList.get(a1 - 1);
Atom atom2 = atomList.get(a2 - 1);
bondList.add(new Bond(atom1, atom2));
}
}
setFileRead(true);
return true;
}
use of ffx.potential.bonded.Atom in project ffx by mjschnie.
the class CrystalReciprocalSpaceTest method test1N7SPermanent.
/**
* Test of permanent method, of class CrystalReciprocalSpace.
*/
@Test
public void test1N7SPermanent() {
String filename = "ffx/xray/structures/1N7S.pdb";
int index = filename.lastIndexOf(".");
String name = filename.substring(0, index);
// load the structure
ClassLoader cl = this.getClass().getClassLoader();
File structure = new File(cl.getResource(filename).getPath());
PotentialsUtils potutil = new PotentialsUtils();
MolecularAssembly mola = potutil.open(structure);
CompositeConfiguration properties = mola.getProperties();
Crystal crystal = new Crystal(39.767, 51.750, 132.938, 90.00, 90.00, 90.00, "P212121");
Resolution resolution = new Resolution(1.45);
ReflectionList reflectionList = new ReflectionList(crystal, resolution);
DiffractionRefinementData refinementData = new DiffractionRefinementData(properties, reflectionList);
mola.finalize(true, mola.getForceField());
ForceFieldEnergy energy = mola.getPotentialEnergy();
List<Atom> atomList = mola.getAtomList();
Atom[] atomArray = atomList.toArray(new Atom[atomList.size()]);
// set up FFT and run it
ParallelTeam parallelTeam = new ParallelTeam();
CrystalReciprocalSpace crs = new CrystalReciprocalSpace(reflectionList, atomArray, parallelTeam, parallelTeam);
crs.computeAtomicDensity(refinementData.fc);
// tests
ComplexNumber b = new ComplexNumber(-828.584, -922.704);
HKL hkl = reflectionList.getHKL(1, 1, 4);
ComplexNumber a = refinementData.getFc(hkl.index());
System.out.println("1 1 4: " + a.toString() + " | " + b.toString() + " | " + a.divides(b).toString());
assertEquals("1 1 4 reflection should be correct", -753.4722104328416, a.re(), 0.0001);
assertEquals("1 1 4 reflection should be correct", -1012.1341308707799, a.im(), 0.0001);
b.re(-70.4582);
b.im(-486.142);
hkl = reflectionList.getHKL(2, 1, 10);
a = refinementData.getFc(hkl.index());
System.out.println("2 1 10: " + a.toString() + " | " + b.toString() + " | " + a.divides(b).toString());
assertEquals("2 1 10 reflection should be correct", -69.39660884054359, a.re(), 0.0001);
assertEquals("2 1 10 reflection should be correct", -412.0147625765328, a.im(), 0.0001);
}
Aggregations