Search in sources :

Example 1 with HmfGenomeRegion

use of com.hartwig.hmftools.common.region.hmfslicer.HmfGenomeRegion in project hmftools by hartwigmedical.

the class ConsequenceDeterminerTest method worksAsExpected.

@Test
public void worksAsExpected() {
    final SortedSetMultimap<String, GenomeRegion> regionMap = TreeMultimap.create();
    GenomeRegion testRegion = GenomeRegionFactory.create(CHROMOSOME, POSITION - 10, POSITION + 10);
    regionMap.put(testRegion.chromosome(), testRegion);
    final Slicer slicer = SlicerFactory.fromRegions(regionMap);
    final Map<String, HmfGenomeRegion> transcriptMap = Maps.newHashMap();
    transcriptMap.put(TRANSCRIPT, hmfRegion());
    final ConsequenceDeterminer determiner = new ConsequenceDeterminer(slicer, transcriptMap);
    final VariantConsequence rightConsequence = VariantConsequence.MISSENSE_VARIANT;
    final VariantConsequence wrongConsequence = VariantConsequence.OTHER;
    final ImmutableVariantAnnotation.Builder annotationBuilder = createVariantAnnotationBuilder().featureID(TRANSCRIPT).featureType(ConsequenceDeterminer.FEATURE_TYPE_TRANSCRIPT).gene(GENE).hgvsCoding(HGVS_CODING).hgvsProtein(HGVS_PROTEIN);
    final VariantAnnotation rightAnnotation = annotationBuilder.consequences(Lists.newArrayList(rightConsequence)).build();
    final VariantAnnotation wrongAnnotation = annotationBuilder.consequences(Lists.newArrayList(wrongConsequence)).build();
    final ImmutableSomaticVariantImpl.Builder variantBuilder = SomaticVariantTestBuilderFactory.create().chromosome(CHROMOSOME).ref(REF).alt(ALT).cosmicID(COSMIC_ID).totalReadCount(TOTAL_READ_COUNT).alleleReadCount(ALLELE_READ_COUNT);
    final SomaticVariant rightVariant = variantBuilder.position(POSITION).annotations(Lists.newArrayList(rightAnnotation)).build();
    final SomaticVariant wrongConsequenceVariant = variantBuilder.position(POSITION).annotations(Lists.newArrayList(wrongAnnotation)).build();
    final SomaticVariant wrongPositionVariant = variantBuilder.position(WRONG_POSITION).annotations(Lists.newArrayList(rightAnnotation)).build();
    final List<VariantReport> findings = determiner.run(Lists.newArrayList(rightVariant, wrongConsequenceVariant, wrongPositionVariant)).findings();
    assertEquals(1, findings.size());
    final VariantReport report = findings.get(0);
    assertEquals(GENE, report.gene());
    assertEquals(CHROMOSOME + ":" + POSITION, report.variant().chromosomePosition());
    assertEquals(REF, report.variant().ref());
    assertEquals(ALT, report.variant().alt());
    assertEquals(TRANSCRIPT + "." + TRANSCRIPT_VERSION, report.transcript());
    assertEquals(HGVS_CODING, report.hgvsCoding());
    assertEquals(HGVS_PROTEIN, report.hgvsProtein());
    assertEquals(rightConsequence.readableSequenceOntologyTerm(), report.consequence());
    assertEquals(COSMIC_ID, report.cosmicID());
    assertEquals(TOTAL_READ_COUNT, report.totalReadCount());
    assertEquals(ALLELE_READ_COUNT, report.alleleReadCount());
}
Also used : SomaticVariant(com.hartwig.hmftools.common.variant.SomaticVariant) Slicer(com.hartwig.hmftools.common.slicing.Slicer) ImmutableVariantAnnotation(com.hartwig.hmftools.common.variant.snpeff.ImmutableVariantAnnotation) VariantAnnotation(com.hartwig.hmftools.common.variant.snpeff.VariantAnnotation) VariantConsequence(com.hartwig.hmftools.common.variant.VariantConsequence) HmfGenomeRegion(com.hartwig.hmftools.common.region.hmfslicer.HmfGenomeRegion) ImmutableHmfGenomeRegion(com.hartwig.hmftools.common.region.hmfslicer.ImmutableHmfGenomeRegion) GenomeRegion(com.hartwig.hmftools.common.region.GenomeRegion) HmfGenomeRegion(com.hartwig.hmftools.common.region.hmfslicer.HmfGenomeRegion) ImmutableHmfGenomeRegion(com.hartwig.hmftools.common.region.hmfslicer.ImmutableHmfGenomeRegion) ImmutableSomaticVariantImpl(com.hartwig.hmftools.common.variant.ImmutableSomaticVariantImpl) ImmutableVariantAnnotation(com.hartwig.hmftools.common.variant.snpeff.ImmutableVariantAnnotation) Test(org.junit.Test)

