Skip to content

Commit

Permalink
fix truncation of results in phased queries where checkAminoAcidChang…
Browse files Browse the repository at this point in the history
…e=TRUE
  • Loading branch information
julie-sullivan committed May 10, 2024
1 parent 596816d commit c627596
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,57 +34,53 @@ public List<CellBaseDataResult<Variant>> run(List<Variant> variantList,
CellBaseDataResult<Variant> variantCellBaseDataResult = variantCellBaseDataResultList.get(j);
if (variantCellBaseDataResult != null && variantCellBaseDataResult.getResults() != null
&& !variantCellBaseDataResult.getResults().isEmpty()) {
// Variants are normalised and data from each of the sources (COSMIC, ClinVar, DOCM, etc.) integrated
// during the build process. Only one variant record should be present per assembly.
if (variantCellBaseDataResult.getResults().size() > 1) {
logger.warn("More than one result found either the clinical_variants or variation collection"
+ "for variant " + variantCellBaseDataResult.getId() + ". Arbitrarily selecting the first one. "
+ "Please, check.");
}

Variant matchedVariant = variantCellBaseDataResult.getResults().get(0);
Variant queryVariant = variantList.get(j);
List<T> annotationObjectList = getAnnotationObjectList(matchedVariant);
// Phase is stored at the evidence entry/population frequency level, e.g.: there might be two ClinVar
// RCVs for one variant:
// - In the first the variant is submitted as part of an MNV and therefore it is phased
// - In the second one the variant is submitted singleton and therefore it is not phased
// both RCVs will be integrated in the same Variant object after decomposition as separate EvidenceEntry
// objects, each with its corresponding phase information
int i = 0;
while (i < annotationObjectList.size()) {
T annotationObject = annotationObjectList.get(i);
List<Variant> databaseHaplotype = getHaplotype(annotationObject, matchedVariant);
// Haplotype empty if EvidenceEntry/PopulationFrequency is not phased
if (databaseHaplotype.isEmpty()) {
i++;
} else {
// Sample Cellbase Match
// -------------------------------
// SNV MNV X
// MNV MNV ✓
// Missing genotypes in the input list will be considered as wildcards towards finding a
// matching haplotype (MNV) in the input list, since otherwise the clinical variant would not be
// returned
if (sameHaplotype(queryVariant, variantList, databaseHaplotype)) {
boolean queryVariantHasTraitAssociations = false;
for (Variant matchedVariant: variantCellBaseDataResult.getResults()) {
List<T> annotationObjectList = getAnnotationObjectList(matchedVariant);
// Phase is stored at the evidence entry/population frequency level, e.g.: there might be two ClinVar
// RCVs for one variant:
// - In the first the variant is submitted as part of an MNV and therefore it is phased
// - In the second one the variant is submitted singleton and therefore it is not phased
// both RCVs will be integrated in the same Variant object after decomposition as separate EvidenceEntry
// objects, each with its corresponding phase information
int i = 0;
while (i < annotationObjectList.size()) {
T annotationObject = annotationObjectList.get(i);
List<Variant> databaseHaplotype = getHaplotype(annotationObject, matchedVariant);
// Haplotype empty if EvidenceEntry/PopulationFrequency is not phased
if (databaseHaplotype.isEmpty()) {
i++;
} else {
annotationObjectList.remove(i);
boolean queryVariantInDBHaplotype = getVariant(databaseHaplotype, queryVariant) != null;
// Sample Cellbase Match
// -------------------------------
// SNV MNV X
// MNV MNV ✓
// Missing genotypes in the input list will be considered as wildcards towards finding a
// matching haplotype (MNV) in the input list, since otherwise the clinical variant would not be
// returned
if (queryVariantInDBHaplotype && sameHaplotype(queryVariant, variantList, databaseHaplotype)) {
i++;
} else {
annotationObjectList.remove(i);
}
// Sample Cellbase Match
// -------------------------------
// SNV SNV ✓
// MNV SNV ✓
}
// Sample Cellbase Match
// -------------------------------
// SNV SNV ✓
// MNV SNV ✓
}
if (!annotationObjectList.isEmpty()) {
queryVariantHasTraitAssociations = true;
}
}

// Remove whole variant from the query result object if ended up without any evidence entry
if (annotationObjectList.isEmpty()) {
if (!queryVariantHasTraitAssociations) {
reset(variantCellBaseDataResult);
}
}
}

return variantCellBaseDataResultList;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public static boolean isMissing(String field) {
return StringUtils.isBlank(field) || field.equals(MISSING_VALUE);
}

private Variant getVariant(List<Variant> variantList, Variant variant) {
protected Variant getVariant(List<Variant> variantList, Variant variant) {
for (Variant variant1 : variantList) {
// TODO: simple chr, start, ref, alt matching here - shall implement something fancier
if (variant.getChromosome().equals(variant1.getChromosome())
Expand Down

0 comments on commit c627596

Please sign in to comment.