private Pair<VariantAnnotationDiff, VariantAnnotationDiff> compare(VariantAnnotation variant1, VariantAnnotation variant2) { Pair<VariantAnnotationDiff, VariantAnnotationDiff> result = Pair.of(new VariantAnnotationDiff(), new VariantAnnotationDiff()); compareSequenceOntologyTerms(result, variant1.getConsequenceTypes(), variant2.getConsequenceTypes()); return result; }
@Override protected Collection<String> featureValueOf(VariantAnnotation actual) { return actual.getConsequenceTypes().stream().map(ConsequenceType::getGeneName).collect(Collectors.toList()); } };
@Override protected Collection<String> featureValueOf(VariantAnnotation actual) { return actual.getConsequenceTypes() .stream() .map(ConsequenceType::getSequenceOntologyTerms) .flatMap(Collection::stream) .map(SequenceOntologyTerm::getAccession) .collect(Collectors.toSet()); } };
public List<Pair<VariantAnnotationDiff, VariantAnnotationDiff>> apply(List<VariantAnnotation> batch) throws Exception { // VEP format does not include the reference allele. It's needed for the benchmark if the cache is activated - // otherwise VariantAnnotationCalculator wont find most of the variants in the variation collection fixReference(batch); removeInvalidVariants(batch); List<Variant> cellBaseBatch = createEmptyVariantList(batch); variantAnnotator.run(cellBaseBatch); List<Pair<VariantAnnotationDiff, VariantAnnotationDiff>> comparisonResultList = new ArrayList<>(); for (int i = 0; i < batch.size(); i++) { // Variants such as MT:453:TTT:ATT are skipped for the benchmark - will not have CellBase annotation // compatible with VEP annotation and therefore consequenceTypeList = null if (batch.get(i).getConsequenceTypes() != null && batch.get(i).getConsequenceTypes().size() > 0 && cellBaseBatch.get(i).getAnnotation().getConsequenceTypes() != null && cellBaseBatch.get(i).getAnnotation().getConsequenceTypes().size() > 0) { Pair<VariantAnnotationDiff, VariantAnnotationDiff> comparisonResult = compare(batch.get(i), cellBaseBatch.get(i).getAnnotation()); comparisonResult.getLeft().setVariantAnnotation(batch.get(i)); comparisonResult.getRight().setVariantAnnotation(cellBaseBatch.get(i).getAnnotation()); comparisonResultList.add(comparisonResult); } } return comparisonResultList; }
private void updateVariantSetStats(VariantAnnotation annotation) { if (annotation != null) { for (ConsequenceType consequenceType : annotation.getConsequenceTypes()) { String biotype = consequenceType.getBiotype(); if (StringUtils.isNotEmpty(biotype)) { stats.addVariantBiotypeCounts(biotype, 1); } if (consequenceType.getSequenceOntologyTerms() != null) { for (SequenceOntologyTerm term : consequenceType.getSequenceOntologyTerms()) { stats.addConsequenceTypeCounts(term.getAccession(), 1); } } } } }
Collections.emptyList(), Collections.emptyMap()); if (variant.getAnnotation() != null && ListUtils.isNotEmpty(variant.getAnnotation().getConsequenceTypes())) { for (ConsequenceType ct : variant.getAnnotation().getConsequenceTypes()) { if (genePanelMap.containsKey(ct.getEnsemblGeneId())) {
private Map<String, ConsequenceType> getConsequenceTypeMap (Variant variant){ Map<String, ConsequenceType> map = new HashMap<>(); if (variant.getAnnotation() != null && ListUtils.isNotEmpty(variant.getAnnotation().getConsequenceTypes())) { for (ConsequenceType consequenceType: variant.getAnnotation().getConsequenceTypes()) { if (StringUtils.isNotEmpty(consequenceType.getEnsemblTranscriptId())) { map.put(consequenceType.getEnsemblTranscriptId(), consequenceType); } } } return map; }
@Override protected Iterable<T> featureValueOf(VariantAnnotation actual) { if (actual.getConsequenceTypes() != null) { Set<T> set = new HashSet<>(); for (ConsequenceType ct : actual.getConsequenceTypes()) { if (ct != null && ct.getProteinVariantAnnotation() != null && ct.getProteinVariantAnnotation().getSubstitutionScores() != null) { for (Score score : ct.getProteinVariantAnnotation().getSubstitutionScores()) { if (score != null && source.equals(score.getSource())) { set.add(mapper.apply(score)); } } } } return set; } return Collections.emptyList(); } };
private void generateReportedVariants(List<Variant> variantList, Phenotype phenotype, Panel diseasePanel, ClinicalProperty.ModeOfInheritance moi, Map<String, ReportedVariant> reportedVariantMap) { for (Variant variant : variantList) { if (!reportedVariantMap.containsKey(variant.getId())) { reportedVariantMap.put(variant.getId(), new ReportedVariant(variant.getImpl(), 0, new ArrayList<>(), Collections.emptyList(), Collections.emptyMap())); } ReportedVariant reportedVariant = reportedVariantMap.get(variant.getId()); // Sanity check if (variant.getAnnotation() != null && ListUtils.isNotEmpty(variant.getAnnotation().getConsequenceTypes())) { for (ConsequenceType ct: variant.getAnnotation().getConsequenceTypes()) { // Create the reported event ReportedEvent reportedEvent = new ReportedEvent() .setId("JT-PF-" + reportedVariant.getReportedEvents().size()) .setPhenotypes(Collections.singletonList(phenotype)) .setConsequenceTypeIds(Collections.singletonList(ct.getBiotype())) .setGenomicFeature(new GenomicFeature(ct.getEnsemblGeneId(), ct.getEnsemblTranscriptId(), ct.getGeneName(), null, null)) .setModeOfInheritance(moi) .setPanelId(diseasePanel.getDiseasePanel().getId()); // TODO: add additional reported event fields // Add reported event to the reported variant reportedVariant.getReportedEvents().add(reportedEvent); } } } }
private void generateReportedVariants(VariantQueryResult<Variant> variantQueryResult, Phenotype phenotype, Panel diseasePanel, ClinicalProperty.ModeOfInheritance moi, Penetrance penetrance, Map<String, ReportedVariant> reportedVariantMap) { for (Variant variant: variantQueryResult.getResult()) { if (!reportedVariantMap.containsKey(variant.getId())) { reportedVariantMap.put(variant.getId(), new ReportedVariant(variant.getImpl(), 0, new ArrayList<>(), Collections.emptyList(), Collections.emptyMap())); } ReportedVariant reportedVariant = reportedVariantMap.get(variant.getId()); // Sanity check if (variant.getAnnotation() != null && ListUtils.isNotEmpty(variant.getAnnotation().getConsequenceTypes())) { for (ConsequenceType ct: variant.getAnnotation().getConsequenceTypes()) { // Create the reported event ReportedEvent reportedEvent = new ReportedEvent() .setId("JT-PF-" + reportedVariant.getReportedEvents().size()) .setPhenotypes(Collections.singletonList(phenotype)) .setConsequenceTypeIds(Collections.singletonList(ct.getBiotype())) .setGenomicFeature(new GenomicFeature(ct.getEnsemblGeneId(), ct.getEnsemblTranscriptId(), ct.getGeneName(), null, null)) .setModeOfInheritance(moi) .setPanelId(diseasePanel.getDiseasePanel().getId()) .setPenetrance(penetrance); // TODO: add additional reported event fields // Add reported event to the reported variant reportedVariant.getReportedEvents().add(reportedEvent); } } } }
private void mergeAnnotation(VariantAnnotation destination, VariantAnnotation origin) { destination.setChromosome(origin.getChromosome()); destination.setStart(origin.getStart()); destination.setReference(origin.getReference()); destination.setAlternate(origin.getAlternate()); if (annotatorSet.contains("variation")) { destination.setId(origin.getId()); } if (annotatorSet.contains("consequenceType")) { destination.setDisplayConsequenceType(origin.getDisplayConsequenceType()); destination.setConsequenceTypes(origin.getConsequenceTypes()); } if (annotatorSet.contains("conservation")) { destination.setConservation(origin.getConservation()); } // destination.setGeneExpression(origin.getGeneExpression()); // destination.setGeneTraitAssociation(origin.getGeneTraitAssociation()); if (annotatorSet.contains("populationFrequencies")) { destination.setPopulationFrequencies(origin.getPopulationFrequencies()); } // destination.setGeneDrugInteraction(origin.getGeneDrugInteraction()); if (annotatorSet.contains("clinical")) { destination.setVariantTraitAssociation(origin.getVariantTraitAssociation()); } if (annotatorSet.contains("functionalScore")) { destination.setFunctionalScore(origin.getFunctionalScore()); } }
private void mergeAnnotation(VariantAnnotation destination, VariantAnnotation origin) { destination.setChromosome(origin.getChromosome()); destination.setStart(origin.getStart()); destination.setReference(origin.getReference()); destination.setAlternate(origin.getAlternate()); if (annotatorSet.contains("variation")) { destination.setId(origin.getId()); } if (annotatorSet.contains("consequenceType")) { destination.setDisplayConsequenceType(origin.getDisplayConsequenceType()); destination.setConsequenceTypes(origin.getConsequenceTypes()); } if (annotatorSet.contains("conservation")) { destination.setConservation(origin.getConservation()); } // destination.setGeneExpression(origin.getGeneExpression()); // destination.setGeneTraitAssociation(origin.getGeneTraitAssociation()); if (annotatorSet.contains("populationFrequencies")) { destination.setPopulationFrequencies(origin.getPopulationFrequencies()); } // destination.setGeneDrugInteraction(origin.getGeneDrugInteraction()); if (annotatorSet.contains("clinical")) { destination.setVariantTraitAssociation(origin.getVariantTraitAssociation()); } if (annotatorSet.contains("functionalScore")) { destination.setFunctionalScore(origin.getFunctionalScore()); } }
for (Variant variant : allVariantsQueryResult.getResult()) { HashSet<String> genesInVariant = new HashSet<>(); for (ConsequenceType consequenceType : variant.getAnnotation().getConsequenceTypes()) { String geneName = consequenceType.getGeneName(); if (geneName != null) {
@Test public void testConvertToDataModelType() throws Exception { DocumentToVariantAnnotationConverter documentToVariantAnnotationConverter = new DocumentToVariantAnnotationConverter(); VariantAnnotation convertedVariantAnnotation = documentToVariantAnnotationConverter.convertToDataModelType(dbObject); assertEquals(convertedVariantAnnotation.getConsequenceTypes().get(2).getProteinVariantAnnotation().getReference(), "CYS"); assertEquals(convertedVariantAnnotation.getVariantTraitAssociation().getCosmic().get(0).getPrimarySite(), "large_intestine"); }
for (ConsequenceType consequenceType : variantAnnotationDiff.getVariantAnnotation().getConsequenceTypes()) { for (SequenceOntologyTerm sequenceOntologyTerm : consequenceType.getSequenceOntologyTerms()) { if (isRegulatory(sequenceOntologyTerm.getName())) {
for (Variant variant : allVariants.getResult()) { Set<String> keywordsInVariant = new HashSet<>(); if (variant.getAnnotation().getConsequenceTypes() != null) { for (ConsequenceType consequenceType : variant.getAnnotation().getConsequenceTypes()) { if (consequenceType.getProteinVariantAnnotation() != null && consequenceType.getProteinVariantAnnotation().getKeywords() != null) { keywordsInVariant.addAll(consequenceType.getProteinVariantAnnotation().getKeywords());
public void testQueries(VariantStorageEngine variantStorageEngine) throws StorageEngineException { long count = variantStorageEngine.count(new Query()).first(); long partialCount = 0; int batchSize = (int) Math.ceil(count / 10.0); for (int i = 0; i < 10; i++) { partialCount += variantStorageEngine.getAnnotation("v2", null, new QueryOptions(QueryOptions.LIMIT, batchSize) .append(QueryOptions.SKIP, batchSize * i)).getResult().size(); } assertEquals(count, partialCount); for (int chr = 1; chr < 22; chr += 2) { Query query = new Query(VariantQueryParam.REGION.key(), chr + "," + (chr + 1)); count = variantStorageEngine.count(query).first(); partialCount = variantStorageEngine.getAnnotation("v2", query, new QueryOptions()).getResult().size(); assertEquals(count, partialCount); } String consequenceTypes = VariantField.ANNOTATION_CONSEQUENCE_TYPES.fieldName().replace(VariantField.ANNOTATION.fieldName() + ".", ""); for (VariantAnnotation annotation : variantStorageEngine.getAnnotation("v2", null, new QueryOptions(QueryOptions.INCLUDE, consequenceTypes)).getResult()) { assertEquals(1, annotation.getConsequenceTypes().size()); } for (VariantAnnotation annotation : variantStorageEngine.getAnnotation("v2", null, new QueryOptions(QueryOptions.EXCLUDE, consequenceTypes)).getResult()) { assertTrue(annotation.getConsequenceTypes() == null || annotation.getConsequenceTypes().isEmpty()); } // Get annotations from a deleted snapshot thrown.expectMessage("Variant Annotation snapshot \"v1\" not found!"); assertEquals(0, variantStorageEngine.getAnnotation("v1", null, null).getResult().size()); }
Set<String> flagsInVariant = new HashSet<>(); for (Variant variant : allVariants.getResult()) { if (variant.getAnnotation().getConsequenceTypes() != null) { for (ConsequenceType consequenceType : variant.getAnnotation().getConsequenceTypes()) { if (consequenceType.getTranscriptAnnotationFlags() != null) { flagsInVariant.addAll(consequenceType.getTranscriptAnnotationFlags());
private void mergeAnnotation(VariantAnnotation destination, VariantAnnotation origin) { if (origin != null) { destination.setId(origin.getId()); destination.setChromosome(origin.getChromosome()); destination.setStart(origin.getStart()); destination.setReference(origin.getReference()); destination.setAlternate(origin.getAlternate()); destination.setDisplayConsequenceType(origin.getDisplayConsequenceType()); destination.setConsequenceTypes(origin.getConsequenceTypes()); destination.setConservation(origin.getConservation()); destination.setGeneExpression(origin.getGeneExpression()); destination.setGeneTraitAssociation(origin.getGeneTraitAssociation()); destination.setGeneDrugInteraction(origin.getGeneDrugInteraction()); destination.setVariantTraitAssociation(origin.getVariantTraitAssociation()); destination.setFunctionalScore(origin.getFunctionalScore()); } }
List<ConsequenceType> consequenceTypes = annotation.getConsequenceTypes(); if (consequenceTypes != null) { for (ConsequenceType type : consequenceTypes) {