use of ffx.crystal.HKL in project ffx by mjschnie.
the class CrystalStats method printSNStats.
/**
* print signal to noise ratio statistics
*/
public void printSNStats() {
double[][] res = new double[n][2];
double[] nhkl = new double[n + 1];
double[][] sn = new double[n + 1][3];
for (int i = 0; i < n; i++) {
res[i][0] = Double.NEGATIVE_INFINITY;
res[i][1] = Double.POSITIVE_INFINITY;
}
for (HKL ih : reflectionlist.hkllist) {
int i = ih.index();
int b = ih.bin();
// ignored cases
if (Double.isNaN(fo[i][0]) || fo[i][1] <= 0.0) {
continue;
}
// determine res limits of each bin
double rs = Crystal.res(crystal, ih);
if (rs > res[b][0]) {
res[b][0] = rs;
}
if (rs < res[b][1]) {
res[b][1] = rs;
}
// running mean
nhkl[b]++;
nhkl[n]++;
sn[b][0] += (fo[i][0] - sn[b][0]) / nhkl[b];
sn[b][1] += (fo[i][1] - sn[b][1]) / nhkl[b];
sn[b][2] += ((fo[i][0] / fo[i][1]) - sn[b][2]) / nhkl[b];
sn[n][0] += (fo[i][0] - sn[n][0]) / nhkl[b];
sn[n][1] += (fo[i][1] - sn[n][1]) / nhkl[b];
sn[n][2] += ((fo[i][0] / fo[i][1]) - sn[n][2]) / nhkl[n];
}
StringBuilder sb = new StringBuilder(String.format("\n %15s | %7s | %7s | %7s \n", "Res. Range", "Signal", "Sigma", "S/N"));
for (int i = 0; i < n; i++) {
sb.append(String.format(" %7.3f %7.3f | ", res[i][0], res[i][1]));
sb.append(String.format("%7.2f | %7.2f | %7.2f\n", sn[i][0], sn[i][1], sn[i][2]));
}
sb.append(String.format(" %7.3f %7.3f | ", res[0][0], res[n - 1][1]));
sb.append(String.format("%7.2f | %7.2f | %7.2f", sn[n][0], sn[n][1], sn[n][2]));
if (print) {
logger.info(sb.toString());
}
}
use of ffx.crystal.HKL in project ffx by mjschnie.
the class CrystalStats method getR.
/**
* simply return the current R value
*
* @return r value as a percent
*/
public double getR() {
double numer = 0.0;
double denom = 0.0;
double sum = 0.0;
double sumfo = 0.0;
double sumall = 0.0;
double sumfoall = 0.0;
for (HKL ih : reflectionlist.hkllist) {
int i = ih.index();
// ignored cases
if (Double.isNaN(fc[i][0]) || Double.isNaN(fo[i][0]) || fo[i][1] <= 0.0) {
continue;
}
// spline setup
double ss = Crystal.invressq(crystal, ih);
double fh = spline.f(ss, refinementdata.spline);
ComplexNumber c = new ComplexNumber(fc[i][0], fc[i][1]);
numer = abs(abs(fo[i][0]) - fh * abs(c.abs()));
denom = abs(fo[i][0]);
sumall += numer;
sumfoall += denom;
if (!refinementdata.isFreeR(i)) {
sum += numer;
sumfo += denom;
}
}
rall = (sumall / sumfoall) * 100.0;
r = (sum / sumfo) * 100.0;
return r;
}
use of ffx.crystal.HKL in project ffx by mjschnie.
the class CrystalStats method printDPIStats.
/**
* output Cruickshank and Blow DPI indices
*
* @param natoms number of atoms in the structure
* @param nnonhatoms number of non-H atoms in the structure
* @see <a href="http://dx.doi.org/10.1107/S0907444998012645"
* target="_blank"> D. W. J. Cruickshank, Acta Cryst. (1999). D55,
* 583-601</a>
* @see <a href="http://dx.doi.org/10.1107/S0907444902003931"
* target="_blank"> D. M. Blow, Acta Cryst. (2002). D58, 792-797</a>
* @see <a href="http://dx.doi.org/10.1107/S0907444998012645"
* target="_blank"> D. W. J. Cruickshank, Acta Cryst. (1999). D55,
* 583-601</a>
* @see <a href="http://dx.doi.org/10.1107/S0907444902003931"
* target="_blank"> D. M. Blow, Acta Cryst. (2002). D58, 792-797</a>
*/
public void printDPIStats(int natoms, int nnonhatoms) {
int nhkli = 0;
int nhklo = refinementdata.n;
double rfreefrac = getRFree() * 0.01;
double res = reflectionlist.resolution.resolutionLimit();
for (HKL ih : reflectionlist.hkllist) {
int i = ih.index();
// ignored cases
if (Double.isNaN(fo[i][0]) || fo[i][1] <= 0.0) {
continue;
}
nhkli++;
}
double va = Math.pow(crystal.volume / crystal.spaceGroup.getNumberOfSymOps(), 0.3333);
blowdpih = 1.28 * Math.sqrt(natoms) * va * Math.pow(nhkli, -0.8333) * rfreefrac;
blowdpi = 1.28 * Math.sqrt(nnonhatoms) * va * Math.pow(nhkli, -0.8333) * rfreefrac;
double natni = Math.sqrt((double) natoms / nhkli);
double noni = Math.pow((double) nhkli / nhklo, -0.3333);
cruickdpih = natni * noni * rfreefrac * res;
natni = Math.sqrt((double) nnonhatoms / nhkli);
cruickdpi = natni * noni * rfreefrac * res;
StringBuilder sb = new StringBuilder("\n");
sb.append(String.format(" Blow DPI for all / non-H atoms: %7.4f / %7.4f\n", blowdpih, blowdpi));
sb.append(String.format(" Cruickshank DPI for all / non-H atoms: %7.4f / %7.4f", cruickdpih, cruickdpi));
if (print) {
logger.info(sb.toString());
}
}
use of ffx.crystal.HKL in project ffx by mjschnie.
the class ScaleBulkMinimize method setInitialScale.
private void setInitialScale() {
double[][] fc = refinementData.fc;
double[][] fo = refinementData.fsigf;
double e = bulkSolventEnergy.energyAndGradient(x, grad);
double fct, sumfofc, sumfc;
sumfofc = sumfc = 0.0;
for (HKL ih : reflectionlist.hkllist) {
int i = ih.index();
if (Double.isNaN(fc[i][0]) || Double.isNaN(fo[i][0]) || fo[i][1] <= 0.0) {
continue;
}
fct = refinementData.fcTotF(i);
sumfofc += fo[i][0] * fct;
sumfc += fct * fct;
}
x[0] = Math.log(4.0 * sumfofc / sumfc);
}
use of ffx.crystal.HKL in project ffx by mjschnie.
the class MTZFilterTest method testMTZHKL.
@Test
public void testMTZHKL() {
MTZFilter mtzFilter = new MTZFilter();
assertTrue("mtz file errors", mtzFilter.readFile(mtzFile, reflectionList, refinementData, null));
HKL hkl = reflectionList.getHKL(-10, 1, 1);
assertEquals("-10 1 1 FP value", 229.90, refinementData.getF(hkl.index()), 0.02);
assertEquals("-10 1 1 SIGFP value", 2.50, refinementData.getSigF(hkl.index()), 0.02);
assertEquals("-10 1 1 FREE value", 1, refinementData.getFreeR(hkl.index()));
hkl = reflectionList.getHKL(-10, 1, 10);
assertEquals("-10 1 10 FP value should be NaN", Double.NaN, refinementData.getF(hkl.index()), 0.1);
assertEquals("-10 1 10 SIGFP value should be NaN", Double.NaN, refinementData.getSigF(hkl.index()), 0.1);
}
Aggregations