Search in sources :

Example 1 with VariantShard

use of org.broadinstitute.hellbender.engine.VariantShard in project gatk by broadinstitute.

the class ShuffleJoinReadsWithVariants method pairReadsWithVariantShards.

private static JavaPairRDD<VariantShard, GATKRead> pairReadsWithVariantShards(final JavaRDD<GATKRead> reads) {
    return reads.flatMapToPair(gatkRead -> {
        List<VariantShard> shards = VariantShard.getVariantShardsFromInterval(gatkRead);
        List<Tuple2<VariantShard, GATKRead>> out = Lists.newArrayList();
        for (VariantShard shard : shards) {
            out.add(new Tuple2<>(shard, gatkRead));
        }
        return out.iterator();
    });
}
Also used : VariantShard(org.broadinstitute.hellbender.engine.VariantShard) Tuple2(scala.Tuple2)

Example 2 with VariantShard

use of org.broadinstitute.hellbender.engine.VariantShard in project gatk by broadinstitute.

the class ShuffleJoinReadsWithVariants method pairVariantsWithVariantShards.

private static JavaPairRDD<VariantShard, GATKVariant> pairVariantsWithVariantShards(final JavaRDD<GATKVariant> variants) {
    return variants.flatMapToPair(variant -> {
        List<VariantShard> shards = VariantShard.getVariantShardsFromInterval(variant);
        List<Tuple2<VariantShard, GATKVariant>> out = Lists.newArrayList();
        for (VariantShard shard : shards) {
            out.add(new Tuple2<>(shard, variant));
        }
        return out.iterator();
    });
}
Also used : VariantShard(org.broadinstitute.hellbender.engine.VariantShard) Tuple2(scala.Tuple2)

Example 3 with VariantShard

use of org.broadinstitute.hellbender.engine.VariantShard in project gatk by broadinstitute.

the class ShuffleJoinReadsWithVariants method pairReadsWithVariants.

private static JavaPairRDD<GATKRead, GATKVariant> pairReadsWithVariants(final JavaPairRDD<VariantShard, GATKRead> readsWShards, final JavaPairRDD<VariantShard, GATKVariant> variantsWShards) {
    JavaPairRDD<VariantShard, Tuple2<Iterable<GATKRead>, Iterable<GATKVariant>>> cogroup = readsWShards.cogroup(variantsWShards);
    return cogroup.flatMapToPair(cogroupValue -> {
        Iterable<GATKRead> iReads = cogroupValue._2()._1();
        Iterable<GATKVariant> iVariants = cogroupValue._2()._2();
        List<Tuple2<GATKRead, GATKVariant>> out = Lists.newArrayList();
        for (GATKRead r : iReads) {
            boolean foundVariants = false;
            SimpleInterval interval = new SimpleInterval(r);
            for (GATKVariant v : iVariants) {
                if (interval.overlaps(v)) {
                    foundVariants = true;
                    out.add(new Tuple2<>(r, v));
                }
            }
            if (!foundVariants) {
                out.add(new Tuple2<>(r, null));
            }
        }
        return out.iterator();
    });
}
Also used : GATKRead(org.broadinstitute.hellbender.utils.read.GATKRead) GATKVariant(org.broadinstitute.hellbender.utils.variant.GATKVariant) VariantShard(org.broadinstitute.hellbender.engine.VariantShard) Tuple2(scala.Tuple2) SimpleInterval(org.broadinstitute.hellbender.utils.SimpleInterval)

Aggregations

VariantShard (org.broadinstitute.hellbender.engine.VariantShard)3 Tuple2 (scala.Tuple2)3 SimpleInterval (org.broadinstitute.hellbender.utils.SimpleInterval)1 GATKRead (org.broadinstitute.hellbender.utils.read.GATKRead)1 GATKVariant (org.broadinstitute.hellbender.utils.variant.GATKVariant)1