Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix truncation of results in phased queries where checkAminoAcidChange=TRUE #690

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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