Example 2 with HmfGenomeRegion

use of com.hartwig.hmftools.common.region.hmfslicer.HmfGenomeRegion in project hmftools by hartwigmedical.

the class CivicAnalyzer method civicVariantAlterations.

@NotNull
private static List<Alteration> civicVariantAlterations(@NotNull final List<VariantReport> reportedVariants, @NotNull final Collection<HmfGenomeRegion> geneRegions, @NotNull final Set<String> relevantDoids) {
    LOGGER.info("  Fetching civic variant alterations...");
    final List<Alteration> alterations = Lists.newArrayList();
    final CivicApiWrapper civicApi = new CivicApiWrapper();
    for (final HmfGenomeRegion region : geneRegions) {
        final List<VariantReport> reportedVariantsInGene = reportedVariants.stream().filter(variantReport -> region.gene().equals(variantReport.gene())).collect(Collectors.toList());
        if (!reportedVariantsInGene.isEmpty()) {
            for (final VariantReport variantReport : reportedVariantsInGene) {
                alterations.addAll(queryCivicAlteration(region.entrezId(), variantList -> Alteration.from(variantReport, variantList, relevantDoids), "  Failed to get civic variants for variant: " + variantReport.variant().chromosomePosition()));
            }
        }
    }
    civicApi.releaseResources();
    return alterations;
}
Also used : GeneDisruptionData(com.hartwig.hmftools.patientreporter.report.data.GeneDisruptionData) VariantReport(com.hartwig.hmftools.patientreporter.variants.VariantReport) GeneModel(com.hartwig.hmftools.common.gene.GeneModel) Predicate(java.util.function.Predicate) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) HmfGenomeRegion(com.hartwig.hmftools.common.region.hmfslicer.HmfGenomeRegion) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) GeneFusionData(com.hartwig.hmftools.patientreporter.report.data.GeneFusionData) CivicApiWrapper(com.hartwig.hmftools.apiclients.civic.api.CivicApiWrapper) List(java.util.List) Lists(com.google.common.collect.Lists) Logger(org.apache.logging.log4j.Logger) CivicVariantWithEvidence(com.hartwig.hmftools.apiclients.civic.data.CivicVariantWithEvidence) Alteration(com.hartwig.hmftools.patientreporter.report.data.Alteration) Observable(io.reactivex.Observable) GeneCopyNumber(com.hartwig.hmftools.common.gene.GeneCopyNumber) NotNull(org.jetbrains.annotations.NotNull) LogManager(org.apache.logging.log4j.LogManager) DiseaseOntologyApiWrapper(com.hartwig.hmftools.apiclients.diseaseontology.api.DiseaseOntologyApiWrapper) VariantReport(com.hartwig.hmftools.patientreporter.variants.VariantReport) Alteration(com.hartwig.hmftools.patientreporter.report.data.Alteration) CivicApiWrapper(com.hartwig.hmftools.apiclients.civic.api.CivicApiWrapper) HmfGenomeRegion(com.hartwig.hmftools.common.region.hmfslicer.HmfGenomeRegion) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with HmfGenomeRegion

use of com.hartwig.hmftools.common.region.hmfslicer.HmfGenomeRegion in project hmftools by hartwigmedical.

the class CivicAnalyzer method nonWildTypeGenes.

