diff --git a/.gitignore b/.gitignore index e91f6df..be5bcb0 100755 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,4 @@ build bin .gradle .DS_Store +.vscode diff --git a/src/main/java/org/kpmp/DataTypeEnum.java b/src/main/java/org/kpmp/DataTypeEnum.java index 704d74a..1dbb22a 100755 --- a/src/main/java/org/kpmp/DataTypeEnum.java +++ b/src/main/java/org/kpmp/DataTypeEnum.java @@ -5,6 +5,8 @@ public enum DataTypeEnum { SINGLE_CELL("sc"), SINGLE_NUCLEUS("sn"), REGIONAL_TRANSCRIPTOMICS("rt"), + + REGIONAL_PROTEOMICS("rp"), SPATIAL_TRANSCRIPTOMICS("st"), TISSUE_IMAGING_AND_CYTOMETRY_3D("3d"), LIGHT_MICROSCOPIC_WHOLE_SLIDE_IMAGES("wsi"), @@ -31,6 +33,8 @@ public static DataTypeEnum fromAbbreviation(String abbreviation) { return SINGLE_NUCLEUS; } else if (REGIONAL_TRANSCRIPTOMICS.abbreviation.equals(abbreviation)) { return REGIONAL_TRANSCRIPTOMICS; + } else if (REGIONAL_PROTEOMICS.abbreviation.equals(abbreviation)) { + return REGIONAL_PROTEOMICS; } else if (SPATIAL_TRANSCRIPTOMICS.abbreviation.equals(abbreviation)) { return SPATIAL_TRANSCRIPTOMICS; } else if (TISSUE_IMAGING_AND_CYTOMETRY_3D.abbreviation.equals(abbreviation)) { diff --git a/src/main/java/org/kpmp/FullDataTypeEnum.java b/src/main/java/org/kpmp/FullDataTypeEnum.java index 4e48c1e..f0eab0b 100755 --- a/src/main/java/org/kpmp/FullDataTypeEnum.java +++ b/src/main/java/org/kpmp/FullDataTypeEnum.java @@ -5,6 +5,8 @@ public enum FullDataTypeEnum { SINGLE_CELL_FULL("Single-cell RNA-seq (scRNA-seq)"), SINGLE_NUCLEUS_FULL("Single-nucleus RNA-seq (snRNA-seq)"), REGIONAL_TRANSCRIPTOMICS_FULL("Regional transcriptomics"), + + REGIONAL_PROTEOMICS_FULL("Regional proteomics"), SPATIAL_TRANSCRIPTOMICS_FULL("Spatial Transcriptomics"), TISSUE_IMAGING_AND_CYTOMETRY_3D_FULL("3D Tissue Imaging and Cytometry"), LIGHT_MICROSCOPIC_WHOLE_SLIDE_IMAGES_FULL("Light Microscopic Whole Slide Images"), @@ -31,6 +33,8 @@ public static FullDataTypeEnum fromLong(String dataEnum) { return SINGLE_NUCLEUS_FULL; } else if (REGIONAL_TRANSCRIPTOMICS_FULL.dataEnum.equals(dataEnum)) { return REGIONAL_TRANSCRIPTOMICS_FULL; + } else if (REGIONAL_PROTEOMICS_FULL.dataEnum.equals(dataEnum)) { + return REGIONAL_PROTEOMICS_FULL; } else if (SPATIAL_TRANSCRIPTOMICS_FULL.dataEnum.equals(dataEnum)) { return SPATIAL_TRANSCRIPTOMICS_FULL; } else if (TISSUE_IMAGING_AND_CYTOMETRY_3D_FULL.dataEnum.equals(dataEnum)) { diff --git a/src/main/java/org/kpmp/Query.java b/src/main/java/org/kpmp/Query.java index e5aaa72..df1487a 100755 --- a/src/main/java/org/kpmp/Query.java +++ b/src/main/java/org/kpmp/Query.java @@ -4,6 +4,8 @@ import java.util.ArrayList; import java.util.List; +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; @@ -13,9 +15,7 @@ import org.kpmp.dataSummary.AtlasRepoSummaryResult; import org.kpmp.dataSummary.DataSummaryService; import org.kpmp.dataSummary.DataTypeSummary; -import org.kpmp.geneExpression.RTExpressionByTissueType; -import org.kpmp.geneExpression.RTExpressionData; -import org.kpmp.geneExpression.RTExpressionDataService; +import org.kpmp.geneExpression.*; import org.kpmp.geneExpressionSummary.GeneExpressionSummary; import org.kpmp.geneExpressionSummary.GeneExpressionSummaryService; import org.kpmp.participant.ParticipantDataTypeSummary; @@ -43,14 +43,18 @@ public class Query implements GraphQLQueryResolver { private UmapDataService umapService; private ClusterHierarchyService clusterHierarchyService; private RTExpressionDataService rtExpressionDataService; + + private RPExpressionDataService rpExpressionDataService; private ParticipantService participantService; + private AtlasMessageService atlasMessageService; private Logger logger = LoggerFactory.getLogger(Query.class); @Autowired public Query(AutocompleteService autocompleteService, CellTypeService cellTypeService, UmapDataService umapService, GeneExpressionSummaryService geneExpressionSummaryService, DataSummaryService dataSummaryService, ClusterHierarchyService clusterHierarchyService, - RTExpressionDataService rtExpressionDataService, ParticipantService participantService) { + RTExpressionDataService rtExpressionDataService, RPExpressionDataService rpExpressionDataService, + ParticipantService participantService, AtlasMessageService atlasMessageService) { this.autocompleteService = autocompleteService; this.cellTypeService = cellTypeService; @@ -59,7 +63,9 @@ public Query(AutocompleteService autocompleteService, CellTypeService cellTypeSe this.dataSummaryService = dataSummaryService; this.clusterHierarchyService = clusterHierarchyService; this.rtExpressionDataService = rtExpressionDataService; + this.rpExpressionDataService = rpExpressionDataService; this.participantService = participantService; + this.atlasMessageService = atlasMessageService; } public List autocomplete(String searchTerm) throws IOException, Exception { @@ -95,9 +101,9 @@ public PlotData getUmapPlotData(String dataType, String geneSymbol, String tissu } } - public List getGeneDatasetInformation(String geneSymbol) throws Exception { + public List getDataTypeSummaryInformation() throws Exception { try { - return geneExpressionSummaryService.getGeneDatasetInformation(geneSymbol); + return geneExpressionSummaryService.getDataTypeSummaryInformation(); } catch (Exception e) { logger.error(e.getMessage()); throw e; @@ -133,6 +139,15 @@ public RTExpressionByTissueType getRTGeneExpressionByTissue(String comparisonTyp } } + public RPExpressionByTissueType getRPGeneExpressionByTissueAndProtein(String geneSymbol, String protein) throws Exception { + try { + return rpExpressionDataService.getByGeneSymbolAndProteinPerTissue(geneSymbol, protein); + } catch (Exception e) { + logger.error(e.getMessage()); + throw e; + } + } + public List getRTGeneExpressionByStructure(String structure) throws Exception { try { return rtExpressionDataService.getByStructure(structure); @@ -142,6 +157,24 @@ public List getRTGeneExpressionByStructure(String st } } + public List getRPGeneExpressionByStructure(String structure) throws Exception { + try { + return rpExpressionDataService.getByStructure(structure); + } catch (Exception e) { + logger.error(e.getMessage()); + throw e; + } + } + public List getRPGeneExpressionByTissue(String geneSymbol) + throws Exception { + try { + return rpExpressionDataService.getByGeneSymbolPerTissue(geneSymbol); + } catch (Exception e) { + logger.error(e.getMessage()); + throw e; + } + } + public ParticipantDataTypeSummary getDataTypeInformationByParticipant(String redcapId) { return participantService.getExperimentCounts(redcapId); } @@ -192,4 +225,13 @@ public AtlasRepoSummaryResult getAtlasSummaryRows() throws Exception { throw e; } } + + public List getAtlasMessages() throws Exception { + try{ + return atlasMessageService.getAtlasMessage(); + }catch (Exception e){ + logger.error("Unable to get Atlas Message data: ", e.getMessage()); + throw e; + } + } } \ No newline at end of file diff --git a/src/main/java/org/kpmp/atlasMessage/AtlasMessage.java b/src/main/java/org/kpmp/atlasMessage/AtlasMessage.java new file mode 100644 index 0000000..1e0cd8b --- /dev/null +++ b/src/main/java/org/kpmp/atlasMessage/AtlasMessage.java @@ -0,0 +1,60 @@ +package org.kpmp.atlasMessage; + +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; + +@Entity +@Table(name = "atlas_messages") +public class AtlasMessage implements Serializable { + @Id + private int id; + private String message; + private String application; + private Date startDate; + private Date endDate; + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public String getMessage() { + return this.message; + } + + public void setMessage(String message) { + this.message = message; + } + + public String getApplication() { + return this.application; + } + + public void setApplication(String application) { + this.application = application; + } + + public Date getStartDate() { + return this.startDate; + } + + public void setStartDate(Date startDate) { + this.startDate = startDate; + } + + public Date getEndDate() { + return this.endDate; + } + + public void setEndDate(Date endDate) { + this.endDate = endDate; + } + +} diff --git a/src/main/java/org/kpmp/atlasMessage/AtlasMessageRepository.java b/src/main/java/org/kpmp/atlasMessage/AtlasMessageRepository.java new file mode 100644 index 0000000..2fb9014 --- /dev/null +++ b/src/main/java/org/kpmp/atlasMessage/AtlasMessageRepository.java @@ -0,0 +1,15 @@ +package org.kpmp.atlasMessage; + + +import java.util.List; + +import org.springframework.cache.annotation.Cacheable; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.CrudRepository; +import org.springframework.stereotype.Repository; + +@Repository +interface AtlasMessageRepository extends CrudRepository{ + @Query(value = "SELECT * FROM atlas_messages am WHERE start_date <= CURRENT_DATE() AND end_date >= CURRENT_DATE() ORDER BY start_date ASC", nativeQuery = true) + List getAtlasMessages(); +} diff --git a/src/main/java/org/kpmp/atlasMessage/AtlasMessageService.java b/src/main/java/org/kpmp/atlasMessage/AtlasMessageService.java new file mode 100644 index 0000000..fafbfd8 --- /dev/null +++ b/src/main/java/org/kpmp/atlasMessage/AtlasMessageService.java @@ -0,0 +1,23 @@ +package org.kpmp.atlasMessage; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + + +@Service +public class AtlasMessageService { + private AtlasMessageRepository atlasMessageRepo; + + @Autowired + public AtlasMessageService(AtlasMessageRepository atlasMessageRepo){ + this.atlasMessageRepo = atlasMessageRepo; + } + + public List getAtlasMessage(){ + return atlasMessageRepo.getAtlasMessages(); + } + +} \ No newline at end of file diff --git a/src/main/java/org/kpmp/cellTypeSummary/ClusterHierarchy.java b/src/main/java/org/kpmp/cellTypeSummary/ClusterHierarchy.java index 8313e73..4a26dd2 100755 --- a/src/main/java/org/kpmp/cellTypeSummary/ClusterHierarchy.java +++ b/src/main/java/org/kpmp/cellTypeSummary/ClusterHierarchy.java @@ -34,6 +34,9 @@ public class ClusterHierarchy implements Serializable { private String isSingleNucCluster; @Column(name = "is_rt") private String isRegionalTranscriptomics; + + @Column(name = "is_rp") + private String isRegionalProteomics; @Column(name = "cell_type") private String cellType; @Column(name = "cell_type_order") @@ -106,6 +109,13 @@ public void setIsRegionalTranscriptomics(String isRegionalTranscriptomics) { this.isRegionalTranscriptomics = isRegionalTranscriptomics; } + public String getIsRegionalProteomics() { + return isRegionalProteomics; + } + + public void setIsRegionalProteomics(String isRegionalProteomics) { + this.isRegionalProteomics = isRegionalProteomics; + } @Nullable public Double getCellTypeOrder() { return cellTypeOrder; diff --git a/src/main/java/org/kpmp/cellTypeSummary/ClusterHierarchyService.java b/src/main/java/org/kpmp/cellTypeSummary/ClusterHierarchyService.java index 619e7af..bb817dd 100755 --- a/src/main/java/org/kpmp/cellTypeSummary/ClusterHierarchyService.java +++ b/src/main/java/org/kpmp/cellTypeSummary/ClusterHierarchyService.java @@ -1,14 +1,10 @@ package org.kpmp.cellTypeSummary; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import org.kpmp.DataTypeEnum; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.data.neo4j.DataNeo4jTypeExcludeFilter; import org.springframework.stereotype.Service; @Service @@ -38,7 +34,16 @@ public List findClustersByCellType(String cellType) { clusterToHierarchy.put(clusterName, clusterHierarchy); } } - + if (cellType.equals("Tubules") || cellType.equals("Interstitium")) { + ClusterHierarchy tiCluster = new ClusterHierarchy(); + tiCluster.setStructureRegion("Tubulo-interstitium"); + tiCluster.setIsSingleCellCluster("N"); + tiCluster.setIsSingleNucCluster("N"); + tiCluster.setIsRegionalProteomics("Y"); + tiCluster.setIsRegionalTranscriptomics("Y"); + tiCluster.setCellTypeOrder(0.01); + result.add(tiCluster); + } result.addAll(clusterToHierarchy.values()); Collections.sort(result, new Comparator() { @Override @@ -51,15 +56,23 @@ public int compare(ClusterHierarchy a, ClusterHierarchy b) { public List findDataTypesByClusterName(String clusterName) { List dataTypesRepresented = new ArrayList<>(); - ClusterHierarchy clustersInDataTypes = clusterHierarchyRepo.findFirstByClusterOrRegion(clusterName); - if (clustersInDataTypes.getIsSingleCellCluster().equalsIgnoreCase("Y")) { - dataTypesRepresented.add(DataTypeEnum.SINGLE_CELL.getAbbreviation()); - } - if (clustersInDataTypes.getIsSingleNucCluster().equalsIgnoreCase("Y")) { - dataTypesRepresented.add(DataTypeEnum.SINGLE_NUCLEUS.getAbbreviation()); - } - if (clustersInDataTypes.getIsRegionalTranscriptomics().equalsIgnoreCase("Y")) { + if (clusterName.equals("Tubulo-interstitium")) { + dataTypesRepresented.add(DataTypeEnum.REGIONAL_PROTEOMICS.getAbbreviation()); dataTypesRepresented.add(DataTypeEnum.REGIONAL_TRANSCRIPTOMICS.getAbbreviation()); + } else { + ClusterHierarchy clustersInDataTypes = clusterHierarchyRepo.findFirstByClusterOrRegion(clusterName); + if (clustersInDataTypes.getIsSingleCellCluster().equalsIgnoreCase("Y")) { + dataTypesRepresented.add(DataTypeEnum.SINGLE_CELL.getAbbreviation()); + } + if (clustersInDataTypes.getIsSingleNucCluster().equalsIgnoreCase("Y")) { + dataTypesRepresented.add(DataTypeEnum.SINGLE_NUCLEUS.getAbbreviation()); + } + if (clustersInDataTypes.getIsRegionalTranscriptomics().equalsIgnoreCase("Y")) { + dataTypesRepresented.add(DataTypeEnum.REGIONAL_TRANSCRIPTOMICS.getAbbreviation()); + } + if (clustersInDataTypes.getIsRegionalProteomics().equalsIgnoreCase("Y")) { + dataTypesRepresented.add(DataTypeEnum.REGIONAL_PROTEOMICS.getAbbreviation()); + } } return dataTypesRepresented; } diff --git a/src/main/java/org/kpmp/geneExpression/RPAccessionGroup.java b/src/main/java/org/kpmp/geneExpression/RPAccessionGroup.java new file mode 100755 index 0000000..2bf554c --- /dev/null +++ b/src/main/java/org/kpmp/geneExpression/RPAccessionGroup.java @@ -0,0 +1,30 @@ +package org.kpmp.geneExpression; +public class RPAccessionGroup { + private String accession; + private RPExpressionByTissueType rpExpressionByTissueType; + + public RPAccessionGroup() { + this.accession = null; + this.rpExpressionByTissueType = null; + } + public RPAccessionGroup(String accession, RPExpressionByTissueType rpExpressionByTissueType) { + this.accession = accession; + this.rpExpressionByTissueType = rpExpressionByTissueType; + } + + public String getAccession() { + return accession; + } + + public void setAccession(String accession) { + this.accession = accession; + } + + public RPExpressionByTissueType getRpExpressionByTissueType() { + return rpExpressionByTissueType; + } + + public void setRpExpressionByTissueType(RPExpressionByTissueType rpExpressionByTissueType) { + this.rpExpressionByTissueType = rpExpressionByTissueType; + } +} diff --git a/src/main/java/org/kpmp/geneExpression/RPExpressionByTissueType.java b/src/main/java/org/kpmp/geneExpression/RPExpressionByTissueType.java new file mode 100755 index 0000000..df2f5de --- /dev/null +++ b/src/main/java/org/kpmp/geneExpression/RPExpressionByTissueType.java @@ -0,0 +1,53 @@ +package org.kpmp.geneExpression; + +import java.util.List; + +public class RPExpressionByTissueType { + + private List all; + private List aki; + private List ckd; + private List hrt; + private List dmr; + + public List getAll() { + return all; + } + + public void setAll(List all) { + this.all = all; + } + + public List getAki() { + return aki; + } + + public void setAki(List aki) { + this.aki = aki; + } + + public List getCkd() { + return ckd; + } + + public void setCkd(List ckd) { + this.ckd = ckd; + } + + public List getHrt() { + return hrt; + } + + public void setHrt(List hrt) { + this.hrt = hrt; + } + + public List getDmr() { + return dmr; + } + + public void setDmr(List dmr) { + this.dmr = dmr; + } + +} diff --git a/src/main/java/org/kpmp/geneExpression/RPExpressionData.java b/src/main/java/org/kpmp/geneExpression/RPExpressionData.java new file mode 100755 index 0000000..0b67b29 --- /dev/null +++ b/src/main/java/org/kpmp/geneExpression/RPExpressionData.java @@ -0,0 +1,165 @@ +package org.kpmp.geneExpression; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; + +@Entity +@Table(name = "rp_expression") +public class RPExpressionData { + + @Id + @Column(name = "id") + private Integer id; + + @Column(name = "fdr_confidence") + private String fdrConfidence; + + @Column(name = "accession") + private String accession; + + @Column(name = "description") + private String description; + + @Column(name = "coverage_pct") + private int coveragePct; + + @Column(name = "num_peptides") + private int numPeptides; + + @Column(name = "num_unique_peptides") + private int numUniquePeptides; + + @Column(name = "gene_symbol") + private String geneSymbol; + + @Column(name = "comparison") + private String comparison; + + @Column(name = "adj_p_val") + private Double adjPVal; + + @Column(name = "fold_change") + private Double foldChange; + + @Column(name = "tissue_type") + private String tissueType; + + @Column(name = "region") + private String region; + + @Column(name = "sample_count") + private Integer sampleCount; + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getFdrConfidence() { + return fdrConfidence; + } + + public void setFdrConfidence(String fdrConfidence) { + this.fdrConfidence = fdrConfidence; + } + + public String getAccession() { + return accession; + } + + public void setAccession(String accession) { + this.accession = accession; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public int getCoveragePct() { + return coveragePct; + } + + public void setCoveragePct(int coveragePct) { + this.coveragePct = coveragePct; + } + + public int getNumPeptides() { + return numPeptides; + } + + public void setNumPeptides(int numPeptides) { + this.numPeptides = numPeptides; + } + + public int getNumUniquePeptides() { + return numUniquePeptides; + } + + public void setNumUniquePeptides(int numUniquePeptides) { + this.numUniquePeptides = numUniquePeptides; + } + + public String getGeneSymbol() { + return geneSymbol; + } + + public void setGeneSymbol(String geneSymbol) { + this.geneSymbol = geneSymbol; + } + + public String getComparison() { + return comparison; + } + + public void setComparison(String comparison) { + this.comparison = comparison; + } + + public Double getAdjPVal() { + return adjPVal; + } + + public void setAdjPVal(Double adjPVal) { + this.adjPVal = adjPVal; + } + + public Double getFoldChange() { + return foldChange; + } + + public void setFoldChange(Double foldChange) { + this.foldChange = foldChange; + } + + public String getTissueType() { + return tissueType; + } + + public void setTissueType(String tissueType) { + this.tissueType = tissueType; + } + + public String getRegion() { + return region; + } + + public void setRegion(String region) { + this.region = region; + } + + public Integer getSampleCount() { + return sampleCount; + } + + public void setSampleCount(Integer sampleCount) { + this.sampleCount = sampleCount; + } +} diff --git a/src/main/java/org/kpmp/geneExpression/RPExpressionDataRepository.java b/src/main/java/org/kpmp/geneExpression/RPExpressionDataRepository.java new file mode 100755 index 0000000..68cd991 --- /dev/null +++ b/src/main/java/org/kpmp/geneExpression/RPExpressionDataRepository.java @@ -0,0 +1,36 @@ +package org.kpmp.geneExpression; + +import org.springframework.cache.annotation.Cacheable; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.query.Param; + +import java.util.List; + +public interface RPExpressionDataRepository extends CrudRepository { + + + @Query(value = "SELECT rpe.*, count(*) as sample_count FROM rp_expression rpe " + + "JOIN rp_metadata rpm ON LOWER(rpe.region) = LOWER(rpm.tissue_region) " + + "WHERE rpe.gene_symbol = :geneSymbol AND rpe.tissue_type = :tissueType " + + "GROUP BY rpe.region, rpe.accession", nativeQuery = true) + List findByGeneSymbolAndTissueTypeWithCounts(String geneSymbol, String tissueType); + + @Query(value = "SELECT rpe.accession from rp_expression rpe " + + "WHERE rpe.gene_symbol = :geneSymbol " + + "GROUP BY rpe.accession", nativeQuery = true) + List findAccessionByGeneSymbol(String geneSymbol); + + @Cacheable("rpExpCountByGene") + @Query(value = "SELECT COUNT(*) FROM rp_expression WHERE gene_symbol = :gene", nativeQuery = true) + long getCountByGene(@Param("gene") String gene); + + @Query(value = "CALL rp_diffex_sp(:structure);", nativeQuery = true) + List findByStructure(@Param("structure") String structure); + @Query(value = "SELECT rpe.*, count(*) as sample_count FROM rp_expression rpe " + + "JOIN rp_metadata rpm ON LOWER(rpe.region) = LOWER(rpm.tissue_region) " + + "WHERE rpe.gene_symbol = :geneSymbol AND rpe.tissue_type = :tissueType " + + "AND rpe.accession = :protein " + + "GROUP BY rpe.region", nativeQuery = true) + List findByGeneSymbolAndTissueTypeAndProteinWithCounts(String geneSymbol, String tissueType, String protein); +} diff --git a/src/main/java/org/kpmp/geneExpression/RPExpressionDataService.java b/src/main/java/org/kpmp/geneExpression/RPExpressionDataService.java new file mode 100755 index 0000000..42c3a6e --- /dev/null +++ b/src/main/java/org/kpmp/geneExpression/RPExpressionDataService.java @@ -0,0 +1,48 @@ +package org.kpmp.geneExpression; + +import org.kpmp.TissueTypeEnum; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Service +public class RPExpressionDataService { + + RPExpressionDataRepository rpExpressionDataRepository; + + @Autowired + public RPExpressionDataService(RPExpressionDataRepository rpExpressionDataRepository) { + this.rpExpressionDataRepository = rpExpressionDataRepository; + } + + public List getByGeneSymbolPerTissue(String geneSymbol) { + List accessionNums = rpExpressionDataRepository.findAccessionByGeneSymbol(geneSymbol); + List groups = new ArrayList<>(); + for (String accession: accessionNums) { + RPExpressionByTissueType rpExpressionByTissueType = getByGeneSymbolAndProteinPerTissue(geneSymbol, accession); + RPAccessionGroup group = new RPAccessionGroup(accession, rpExpressionByTissueType); + groups.add(group); + } + return groups; + } + + public RPExpressionByTissueType getByGeneSymbolAndProteinPerTissue(String geneSymbol, String protein) { + RPExpressionByTissueType rpExpressionByTissueType = new RPExpressionByTissueType(); + + rpExpressionByTissueType.setAki(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeAndProteinWithCounts(geneSymbol, TissueTypeEnum.AKI.getParticipantTissueType(), protein)); + rpExpressionByTissueType.setCkd(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeAndProteinWithCounts(geneSymbol, TissueTypeEnum.CKD.getParticipantTissueType(), protein)); + rpExpressionByTissueType.setDmr(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeAndProteinWithCounts(geneSymbol, TissueTypeEnum.DMR.getParticipantTissueType(), protein)); + rpExpressionByTissueType.setHrt(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeAndProteinWithCounts(geneSymbol, TissueTypeEnum.HEALTHY_REFERENCE.getParticipantTissueType(), protein)); + rpExpressionByTissueType.setAll(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeAndProteinWithCounts(geneSymbol, TissueTypeEnum.ALL.getParticipantTissueType(), protein)); + + return rpExpressionByTissueType; + } + + public List getByStructure(String structure) { + return rpExpressionDataRepository.findByStructure(structure); + } +} diff --git a/src/main/java/org/kpmp/geneExpression/ExpressionDataService.java b/src/main/java/org/kpmp/geneExpression/SNSCExpressionDataService.java similarity index 86% rename from src/main/java/org/kpmp/geneExpression/ExpressionDataService.java rename to src/main/java/org/kpmp/geneExpression/SNSCExpressionDataService.java index cd2f51a..4723209 100755 --- a/src/main/java/org/kpmp/geneExpression/ExpressionDataService.java +++ b/src/main/java/org/kpmp/geneExpression/SNSCExpressionDataService.java @@ -7,13 +7,13 @@ import org.springframework.stereotype.Service; @Service -public class ExpressionDataService { +public class SNSCExpressionDataService { private SNExpressionDataRepository snRepo; private SCExpressionDataRepository scRepo; @Autowired - public ExpressionDataService(SNExpressionDataRepository snRepo, SCExpressionDataRepository scRepo) { + public SNSCExpressionDataService(SNExpressionDataRepository snRepo, SCExpressionDataRepository scRepo) { this.snRepo = snRepo; this.scRepo = scRepo; } diff --git a/src/main/java/org/kpmp/geneExpressionSummary/GeneExpressionSummaryService.java b/src/main/java/org/kpmp/geneExpressionSummary/GeneExpressionSummaryService.java index 9ebccc9..9c21970 100755 --- a/src/main/java/org/kpmp/geneExpressionSummary/GeneExpressionSummaryService.java +++ b/src/main/java/org/kpmp/geneExpressionSummary/GeneExpressionSummaryService.java @@ -9,7 +9,14 @@ import org.kpmp.OmicsTypeEnum; import org.kpmp.TissueTypeEnum; import org.kpmp.dataSummary.DataTypeSummary; +import org.kpmp.geneExpression.RPExpressionDataRepository; import org.kpmp.geneExpression.RTExpressionDataAllSegmentsRepository; +import org.kpmp.geneExpressionSummary.regionalProteomics.RPParticipantRepository; +import org.kpmp.geneExpressionSummary.regionalTranscriptomics.RTParticipantRepository; +import org.kpmp.geneExpressionSummary.singleCell.SCRNAGeneExpressionSummaryRepository; +import org.kpmp.geneExpressionSummary.singleCell.SCRNAParticipantRepository; +import org.kpmp.geneExpressionSummary.singleNucleus.SNRNAGeneExpressionSummaryRepository; +import org.kpmp.geneExpressionSummary.singleNucleus.SNRNAParticipantRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -20,6 +27,9 @@ public class GeneExpressionSummaryService { private SCRNAParticipantRepository scrnaParticipantRepository; private SNRNAParticipantRepository snrnaParticipantRepository; private RTParticipantRepository rtParticipantRepository; + + private RPParticipantRepository rpParticipantRepository; + private RPExpressionDataRepository rpExpressionDataRepository; RTExpressionDataAllSegmentsRepository rtExpressionDataAllSegmentsRepository; @Autowired @@ -27,12 +37,14 @@ public GeneExpressionSummaryService(SCRNAGeneExpressionSummaryRepository scrnaGe SNRNAGeneExpressionSummaryRepository snrnaGeneExpressionRepository, SCRNAParticipantRepository scrnaParticipantRepository, SNRNAParticipantRepository snrnaParticipantRepository, RTParticipantRepository rtParticipantRepository, - RTExpressionDataAllSegmentsRepository rtExpressionDataAllSegmentsRepository) { + RTExpressionDataAllSegmentsRepository rtExpressionDataAllSegmentsRepository, RPExpressionDataRepository rpExpressionDataRepository, RPParticipantRepository rpParticipantRepository) { this.scrnaGeneExpressionRepository = scrnaGeneExpressionRepository; this.snrnaGeneExpressionRepository = snrnaGeneExpressionRepository; this.scrnaParticipantRepository = scrnaParticipantRepository; this.snrnaParticipantRepository = snrnaParticipantRepository; this.rtParticipantRepository = rtParticipantRepository; + this.rpExpressionDataRepository = rpExpressionDataRepository; + this.rpParticipantRepository = rpParticipantRepository; this.rtExpressionDataAllSegmentsRepository = rtExpressionDataAllSegmentsRepository; } @@ -107,12 +119,16 @@ public List findDataTypesByGene(String gene) { if (rtCountByGene != 0) { dataTypes.add(DataTypeEnum.REGIONAL_TRANSCRIPTOMICS.getAbbreviation()); } + long rpCountByGene = rpExpressionDataRepository.getCountByGene(gene); + if (rpCountByGene != 0) { + dataTypes.add(DataTypeEnum.REGIONAL_PROTEOMICS.getAbbreviation()); + } return dataTypes; } - public List getGeneDatasetInformation(String geneSymbol) { - List geneSummary = new ArrayList<>(); - geneSummary.add(new DataTypeSummary(OmicsTypeEnum.TRANSCRIPTOMICS.getEnum(), + public List getDataTypeSummaryInformation() { + List dataTypeSummary = new ArrayList<>(); + dataTypeSummary.add(new DataTypeSummary(OmicsTypeEnum.TRANSCRIPTOMICS.getEnum(), FullDataTypeEnum.SINGLE_CELL_FULL.getFullName(), DataTypeEnum.SINGLE_CELL.getAbbreviation(), scrnaGeneExpressionRepository.getCountByTissue(TissueTypeEnum.AKI.getParticipantTissueType()), scrnaGeneExpressionRepository.getCountByTissue(TissueTypeEnum.CKD.getParticipantTissueType()), @@ -120,7 +136,7 @@ public List getGeneDatasetInformation(String geneSymbol) { .getCountByTissue(TissueTypeEnum.HEALTHY_REFERENCE.getParticipantTissueType()), scrnaGeneExpressionRepository.getCountByTissue(TissueTypeEnum.DMR.getParticipantTissueType()), scrnaParticipantRepository.getParticipantCount())); - geneSummary.add(new DataTypeSummary(OmicsTypeEnum.NONE.getEnum(), + dataTypeSummary.add(new DataTypeSummary(OmicsTypeEnum.NONE.getEnum(), FullDataTypeEnum.SINGLE_NUCLEUS_FULL.getFullName(), DataTypeEnum.SINGLE_NUCLEUS.getAbbreviation(), snrnaGeneExpressionRepository.getCountByTissue(TissueTypeEnum.AKI.getParticipantTissueType()), snrnaGeneExpressionRepository.getCountByTissue(TissueTypeEnum.CKD.getParticipantTissueType()), @@ -128,7 +144,7 @@ public List getGeneDatasetInformation(String geneSymbol) { .getCountByTissue(TissueTypeEnum.HEALTHY_REFERENCE.getParticipantTissueType()), snrnaGeneExpressionRepository.getCountByTissue(TissueTypeEnum.DMR.getParticipantTissueType()), snrnaParticipantRepository.getParticipantCount())); - geneSummary.add(new DataTypeSummary(OmicsTypeEnum.NONE.getEnum(), + dataTypeSummary.add(new DataTypeSummary(OmicsTypeEnum.NONE.getEnum(), FullDataTypeEnum.REGIONAL_TRANSCRIPTOMICS_FULL.getFullName(), DataTypeEnum.REGIONAL_TRANSCRIPTOMICS.getAbbreviation(), rtParticipantRepository.getCountByTissueType(TissueTypeEnum.AKI.getParticipantTissueType()), @@ -137,7 +153,16 @@ public List getGeneDatasetInformation(String geneSymbol) { .getCountByTissueType(TissueTypeEnum.HEALTHY_REFERENCE.getParticipantTissueType()), rtParticipantRepository.getCountByTissueType(TissueTypeEnum.DMR.getParticipantTissueType()), rtParticipantRepository.getParticipantCount())); - return geneSummary; + dataTypeSummary.add(new DataTypeSummary(OmicsTypeEnum.NONE.getEnum(), + FullDataTypeEnum.REGIONAL_PROTEOMICS_FULL.getFullName(), + DataTypeEnum.REGIONAL_PROTEOMICS.getAbbreviation(), + rpParticipantRepository.getCountByTissueType(TissueTypeEnum.AKI.getParticipantTissueType()), + rpParticipantRepository.getCountByTissueType(TissueTypeEnum.CKD.getParticipantTissueType()), + rpParticipantRepository + .getCountByTissueType(TissueTypeEnum.HEALTHY_REFERENCE.getParticipantTissueType()), + rpParticipantRepository.getCountByTissueType(TissueTypeEnum.DMR.getParticipantTissueType()), + rpParticipantRepository.getParticipantCount())); + return dataTypeSummary; } } diff --git a/src/main/java/org/kpmp/geneExpressionSummary/regionalProteomics/RPParticipantRepository.java b/src/main/java/org/kpmp/geneExpressionSummary/regionalProteomics/RPParticipantRepository.java new file mode 100755 index 0000000..e5ac8bc --- /dev/null +++ b/src/main/java/org/kpmp/geneExpressionSummary/regionalProteomics/RPParticipantRepository.java @@ -0,0 +1,18 @@ +package org.kpmp.geneExpressionSummary.regionalProteomics; + +import org.springframework.cache.annotation.Cacheable; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.CrudRepository; + +public interface RPParticipantRepository extends CrudRepository { + @Cacheable("rpCounts") + @Query(value = "SELECT COUNT(DISTINCT rp.redcap_id) FROM rp_participant_tissue_v rp", nativeQuery = true) + Long getParticipantCount(); + + @Cacheable("rpCountsByTissue") + @Query(value = "SELECT COUNT(DISTINCT rp.redcap_id) FROM rp_participant_tissue_v rp WHERE rp.tissue_type = :tissueType", nativeQuery = true) + Long getCountByTissueType(String tissueType); + + boolean existsByRedcapId(String redcapId); + +} diff --git a/src/main/java/org/kpmp/geneExpressionSummary/regionalProteomics/RPParticipantValue.java b/src/main/java/org/kpmp/geneExpressionSummary/regionalProteomics/RPParticipantValue.java new file mode 100755 index 0000000..c36dbba --- /dev/null +++ b/src/main/java/org/kpmp/geneExpressionSummary/regionalProteomics/RPParticipantValue.java @@ -0,0 +1,41 @@ +package org.kpmp.geneExpressionSummary.regionalProteomics; + +import org.kpmp.geneExpressionSummary.Participant; +import org.kpmp.geneExpressionSummary.ParticipantId; + +import javax.persistence.*; +import java.io.Serializable; + +@Entity +@Table(name = "rp_participant_tissue_v") +@IdClass(ParticipantId.class) +public class RPParticipantValue implements Participant, Serializable { + + @Column(name = "tissue_type") + private String tissueType; + + @Column(name = "redcap_id") + private String redcapId; + + @Override + @Id + public String getRedcapId() { + return redcapId; + } + + @Override + public void setRedcapId(String redcapId) { + this.redcapId = redcapId; + } + + @Override + public String getTissueType() { + return tissueType; + } + + @Override + public void setTissueType(String tissueType) { + this.tissueType = tissueType; + } + +} diff --git a/src/main/java/org/kpmp/geneExpressionSummary/RTParticipantRepository.java b/src/main/java/org/kpmp/geneExpressionSummary/regionalTranscriptomics/RTParticipantRepository.java similarity index 89% rename from src/main/java/org/kpmp/geneExpressionSummary/RTParticipantRepository.java rename to src/main/java/org/kpmp/geneExpressionSummary/regionalTranscriptomics/RTParticipantRepository.java index 08dd2cd..615c7cd 100755 --- a/src/main/java/org/kpmp/geneExpressionSummary/RTParticipantRepository.java +++ b/src/main/java/org/kpmp/geneExpressionSummary/regionalTranscriptomics/RTParticipantRepository.java @@ -1,4 +1,4 @@ -package org.kpmp.geneExpressionSummary; +package org.kpmp.geneExpressionSummary.regionalTranscriptomics; import org.springframework.cache.annotation.Cacheable; import org.springframework.data.jpa.repository.Query; diff --git a/src/main/java/org/kpmp/geneExpressionSummary/RTParticipantValue.java b/src/main/java/org/kpmp/geneExpressionSummary/regionalTranscriptomics/RTParticipantValue.java similarity index 79% rename from src/main/java/org/kpmp/geneExpressionSummary/RTParticipantValue.java rename to src/main/java/org/kpmp/geneExpressionSummary/regionalTranscriptomics/RTParticipantValue.java index 62df11f..e14162a 100755 --- a/src/main/java/org/kpmp/geneExpressionSummary/RTParticipantValue.java +++ b/src/main/java/org/kpmp/geneExpressionSummary/regionalTranscriptomics/RTParticipantValue.java @@ -1,4 +1,7 @@ -package org.kpmp.geneExpressionSummary; +package org.kpmp.geneExpressionSummary.regionalTranscriptomics; + +import org.kpmp.geneExpressionSummary.Participant; +import org.kpmp.geneExpressionSummary.ParticipantId; import java.io.Serializable; @@ -11,6 +14,7 @@ @Entity @Table(name = "rt_participant_tissue_v") @IdClass(ParticipantId.class) +public class RTParticipantValue implements Participant, Serializable { private static final long serialVersionUID = 5368734102102552073L; diff --git a/src/main/java/org/kpmp/geneExpressionSummary/SCRNAGeneExpressionExpressionSummaryValue.java b/src/main/java/org/kpmp/geneExpressionSummary/singleCell/SCRNAGeneExpressionExpressionSummaryValue.java similarity index 90% rename from src/main/java/org/kpmp/geneExpressionSummary/SCRNAGeneExpressionExpressionSummaryValue.java rename to src/main/java/org/kpmp/geneExpressionSummary/singleCell/SCRNAGeneExpressionExpressionSummaryValue.java index 8cc08ef..420c53c 100755 --- a/src/main/java/org/kpmp/geneExpressionSummary/SCRNAGeneExpressionExpressionSummaryValue.java +++ b/src/main/java/org/kpmp/geneExpressionSummary/singleCell/SCRNAGeneExpressionExpressionSummaryValue.java @@ -1,4 +1,4 @@ -package org.kpmp.geneExpressionSummary; +package org.kpmp.geneExpressionSummary.singleCell; import java.beans.Transient; import java.io.Serializable; @@ -11,6 +11,8 @@ import javax.persistence.Table; import org.kpmp.DataTypeEnum; +import org.kpmp.geneExpressionSummary.GeneExpressionId; +import org.kpmp.geneExpressionSummary.GeneExpressionSummary; @Entity @Table(name = "sc_rnaseq") diff --git a/src/main/java/org/kpmp/geneExpressionSummary/SCRNAGeneExpressionSummaryRepository.java b/src/main/java/org/kpmp/geneExpressionSummary/singleCell/SCRNAGeneExpressionSummaryRepository.java similarity index 94% rename from src/main/java/org/kpmp/geneExpressionSummary/SCRNAGeneExpressionSummaryRepository.java rename to src/main/java/org/kpmp/geneExpressionSummary/singleCell/SCRNAGeneExpressionSummaryRepository.java index 1a13ca5..ce1c0b2 100755 --- a/src/main/java/org/kpmp/geneExpressionSummary/SCRNAGeneExpressionSummaryRepository.java +++ b/src/main/java/org/kpmp/geneExpressionSummary/singleCell/SCRNAGeneExpressionSummaryRepository.java @@ -1,7 +1,8 @@ -package org.kpmp.geneExpressionSummary; +package org.kpmp.geneExpressionSummary.singleCell; import java.util.List; +import org.kpmp.geneExpressionSummary.GeneExpressionId; import org.springframework.cache.annotation.Cacheable; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.CrudRepository; diff --git a/src/main/java/org/kpmp/geneExpressionSummary/SCRNAParticipantRepository.java b/src/main/java/org/kpmp/geneExpressionSummary/singleCell/SCRNAParticipantRepository.java similarity index 83% rename from src/main/java/org/kpmp/geneExpressionSummary/SCRNAParticipantRepository.java rename to src/main/java/org/kpmp/geneExpressionSummary/singleCell/SCRNAParticipantRepository.java index 08c5e71..26b8933 100755 --- a/src/main/java/org/kpmp/geneExpressionSummary/SCRNAParticipantRepository.java +++ b/src/main/java/org/kpmp/geneExpressionSummary/singleCell/SCRNAParticipantRepository.java @@ -1,5 +1,6 @@ -package org.kpmp.geneExpressionSummary; +package org.kpmp.geneExpressionSummary.singleCell; +import org.kpmp.geneExpressionSummary.ParticipantId; import org.springframework.cache.annotation.Cacheable; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.CrudRepository; diff --git a/src/main/java/org/kpmp/geneExpressionSummary/SCRNAParticipantValue.java b/src/main/java/org/kpmp/geneExpressionSummary/singleCell/SCRNAParticipantValue.java similarity index 88% rename from src/main/java/org/kpmp/geneExpressionSummary/SCRNAParticipantValue.java rename to src/main/java/org/kpmp/geneExpressionSummary/singleCell/SCRNAParticipantValue.java index a758ab5..d5a6e26 100755 --- a/src/main/java/org/kpmp/geneExpressionSummary/SCRNAParticipantValue.java +++ b/src/main/java/org/kpmp/geneExpressionSummary/singleCell/SCRNAParticipantValue.java @@ -1,4 +1,6 @@ -package org.kpmp.geneExpressionSummary; +package org.kpmp.geneExpressionSummary.singleCell; + +import org.kpmp.geneExpressionSummary.ParticipantId; import java.io.Serializable; diff --git a/src/main/java/org/kpmp/geneExpressionSummary/SNRNAGeneExpressionExpressionSummaryValue.java b/src/main/java/org/kpmp/geneExpressionSummary/singleNucleus/SNRNAGeneExpressionExpressionSummaryValue.java similarity index 90% rename from src/main/java/org/kpmp/geneExpressionSummary/SNRNAGeneExpressionExpressionSummaryValue.java rename to src/main/java/org/kpmp/geneExpressionSummary/singleNucleus/SNRNAGeneExpressionExpressionSummaryValue.java index 7093151..294b99c 100755 --- a/src/main/java/org/kpmp/geneExpressionSummary/SNRNAGeneExpressionExpressionSummaryValue.java +++ b/src/main/java/org/kpmp/geneExpressionSummary/singleNucleus/SNRNAGeneExpressionExpressionSummaryValue.java @@ -1,4 +1,4 @@ -package org.kpmp.geneExpressionSummary; +package org.kpmp.geneExpressionSummary.singleNucleus; import java.io.Serializable; @@ -10,6 +10,8 @@ import javax.persistence.Transient; import org.kpmp.DataTypeEnum; +import org.kpmp.geneExpressionSummary.GeneExpressionId; +import org.kpmp.geneExpressionSummary.GeneExpressionSummary; import org.springframework.lang.Nullable; @Entity diff --git a/src/main/java/org/kpmp/geneExpressionSummary/SNRNAGeneExpressionSummaryRepository.java b/src/main/java/org/kpmp/geneExpressionSummary/singleNucleus/SNRNAGeneExpressionSummaryRepository.java similarity index 94% rename from src/main/java/org/kpmp/geneExpressionSummary/SNRNAGeneExpressionSummaryRepository.java rename to src/main/java/org/kpmp/geneExpressionSummary/singleNucleus/SNRNAGeneExpressionSummaryRepository.java index 9f79f93..2a52d87 100755 --- a/src/main/java/org/kpmp/geneExpressionSummary/SNRNAGeneExpressionSummaryRepository.java +++ b/src/main/java/org/kpmp/geneExpressionSummary/singleNucleus/SNRNAGeneExpressionSummaryRepository.java @@ -1,7 +1,8 @@ -package org.kpmp.geneExpressionSummary; +package org.kpmp.geneExpressionSummary.singleNucleus; import java.util.List; +import org.kpmp.geneExpressionSummary.GeneExpressionId; import org.springframework.cache.annotation.Cacheable; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.CrudRepository; diff --git a/src/main/java/org/kpmp/geneExpressionSummary/SNRNAParticipantRepository.java b/src/main/java/org/kpmp/geneExpressionSummary/singleNucleus/SNRNAParticipantRepository.java similarity index 82% rename from src/main/java/org/kpmp/geneExpressionSummary/SNRNAParticipantRepository.java rename to src/main/java/org/kpmp/geneExpressionSummary/singleNucleus/SNRNAParticipantRepository.java index 6b306ba..c2e146b 100755 --- a/src/main/java/org/kpmp/geneExpressionSummary/SNRNAParticipantRepository.java +++ b/src/main/java/org/kpmp/geneExpressionSummary/singleNucleus/SNRNAParticipantRepository.java @@ -1,5 +1,6 @@ -package org.kpmp.geneExpressionSummary; +package org.kpmp.geneExpressionSummary.singleNucleus; +import org.kpmp.geneExpressionSummary.ParticipantId; import org.springframework.cache.annotation.Cacheable; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.CrudRepository; diff --git a/src/main/java/org/kpmp/geneExpressionSummary/SNRNAParticipantValue.java b/src/main/java/org/kpmp/geneExpressionSummary/singleNucleus/SNRNAParticipantValue.java similarity index 84% rename from src/main/java/org/kpmp/geneExpressionSummary/SNRNAParticipantValue.java rename to src/main/java/org/kpmp/geneExpressionSummary/singleNucleus/SNRNAParticipantValue.java index 6c9dadc..c6a0d3f 100755 --- a/src/main/java/org/kpmp/geneExpressionSummary/SNRNAParticipantValue.java +++ b/src/main/java/org/kpmp/geneExpressionSummary/singleNucleus/SNRNAParticipantValue.java @@ -1,4 +1,7 @@ -package org.kpmp.geneExpressionSummary; +package org.kpmp.geneExpressionSummary.singleNucleus; + +import org.kpmp.geneExpressionSummary.Participant; +import org.kpmp.geneExpressionSummary.ParticipantId; import java.io.Serializable; diff --git a/src/main/java/org/kpmp/participant/ParticipantService.java b/src/main/java/org/kpmp/participant/ParticipantService.java index 2c63ac7..03729ec 100755 --- a/src/main/java/org/kpmp/participant/ParticipantService.java +++ b/src/main/java/org/kpmp/participant/ParticipantService.java @@ -7,7 +7,8 @@ import org.kpmp.TissueTypeEnum; import org.kpmp.dataSummary.AtlasRepoSummaryLinkInformation; import org.kpmp.dataSummary.DataSummaryRepository; -import org.kpmp.geneExpressionSummary.RTParticipantRepository; +import org.kpmp.geneExpressionSummary.regionalProteomics.RPParticipantRepository; +import org.kpmp.geneExpressionSummary.regionalTranscriptomics.RTParticipantRepository; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -26,17 +27,20 @@ public class ParticipantService { private SingleNucleusMetadataRepository snMetadataRepo; private RTParticipantRepository rtParticipantRepo; + private RPParticipantRepository rpParticipantRepository; + @Autowired public ParticipantService(DataSummaryRepository dataSummaryRepo, SpatialViewerTypeRepository svTypeRepo, SingleCellMetadataRepository scMetadataRepo, SingleNucleusMetadataRepository snMetadataRepo, RTParticipantRepository rtParticipantRepo, - ParticipantSummaryDatasetRepository participantSummaryDatasetRepository) { + ParticipantSummaryDatasetRepository participantSummaryDatasetRepository, RPParticipantRepository rpParticipantRepository) { this.dataSummaryRepo = dataSummaryRepo; this.svTypeRepo = svTypeRepo; this.scMetadataRepo = scMetadataRepo; this.snMetadataRepo = snMetadataRepo; this.rtParticipantRepo = rtParticipantRepo; this.participantSummaryDatasetRepository = participantSummaryDatasetRepository; + this.rpParticipantRepository = rpParticipantRepository; } public ParticipantSummaryDataset getParticipantSummaryDataset(String redcapId) { @@ -104,6 +108,14 @@ private List getExplorerCounts(String redcapId) FullDataTypeEnum.REGIONAL_TRANSCRIPTOMICS_FULL.getFullName(), regionalTranscriptomicsCount, true); explorerExperiments.add(regionalTranscriptomicsData); + int regionalProteomicsCount = 0; + if (rpParticipantRepository.existsByRedcapId(redcapId)) { + regionalProteomicsCount = 1; + } + ParticipantDataTypeInformation regionalProteomicsData = new ParticipantDataTypeInformation( + FullDataTypeEnum.REGIONAL_PROTEOMICS_FULL.getFullName(), regionalProteomicsCount, true); + explorerExperiments.add(regionalProteomicsData); + return explorerExperiments; } diff --git a/src/main/java/org/kpmp/umap/UmapDataService.java b/src/main/java/org/kpmp/umap/UmapDataService.java index c68a949..f3dc921 100755 --- a/src/main/java/org/kpmp/umap/UmapDataService.java +++ b/src/main/java/org/kpmp/umap/UmapDataService.java @@ -10,20 +10,20 @@ import org.json.JSONObject; import org.kpmp.DataTypeEnum; import org.kpmp.TissueTypeEnum; -import org.kpmp.geneExpression.ExpressionDataService; +import org.kpmp.geneExpression.SNSCExpressionDataService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @Service public class UmapDataService { - private ExpressionDataService expressionService; + private SNSCExpressionDataService expressionService; private SNMetadataRepository snMetadataRepo; private SCMetadataRepository scMetadataRepo; @Autowired public UmapDataService(SCMetadataRepository scMetadataRepo, SNMetadataRepository snMetadataRepo, - ExpressionDataService expressionService) { + SNSCExpressionDataService expressionService) { this.scMetadataRepo = scMetadataRepo; this.snMetadataRepo = snMetadataRepo; this.expressionService = expressionService; diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index cae2092..ce7be51 100755 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -8,3 +8,4 @@ graphql.servlet.exception-handlers-enabled=true spring.jpa.show_sql=false spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect server.port=3030 +spring.jpa.properties.hibernate.jdbc.time_zone=America/Detroit \ No newline at end of file diff --git a/src/main/resources/knowledge_environment.graphqls b/src/main/resources/knowledge_environment.graphqls index ddbece8..45ed169 100755 --- a/src/main/resources/knowledge_environment.graphqls +++ b/src/main/resources/knowledge_environment.graphqls @@ -5,10 +5,13 @@ type Query { getClusterHieararchies(cellType: String!): [ClusterHierarchy] getUmapPlotData(dataType: String!, geneSymbol: String!, tissueType: String): PlotData dataTypesForConcept(geneSymbol: String, clusterName: String): [String] - getGeneDatasetInformation(geneSymbol: String): [GeneDatasetInformation] + getDataTypeSummaryInformation: [DataTypeSummaryInformation] getRTGeneExpressionByTissue(comparisonType: String, geneSymbol: String): RTGeneExpressionByTissue + getRPGeneExpressionByTissue(geneSymbol: String!): [RPAccessionGroup] + getRPGeneExpressionByTissueAndProtein(geneSymbol: String!, protein: String!): RPExpressionByTissueType getRTGeneExpressionByStructure(structure: String): [RTGeneExpression] - getSummaryData: [GeneDatasetInformation] + getRPGeneExpressionByStructure(structure: String): [RPGeneExpression] + getSummaryData: [DataTypeSummaryInformation] getDataTypeInformationByParticipant(redcapId: String!): ParticipantDataTypeSummary getRepoDataTypeInformationByParticipant(redcapId: String!): ParticipantRepoDataTypeSummary participantSummaryDataset(redcapId: String): ParticipantSummaryDataset @@ -16,6 +19,15 @@ type Query { getTotalParticipantFilesCount(redcapId: String): ParticipantRepoDataTypeInformation getTissueTypeSummaryData: [ParticipantTissueTypeSummary] getAtlasSummaryRows: AtlasRepoSummaryResult + getAtlasMessages: [AtlasMessages] +} + +type AtlasMessages { + id: Int + message: String + startDate: String + endDate: String + application: String } type AtlasRepoSummaryResult { @@ -63,7 +75,7 @@ type ParticipantRepoDataTypeInformation { linkInformation: AtlasRepoSummaryLinkInformation } -type GeneDatasetInformation { +type DataTypeSummaryInformation { omicsType: String dataType: String dataTypeShort: String @@ -74,6 +86,7 @@ type GeneDatasetInformation { participantCount: Long } + type AutoCompleteResult { value: String name: String @@ -126,6 +139,7 @@ type ClusterHierarchy { isSingleNucCluster: String isSingleCellCluster: String isRegionalTranscriptomics: String + isRegionalProteomics: String cellTypeOrder: Float } @@ -170,6 +184,36 @@ type RTGeneExpressionByTissue { aki: [RTGeneExpression] } +type RPAccessionGroup { + accession: String + rpExpressionByTissueType: RPExpressionByTissueType +} + +type RPGeneExpression { + id: ID + geneSymbol: String + fdrConfidence: String + accession: String + description: String + coveragePct: Int + numPeptides: Int + numUniquePeptides: Int + comparison: String + region: String + foldChange: Float + adjPVal: Float + tissueType: String + sampleCount: Int +} + +type RPExpressionByTissueType { + all: [RPGeneExpression] + hrt: [RPGeneExpression] + ckd: [RPGeneExpression] + dmr: [RPGeneExpression] + aki: [RPGeneExpression] +} + type ParticipantSummaryDataset { participantId: String redcapId: String diff --git a/src/test/java/org/kpmp/DataTypeEnumTest.java b/src/test/java/org/kpmp/DataTypeEnumTest.java index ec70074..75d5fe0 100755 --- a/src/test/java/org/kpmp/DataTypeEnumTest.java +++ b/src/test/java/org/kpmp/DataTypeEnumTest.java @@ -8,7 +8,7 @@ public class DataTypeEnumTest { @Test public void testGetAbbreviation() { - assertEquals(11, DataTypeEnum.values().length); + assertEquals(12, DataTypeEnum.values().length); assertEquals("sn", DataTypeEnum.SINGLE_NUCLEUS.getAbbreviation()); assertEquals("sc", DataTypeEnum.SINGLE_CELL.getAbbreviation()); assertEquals("rt", DataTypeEnum.REGIONAL_TRANSCRIPTOMICS.getAbbreviation()); @@ -16,6 +16,7 @@ public void testGetAbbreviation() { assertEquals("sl", DataTypeEnum.SPATIAL_LIPIDOMICS.getAbbreviation()); assertEquals("sm", DataTypeEnum.SPATIAL_METABOLOMICS.getAbbreviation()); assertEquals("sng", DataTypeEnum.SPATIAL_NGLYCOMICS.getAbbreviation()); + assertEquals("rp", DataTypeEnum.REGIONAL_PROTEOMICS.getAbbreviation()); assertEquals("", DataTypeEnum.UNKNOWN.getAbbreviation()); } @@ -28,6 +29,7 @@ public void testFromAbbreviation() { assertEquals(DataTypeEnum.SPATIAL_LIPIDOMICS, DataTypeEnum.fromAbbreviation("sl")); assertEquals(DataTypeEnum.SPATIAL_METABOLOMICS, DataTypeEnum.fromAbbreviation("sm")); assertEquals(DataTypeEnum.SPATIAL_NGLYCOMICS, DataTypeEnum.fromAbbreviation("sng")); + assertEquals(DataTypeEnum.REGIONAL_PROTEOMICS, DataTypeEnum.fromAbbreviation("rp")); assertEquals(DataTypeEnum.UNKNOWN, DataTypeEnum.fromAbbreviation("xxx")); assertEquals(DataTypeEnum.UNKNOWN, DataTypeEnum.fromAbbreviation("")); assertEquals(DataTypeEnum.UNKNOWN, DataTypeEnum.fromAbbreviation(null)); diff --git a/src/test/java/org/kpmp/FullDataTypeEnumTest.java b/src/test/java/org/kpmp/FullDataTypeEnumTest.java index d915b82..203c958 100755 --- a/src/test/java/org/kpmp/FullDataTypeEnumTest.java +++ b/src/test/java/org/kpmp/FullDataTypeEnumTest.java @@ -8,14 +8,15 @@ public class FullDataTypeEnumTest { @Test public void testGetLong() { - assertEquals(11, FullDataTypeEnum.values().length); + assertEquals(12, FullDataTypeEnum.values().length); assertEquals("Single-nucleus RNA-seq (snRNA-seq)", FullDataTypeEnum.SINGLE_NUCLEUS_FULL.getFullName()); assertEquals("Single-cell RNA-seq (scRNA-seq)", FullDataTypeEnum.SINGLE_CELL_FULL.getFullName()); assertEquals("Regional transcriptomics", FullDataTypeEnum.REGIONAL_TRANSCRIPTOMICS_FULL.getFullName()); assertEquals("CODEX", FullDataTypeEnum.CODEX_FULL.getFullName()); assertEquals("Spatial Lipidomics", FullDataTypeEnum.SPATIAL_LIPIDOMICS_FULL.getFullName()); assertEquals("Spatial Metabolomics", FullDataTypeEnum.SPATIAL_METABOLOMICS_FULL.getFullName()); - assertEquals("Spatial N-glycomics", FullDataTypeEnum.SPATIAL_NGLYCOMICS_FULL.getFullName()); + assertEquals("Spatial N-glycomics", FullDataTypeEnum.SPATIAL_NGLYCOMICS_FULL.getFullName()); + assertEquals("Regional proteomics", FullDataTypeEnum.REGIONAL_PROTEOMICS_FULL.getFullName()); assertEquals("", FullDataTypeEnum.UNKNOWN_FULL.getFullName()); } diff --git a/src/test/java/org/kpmp/QueryTest.java b/src/test/java/org/kpmp/QueryTest.java index f713d7d..b54428e 100755 --- a/src/test/java/org/kpmp/QueryTest.java +++ b/src/test/java/org/kpmp/QueryTest.java @@ -8,13 +8,18 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import java.text.DateFormat; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; +import java.util.Date; import java.util.List; import org.junit.After; import org.junit.Before; import org.junit.Test; +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; @@ -24,12 +29,14 @@ import org.kpmp.dataSummary.AtlasRepoSummaryResult; import org.kpmp.dataSummary.DataSummaryService; import org.kpmp.dataSummary.DataTypeSummary; +import org.kpmp.geneExpression.RPExpressionByTissueType; +import org.kpmp.geneExpression.RPExpressionDataService; import org.kpmp.geneExpression.RTExpressionByTissueType; import org.kpmp.geneExpression.RTExpressionDataAllSegments; import org.kpmp.geneExpression.RTExpressionDataService; import org.kpmp.geneExpressionSummary.GeneExpressionSummaryService; -import org.kpmp.geneExpressionSummary.SCRNAGeneExpressionExpressionSummaryValue; -import org.kpmp.geneExpressionSummary.SNRNAGeneExpressionExpressionSummaryValue; +import org.kpmp.geneExpressionSummary.singleCell.SCRNAGeneExpressionExpressionSummaryValue; +import org.kpmp.geneExpressionSummary.singleNucleus.SNRNAGeneExpressionExpressionSummaryValue; import org.kpmp.participant.ParticipantDataTypeSummary; import org.kpmp.participant.ParticipantRepoDataTypeSummary; import org.kpmp.participant.ParticipantService; @@ -63,12 +70,18 @@ public class QueryTest { private ParticipantService participantService; @Mock private ParticipantTissueTypeSummary participantTissueTypeSummary; + @Mock + private AtlasMessageService atlasMessageService; + + @Mock + private RPExpressionDataService rpExpressionDataService; @Before public void setUp() throws Exception { MockitoAnnotations.openMocks(this); query = new Query(autocompleteService, cellTypeService, umapDataService, geneExpressionService, - dataSummaryService, clusterHierarchyService, rtExpressionDataService, participantService); + dataSummaryService, clusterHierarchyService, rtExpressionDataService, rpExpressionDataService, + participantService, atlasMessageService); } @After @@ -211,9 +224,9 @@ public void getGeneDatasetInformation() throws Exception { expectedResult.add(new DataTypeSummary(OmicsTypeEnum.NONE.getEnum(), FullDataTypeEnum.SINGLE_NUCLEUS_FULL.getFullName(), DataTypeEnum.SINGLE_NUCLEUS.getAbbreviation(), Long.valueOf(0), Long.valueOf(0), Long.valueOf(0), Long.valueOf(0), Long.valueOf(0))); - when(geneExpressionService.getGeneDatasetInformation("AAA")).thenReturn(expectedResult); + when(geneExpressionService.getDataTypeSummaryInformation()).thenReturn(expectedResult); - List datasetSummary = query.getGeneDatasetInformation("AAA"); + List datasetSummary = query.getDataTypeSummaryInformation(); assertEquals(expectedResult, datasetSummary); } @@ -237,6 +250,16 @@ public void testGetRTGeneExpressionByStructure() throws Exception { assertEquals(data, query.getRTGeneExpressionByStructure("tubulers")); } + @Test + public void testGetRPGeneExpressionByTissueAndProtein() throws Exception { + RPExpressionByTissueType expected = new RPExpressionByTissueType(); + when(rpExpressionDataService.getByGeneSymbolAndProteinPerTissue("APOL1", "steak")).thenReturn(expected); + + RPExpressionByTissueType result = query.getRPGeneExpressionByTissueAndProtein("APOL1", "steak"); + + assertEquals(expected, result); + } + @Test public void testGetDataTypeInformationByParticipant() throws Exception { ParticipantDataTypeSummary expected = mock(ParticipantDataTypeSummary.class); @@ -284,4 +307,22 @@ public void getParticipantTissueTypeSummary() throws Exception { assertEquals(expectedResult, tissueSummary); } + + @Test + public void testGetAtlasMessage() throws Exception { + AtlasMessage atlasMessage = new AtlasMessage(); + DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + String endDateString = "2023-12-25"; + String startDateString = "2023-12-01"; + Date endDate = dateFormat.parse(endDateString); + Date startDate = dateFormat.parse(startDateString); + atlasMessage.setId(0); + atlasMessage.setApplication("Explorer"); + atlasMessage.setEndDate(endDate); + atlasMessage.setStartDate(startDate); + atlasMessage.setMessage("THE END IS NEAR"); + List expectedResult = Arrays.asList(new AtlasMessage()); + when(atlasMessageService.getAtlasMessage()).thenReturn(expectedResult); + assertEquals(expectedResult, query.getAtlasMessages()); + } } \ No newline at end of file diff --git a/src/test/java/org/kpmp/atlasMessage/AtlasMessageServiceTest.java b/src/test/java/org/kpmp/atlasMessage/AtlasMessageServiceTest.java new file mode 100644 index 0000000..c7db503 --- /dev/null +++ b/src/test/java/org/kpmp/atlasMessage/AtlasMessageServiceTest.java @@ -0,0 +1,55 @@ +package org.kpmp.atlasMessage; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.when; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; + +import java.util.Arrays; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + +public class AtlasMessageServiceTest { + private AtlasMessageService atlasMessageService; + @Mock + private AtlasMessageRepository atlasMessageRepository; + @Mock + private AtlasMessage atlasMessage; + @BeforeEach + public void setUp() throws Exception { + MockitoAnnotations.openMocks(this); + atlasMessageService = new AtlasMessageService(atlasMessageRepository); + } + + @AfterEach + public void tearDown() throws Exception { + MockitoAnnotations.openMocks(this).close(); + atlasMessageService = null; + } + + @Test + public void testGetAtlasMessage() throws Exception { + AtlasMessage message = new AtlasMessage(); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + String endDateString = "2023-12-31"; + String startDateString = "2022-12-31"; + Date endDate = format.parse(endDateString); + Date startDate = format.parse(startDateString); + message.setApplication("Explorer"); + message.setEndDate(endDate); + message.setStartDate(startDate); + message.setId(1); + AtlasMessage message2 = new AtlasMessage(); + message2.setApplication(null); + message2.setEndDate(null); + message2.setStartDate(null); + message2.setId(2); + List messageList = Arrays.asList(message, message2); + when(atlasMessageRepository.getAtlasMessages()).thenReturn(messageList); + } +} diff --git a/src/test/java/org/kpmp/atlasMessage/AtlasMessageTest.java b/src/test/java/org/kpmp/atlasMessage/AtlasMessageTest.java new file mode 100644 index 0000000..d07668a --- /dev/null +++ b/src/test/java/org/kpmp/atlasMessage/AtlasMessageTest.java @@ -0,0 +1,62 @@ +package org.kpmp.atlasMessage; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.Mock; + +public class AtlasMessageTest { + @Mock + private AtlasMessage atlasMessage; + @BeforeEach + public void setUp() throws Exception { + atlasMessage = new AtlasMessage(); + } + + @AfterEach + public void tearDown() throws Exception { + atlasMessage = null; + } + + @Test + public void testGetApplication() throws Exception { + atlasMessage.setApplication("Explorer"); + assertEquals("Explorer", atlasMessage.getApplication()); + } + + @Test + public void testGetId() throws Exception{ + atlasMessage.setId(1); + assertEquals(1, atlasMessage.getId()); + } + + @Test + public void testGetStartDate() throws Exception { + DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + String startDateString = "2023-12-25"; + Date startDate = dateFormat.parse(startDateString); + atlasMessage.setStartDate(startDate); + assertEquals(startDate, atlasMessage.getStartDate()); + } + + @Test + public void testGetEndDate() throws Exception { + DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + String endDateString = "2023-12-25"; + Date endDate = dateFormat.parse(endDateString); + atlasMessage.setEndDate(endDate); + assertEquals(endDate, atlasMessage.getEndDate()); + } + + @Test + public void testGetAtlasMessage() throws Exception { + atlasMessage.setMessage("THE END IS NEAR"); + assertEquals("THE END IS NEAR", atlasMessage.getMessage()); + } +} diff --git a/src/test/java/org/kpmp/cellTypeSummary/ClusterHierarchyServiceTest.java b/src/test/java/org/kpmp/cellTypeSummary/ClusterHierarchyServiceTest.java index c303947..a46778c 100755 --- a/src/test/java/org/kpmp/cellTypeSummary/ClusterHierarchyServiceTest.java +++ b/src/test/java/org/kpmp/cellTypeSummary/ClusterHierarchyServiceTest.java @@ -1,9 +1,10 @@ package org.kpmp.cellTypeSummary; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.*; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -101,6 +102,7 @@ public void testFindDataTypesByClusterNameWhenBothY() throws Exception { clusterHierarchy.setIsSingleCellCluster("Y"); clusterHierarchy.setIsSingleNucCluster("Y"); clusterHierarchy.setIsRegionalTranscriptomics("N"); + clusterHierarchy.setIsRegionalProteomics("N"); when(clusterHierarchyRepo.findFirstByClusterOrRegion("cluster")).thenReturn(clusterHierarchy); List dataTypes = service.findDataTypesByClusterName("cluster"); @@ -117,7 +119,7 @@ public void testFindDataTypesByClusterNameWhenSingleCellY() throws Exception { clusterHierarchy.setIsSingleCellCluster("Y"); clusterHierarchy.setIsSingleNucCluster("N"); clusterHierarchy.setIsRegionalTranscriptomics("N"); - + clusterHierarchy.setIsRegionalProteomics("N"); when(clusterHierarchyRepo.findFirstByClusterOrRegion("cluster")).thenReturn(clusterHierarchy); List dataTypes = service.findDataTypesByClusterName("cluster"); @@ -133,6 +135,7 @@ public void testFindDataTypesByClusterNameWhenSingleNucY() throws Exception { clusterHierarchy.setIsSingleCellCluster("N"); clusterHierarchy.setIsSingleNucCluster("y"); clusterHierarchy.setIsRegionalTranscriptomics("N"); + clusterHierarchy.setIsRegionalProteomics("N"); when(clusterHierarchyRepo.findFirstByClusterOrRegion("cluster")).thenReturn(clusterHierarchy); List dataTypes = service.findDataTypesByClusterName("cluster"); @@ -148,6 +151,7 @@ public void testFindDataTypesByClusterNameWhenNeitherY() throws Exception { clusterHierarchy.setIsSingleCellCluster("N"); clusterHierarchy.setIsSingleNucCluster("N"); clusterHierarchy.setIsRegionalTranscriptomics("N"); + clusterHierarchy.setIsRegionalProteomics("N"); when(clusterHierarchyRepo.findFirstByClusterOrRegion("cluster")).thenReturn(clusterHierarchy); List dataTypes = service.findDataTypesByClusterName("cluster"); @@ -162,6 +166,7 @@ public void testFindDataTypesByClusterNameWhenRTY() throws Exception { clusterHierarchy.setIsSingleCellCluster("N"); clusterHierarchy.setIsSingleNucCluster("N"); clusterHierarchy.setIsRegionalTranscriptomics("Y"); + clusterHierarchy.setIsRegionalProteomics("N"); when(clusterHierarchyRepo.findFirstByClusterOrRegion("cluster")).thenReturn(clusterHierarchy); List dataTypes = service.findDataTypesByClusterName("cluster"); @@ -169,4 +174,41 @@ public void testFindDataTypesByClusterNameWhenRTY() throws Exception { assertEquals(1, dataTypes.size()); verify(clusterHierarchyRepo).findFirstByClusterOrRegion("cluster"); } + + + @Test + public void testFindDataTypesByClusterNameWhenRPY() throws Exception { + ClusterHierarchy clusterHierarchy = new ClusterHierarchy(); + clusterHierarchy.setIsSingleCellCluster("N"); + clusterHierarchy.setIsSingleNucCluster("N"); + clusterHierarchy.setIsRegionalTranscriptomics("N"); + clusterHierarchy.setIsRegionalProteomics("Y"); + when(clusterHierarchyRepo.findFirstByClusterOrRegion("cluster")).thenReturn(clusterHierarchy); + + List dataTypes = service.findDataTypesByClusterName("cluster"); + + assertEquals(1, dataTypes.size()); + assertEquals(Arrays.asList("rp"), dataTypes); + verify(clusterHierarchyRepo).findFirstByClusterOrRegion("cluster"); + } + + @Test + public void testFindClustersByCellTypeTubulesOrInterstitium() throws Exception { + List clusterHierarchies = new ArrayList<>(); + when(clusterHierarchyRepo.findByCellType("Tubules")).thenReturn(clusterHierarchies); + when(clusterHierarchyRepo.findByCellType("Interstitium")).thenReturn(clusterHierarchies); + List clusters = service.findClustersByCellType("Tubules"); + assertEquals("Tubulo-interstitium", clusters.get(0).getStructureRegion()); + List clusters2 = service.findClustersByCellType("Interstitium"); + assertEquals("Tubulo-interstitium", clusters2.get(0).getStructureRegion()); + } + + @Test + public void testFindDataTypesByClusterNameTi() throws Exception { + List dataTypes = service.findDataTypesByClusterName("Tubulo-interstitium"); + assertTrue(dataTypes.contains(DataTypeEnum.REGIONAL_PROTEOMICS.getAbbreviation())); + assertTrue(dataTypes.contains(DataTypeEnum.REGIONAL_TRANSCRIPTOMICS.getAbbreviation())); + assertFalse(dataTypes.contains(DataTypeEnum.SINGLE_CELL.getAbbreviation())); + assertFalse(dataTypes.contains(DataTypeEnum.SINGLE_NUCLEUS.getAbbreviation())); + } } diff --git a/src/test/java/org/kpmp/cellTypeSummary/ClusterHierarchyTest.java b/src/test/java/org/kpmp/cellTypeSummary/ClusterHierarchyTest.java index c0d6544..18b33b6 100755 --- a/src/test/java/org/kpmp/cellTypeSummary/ClusterHierarchyTest.java +++ b/src/test/java/org/kpmp/cellTypeSummary/ClusterHierarchyTest.java @@ -61,4 +61,16 @@ public void testSetIsSingleNucCluster() throws Exception { clusterHierarchy.setIsSingleNucCluster("N"); assertEquals("N", clusterHierarchy.getIsSingleNucCluster()); } + + @Test + public void testSetIsRPCluster() throws Exception { + clusterHierarchy.setIsRegionalProteomics("N"); + assertEquals("N", clusterHierarchy.getIsRegionalProteomics()); + } + + @Test + public void testSetIsRTCluster() throws Exception { + clusterHierarchy.setIsRegionalTranscriptomics("N"); + assertEquals("N", clusterHierarchy.getIsRegionalTranscriptomics()); + } } diff --git a/src/test/java/org/kpmp/geneExpression/ExpressionDataServiceTest.java b/src/test/java/org/kpmp/geneExpression/ExpressionDataServiceTest.java index 5e6557a..2030703 100755 --- a/src/test/java/org/kpmp/geneExpression/ExpressionDataServiceTest.java +++ b/src/test/java/org/kpmp/geneExpression/ExpressionDataServiceTest.java @@ -19,12 +19,12 @@ public class ExpressionDataServiceTest { private SNExpressionDataRepository snRepo; @Mock private SCExpressionDataRepository scRepo; - private ExpressionDataService service; + private SNSCExpressionDataService service; @Before public void setUp() throws Exception { MockitoAnnotations.openMocks(this); - service = new ExpressionDataService(snRepo, scRepo); + service = new SNSCExpressionDataService(snRepo, scRepo); } @After diff --git a/src/test/java/org/kpmp/geneExpression/RPAccessionGroupTest.java b/src/test/java/org/kpmp/geneExpression/RPAccessionGroupTest.java new file mode 100755 index 0000000..70015f9 --- /dev/null +++ b/src/test/java/org/kpmp/geneExpression/RPAccessionGroupTest.java @@ -0,0 +1,41 @@ +package org.kpmp.geneExpression; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class RPAccessionGroupTest { + + private RPAccessionGroup rpAccessionGroup; + + @Before + public void setUp() throws Exception { + rpAccessionGroup = new RPAccessionGroup(); + } + + @After + public void tearDown() throws Exception { + rpAccessionGroup = null; + } + + @Test + public void testConstructor() throws Exception { + RPExpressionByTissueType rpExpressionByTissueType = new RPExpressionByTissueType(); + RPAccessionGroup rpAccessionGroup1 = new RPAccessionGroup("accession", rpExpressionByTissueType); + assertEquals(rpExpressionByTissueType, rpAccessionGroup1.getRpExpressionByTissueType()); + assertEquals("accession", rpAccessionGroup1.getAccession()); + } + + @Test + public void testSetters() throws Exception { + RPExpressionByTissueType rpExpressionByTissueType = new RPExpressionByTissueType(); + rpAccessionGroup.setAccession("1234"); + rpAccessionGroup.setRpExpressionByTissueType(rpExpressionByTissueType); + assertEquals("1234", rpAccessionGroup.getAccession()); + assertEquals(rpExpressionByTissueType, rpAccessionGroup.getRpExpressionByTissueType()); + } + + +} diff --git a/src/test/java/org/kpmp/geneExpression/RPExpressionByTissueTypeTest.java b/src/test/java/org/kpmp/geneExpression/RPExpressionByTissueTypeTest.java new file mode 100644 index 0000000..ef8452b --- /dev/null +++ b/src/test/java/org/kpmp/geneExpression/RPExpressionByTissueTypeTest.java @@ -0,0 +1,67 @@ +package org.kpmp.geneExpression; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.mock; + +import java.util.Arrays; +import java.util.List; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class RPExpressionByTissueTypeTest { + + private RPExpressionByTissueType rpExpression; + + @Before + public void setUp() throws Exception { + rpExpression = new RPExpressionByTissueType(); + } + + @After + public void tearDown() throws Exception { + rpExpression = null; + } + + @Test + public void setAll() { + List allataList = Arrays.asList(mock(RPExpressionData.class)); + rpExpression.setAll(allataList); + List actual = rpExpression.getAll(); + assertEquals(allataList, actual); + } + + @Test + public void setAki() { + List allAkiDataList = Arrays.asList(mock(RPExpressionData.class)); + rpExpression.setAki(allAkiDataList); + List actual = rpExpression.getAki(); + assertEquals(allAkiDataList, actual); + } + + @Test + public void setCkd() { + List allCkdDataList = Arrays.asList(mock(RPExpressionData.class)); + rpExpression.setCkd(allCkdDataList); + List actual = rpExpression.getCkd(); + assertEquals(allCkdDataList, actual); + } + + @Test + public void setHrt() { + List allHrtDataList = Arrays.asList(mock(RPExpressionData.class)); + rpExpression.setHrt(allHrtDataList); + List actual = rpExpression.getHrt(); + assertEquals(allHrtDataList, actual); + } + + @Test + public void setDmr() { + List allDmrDataList = Arrays.asList(mock(RPExpressionData.class)); + rpExpression.setDmr(allDmrDataList); + List actual = rpExpression.getDmr(); + assertEquals(allDmrDataList, actual); + } + +} \ No newline at end of file diff --git a/src/test/java/org/kpmp/geneExpression/RPExpressionDataByTissueTypeTest.java b/src/test/java/org/kpmp/geneExpression/RPExpressionDataByTissueTypeTest.java new file mode 100755 index 0000000..61f54b3 --- /dev/null +++ b/src/test/java/org/kpmp/geneExpression/RPExpressionDataByTissueTypeTest.java @@ -0,0 +1,71 @@ +package org.kpmp.geneExpression; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import java.util.Arrays; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class RPExpressionDataByTissueTypeTest { + + private RPExpressionByTissueType rpExpressionByTissueType; + + @Before + public void setUp() throws Exception { + rpExpressionByTissueType = new RPExpressionByTissueType(); + } + + @After + public void tearDown() throws Exception { + rpExpressionByTissueType = null; + } + + @Test + public void setAll() { + RPExpressionData allData = new RPExpressionData(); + List allataList = Arrays.asList(allData); + rpExpressionByTissueType.setAll(allataList); + List actual = rpExpressionByTissueType.getAll(); + assertEquals(allataList, actual); + } + + @Test + public void setAki() { + RPExpressionData allAkiData = new RPExpressionData(); + List allAkiDataList = Arrays.asList(allAkiData); + rpExpressionByTissueType.setAki(allAkiDataList); + List actual = rpExpressionByTissueType.getAki(); + assertEquals(allAkiDataList, actual); + } + + @Test + public void setCkd() { + RPExpressionData allCkdData = new RPExpressionData(); + List allCkdDataList = Arrays.asList(allCkdData); + rpExpressionByTissueType.setCkd(allCkdDataList); + List actual = rpExpressionByTissueType.getCkd(); + assertEquals(allCkdDataList, actual); + } + + @Test + public void setHrt() { + RPExpressionData allHrtData = new RPExpressionData(); + List allHrtDataList = Arrays.asList(allHrtData); + rpExpressionByTissueType.setHrt(allHrtDataList); + List actual = rpExpressionByTissueType.getHrt(); + assertEquals(allHrtDataList, actual); + } + + @Test + public void setDmr() { + RPExpressionData allDmrData = new RPExpressionData(); + List allDmrDataList = Arrays.asList(allDmrData); + rpExpressionByTissueType.setDmr(allDmrDataList); + List actual = rpExpressionByTissueType.getDmr(); + assertEquals(allDmrDataList, actual); + } + +} diff --git a/src/test/java/org/kpmp/geneExpression/RPExpressionDataServiceTest.java b/src/test/java/org/kpmp/geneExpression/RPExpressionDataServiceTest.java new file mode 100755 index 0000000..853b9a7 --- /dev/null +++ b/src/test/java/org/kpmp/geneExpression/RPExpressionDataServiceTest.java @@ -0,0 +1,132 @@ +package org.kpmp.geneExpression; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.kpmp.TissueTypeEnum; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import static org.mockito.Mockito.when; + +public class RPExpressionDataServiceTest { + + @Mock + RPExpressionDataRepository rpExpressionDataRepository; + + RPExpressionDataService rpExpressionDataService; + + @Before + public void setUp() throws Exception { + MockitoAnnotations.openMocks(this); + rpExpressionDataService = new RPExpressionDataService(rpExpressionDataRepository); + } + + @After + public void tearDown() throws Exception { + MockitoAnnotations.openMocks(this).close(); + rpExpressionDataService = null; + } + + @Test + public void testGetByGeneSymbolPerTissue() throws Exception { + + List accessions = new ArrayList<>(); + accessions.add("a1"); + accessions.add("a2"); + when(rpExpressionDataRepository.findAccessionByGeneSymbol("gene")).thenReturn(accessions); + + List rpExpressionDataAki = Arrays.asList(new RPExpressionData[]{new RPExpressionData()}); + List rpExpressionDataCkd = Arrays.asList(new RPExpressionData[]{new RPExpressionData()}); + List rpExpressionDataHrt = Arrays.asList(new RPExpressionData[]{new RPExpressionData()}); + List rpExpressionDataDmr = Arrays.asList(new RPExpressionData[]{new RPExpressionData()}); + List rpExpressionDataAll = Arrays.asList(new RPExpressionData[]{new RPExpressionData()}); + + List rpExpressionDataAki2 = Arrays.asList(new RPExpressionData[]{new RPExpressionData()}); + List rpExpressionDataCkd2 = Arrays.asList(new RPExpressionData[]{new RPExpressionData()}); + List rpExpressionDataHrt2 = Arrays.asList(new RPExpressionData[]{new RPExpressionData()}); + List rpExpressionDataDmr2 = Arrays.asList(new RPExpressionData[]{new RPExpressionData()}); + List rpExpressionDataAll2 = Arrays.asList(new RPExpressionData[]{new RPExpressionData()}); + + when(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeAndProteinWithCounts("gene", TissueTypeEnum.AKI.getParticipantTissueType(), "a1")). + thenReturn(rpExpressionDataAki); + when(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeAndProteinWithCounts("gene", TissueTypeEnum.CKD.getParticipantTissueType(), "a1")). + thenReturn(rpExpressionDataCkd); + when(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeAndProteinWithCounts("gene", TissueTypeEnum.HEALTHY_REFERENCE.getParticipantTissueType(), "a1")). + thenReturn(rpExpressionDataHrt); + when(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeAndProteinWithCounts("gene", TissueTypeEnum.DMR.getParticipantTissueType(), "a1")). + thenReturn(rpExpressionDataDmr); + when(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeAndProteinWithCounts("gene", TissueTypeEnum.ALL.getParticipantTissueType(), "a1")). + thenReturn(rpExpressionDataAll); + + when(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeAndProteinWithCounts("gene", TissueTypeEnum.AKI.getParticipantTissueType(), "a2")). + thenReturn(rpExpressionDataAki2); + when(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeAndProteinWithCounts("gene", TissueTypeEnum.CKD.getParticipantTissueType(), "a2")). + thenReturn(rpExpressionDataCkd2); + when(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeAndProteinWithCounts("gene", TissueTypeEnum.HEALTHY_REFERENCE.getParticipantTissueType(), "a2")). + thenReturn(rpExpressionDataHrt2); + when(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeAndProteinWithCounts("gene", TissueTypeEnum.DMR.getParticipantTissueType(), "a2")). + thenReturn(rpExpressionDataDmr2); + when(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeAndProteinWithCounts("gene", TissueTypeEnum.ALL.getParticipantTissueType(), "a2")). + thenReturn(rpExpressionDataAll2); + + List rpAccessionGroups = rpExpressionDataService.getByGeneSymbolPerTissue("gene"); + + assertEquals("a1", rpAccessionGroups.get(0).getAccession()); + assertEquals("a2", rpAccessionGroups.get(1).getAccession()); + RPExpressionByTissueType rpExpressionByTissueType1 = rpAccessionGroups.get(0).getRpExpressionByTissueType(); + RPExpressionByTissueType rpExpressionByTissueType2 = rpAccessionGroups.get(1).getRpExpressionByTissueType(); + + + assertEquals(rpExpressionByTissueType1.getHrt(), rpExpressionDataHrt); + assertEquals(rpExpressionByTissueType1.getCkd(), rpExpressionDataCkd); + assertEquals(rpExpressionByTissueType1.getAll(), rpExpressionDataAll); + assertEquals(rpExpressionByTissueType1.getDmr(), rpExpressionDataDmr); + + assertEquals(rpExpressionByTissueType2.getHrt(), rpExpressionDataHrt2); + assertEquals(rpExpressionByTissueType2.getCkd(), rpExpressionDataCkd2); + assertEquals(rpExpressionByTissueType2.getAll(), rpExpressionDataAll2); + assertEquals(rpExpressionByTissueType2.getDmr(), rpExpressionDataDmr2); + + } + + @Test + public void testGetByGeneSymbolAndProteinPerTissue() throws Exception { + List rpExpressionDataAki = Arrays.asList(new RPExpressionData[]{new RPExpressionData()}); + List rpExpressionDataCkd = Arrays.asList(new RPExpressionData[]{new RPExpressionData()}); + List rpExpressionDataHrt = Arrays.asList(new RPExpressionData[]{new RPExpressionData()}); + List rpExpressionDataDmr = Arrays.asList(new RPExpressionData[]{new RPExpressionData()}); + List rpExpressionDataAll = Arrays.asList(new RPExpressionData[]{new RPExpressionData()}); + when(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeAndProteinWithCounts("gene", TissueTypeEnum.AKI.getParticipantTissueType(), "protein")). + thenReturn(rpExpressionDataAki); + when(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeAndProteinWithCounts("gene", TissueTypeEnum.CKD.getParticipantTissueType(), "protein")). + thenReturn(rpExpressionDataCkd); + when(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeAndProteinWithCounts("gene", TissueTypeEnum.HEALTHY_REFERENCE.getParticipantTissueType(), "protein")). + thenReturn(rpExpressionDataHrt); + when(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeAndProteinWithCounts("gene", TissueTypeEnum.DMR.getParticipantTissueType(), "protein")). + thenReturn(rpExpressionDataDmr); + when(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeAndProteinWithCounts("gene", TissueTypeEnum.ALL.getParticipantTissueType(), "protein")). + thenReturn(rpExpressionDataAll); + + RPExpressionByTissueType rpExpressionByTissueType = rpExpressionDataService.getByGeneSymbolAndProteinPerTissue("gene", "protein"); + + assertEquals(rpExpressionByTissueType.getAki(), rpExpressionDataAki); + assertEquals(rpExpressionByTissueType.getHrt(), rpExpressionDataHrt); + assertEquals(rpExpressionByTissueType.getCkd(), rpExpressionDataCkd); + assertEquals(rpExpressionByTissueType.getAll(), rpExpressionDataAll); + assertEquals(rpExpressionByTissueType.getDmr(), rpExpressionDataDmr); + } + + @Test + public void testGetByStructure() throws Exception { + List rpExpressionDataList = new ArrayList<>(); + when(rpExpressionDataRepository.findByStructure("structure")).thenReturn(rpExpressionDataList); + assertEquals(rpExpressionDataList, rpExpressionDataService.getByStructure("structure")); + } +} diff --git a/src/test/java/org/kpmp/geneExpression/RPExpressionDataTest.java b/src/test/java/org/kpmp/geneExpression/RPExpressionDataTest.java new file mode 100755 index 0000000..062b41f --- /dev/null +++ b/src/test/java/org/kpmp/geneExpression/RPExpressionDataTest.java @@ -0,0 +1,57 @@ +package org.kpmp.geneExpression; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class RPExpressionDataTest { + + private RPExpressionData rpExpressionData; + + @Before + public void setUp() throws Exception { + rpExpressionData = new RPExpressionData(); + } + + @After + public void tearDown() throws Exception { + rpExpressionData = null; + } + + @Test + public void testSettersAndGetters() throws Exception { + + rpExpressionData.setAccession("accession"); + rpExpressionData.setAdjPVal(123.123); + rpExpressionData.setComparison("comparison"); + rpExpressionData.setFoldChange(1.1234); + rpExpressionData.setId(1); + rpExpressionData.setGeneSymbol("symbol"); + rpExpressionData.setCoveragePct(123); + rpExpressionData.setSampleCount(321); + rpExpressionData.setFdrConfidence("confidence"); + rpExpressionData.setDescription("desc"); + rpExpressionData.setNumPeptides(678); + rpExpressionData.setNumUniquePeptides(456); + rpExpressionData.setTissueType("tissue"); + rpExpressionData.setRegion("region"); + assertEquals(rpExpressionData.getAccession(),"accession"); + assertEquals(rpExpressionData.getAdjPVal(), 123.123); + assertEquals(rpExpressionData.getComparison(), "comparison"); + assertEquals(rpExpressionData.getFoldChange(), 1.1234); + assertEquals(rpExpressionData.getId(), 1); + assertEquals(rpExpressionData.getGeneSymbol(), "symbol"); + assertEquals(rpExpressionData.getCoveragePct(), 123); + assertEquals(rpExpressionData.getSampleCount(), 321); + assertEquals(rpExpressionData.getFdrConfidence(), "confidence"); + assertEquals(rpExpressionData.getDescription(), "desc"); + assertEquals(rpExpressionData.getNumPeptides(), 678); + assertEquals(rpExpressionData.getNumUniquePeptides(), 456); + assertEquals(rpExpressionData.getTissueType(), "tissue"); + assertEquals(rpExpressionData.getRegion(), "region"); + + } + +} diff --git a/src/test/java/org/kpmp/geneExpressionSummary/GeneExpressionSummaryServiceTest.java b/src/test/java/org/kpmp/geneExpressionSummary/GeneExpressionSummaryServiceTest.java index e7f5054..e788e8f 100755 --- a/src/test/java/org/kpmp/geneExpressionSummary/GeneExpressionSummaryServiceTest.java +++ b/src/test/java/org/kpmp/geneExpressionSummary/GeneExpressionSummaryServiceTest.java @@ -13,7 +13,16 @@ import org.junit.Test; import org.kpmp.DataTypeEnum; import org.kpmp.dataSummary.DataTypeSummary; +import org.kpmp.geneExpression.RPExpressionDataRepository; import org.kpmp.geneExpression.RTExpressionDataAllSegmentsRepository; +import org.kpmp.geneExpressionSummary.regionalProteomics.RPParticipantRepository; +import org.kpmp.geneExpressionSummary.regionalTranscriptomics.RTParticipantRepository; +import org.kpmp.geneExpressionSummary.singleCell.SCRNAGeneExpressionExpressionSummaryValue; +import org.kpmp.geneExpressionSummary.singleCell.SCRNAGeneExpressionSummaryRepository; +import org.kpmp.geneExpressionSummary.singleCell.SCRNAParticipantRepository; +import org.kpmp.geneExpressionSummary.singleNucleus.SNRNAGeneExpressionExpressionSummaryValue; +import org.kpmp.geneExpressionSummary.singleNucleus.SNRNAGeneExpressionSummaryRepository; +import org.kpmp.geneExpressionSummary.singleNucleus.SNRNAParticipantRepository; import org.mockito.Mock; import org.mockito.MockitoAnnotations; @@ -33,13 +42,19 @@ public class GeneExpressionSummaryServiceTest { @Mock private RTParticipantRepository rtParticipantRepository; + @Mock + RPExpressionDataRepository rpExpressionDataRepository; + + @Mock + private RPParticipantRepository rpParticipantRepository; + @Before public void setUp() throws Exception { MockitoAnnotations.openMocks(this); geneExpressionService = new GeneExpressionSummaryService( scrnaGeneExpressionRepository, snrnaGeneExpressionRepository, scrnaParticipantRepository, snrnaParticipantRepository, - rtParticipantRepository, rtExpressionDataAllSegmentsRepository); + rtParticipantRepository, rtExpressionDataAllSegmentsRepository, rpExpressionDataRepository, rpParticipantRepository); } @After @@ -134,16 +149,19 @@ public void testFindDataTypesByGeneWhenBothHaveData() throws Exception { when(snrnaGeneExpressionRepository.getCountByGene("gene")).thenReturn(1l); when(scrnaGeneExpressionRepository.getCountByGene("gene")).thenReturn(1l); when(rtExpressionDataAllSegmentsRepository.getCountByGene("gene")).thenReturn(1l); + when(rpExpressionDataRepository.getCountByGene("gene")).thenReturn(1l); + List dataTypes = geneExpressionService.findDataTypesByGene("gene"); - assertEquals(3, dataTypes.size()); + assertEquals(4, dataTypes.size()); assertEquals(Arrays.asList(DataTypeEnum.SINGLE_CELL.getAbbreviation(), - DataTypeEnum.SINGLE_NUCLEUS.getAbbreviation(), DataTypeEnum.REGIONAL_TRANSCRIPTOMICS.getAbbreviation()), + DataTypeEnum.SINGLE_NUCLEUS.getAbbreviation(), DataTypeEnum.REGIONAL_TRANSCRIPTOMICS.getAbbreviation(), DataTypeEnum.REGIONAL_PROTEOMICS.getAbbreviation()), dataTypes); verify(snrnaGeneExpressionRepository).getCountByGene("gene"); verify(scrnaGeneExpressionRepository).getCountByGene("gene"); verify(rtExpressionDataAllSegmentsRepository).getCountByGene("gene"); + verify(rpExpressionDataRepository).getCountByGene("gene"); } @Test @@ -189,7 +207,7 @@ public void testFindDataTypesByGeneWhenNeitherHaveData() throws Exception { } @Test - public void testGetGeneDatasetInformation() throws Exception { + public void getDataTypeSummaryInformation() throws Exception { when(rtParticipantRepository.getCountByTissueType("aki")).thenReturn((long) 0); when(rtParticipantRepository.getCountByTissueType("ckd")).thenReturn((long) 0); @@ -203,11 +221,17 @@ public void testGetGeneDatasetInformation() throws Exception { when(snrnaGeneExpressionRepository.getCountByTissue("ckd")).thenReturn(Long.valueOf(0)); when(snrnaGeneExpressionRepository.getCountByTissue("hrt")).thenReturn(Long.valueOf(0)); when(snrnaParticipantRepository.getParticipantCount()).thenReturn(Long.valueOf(0)); + when(rpParticipantRepository.getCountByTissueType("aki")).thenReturn((long) 0); + when(rpParticipantRepository.getCountByTissueType("ckd")).thenReturn((long) 0); + when(rpParticipantRepository.getCountByTissueType("hrt")).thenReturn((long) 0); + when(rpParticipantRepository.getParticipantCount()).thenReturn((long) 0); - List result = geneExpressionService.getGeneDatasetInformation("AAA"); + List result = geneExpressionService.getDataTypeSummaryInformation(); + assertEquals(4, result.size()); DataTypeSummary resultDataSC = result.get(0); DataTypeSummary resultDataSN = result.get(1); DataTypeSummary resultDataRt = result.get(2); + DataTypeSummary resultDataRp = result.get(3); assertEquals(Long.valueOf(0), resultDataSC.getAkiCount()); assertEquals(Long.valueOf(0), resultDataSC.getCkdCount()); @@ -218,9 +242,15 @@ public void testGetGeneDatasetInformation() throws Exception { assertEquals(Long.valueOf(0), resultDataRt.getAkiCount()); assertEquals(Long.valueOf(0), resultDataRt.getCkdCount()); assertEquals(Long.valueOf(0), resultDataRt.getHrtCount()); + assertEquals(Long.valueOf(0), resultDataRp.getHrtCount()); + assertEquals(Long.valueOf(0), resultDataRp.getAkiCount()); + assertEquals(Long.valueOf(0), resultDataRp.getCkdCount()); + assertEquals(Long.valueOf(0), resultDataRp.getHrtCount()); + assertEquals("sc", resultDataSC.getDataTypeShort()); assertEquals("sn", resultDataSN.getDataTypeShort()); assertEquals("rt", resultDataRt.getDataTypeShort()); + assertEquals("rp", resultDataRp.getDataTypeShort()); assertEquals(Long.valueOf(0), resultDataSN.getParticipantCount()); } diff --git a/src/test/java/org/kpmp/geneExpressionSummary/RTParticipantValueTest.java b/src/test/java/org/kpmp/geneExpressionSummary/RTParticipantValueTest.java index 2325927..5a1d8aa 100755 --- a/src/test/java/org/kpmp/geneExpressionSummary/RTParticipantValueTest.java +++ b/src/test/java/org/kpmp/geneExpressionSummary/RTParticipantValueTest.java @@ -5,6 +5,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; import org.junit.jupiter.api.TestInstance.Lifecycle; +import org.kpmp.geneExpressionSummary.regionalTranscriptomics.RTParticipantValue; import static org.junit.jupiter.api.Assertions.*; diff --git a/src/test/java/org/kpmp/geneExpressionSummary/SCRNAGeneExpressionSummaryValueTest.java b/src/test/java/org/kpmp/geneExpressionSummary/SCRNAGeneExpressionSummaryValueTest.java index 5debdcf..7252d58 100755 --- a/src/test/java/org/kpmp/geneExpressionSummary/SCRNAGeneExpressionSummaryValueTest.java +++ b/src/test/java/org/kpmp/geneExpressionSummary/SCRNAGeneExpressionSummaryValueTest.java @@ -5,6 +5,7 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.kpmp.geneExpressionSummary.singleCell.SCRNAGeneExpressionExpressionSummaryValue; public class SCRNAGeneExpressionSummaryValueTest { diff --git a/src/test/java/org/kpmp/geneExpressionSummary/SCRNAParticipantValueTest.java b/src/test/java/org/kpmp/geneExpressionSummary/SCRNAParticipantValueTest.java index 9dc2c1f..214ee2c 100755 --- a/src/test/java/org/kpmp/geneExpressionSummary/SCRNAParticipantValueTest.java +++ b/src/test/java/org/kpmp/geneExpressionSummary/SCRNAParticipantValueTest.java @@ -5,6 +5,7 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.kpmp.geneExpressionSummary.singleCell.SCRNAParticipantValue; public class SCRNAParticipantValueTest { diff --git a/src/test/java/org/kpmp/geneExpressionSummary/SNRNAGeneExpressionSummaryValueTest.java b/src/test/java/org/kpmp/geneExpressionSummary/SNRNAGeneExpressionSummaryValueTest.java index 46176bc..118e05c 100755 --- a/src/test/java/org/kpmp/geneExpressionSummary/SNRNAGeneExpressionSummaryValueTest.java +++ b/src/test/java/org/kpmp/geneExpressionSummary/SNRNAGeneExpressionSummaryValueTest.java @@ -5,6 +5,7 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.kpmp.geneExpressionSummary.singleNucleus.SNRNAGeneExpressionExpressionSummaryValue; public class SNRNAGeneExpressionSummaryValueTest { diff --git a/src/test/java/org/kpmp/geneExpressionSummary/SNRNAParticipantValueTest.java b/src/test/java/org/kpmp/geneExpressionSummary/SNRNAParticipantValueTest.java index 19ffe38..3dbed99 100755 --- a/src/test/java/org/kpmp/geneExpressionSummary/SNRNAParticipantValueTest.java +++ b/src/test/java/org/kpmp/geneExpressionSummary/SNRNAParticipantValueTest.java @@ -5,6 +5,7 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.kpmp.geneExpressionSummary.singleNucleus.SNRNAParticipantValue; public class SNRNAParticipantValueTest { diff --git a/src/test/java/org/kpmp/participant/ParticipantServiceTest.java b/src/test/java/org/kpmp/participant/ParticipantServiceTest.java index 2324497..872ae19 100755 --- a/src/test/java/org/kpmp/participant/ParticipantServiceTest.java +++ b/src/test/java/org/kpmp/participant/ParticipantServiceTest.java @@ -11,7 +11,8 @@ import org.junit.Before; import org.junit.Test; import org.kpmp.dataSummary.DataSummaryRepository; -import org.kpmp.geneExpressionSummary.RTParticipantRepository; +import org.kpmp.geneExpressionSummary.regionalProteomics.RPParticipantRepository; +import org.kpmp.geneExpressionSummary.regionalTranscriptomics.RTParticipantRepository; import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.MockitoAnnotations; @@ -32,11 +33,14 @@ public class ParticipantServiceTest { @Mock private RTParticipantRepository rtParticipantRepo; + @Mock + private RPParticipantRepository rpParticipantRepository; + @Before public void setUp() throws Exception { MockitoAnnotations.openMocks(this); participantService = new ParticipantService(dataSummaryRepo, svTypeRepo, scMetadataRepo, snMetadataRepo, - rtParticipantRepo, participantSummaryDatasetRepository); + rtParticipantRepo, participantSummaryDatasetRepository, rpParticipantRepository); } @After @@ -92,13 +96,14 @@ public void testGetExperimentCounts() { when(scMetadataRepo.existsByRedcapId("redcapId")).thenReturn(true); when(snMetadataRepo.existsByRedcapId("redcapId")).thenReturn(true); when(rtParticipantRepo.existsByRedcapId("redcapId")).thenReturn(true); + when(rpParticipantRepository.existsByRedcapId("redcapId")).thenReturn(true); ParticipantDataTypeSummary result = participantService.getExperimentCounts("redcapId"); List spatialViewerDataTypes = result.getSpatialViewerDataTypes(); assertEquals(2, spatialViewerDataTypes.size()); List explorerDataTypes = result.getExplorerDataTypes(); - assertEquals(3, explorerDataTypes.size()); + assertEquals(4, explorerDataTypes.size()); for (ParticipantDataTypeInformation participantDataTypeInformation : spatialViewerDataTypes) { if (participantDataTypeInformation.getDataType().equals("Light Microscopy")) { assertEquals(new Integer(5), participantDataTypeInformation.getCount()); diff --git a/src/test/java/org/kpmp/umap/UmapDataServiceTest.java b/src/test/java/org/kpmp/umap/UmapDataServiceTest.java index 167f740..920ed34 100755 --- a/src/test/java/org/kpmp/umap/UmapDataServiceTest.java +++ b/src/test/java/org/kpmp/umap/UmapDataServiceTest.java @@ -10,7 +10,7 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.kpmp.geneExpression.ExpressionDataService; +import org.kpmp.geneExpression.SNSCExpressionDataService; import org.mockito.Mock; import org.mockito.MockitoAnnotations; @@ -18,7 +18,7 @@ public class UmapDataServiceTest { private UmapDataService service; @Mock - private ExpressionDataService expressionDataService; + private SNSCExpressionDataService expressionDataService; @Mock private SCMetadataRepository scMetadataRepository; @Mock