Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
687 changes: 11 additions & 676 deletions .classpath

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .java-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
11
21.0.4
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ dependencies {
implementation 'org.springframework.graphql:spring-graphql'
implementation 'org.springframework.boot:spring-boot-starter-cache'
implementation 'com.hazelcast:hazelcast-all:4.2.5'
implementation 'com.graphql-java:graphql-java-extended-scalars:21.0'

testImplementation('org.mockito:mockito-junit-jupiter:3.12.4')
testImplementation 'org.springframework.boot:spring-boot-starter-test'
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/org/kpmp/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import graphql.scalars.ExtendedScalars;
import org.springframework.graphql.execution.RuntimeWiringConfigurer;

@Configuration
@EnableCaching
@SpringBootApplication
Expand All @@ -28,4 +31,9 @@ public void addCorsMappings(CorsRegistry registry) {
}
};
}

@Bean
public RuntimeWiringConfigurer runtimeWiringConfigurer() {
return wiringBuilder -> wiringBuilder.scalar(ExtendedScalars.Json);
}
}
12 changes: 11 additions & 1 deletion src/main/java/org/kpmp/QueryController.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.kpmp.atlasMessage.AtlasMessage;
import org.kpmp.atlasMessage.AtlasMessageService;
import org.kpmp.autocomplete.AutocompleteResult;
import org.kpmp.autocomplete.AutocompleteService;
import org.kpmp.cellType.CellTypeHierarchy;
import org.kpmp.cellType.CellTypeService;
import org.kpmp.cellType.HubmapCellTypeMappingService;
import org.kpmp.cellType.HubmapOntologyCellType;
import org.kpmp.cellTypeSummary.ClusterHierarchy;
import org.kpmp.cellTypeSummary.ClusterHierarchyService;
import org.kpmp.dataSummary.AtlasRepoSummaryResult;
Expand Down Expand Up @@ -43,14 +46,15 @@ public class QueryController implements GraphQLQueryResolver {
private RPExpressionDataService rpExpressionDataService;
private ParticipantService2025 participantService2025;
private AtlasMessageService atlasMessageService;
private HubmapCellTypeMappingService hubmapCellTypeMappingService;
private Logger logger = LoggerFactory.getLogger(QueryController.class);

@Autowired
public QueryController(AutocompleteService autocompleteService, CellTypeService cellTypeService, UmapDataService2025 umapService2025,
GeneExpressionSummaryService2025 geneExpressionService2025,
DataSummaryService dataSummaryService, ClusterHierarchyService clusterHierarchyService,
RTExpressionDataService rtExpressionDataService, RPExpressionDataService rpExpressionDataService, ParticipantService2025 participantService2025,
AtlasMessageService atlasMessageService) {
AtlasMessageService atlasMessageService, HubmapCellTypeMappingService hubmapCellTypeMappingService) {

this.autocompleteService = autocompleteService;
this.cellTypeService = cellTypeService;
Expand All @@ -62,6 +66,7 @@ public QueryController(AutocompleteService autocompleteService, CellTypeService
this.rpExpressionDataService = rpExpressionDataService;
this.participantService2025 = participantService2025;
this.atlasMessageService = atlasMessageService;
this.hubmapCellTypeMappingService = hubmapCellTypeMappingService;
}

@QueryMapping
Expand Down Expand Up @@ -262,4 +267,9 @@ public List<AtlasMessage> getAtlasMessages() throws Exception {
public List<ParticipantRepoDataTypeInformation> getExperimentalStrategyCountsByParticipant(@Argument String redcapId) {
return participantService2025.getExperimentalStrategyCountsByParticipant(redcapId);
}

@QueryMapping
public List<HubmapOntologyCellType> getHubmapTermMap() {
return hubmapCellTypeMappingService.buildHubmapIdToCellTypeMap();
}
}
18 changes: 18 additions & 0 deletions src/main/java/org/kpmp/cellType/HubmapCellTypeMappingService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.kpmp.cellType;

import java.util.List;
import org.springframework.stereotype.Service;

@Service
public class HubmapCellTypeMappingService {

private final HubmapOnotologyCellTypeRepository repo;

public HubmapCellTypeMappingService(HubmapOnotologyCellTypeRepository repo) {
this.repo = repo;
}

public List<HubmapOntologyCellType> buildHubmapIdToCellTypeMap() {
return repo.findAll();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.kpmp.cellType;

import org.jetbrains.annotations.NotNull;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface HubmapOnotologyCellTypeRepository extends CrudRepository<HubmapOntologyCellType, String> {

@NotNull
@Cacheable("hubmapOntologyCellTypeMap")
List<HubmapOntologyCellType> findAll();
}
35 changes: 35 additions & 0 deletions src/main/java/org/kpmp/cellType/HubmapOntologyCellType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package org.kpmp.cellType;

import java.io.Serializable;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;

@Entity
@Table(name = "hubmap_ontology_celltype_v")
public class HubmapOntologyCellType implements Serializable{

@Id
@Column(name = "hubmap_ontology_id", nullable = false, insertable = false, updatable = false)
private String hubmapOntologyId;
private String cellType;

public String getHubmapOntologyId() {
return hubmapOntologyId;
}

public void setHubmapOntologyId(String hubmapOntologyId) {
this.hubmapOntologyId = hubmapOntologyId;
}

public String getCellType() {
return cellType;
}

public void setCellType(String cell_type) {
this.cellType = cell_type;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.util.List;

import org.kpmp.cluster.Cluster;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

import org.springframework.lang.Nullable;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonInclude;

@Entity
@Table(name = "cluster_hierarchy_v")
Expand Down
1 change: 0 additions & 1 deletion src/main/java/org/kpmp/umap/SNMetadataRepository2025.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.util.List;

import org.checkerframework.checker.units.qual.C;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
Expand Down
12 changes: 9 additions & 3 deletions src/main/resources/graphql/knowledge_environment.graphqls
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
type Query {
autocomplete(searchTerm: String): [AutoCompleteResult]
cellTypeHierarchy2025: CellTypeHierarchy
cellTypeHierarchy2025: CellTypeHierarchy
geneExpressionSummary2025(dataType: String, geneSymbol: String, cellType: String, enrollmentCategory: String) : [GeneExpressionSummary2025]
getClusterHieararchies2025(cellType: String!): [ClusterHierarchy]
getClusterHieararchies2025(cellType: String!): [ClusterHierarchy]
getUmapPlotData2025(dataType: String!, geneSymbol: String!, enrollmentCategory: String): PlotData2025
dataTypesForConcept2025(geneSymbol: String, clusterName: String): [String]
dataTypesForConcept2025(geneSymbol: String, clusterName: String): [String]
getDataTypeSummaryInformation2025: [DataTypeSummaryInformation2025]
getRTGeneExpressionByEnrollment(comparisonType: String, geneSymbol: String): RTGeneExpressionByEnrollment
getRPGeneExpressionByEnrollment(geneSymbol: String!): [RPAccessionGroup]
Expand All @@ -21,6 +21,12 @@ type Query {
getAtlasMessages: [AtlasMessages]
getExperimentalStrategyCountsByParticipant(redcapId: String!): [ParticipantRepoDataTypeInformation]
getParticipantClinicalDataset(redcapId: String!): ParticipantClinicalDataset
getHubmapTermMap: [HubmapOntologyCellType]
}

type HubmapOntologyCellType {
hubmapOntologyId: String
cellType: String
}

type AtlasMessages {
Expand Down
24 changes: 23 additions & 1 deletion src/test/java/org/kpmp/QueryControllerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
Expand All @@ -23,6 +24,8 @@
import org.kpmp.autocomplete.AutocompleteResult;
import org.kpmp.autocomplete.AutocompleteService;
import org.kpmp.cellType.CellTypeService;
import org.kpmp.cellType.HubmapCellTypeMappingService;
import org.kpmp.cellType.HubmapOntologyCellType;
import org.kpmp.cellTypeSummary.ClusterHierarchy;
import org.kpmp.cellTypeSummary.ClusterHierarchyService;
import org.kpmp.dataSummary.AtlasRepoSummaryResult;
Expand Down Expand Up @@ -74,13 +77,15 @@ public class QueryControllerTest {
private UmapDataService2025 umapDataService2025;

@Mock ParticipantService2025 participantService2025;
@Mock
HubmapCellTypeMappingService hubmapCellTypeMappingService;

@BeforeEach
public void setUp() throws Exception {
MockitoAnnotations.openMocks(this);
query = new QueryController(autocompleteService, cellTypeService, umapDataService2025,
geneExpressionService2025, dataSummaryService, clusterHierarchyService, rtExpressionDataService, rpExpressionDataService,
participantService2025, atlasMessageService);
participantService2025, atlasMessageService, hubmapCellTypeMappingService);
}

@AfterEach
Expand Down Expand Up @@ -380,4 +385,21 @@ public void testGetExperimentalStrategyCountsByParticipant() {

assertEquals(expectedResults, result);
}
@Test
public void testGetHubmapTermMap() {
HubmapOntologyCellType cellType1 = mock(HubmapOntologyCellType.class);
when(cellType1.getHubmapOntologyId()).thenReturn("HUBMAP:001");
when(cellType1.getCellType()).thenReturn("Podocyte");

HubmapOntologyCellType cellType2 = mock(HubmapOntologyCellType.class);
when(cellType2.getHubmapOntologyId()).thenReturn("HUBMAP:002");
when(cellType2.getCellType()).thenReturn("Tubule cell");

List<HubmapOntologyCellType> expectedList = Arrays.asList(cellType1, cellType2);
when(hubmapCellTypeMappingService.buildHubmapIdToCellTypeMap()).thenReturn(expectedList);

List<HubmapOntologyCellType> result = query.getHubmapTermMap();
assertEquals(expectedList, result);
verify(hubmapCellTypeMappingService).buildHubmapIdToCellTypeMap();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package org.kpmp.cellType;

import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.*;

import java.util.*;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

class HubmapCellTypeMappingServiceTest {
private HubmapOnotologyCellTypeRepository repo;
private HubmapCellTypeMappingService service;

@BeforeEach
void setUp() {
repo = mock(HubmapOnotologyCellTypeRepository.class);
service = new HubmapCellTypeMappingService(repo);
}

@Test
void testBuildHubmapIdToCellTypeMap_returnsCorrectList() {
HubmapOntologyCellType cellType1 = mock(HubmapOntologyCellType.class);
when(cellType1.getHubmapOntologyId()).thenReturn("HUBMAP:001");
when(cellType1.getCellType()).thenReturn("Podocyte");

HubmapOntologyCellType cellType2 = mock(HubmapOntologyCellType.class);
when(cellType2.getHubmapOntologyId()).thenReturn("HUBMAP:002");
when(cellType2.getCellType()).thenReturn("Tubule cell");

List<HubmapOntologyCellType> cellTypes = Arrays.asList(cellType1, cellType2);
when(repo.findAll()).thenReturn(cellTypes);

List<HubmapOntologyCellType> result = service.buildHubmapIdToCellTypeMap();
assertEquals(2, result.size());
assertTrue(result.contains(cellType1));
assertTrue(result.contains(cellType2));
}

@Test
void testBuildHubmapIdToCellTypeMap_emptyListReturnsEmptyList() {
when(repo.findAll()).thenReturn(Collections.emptyList());
List<HubmapOntologyCellType> result = service.buildHubmapIdToCellTypeMap();
assertTrue(result.isEmpty());
}
}
24 changes: 24 additions & 0 deletions src/test/java/org/kpmp/cellType/HubmapOntologyCellTypeTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.kpmp.cellType;

import static org.junit.jupiter.api.Assertions.*;

import org.junit.jupiter.api.Test;

class HubmapOntologyCellTypeTest {
@Test
void testGettersAndSetters() {
HubmapOntologyCellType cellType = new HubmapOntologyCellType();
cellType.setHubmapOntologyId("HUBMAP:123");
cellType.setCellType("Podocyte");

assertEquals("HUBMAP:123", cellType.getHubmapOntologyId());
assertEquals("Podocyte", cellType.getCellType());
}

@Test
void testDefaultValues() {
HubmapOntologyCellType cellType = new HubmapOntologyCellType();
assertNull(cellType.getHubmapOntologyId());
assertNull(cellType.getCellType());
}
}
Loading