DefaultDiseaseDao implements DiseaseDao { @Cacheable(value = "diseases") @Override public List<Disease> getDiseaseDataAssociatedWithGeneId(int geneId) { String query = "SELECT" + " gene_id AS entrez_id" + ", symbol AS human_gene_symbol" + ", d.disease_id AS disease_id" + ", d.diseasename AS disease_name" + ", d.TYPE AS disease_type" + ", d.INHERITANCE AS inheritance_code" + ", hp_id AS pheno_ids " + "FROM entrez2sym e, disease_hp dhp, disease d " + "WHERE dhp.disease_id = d.DISEASE_ID " + "AND e.entrezid = d.GENE_ID " + "AND d.TYPE in ('D', 'C', 'S', '?')" + "AND d.GENE_ID = ?"; try (Connection connection = dataSource.getConnection()) { try (PreparedStatement statement = connection.prepareStatement(query)) { statement.setInt(1, geneId); ResultSet rs = statement.executeQuery(); return processDiseaseResults(rs); } } catch (SQLException e) { logger.error("Unable to execute query '{}' for geneId: '{}'", query, geneId, e); } return Collections.emptyList(); } DefaultDiseaseDao(DataSource phenotypeDataSource); @Cacheable(value = "diseaseHp") @Override Set<String> getHpoIdsForDiseaseId(String diseaseId); @Cacheable(value = "diseases") @Override List<Disease> getDiseaseDataAssociatedWithGeneId(int geneId);  }
@Test public void testGetDiseaseDataAssociatedWithGeneId() { List<Disease> expected = Lists.newArrayList(disease) ; assertThat(instance.getDiseaseDataAssociatedWithGeneId(2263), equalTo(expected)); }
@Test public void testGetCnvDiseaseDataAssociatedWithGeneId() { Disease cnv = Disease.builder() .diseaseId("ORPHA:11111") .diseaseName("Test CNV disease") .diseaseType(Disease.DiseaseType.CNV) .inheritanceMode(InheritanceMode.UNKNOWN) .associatedGeneId(2222) .associatedGeneSymbol("GENE2") .phenotypeIds(ImmutableList.of("HP:0000001")) .build(); List<Disease> expected = Lists.newArrayList(cnv) ; assertThat(instance.getDiseaseDataAssociatedWithGeneId(2222), equalTo(expected)); }
@Test public void testGetUnconfirmedDiseaseDataAssociatedWithGeneId() { Disease disease = Disease.builder() .diseaseId("OMIM:123456") .diseaseName("Test unconfirmed disease association") .diseaseType(Disease.DiseaseType.UNCONFIRMED) .inheritanceMode(InheritanceMode.UNKNOWN) .associatedGeneId(3333) .associatedGeneSymbol("GENE3") .phenotypeIds(ImmutableList.of("HP:0000002")) .build(); List<Disease> expected = Lists.newArrayList(disease) ; assertThat(instance.getDiseaseDataAssociatedWithGeneId(3333), equalTo(expected)); }
@Test public void testGetSusceptibilityDiseaseDataAssociatedWithGeneId() { Disease disease = Disease.builder() .diseaseId("OMIM:234567") .diseaseName("Test susceptibility disease association") .diseaseType(Disease.DiseaseType.SUSCEPTIBILITY) .inheritanceMode(InheritanceMode.UNKNOWN) .associatedGeneId(4444) .associatedGeneSymbol("GENE4") .phenotypeIds(ImmutableList.of("HP:0000002")) .build(); List<Disease> expected = Lists.newArrayList(disease) ; assertThat(instance.getDiseaseDataAssociatedWithGeneId(4444), equalTo(expected)); }