|
| 1 | +package org.alliancegenome.indexer; |
| 2 | + |
| 3 | +import java.util.List; |
| 4 | + |
| 5 | +import org.alliancegenome.core.config.ConfigHelper; |
| 6 | +import org.alliancegenome.curation_api.interfaces.document.GeneDocumentInterface; |
| 7 | +import org.alliancegenome.curation_api.model.document.es.GeneSummaryDocument; |
| 8 | +import org.alliancegenome.curation_api.model.entities.Gene; |
| 9 | +import org.alliancegenome.curation_api.model.entities.ontology.OntologyTermClosure; |
| 10 | +import org.alliancegenome.curation_api.model.entities.ontology.SOTerm; |
| 11 | +import org.alliancegenome.curation_api.response.SearchResponse; |
| 12 | +import org.alliancegenome.es.rest.RestConfig; |
| 13 | + |
| 14 | +import si.mazi.rescu.RestProxyFactory; |
| 15 | + |
| 16 | +public class TestAncestors { |
| 17 | + |
| 18 | + public static void main(String[] args) throws Exception { |
| 19 | + long geneId = args.length > 0 ? Long.parseLong(args[0]) : 28821279L; |
| 20 | + |
| 21 | + GeneDocumentInterface geneApi = RestProxyFactory.createProxy(GeneDocumentInterface.class, ConfigHelper.getCurationApiUrl(), RestConfig.config); |
| 22 | + |
| 23 | + System.out.println("=== API URL: " + ConfigHelper.getCurationApiUrl() + " ==="); |
| 24 | + System.out.println("=== Gene ID: " + geneId + " ===\n"); |
| 25 | + |
| 26 | + SearchResponse<GeneSummaryDocument> response = geneApi.findByIds(List.of(geneId)); |
| 27 | + |
| 28 | + System.out.println("=== GeneSummaryDocument from API ==="); |
| 29 | + for (GeneSummaryDocument doc : response.getResults()) { |
| 30 | + Gene gene = doc.getGene(); |
| 31 | + if (gene == null) { |
| 32 | + System.out.println("Gene is null"); |
| 33 | + continue; |
| 34 | + } |
| 35 | + System.out.println("Gene symbol: " + (gene.getGeneSymbol() != null ? gene.getGeneSymbol().getDisplayText() : "null")); |
| 36 | + |
| 37 | + SOTerm geneType = gene.getGeneType(); |
| 38 | + if (geneType == null) { |
| 39 | + System.out.println("geneType is null"); |
| 40 | + continue; |
| 41 | + } |
| 42 | + System.out.println("geneType curie: " + geneType.getCurie()); |
| 43 | + System.out.println("geneType name: " + geneType.getName()); |
| 44 | + |
| 45 | + if (geneType.getAncestors() == null) { |
| 46 | + System.out.println("ancestors: null"); |
| 47 | + } else { |
| 48 | + System.out.println("ancestors count: " + geneType.getAncestors().size()); |
| 49 | + for (OntologyTermClosure closure : geneType.getAncestors()) { |
| 50 | + System.out.println(" " + closure.getClosureObject().getCurie() + " " + closure.getClosureTypes()); |
| 51 | + } |
| 52 | + } |
| 53 | + } |
| 54 | + System.out.println("\n=== Done ==="); |
| 55 | + } |
| 56 | + |
| 57 | +} |
0 commit comments