forked from phenotips/remote-matching
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue phenotips#25: Convert all remote gene IDs to the same standard …
…we use in PhenpoTips. Using getTerms() from GeneNomenclature class
- Loading branch information
1 parent
57f3121
commit fdcc2af
Showing
1 changed file
with
31 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,23 +30,39 @@ | |
import org.phenotips.remote.common.internal.RemotePatientFeature; | ||
import org.phenotips.remote.common.internal.RemotePatientGene; | ||
import org.phenotips.remote.common.internal.RemotePatientContactInfo; | ||
import org.phenotips.vocabulary.Vocabulary; | ||
import org.phenotips.vocabulary.VocabularyTerm; | ||
import org.slf4j.Logger; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
import java.util.regex.Pattern; | ||
|
||
import javax.inject.Inject; | ||
import javax.inject.Named; | ||
|
||
import net.sf.json.JSONArray; | ||
import net.sf.json.JSONObject; | ||
|
||
public class DefaultJSONToMatchingPatientConverter implements JSONToMatchingPatientConverter | ||
{ | ||
private static final String ENSEMBL_GENE_ID_FIELD_NAME = "ensembl_gene_id"; | ||
|
||
private static final String ENTREZ_ID_FIELD_NAME = "entrez_id"; | ||
|
||
This comment has been minimized.
Sorry, something went wrong. |
||
private Logger logger; | ||
|
||
private final String apiVersion; | ||
|
||
private final Pattern hpoTerm; // not static: may be different from api version to api version | ||
private final Pattern disorderTerm; | ||
|
||
@Inject | ||
@Named("hgnc") | ||
private Vocabulary ontologyService; | ||
|
||
public DefaultJSONToMatchingPatientConverter(String apiVersion, Logger logger) | ||
{ | ||
|
@@ -172,8 +188,21 @@ private Set<MatchingPatientGene> convertGenes(JSONObject json) | |
throw new ApiViolationException("A gene has no id"); | ||
} | ||
// TODO: check if name is a valid gene symbol or ensembl id | ||
MatchingPatientGene gene = new RemotePatientGene(geneName); | ||
geneSet.add(gene); | ||
|
||
Collection<String> symbols = new ArrayList<String>(); | ||
symbols.add(geneName); | ||
Set<VocabularyTerm> matches = this.ontologyService.getTerms(symbols); | ||
|
||
if (matches != null) { | ||
for (VocabularyTerm term : matches) { | ||
This comment has been minimized.
Sorry, something went wrong.
allasm
|
||
MatchingPatientGene gene = new RemotePatientGene((String) term.get("symbol")); | ||
geneSet.add(gene); | ||
} | ||
} else { | ||
MatchingPatientGene gene = new RemotePatientGene(geneName); | ||
geneSet.add(gene); | ||
} | ||
|
||
// TODO: variants | ||
} | ||
return geneSet; | ||
|
These are not used anywhere as of this commit... but I think they should be used as we only want to check for those two specific kinds of IDs, not any Id system "hgnc" ontologyService supports.