use of org.broadinstitute.hdf5.HDF5File in project gatk by broadinstitute.
the class HDF5PCACoveragePoNUnitTest method testLogNormalizedSampleNameReading.
@Test(dependsOnMethods = "testSampleNameReading")
public void testLogNormalizedSampleNameReading() throws IOException {
final HDF5File reader = new HDF5File(TEST_PON);
final PCACoveragePoN pon = new HDF5PCACoveragePoN(reader);
final List<String> expected = readLines(TEST_PON_LOG_NORMAL_SAMPLES);
final List<String> logNormalizedSampleNames = pon.getPanelSampleNames().stream().sorted().collect(Collectors.toList());
Assert.assertEquals(logNormalizedSampleNames, expected);
}
use of org.broadinstitute.hdf5.HDF5File in project gatk by broadinstitute.
the class HDF5PCACoveragePoNUnitTest method testNormalizedPcovReading.
@Test(dependsOnMethods = { "testTargetNameReading", "testSampleNameReading" })
public void testNormalizedPcovReading() throws IOException {
final HDF5File reader = new HDF5File(TEST_PON);
final PCACoveragePoN pon = new HDF5PCACoveragePoN(reader);
final List<String> targets = pon.getTargetNames();
final List<String> samples = pon.getSampleNames();
final RealMatrix actual = pon.getNormalizedCounts();
Assert.assertNotNull(actual);
Assert.assertEquals(actual.getRowDimension(), targets.size());
Assert.assertEquals(actual.getColumnDimension(), samples.size());
final RealMatrix expected = readDoubleMatrix(TEST_PON_NORMALIZED_PCOV);
MathObjectAsserts.assertRealMatrixEquals(actual, expected);
}
use of org.broadinstitute.hdf5.HDF5File in project gatk by broadinstitute.
the class HDF5PCACoveragePoNUnitTest method testTargetFactorsReading.
@Test(dependsOnMethods = "testTargetNameReading")
public void testTargetFactorsReading() throws IOException {
final HDF5File reader = new HDF5File(TEST_PON);
final PCACoveragePoN pon = new HDF5PCACoveragePoN(reader);
final List<String> targets = pon.getTargetNames();
final double[] factors = pon.getTargetFactors();
Assert.assertEquals(factors.length, targets.size());
final List<Double> expected = readDoubleLines(TEST_PON_TARGET_FACTORS);
Assert.assertNotNull(factors);
Assert.assertEquals(factors.length, expected.size());
for (int i = 0; i < expected.size(); i++) {
Assert.assertEquals(factors[i], expected.get(i), Math.abs(expected.get(i)) * 0.0001);
}
reader.close();
}
use of org.broadinstitute.hdf5.HDF5File in project gatk by broadinstitute.
the class HDF5PCACoveragePoNUnitTest method testLogNormalizedPInvMatrixReading.
@Test(dependsOnMethods = { "testTargetNameReading", "testLogNormalizedSampleNameReading" })
public void testLogNormalizedPInvMatrixReading() throws IOException {
final HDF5File reader = new HDF5File(TEST_PON);
final PCACoveragePoN pon = new HDF5PCACoveragePoN(reader);
final List<String> targets = pon.getTargetNames();
final List<String> samples = pon.getPanelSampleNames();
final RealMatrix actual = pon.getLogNormalizedPInverseCounts();
Assert.assertNotNull(actual);
Assert.assertEquals(actual.getRowDimension(), samples.size());
Assert.assertEquals(actual.getColumnDimension(), targets.size());
final RealMatrix expected = readDoubleMatrix(TEST_PON_LOG_NORMALS_PINV);
MathObjectAsserts.assertRealMatrixEquals(actual, expected);
}
use of org.broadinstitute.hdf5.HDF5File in project gatk by broadinstitute.
the class HDF5LibraryUnitTest method testReMakeDoubleArray.
@Test()
public void testReMakeDoubleArray() throws IOException {
final File testFile = File.createTempFile("hdf5", ".hd5");
HDF5File file = new HDF5File(testFile, HDF5File.OpenMode.CREATE);
file.makeGroup("test-group/double-group");
final double[] testValues1 = new double[] { 1.1, -2.2, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, 0.0111e10 - 10 };
final double[] testValues2 = new double[] { 11.1, -22.2, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, 1.0111e10 - 10 };
Assert.assertTrue(file.makeDoubleArray("test-group/double-group/my-double", testValues1));
System.err.println(testFile);
file.close();
final long time = System.currentTimeMillis();
Assert.assertTrue(testFile.length() > 0);
Assert.assertTrue(testFile.lastModified() <= time);
file = new HDF5File(testFile, HDF5File.OpenMode.READ_WRITE);
final double[] theDoubles1 = file.readDoubleArray("test-group/double-group/my-double");
Assert.assertEquals(theDoubles1, testValues1.clone());
Assert.assertFalse(file.makeDoubleArray("test-group/double-group/my-double", testValues2));
final double[] theDoubles2 = file.readDoubleArray("test-group/double-group/my-double");
Assert.assertEquals(theDoubles2, testValues2.clone());
file.close();
}
Aggregations