Search in sources :

Example 1 with CivicApiWrapper

use of com.hartwig.hmftools.apiclients.civic.api.CivicApiWrapper 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 2 with CivicApiWrapper

use of com.hartwig.hmftools.apiclients.civic.api.CivicApiWrapper 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)

Example 3 with CivicApiWrapper

use of com.hartwig.hmftools.apiclients.civic.api.CivicApiWrapper in project hmftools by hartwigmedical.

the class CivicAnalyzer method queryCivicAlteration.

@NotNull
private static List<Alteration> queryCivicAlteration(@NotNull final List<Integer> entrezIds, io.reactivex.functions.Function<List<CivicVariantWithEvidence>, Alteration> alterationBuilder, @NotNull final String error) {
    final CivicApiWrapper civicApi = new CivicApiWrapper();
    final List<Alteration> result = Lists.newArrayList();
    try {
        result.addAll(Observable.fromIterable(entrezIds).flatMap(civicApi::getVariantsForGene).toList().map(alterationBuilder).filter(alteration -> !alteration.getMatches().isEmpty()).toObservable().toList().blockingGet());
    } catch (final Throwable throwable) {
        LOGGER.error("{}. Error message: {}", error, throwable.getMessage());
    }
    civicApi.releaseResources();
    return result;
}
Also used : CivicApiWrapper(com.hartwig.hmftools.apiclients.civic.api.CivicApiWrapper) Alteration(com.hartwig.hmftools.patientreporter.report.data.Alteration) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

CivicApiWrapper (com.hartwig.hmftools.apiclients.civic.api.CivicApiWrapper)3 Alteration (com.hartwig.hmftools.patientreporter.report.data.Alteration)3 NotNull (org.jetbrains.annotations.NotNull)3 Lists (com.google.common.collect.Lists)2 Sets (com.google.common.collect.Sets)2 CivicVariantWithEvidence (com.hartwig.hmftools.apiclients.civic.data.CivicVariantWithEvidence)2 DiseaseOntologyApiWrapper (com.hartwig.hmftools.apiclients.diseaseontology.api.DiseaseOntologyApiWrapper)2 GeneCopyNumber (com.hartwig.hmftools.common.gene.GeneCopyNumber)2 GeneModel (com.hartwig.hmftools.common.gene.GeneModel)2 HmfGenomeRegion (com.hartwig.hmftools.common.region.hmfslicer.HmfGenomeRegion)2 GeneDisruptionData (com.hartwig.hmftools.patientreporter.report.data.GeneDisruptionData)2 GeneFusionData (com.hartwig.hmftools.patientreporter.report.data.GeneFusionData)2 VariantReport (com.hartwig.hmftools.patientreporter.variants.VariantReport)2 Observable (io.reactivex.Observable)2 Collection (java.util.Collection)2 List (java.util.List)2 Set (java.util.Set)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 Predicate (java.util.function.Predicate)2 Collectors (java.util.stream.Collectors)2