@NotNull
private static List<HmfGenomeRegion> nonWildTypeGenes(@NotNull final List<VariantReport> reportedVariants, @NotNull final List<GeneCopyNumber> copyNumbers, @NotNull final List<GeneDisruptionData> disruptions, @NotNull final List<GeneFusionData> fusions, @NotNull final Collection<HmfGenomeRegion> geneRegions) {
    final List<HmfGenomeRegion> nonWildTypeGenes = Lists.newArrayList();
    for (final HmfGenomeRegion region : geneRegions) {
        final boolean hasVariant = reportedVariants.stream().filter(variantReport -> region.gene().equals(variantReport.gene())).count() > 0;
        final boolean geneLost = copyNumbers.stream().filter(geneCopyNumber -> region.gene().equals(geneCopyNumber.gene()) && geneCopyNumber.value() < 1).count() > 0;
        final boolean geneDisrupted = disruptions.stream().filter(disruption -> region.gene().equals(disruption.gene())).count() > 0;
        final boolean geneFused = fusions.stream().filter(fusion -> region.gene().equals(fusion.geneStart()) || region.gene().equals(fusion.geneEnd())).count() > 0;
        if (hasVariant || geneLost || geneDisrupted || geneFused) {
            nonWildTypeGenes.add(region);
        }
    }
    return nonWildTypeGenes;
}
Also used : HmfGenomeRegion(com.hartwig.hmftools.common.region.hmfslicer.HmfGenomeRegion) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with HmfGenomeRegion

use of com.hartwig.hmftools.common.region.hmfslicer.HmfGenomeRegion in project hmftools by hartwigmedical.

the class CivicAnalyzer method civicCopyNumberAlterations.

@NotNull
private static List<Alteration> civicCopyNumberAlterations(@NotNull final List<GeneCopyNumber> copyNumbers, @NotNull final Collection<HmfGenomeRegion> geneRegions, @NotNull final Set<String> relevantDoids) {
    LOGGER.info("  Fetching civic copy number alterations...");
    final List<Alteration> alterations = Lists.newArrayList();
    for (final GeneCopyNumber copyNumberReport : copyNumbers) {
        for (final HmfGenomeRegion region : geneRegions) {
            if (region.gene().equals(copyNumberReport.gene())) {
                alterations.addAll(queryCivicAlteration(region.entrezId(), variantList -> Alteration.from(copyNumberReport, variantList, relevantDoids), "  Failed to get civic variants for copy number: " + copyNumberReport.gene()));
            }
        }
    }
    return alterations;
}
Also used : GeneDisruptionData(com.hartwig.hmftools.patientreporter.report.data.GeneDisruptionData) VariantReport(com.hartwig.hmftools.patientreporter.variants.VariantReport) GeneModel(com.hartwig.hmftools.common.gene.GeneModel) Predicate(java.util.function.Predicate) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) HmfGenomeRegion(com.hartwig.hmftools.common.region.hmfslicer.HmfGenomeRegion) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) GeneFusionData(com.hartwig.hmftools.patientreporter.report.data.GeneFusionData) CivicApiWrapper(com.hartwig.hmftools.apiclients.civic.api.CivicApiWrapper) List(java.util.List) Lists(com.google.common.collect.Lists) Logger(org.apache.logging.log4j.Logger) CivicVariantWithEvidence(com.hartwig.hmftools.apiclients.civic.data.CivicVariantWithEvidence) Alteration(com.hartwig.hmftools.patientreporter.report.data.Alteration) Observable(io.reactivex.Observable) GeneCopyNumber(com.hartwig.hmftools.common.gene.GeneCopyNumber) NotNull(org.jetbrains.annotations.NotNull) LogManager(org.apache.logging.log4j.LogManager) DiseaseOntologyApiWrapper(com.hartwig.hmftools.apiclients.diseaseontology.api.DiseaseOntologyApiWrapper) Alteration(com.hartwig.hmftools.patientreporter.report.data.Alteration) HmfGenomeRegion(com.hartwig.hmftools.common.region.hmfslicer.HmfGenomeRegion) GeneCopyNumber(com.hartwig.hmftools.common.gene.GeneCopyNumber) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with HmfGenomeRegion

use of com.hartwig.hmftools.common.region.hmfslicer.HmfGenomeRegion in project hmftools by hartwigmedical.

