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();
});
}
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();
});
}
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();
});
}
Aggregations