Search in sources :

Example 6 with GenomePosition

use of com.hartwig.hmftools.common.position.GenomePosition in project hmftools by hartwigmedical.

the class GenomeRegionSelectorImpl method select.

@Override
public void select(@NotNull final GenomeRegion region, @NotNull final Consumer<R> handler) {
    final GenomePosition start = GenomePositions.create(region.chromosome(), region.start());
    final GenomePosition end = GenomePositions.create(region.chromosome(), region.end());
    if (lastPosition != null && start.compareTo(lastPosition) < 0) {
        throw new IllegalArgumentException("Selector only goes forward, never backwards!");
    }
    while (next != null && compare(start, next) > 0) {
        next = regions.hasNext() ? this.regions.next() : null;
    }
    while (next != null && compare(start, next) <= 0 && compare(end, next) >= 0) {
        handler.accept(next);
        next = regions.hasNext() ? this.regions.next() : null;
    }
    lastPosition = end;
}
Also used : GenomePosition(com.hartwig.hmftools.common.position.GenomePosition)

Example 7 with GenomePosition

use of com.hartwig.hmftools.common.position.GenomePosition in project hmftools by hartwigmedical.

the class BachelorEligibility method processStructuralVariant.

private Collection<EligibilityReport> processStructuralVariant(final String patient, final GenomePosition position, final GenomePosition other, final StructuralVariantType svType) {
    final List<EligibilityReport> results = Lists.newArrayList();
    // TODO: can we do better than this performance wise? new map?
    for (final HmfGenomeRegion region : allGenesByChromosomeMap.get(position.chromosome())) {
        if (!region.contains(position)) {
            continue;
        }
        // skip non-inversion intronic variants
        if (region.contains(other) && svType != StructuralVariantType.INV) {
            final int intronStart = intron(region.exome(), position);
            final int intronEnd = intron(region.exome(), other);
            // the variant is intronic in a gene -- we will filter it
            if (intronStart >= 0 && intronStart == intronEnd) {
                continue;
            }
        }
        programs.stream().filter(p -> p.disruptionProcessor().test(region)).map(p -> ImmutableEligibilityReport.builder().patient(patient).source(SOMATIC_DISRUPTION).program(p.name()).id("").genes(region.gene()).chrom(region.chromosome()).pos(position.position()).ref("").alts("").effects("").build()).forEach(results::add);
    }
    return results;
}
Also used : ProgramPanel(nl.hartwigmedicalfoundation.bachelor.ProgramPanel) Genotype(htsjdk.variant.variantcontext.Genotype) CloseableIterator(htsjdk.samtools.util.CloseableIterator) SOMATIC_DELETION(com.hartwig.hmftools.bachelor.EligibilityReport.ReportType.SOMATIC_DELETION) SOMATIC_DISRUPTION(com.hartwig.hmftools.bachelor.EligibilityReport.ReportType.SOMATIC_DISRUPTION) VCFFileReader(htsjdk.variant.vcf.VCFFileReader) HmfGenomeRegion(com.hartwig.hmftools.common.region.hmfslicer.HmfGenomeRegion) Multimap(com.google.common.collect.Multimap) StructuralVariant(com.hartwig.hmftools.common.variant.structural.StructuralVariant) HmfGenePanelSupplier(com.hartwig.hmftools.genepanel.HmfGenePanelSupplier) HashMultimap(com.google.common.collect.HashMultimap) Lists(com.google.common.collect.Lists) GenomePosition(com.hartwig.hmftools.common.position.GenomePosition) VariantAnnotation(com.hartwig.hmftools.common.variant.snpeff.VariantAnnotation) Map(java.util.Map) StructuralVariantType(com.hartwig.hmftools.common.variant.structural.StructuralVariantType) GenomePositions(com.hartwig.hmftools.common.position.GenomePositions) SnpEffect(nl.hartwigmedicalfoundation.bachelor.SnpEffect) GERMLINE_DELETION(com.hartwig.hmftools.bachelor.EligibilityReport.ReportType.GERMLINE_DELETION) SortedSetMultimap(com.google.common.collect.SortedSetMultimap) OtherEffect(nl.hartwigmedicalfoundation.bachelor.OtherEffect) Predicate(java.util.function.Predicate) Collection(java.util.Collection) Program(nl.hartwigmedicalfoundation.bachelor.Program) Set(java.util.Set) WhitelistPredicate(com.hartwig.hmftools.bachelor.predicates.WhitelistPredicate) Collectors(java.util.stream.Collectors) Maps(com.google.common.collect.Maps) Sets(com.google.common.collect.Sets) GeneIdentifier(nl.hartwigmedicalfoundation.bachelor.GeneIdentifier) List(java.util.List) Stream(java.util.stream.Stream) Logger(org.apache.logging.log4j.Logger) VariantContext(htsjdk.variant.variantcontext.VariantContext) HmfExonRegion(com.hartwig.hmftools.common.region.hmfslicer.HmfExonRegion) GeneCopyNumber(com.hartwig.hmftools.common.gene.GeneCopyNumber) NotNull(org.jetbrains.annotations.NotNull) Collections(java.util.Collections) LogManager(org.apache.logging.log4j.LogManager) BlacklistPredicate(com.hartwig.hmftools.bachelor.predicates.BlacklistPredicate) HmfGenomeRegion(com.hartwig.hmftools.common.region.hmfslicer.HmfGenomeRegion)

Aggregations

GenomePosition (com.hartwig.hmftools.common.position.GenomePosition)7 NotNull (org.jetbrains.annotations.NotNull)5 VisibleForTesting (com.google.common.annotations.VisibleForTesting)4 Lists (com.google.common.collect.Lists)3 Multimap (com.google.common.collect.Multimap)3 GenomePositions (com.hartwig.hmftools.common.position.GenomePositions)3 StructuralVariant (com.hartwig.hmftools.common.variant.structural.StructuralVariant)3 Collections (java.util.Collections)3 List (java.util.List)3 Doubles (com.hartwig.hmftools.common.numeric.Doubles)2 StructuralVariantLeg (com.hartwig.hmftools.common.variant.structural.StructuralVariantLeg)2 StructuralVariantType (com.hartwig.hmftools.common.variant.structural.StructuralVariantType)2 Collection (java.util.Collection)2 Optional (java.util.Optional)2 Collectors (java.util.stream.Collectors)2 ArrayListMultimap (com.google.common.collect.ArrayListMultimap)1 HashMultimap (com.google.common.collect.HashMultimap)1 ListMultimap (com.google.common.collect.ListMultimap)1 Maps (com.google.common.collect.Maps)1 Sets (com.google.common.collect.Sets)1