Search in sources :

Example 41 with HDF5File

use of org.broadinstitute.hdf5.HDF5File in project gatk-protected by broadinstitute.

the class HDF5LibraryUnitTest method testCreateGroup.

@Test()
public void testCreateGroup() {
    final File testFile = BaseTest.createTempFile("hdf5", ".hd5");
    final HDF5File file = new HDF5File(testFile, HDF5File.OpenMode.CREATE);
    Assert.assertTrue(file.makeGroup("test-group/lola-run"));
    Assert.assertFalse(file.makeGroup("test-group"));
    Assert.assertFalse(file.makeGroup("test-group/lola-run"));
    Assert.assertTrue(file.makeGroup("test-group/peter-pan"));
    file.close();
}
Also used : HDF5File(org.broadinstitute.hdf5.HDF5File) File(java.io.File) HDF5File(org.broadinstitute.hdf5.HDF5File) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 42 with HDF5File

use of org.broadinstitute.hdf5.HDF5File in project gatk-protected by broadinstitute.

the class HDF5LibraryUnitTest method testMakeDoubleArray.

@Test()
public void testMakeDoubleArray() 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[] { 1.1, -2.2, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, 0.0111e10 - 10 };
    Assert.assertTrue(file.makeDoubleArray("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.readDoubleArray("test-group/double-group/my-double");
    Assert.assertEquals(theDoubles, testValues.clone());
    file.close();
}
Also used : HDF5File(org.broadinstitute.hdf5.HDF5File) File(java.io.File) HDF5File(org.broadinstitute.hdf5.HDF5File) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 43 with HDF5File

use of org.broadinstitute.hdf5.HDF5File in project gatk-protected by broadinstitute.

the class HDF5LibraryUnitTest method testCreateHDF5File.

@Test()
public void testCreateHDF5File() {
    final File testFile = BaseTest.createTempFile("hdf5", ".hd5");
    testFile.delete();
    final HDF5File file = new HDF5File(testFile, HDF5File.OpenMode.CREATE);
    file.close();
}
Also used : HDF5File(org.broadinstitute.hdf5.HDF5File) File(java.io.File) HDF5File(org.broadinstitute.hdf5.HDF5File) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 44 with HDF5File

use of org.broadinstitute.hdf5.HDF5File in project gatk-protected by broadinstitute.

the class HDF5LibraryUnitTest method testMakeStringArray.

@Test()
public void testMakeStringArray() throws IOException {
    final File testFile = File.createTempFile("hdf5", ".hd5");
    HDF5File file = new HDF5File(testFile, HDF5File.OpenMode.CREATE);
    file.makeGroup("test-group/double-group");
    final String[] testValues = new String[] { "0", "1", "absdsd12 sdsad121 sdasadsad 1212sdasdas", StringUtils.repeat("x", 2000) };
    Assert.assertTrue(file.makeStringArray("test-group/double-group/my-double", testValues));
    System.err.println(testFile);
    file.close();
    FileUtils.copyFile(testFile, new File("/tmp/3.hd5"));
    final long time = System.currentTimeMillis();
    Assert.assertTrue(testFile.length() > 0);
    Assert.assertTrue(testFile.lastModified() <= time);
    file = new HDF5File(testFile, HDF5File.OpenMode.READ_ONLY);
    final String[] theStrings = file.readStringArray("test-group/double-group/my-double");
    Assert.assertEquals(theStrings, testValues.clone());
    file.close();
}
Also used : HDF5File(org.broadinstitute.hdf5.HDF5File) File(java.io.File) HDF5File(org.broadinstitute.hdf5.HDF5File) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 45 with HDF5File

use of org.broadinstitute.hdf5.HDF5File in project gatk-protected by broadinstitute.

the class HDF5LibraryUnitTest method testOpenReadOnlyOnBadFile.

@Test(expectedExceptions = HDF5LibException.class)
public void testOpenReadOnlyOnBadFile() {
    final HDF5File reader = new HDF5File(new File("/tmp/no-file"));
    reader.close();
}
Also used : HDF5File(org.broadinstitute.hdf5.HDF5File) File(java.io.File) HDF5File(org.broadinstitute.hdf5.HDF5File) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Aggregations

HDF5File (org.broadinstitute.hdf5.HDF5File)82 Test (org.testng.annotations.Test)58 BaseTest (org.broadinstitute.hellbender.utils.test.BaseTest)56 File (java.io.File)32 Array2DRowRealMatrix (org.apache.commons.math3.linear.Array2DRowRealMatrix)24 RealMatrix (org.apache.commons.math3.linear.RealMatrix)24 HDF5PCACoveragePoN (org.broadinstitute.hellbender.tools.pon.coverage.pca.HDF5PCACoveragePoN)20 BeforeTest (org.testng.annotations.BeforeTest)20 PCACoveragePoN (org.broadinstitute.hellbender.tools.pon.coverage.pca.PCACoveragePoN)16 JavaSparkContext (org.apache.spark.api.java.JavaSparkContext)10 HDF5Library (org.broadinstitute.hdf5.HDF5Library)6 UserException (org.broadinstitute.hellbender.exceptions.UserException)6 ArrayList (java.util.ArrayList)4 List (java.util.List)4 OptionalInt (java.util.OptionalInt)4 StandardArgumentDefinitions (org.broadinstitute.hellbender.cmdline.StandardArgumentDefinitions)4 IOException (java.io.IOException)2 UncheckedIOException (java.io.UncheckedIOException)2 DoubleStream (java.util.stream.DoubleStream)2 IntStream (java.util.stream.IntStream)2