use of org.broadinstitute.hdf5.HDF5File in project gatk-protected by broadinstitute.
the class HDF5LibraryUnitTest method testMakeDoubleMatrix.
@Test()
public void testMakeDoubleMatrix() 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[][] testValues = new double[][] { new double[] { 1.1, -2.2, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, 0.0111e10 - 10 }, new double[] { -1.1, 2.2, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, -0.01111e10 - 10 } };
Assert.assertTrue(file.makeDoubleMatrix("test-group/double-group/my-double", testValues));
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_ONLY);
final double[][] theDoubles = file.readDoubleMatrix("test-group/double-group/my-double");
Assert.assertTrue(Arrays.deepEquals(theDoubles, testValues.clone()));
file.close();
}
use of org.broadinstitute.hdf5.HDF5File in project gatk by broadinstitute.
the class CreatePanelOfNormalsIntegrationTest method assertBasicPoNAssumptions.
private void assertBasicPoNAssumptions(final File ponFile, final File initialTargetsFileUsedToCreatePoN) {
try (final HDF5File ponHDF5File = new HDF5File(ponFile)) {
final HDF5PCACoveragePoN pon = new HDF5PCACoveragePoN(ponHDF5File);
Assert.assertTrue(pon.getTargets().size() >= pon.getPanelTargets().size());
Assert.assertTrue(pon.getRawTargets().size() > pon.getTargets().size());
Assert.assertTrue(pon.getTargetNames().size() == pon.getTargets().size());
Assert.assertTrue(pon.getPanelTargetNames().size() == pon.getPanelTargetNames().size());
Assert.assertTrue(pon.getRawTargetNames().size() == pon.getRawTargetNames().size());
if (initialTargetsFileUsedToCreatePoN != null) {
final TargetCollection<Target> tc = TargetArgumentCollection.readTargetCollection(initialTargetsFileUsedToCreatePoN);
Assert.assertEquals(pon.getRawTargets().size(), tc.targetCount());
// Check that the raw targets are the same
Assert.assertTrue(IntStream.of(new IntRange(0, pon.getRawTargets().size() - 1).toArray()).boxed().map(i -> pon.getRawTargets().get(i).equals(tc.target(i))).allMatch(t -> t));
}
}
}
use of org.broadinstitute.hdf5.HDF5File in project gatk-protected by broadinstitute.
the class HDF5LibraryUnitTest method testOpenReadOnly.
@Test
public void testOpenReadOnly() {
final HDF5File reader = new HDF5File(TEST_PON);
reader.close();
}
use of org.broadinstitute.hdf5.HDF5File in project gatk-protected by broadinstitute.
the class HDF5LibraryUnitTest method testCreateLargeMatrix.
@Test
public void testCreateLargeMatrix() {
// Creates a large PoN of junk values and simply tests that these can be written and read.
// Make a big, fake set of read counts.
final int numRows = 2500000;
final int numCols = 10;
final double mean = 3e-7;
final double sigma = 1e-9;
final RealMatrix bigCounts = createMatrixOfGaussianValues(numRows, numCols, mean, sigma);
final File tempOutputHD5 = IOUtils.createTempFile("big-ol-", ".hd5");
final HDF5File hdf5File = new HDF5File(tempOutputHD5, HDF5File.OpenMode.CREATE);
final String hdf5Path = "/test/m";
hdf5File.makeDoubleMatrix(hdf5Path, bigCounts.getData());
hdf5File.close();
final HDF5File hdf5FileForReading = new HDF5File(tempOutputHD5, HDF5File.OpenMode.READ_ONLY);
final double[][] result = hdf5FileForReading.readDoubleMatrix(hdf5Path);
final RealMatrix resultAsRealMatrix = new Array2DRowRealMatrix(result);
Assert.assertTrue(resultAsRealMatrix.getRowDimension() == numRows);
Assert.assertTrue(resultAsRealMatrix.getColumnDimension() == numCols);
final RealMatrix readMatrix = new Array2DRowRealMatrix(result);
PoNTestUtils.assertEqualsMatrix(readMatrix, bigCounts, false);
}
use of org.broadinstitute.hdf5.HDF5File in project gatk-protected by broadinstitute.
the class HDF5LibraryUnitTest method testMakeDouble.
@Test()
public void testMakeDouble() throws IOException {
final File testFile = File.createTempFile("hdf5", ".hd5");
HDF5File file = new HDF5File(testFile, HDF5File.OpenMode.CREATE);
file.makeGroup("test-group/double-group");
Assert.assertTrue(file.makeDouble("test-group/double-group/my-double", 1.1));
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_ONLY);
final double theDouble = file.readDouble("test-group/double-group/my-double");
Assert.assertEquals(theDouble, 1.1);
file.close();
}
Aggregations