-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2427 from opencb/TASK-5878
TASK-5878 - Unable to filter by dbSNP (rsIds) and HGVS id in variant browser
- Loading branch information
Showing
22 changed files
with
594 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 106 additions & 0 deletions
106
...pencb/opencga/storage/core/variant/annotation/converters/VariantAnnotationModelUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
package org.opencb.opencga.storage.core.variant.annotation.converters; | ||
|
||
import org.apache.commons.collections4.CollectionUtils; | ||
import org.opencb.biodata.models.variant.avro.*; | ||
|
||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
public class VariantAnnotationModelUtils { | ||
|
||
/** | ||
* Extracts all the XRefs from a VariantAnnotation object. | ||
* Includes: | ||
* - annotation.id | ||
* - annotation.xrefs.id | ||
* - annotation.hgvs | ||
* - annotation.consequenceTypes.geneName | ||
* - annotation.consequenceTypes.geneId | ||
* - annotation.consequenceTypes.ensemblGeneId | ||
* - annotation.consequenceTypes.transcriptId | ||
* - annotation.consequenceTypes.ensemblTranscriptId | ||
* - annotation.consequenceTypes.hgvs | ||
* - annotation.consequenceTypes.proteinVariantAnnotation.uniprotAccession | ||
* - annotation.consequenceTypes.proteinVariantAnnotation.uniprotName | ||
* - annotation.consequenceTypes.proteinVariantAnnotation.uniprotVariantId | ||
* - annotation.consequenceTypes.proteinVariantAnnotation.features.id | ||
* - annotation.traitAssociation.id | ||
* - annotation.geneTraitAssociation.hpo | ||
* - annotation.geneTraitAssociation.id | ||
* | ||
* @param variantAnnotation VariantAnnotation object | ||
* @return Set of XRefs | ||
*/ | ||
public Set<String> extractXRefs(VariantAnnotation variantAnnotation) { | ||
Set<String> xrefs = new HashSet<>(); | ||
|
||
if (variantAnnotation == null) { | ||
return xrefs; | ||
} | ||
|
||
xrefs.add(variantAnnotation.getId()); | ||
|
||
if (variantAnnotation.getXrefs() != null) { | ||
for (Xref xref : variantAnnotation.getXrefs()) { | ||
if (xref != null) { | ||
xrefs.add(xref.getId()); | ||
} | ||
} | ||
} | ||
|
||
if (variantAnnotation.getHgvs() != null) { | ||
xrefs.addAll(variantAnnotation.getHgvs()); | ||
} | ||
|
||
List<ConsequenceType> consequenceTypes = variantAnnotation.getConsequenceTypes(); | ||
if (consequenceTypes != null) { | ||
for (ConsequenceType conseqType : consequenceTypes) { | ||
xrefs.add(conseqType.getGeneName()); | ||
xrefs.add(conseqType.getGeneId()); | ||
xrefs.add(conseqType.getEnsemblGeneId()); | ||
xrefs.add(conseqType.getTranscriptId()); | ||
xrefs.add(conseqType.getEnsemblTranscriptId()); | ||
|
||
if (conseqType.getHgvs() != null) { | ||
xrefs.addAll(conseqType.getHgvs()); | ||
} | ||
|
||
ProteinVariantAnnotation protVarAnnotation = conseqType.getProteinVariantAnnotation(); | ||
if (protVarAnnotation != null) { | ||
|
||
xrefs.add(protVarAnnotation.getUniprotAccession()); | ||
xrefs.add(protVarAnnotation.getUniprotName()); | ||
xrefs.add(protVarAnnotation.getUniprotVariantId()); | ||
|
||
if (protVarAnnotation.getFeatures() != null) { | ||
for (ProteinFeature proteinFeature : protVarAnnotation.getFeatures()) { | ||
xrefs.add(proteinFeature.getId()); | ||
} | ||
} | ||
} | ||
} | ||
|
||
} | ||
|
||
if (CollectionUtils.isNotEmpty(variantAnnotation.getTraitAssociation())) { | ||
for (EvidenceEntry evidenceEntry : variantAnnotation.getTraitAssociation()) { | ||
xrefs.add(evidenceEntry.getId()); | ||
} | ||
} | ||
|
||
if (variantAnnotation.getGeneTraitAssociation() != null) { | ||
for (GeneTraitAssociation geneTrait : variantAnnotation.getGeneTraitAssociation()) { | ||
xrefs.add(geneTrait.getHpo()); | ||
xrefs.add(geneTrait.getId()); | ||
} | ||
} | ||
|
||
// Remove empty strings and nulls | ||
xrefs.remove(""); | ||
xrefs.remove(null); | ||
|
||
return xrefs; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.