Skip to content

Commit

Permalink
Issue phenotips#25: Convert all remote gene IDs to the same standard …
Browse files Browse the repository at this point in the history
…we use in PhenpoTips. Using getTerms() from GeneNomenclature class
  • Loading branch information
veronikaslc committed Jul 28, 2015
1 parent 57f3121 commit fdcc2af
Showing 1 changed file with 31 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Copy link
@allasm

allasm Aug 4, 2015

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.

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)
{
Expand Down Expand Up @@ -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.

Copy link
@allasm

allasm Aug 4, 2015

Need to think what to do if there is more than one term (ambiguous ID? an error should likley be returned?) - supposedly if there is just one gene in the request there should only be one gene added

MatchingPatientGene gene = new RemotePatientGene((String) term.get("symbol"));
geneSet.add(gene);
}
} else {
MatchingPatientGene gene = new RemotePatientGene(geneName);
geneSet.add(gene);
}

// TODO: variants
}
return geneSet;
Expand Down

0 comments on commit fdcc2af

Please sign in to comment.