Search in sources :

Example 36 with SparkConf

use of org.apache.spark.SparkConf in project gatk by broadinstitute.

the class SparkContextFactoryUnitTest method testSetupSparkConf.

@Test(groups = "spark")
public void testSetupSparkConf() {
    final String appName = "appName";
    final String master = "master";
    final SparkConf sparkConf = SparkContextFactory.setupSparkConf(appName, master, SUGGESTED, OVERRIDE);
    Assert.assertEquals(sparkConf.get("spark.master"), master);
    Assert.assertEquals(sparkConf.get("spark.app.name"), appName);
    Assert.assertEquals(sparkConf.get(prop1), value1_override);
    Assert.assertEquals(sparkConf.get(prop2), value2);
    Assert.assertEquals(sparkConf.get(prop3), value3);
}
Also used : SparkConf(org.apache.spark.SparkConf) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 37 with SparkConf

use of org.apache.spark.SparkConf in project gatk by broadinstitute.

the class SAMRecordSerializerUnitTest method testChangingContigsOnHeaderlessSAMRecord.

@Test
public void testChangingContigsOnHeaderlessSAMRecord() {
    final SparkConf conf = new SparkConf().set("spark.kryo.registrator", "org.broadinstitute.hellbender.engine.spark.SAMRecordSerializerUnitTest$TestGATKRegistrator");
    final SAMRecord read = ((SAMRecordToGATKReadAdapter) ArtificialReadUtils.createHeaderlessSamBackedRead("read1", "1", 100, 50)).getEncapsulatedSamRecord();
    final SAMRecord roundTrippedRead = SparkTestUtils.roundTripInKryo(read, SAMRecord.class, conf);
    Assert.assertEquals(roundTrippedRead, read, "\nActual read: " + roundTrippedRead.getSAMString() + "\nExpected read: " + read.getSAMString());
    read.setReferenceName("2");
    read.setAlignmentStart(1);
    final SAMRecord roundTrippedRead2 = SparkTestUtils.roundTripInKryo(read, SAMRecord.class, conf);
    Assert.assertEquals(roundTrippedRead2, read, "\nActual read: " + roundTrippedRead2.getSAMString() + "\nExpected read: " + read.getSAMString());
}
Also used : SAMRecordToGATKReadAdapter(org.broadinstitute.hellbender.utils.read.SAMRecordToGATKReadAdapter) SAMRecord(htsjdk.samtools.SAMRecord) SparkConf(org.apache.spark.SparkConf) Test(org.testng.annotations.Test)

Example 38 with SparkConf

use of org.apache.spark.SparkConf in project gatk by broadinstitute.

the class SAMRecordSerializerUnitTest method testSerializerRoundTripHeaderlessSAMRecord.

@Test
public void testSerializerRoundTripHeaderlessSAMRecord() {
    SparkConf conf = new SparkConf().set("spark.kryo.registrator", "org.broadinstitute.hellbender.engine.spark.SAMRecordSerializerUnitTest$TestGATKRegistrator");
    // check round trip with no header
    final SAMRecord read = ((SAMRecordToGATKReadAdapter) ArtificialReadUtils.createHeaderlessSamBackedRead("read1", "1", 100, 50)).getEncapsulatedSamRecord();
    final SAMRecord roundTrippedRead = SparkTestUtils.roundTripInKryo(read, SAMRecord.class, conf);
    Assert.assertEquals(roundTrippedRead, read, "\nActual read: " + roundTrippedRead.getSAMString() + "\nExpected read: " + read.getSAMString());
}
Also used : SAMRecordToGATKReadAdapter(org.broadinstitute.hellbender.utils.read.SAMRecordToGATKReadAdapter) SAMRecord(htsjdk.samtools.SAMRecord) SparkConf(org.apache.spark.SparkConf) Test(org.testng.annotations.Test)

Example 39 with SparkConf

use of org.apache.spark.SparkConf in project gatk by broadinstitute.

the class SAMRecordToGATKReadAdapterSerializerUnitTest method testChangingContigsOnHeaderlessGATKRead.

@Test
public void testChangingContigsOnHeaderlessGATKRead() {
    final SparkConf conf = new SparkConf().set("spark.kryo.registrator", "org.broadinstitute.hellbender.engine.spark.SAMRecordToGATKReadAdapterSerializerUnitTest$TestGATKRegistrator");
    final GATKRead read = ArtificialReadUtils.createHeaderlessSamBackedRead("read1", "1", 100, 50);
    final GATKRead roundTrippedRead = SparkTestUtils.roundTripInKryo(read, GATKRead.class, conf);
    Assert.assertEquals(roundTrippedRead, read);
    read.setPosition("2", 1);
    final GATKRead roundTrippedRead2 = SparkTestUtils.roundTripInKryo(read, GATKRead.class, conf);
    Assert.assertEquals(roundTrippedRead2, read);
}
Also used : GATKRead(org.broadinstitute.hellbender.utils.read.GATKRead) SparkConf(org.apache.spark.SparkConf) Test(org.testng.annotations.Test)

Example 40 with SparkConf

use of org.apache.spark.SparkConf in project gatk by broadinstitute.

the class ReferenceMultiSourceUnitTest method testSerializeRoundTrip2Bit.

@Test
public void testSerializeRoundTrip2Bit() {
    PipelineOptions options = null;
    ReferenceMultiSource referenceMultiSource = new ReferenceMultiSource(options, twoBitRefURL, ReferenceWindowFunctions.IDENTITY_FUNCTION);
    final ReferenceMultiSource roundTrippedReference = SparkTestUtils.roundTripInKryo(referenceMultiSource, ReferenceMultiSource.class, new SparkConf());
    Assert.assertEquals(roundTrippedReference.getReferenceSequenceDictionary(null), referenceMultiSource.getReferenceSequenceDictionary(null), "\nActual ref: " + roundTrippedReference.getReferenceSequenceDictionary(null) + "\nExpected ref: " + referenceMultiSource.getReferenceSequenceDictionary(null));
    Assert.assertNotNull(roundTrippedReference.getReferenceWindowFunction());
}
Also used : ReferenceMultiSource(org.broadinstitute.hellbender.engine.datasources.ReferenceMultiSource) PipelineOptions(com.google.cloud.dataflow.sdk.options.PipelineOptions) SparkConf(org.apache.spark.SparkConf) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Aggregations

SparkConf (org.apache.spark.SparkConf)83 JavaSparkContext (org.apache.spark.api.java.JavaSparkContext)46 Test (org.junit.Test)21 ArrayList (java.util.ArrayList)20 Configuration (org.apache.hadoop.conf.Configuration)20 Tuple2 (scala.Tuple2)15 Graph (uk.gov.gchq.gaffer.graph.Graph)13 DataOutputStream (java.io.DataOutputStream)11 File (java.io.File)10 HashSet (java.util.HashSet)10 ByteArrayOutputStream (org.apache.commons.io.output.ByteArrayOutputStream)10 Edge (uk.gov.gchq.gaffer.data.element.Edge)10 Element (uk.gov.gchq.gaffer.data.element.Element)10 Entity (uk.gov.gchq.gaffer.data.element.Entity)10 User (uk.gov.gchq.gaffer.user.User)10 Ignore (org.junit.Ignore)6 HBaseConfiguration (org.apache.hadoop.hbase.HBaseConfiguration)5 JavaHBaseContext (org.apache.hadoop.hbase.spark.JavaHBaseContext)5 Test (org.testng.annotations.Test)5 AddElements (uk.gov.gchq.gaffer.operation.impl.add.AddElements)5