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