the class CivicAnalyzer method civicWildTypeAlterations.

@NotNull
private static List<Alteration> civicWildTypeAlterations(@NotNull final List<HmfGenomeRegion> nonWildTypeGenes, @NotNull final Set<String> relevantDoids) {
    LOGGER.info("  Fetching civic wild type alterations...");
    final CivicApiWrapper civicApi = new CivicApiWrapper();
    final Set<String> nonWildTypeEntrezIds = nonWildTypeGenes.stream().flatMap(hmfGenomeRegion -> hmfGenomeRegion.entrezId().stream().map(Object::toString)).collect(Collectors.toSet());
    final List<Alteration> wildTypeAlterations = civicApi.getAllWildTypeVariants().filter(civicVariant -> !nonWildTypeEntrezIds.contains(civicVariant.entrezId())).groupBy(CivicVariantWithEvidence::gene).flatMap(pair -> pair.toList().map(variantList -> Alteration.fromWildType(pair.getKey(), variantList, relevantDoids)).filter(alteration -> !alteration.getMatches().isEmpty()).toObservable()).toList().blockingGet();
    civicApi.releaseResources();
    return wildTypeAlterations;
}
Also used : GeneDisruptionData(com.hartwig.hmftools.patientreporter.report.data.GeneDisruptionData) VariantReport(com.hartwig.hmftools.patientreporter.variants.VariantReport) GeneModel(com.hartwig.hmftools.common.gene.GeneModel) Predicate(java.util.function.Predicate) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) HmfGenomeRegion(com.hartwig.hmftools.common.region.hmfslicer.HmfGenomeRegion) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) GeneFusionData(com.hartwig.hmftools.patientreporter.report.data.GeneFusionData) CivicApiWrapper(com.hartwig.hmftools.apiclients.civic.api.CivicApiWrapper) List(java.util.List) Lists(com.google.common.collect.Lists) Logger(org.apache.logging.log4j.Logger) CivicVariantWithEvidence(com.hartwig.hmftools.apiclients.civic.data.CivicVariantWithEvidence) Alteration(com.hartwig.hmftools.patientreporter.report.data.Alteration) Observable(io.reactivex.Observable) GeneCopyNumber(com.hartwig.hmftools.common.gene.GeneCopyNumber) NotNull(org.jetbrains.annotations.NotNull) LogManager(org.apache.logging.log4j.LogManager) DiseaseOntologyApiWrapper(com.hartwig.hmftools.apiclients.diseaseontology.api.DiseaseOntologyApiWrapper) CivicApiWrapper(com.hartwig.hmftools.apiclients.civic.api.CivicApiWrapper) Alteration(com.hartwig.hmftools.patientreporter.report.data.Alteration) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

HmfGenomeRegion (com.hartwig.hmftools.common.region.hmfslicer.HmfGenomeRegion)17 NotNull (org.jetbrains.annotations.NotNull)11 Lists (com.google.common.collect.Lists)5 Sets (com.google.common.collect.Sets)5 GeneCopyNumber (com.hartwig.hmftools.common.gene.GeneCopyNumber)5 Collection (java.util.Collection)5 List (java.util.List)5 Set (java.util.Set)5 Predicate (java.util.function.Predicate)5 Collectors (java.util.stream.Collectors)5 Test (org.junit.Test)5 VariantAnnotation (com.hartwig.hmftools.common.variant.snpeff.VariantAnnotation)4 LogManager (org.apache.logging.log4j.LogManager)4 Logger (org.apache.logging.log4j.Logger)4 CivicApiWrapper (com.hartwig.hmftools.apiclients.civic.api.CivicApiWrapper)3 CivicVariantWithEvidence (com.hartwig.hmftools.apiclients.civic.data.CivicVariantWithEvidence)3 DiseaseOntologyApiWrapper (com.hartwig.hmftools.apiclients.diseaseontology.api.DiseaseOntologyApiWrapper)3 GeneModel (com.hartwig.hmftools.common.gene.GeneModel)3 SomaticVariant (com.hartwig.hmftools.common.variant.SomaticVariant)3 Alteration (com.hartwig.hmftools.patientreporter.report.data.Alteration)3