From fa5e4f354d1c6cd79b46a67eebaf1899785e37b3 Mon Sep 17 00:00:00 2001 From: Zach Wright Date: Thu, 16 Nov 2023 16:13:47 -0500 Subject: [PATCH 01/34] KPMP-4430: Cleanup confusing naming --- src/main/java/org/kpmp/DataTypeEnum.java | 4 + src/main/java/org/kpmp/FullDataTypeEnum.java | 4 + src/main/java/org/kpmp/Query.java | 4 +- .../GeneExpressionSummaryService.java | 29 ++- .../RTParticipantRepository.java | 19 -- .../RTParticipantValue.java | 44 ---- ...AGeneExpressionExpressionSummaryValue.java | 203 ---------------- .../SCRNAGeneExpressionSummaryRepository.java | 39 ---- .../SCRNAParticipantRepository.java | 13 -- .../SCRNAParticipantValue.java | 40 ---- ...AGeneExpressionExpressionSummaryValue.java | 216 ------------------ .../SNRNAGeneExpressionSummaryRepository.java | 39 ---- .../SNRNAParticipantRepository.java | 14 -- .../SNRNAParticipantValue.java | 44 ---- .../kpmp/participant/ParticipantService.java | 2 +- .../resources/knowledge_environment.graphqls | 4 +- src/test/java/org/kpmp/QueryTest.java | 4 +- .../GeneExpressionSummaryServiceTest.java | 7 + .../RTParticipantValueTest.java | 1 + .../SCRNAGeneExpressionSummaryValueTest.java | 1 + .../SCRNAParticipantValueTest.java | 1 + .../SNRNAGeneExpressionSummaryValueTest.java | 1 + .../SNRNAParticipantValueTest.java | 1 + .../participant/ParticipantServiceTest.java | 2 +- 24 files changed, 51 insertions(+), 685 deletions(-) delete mode 100755 src/main/java/org/kpmp/geneExpressionSummary/RTParticipantRepository.java delete mode 100755 src/main/java/org/kpmp/geneExpressionSummary/RTParticipantValue.java delete mode 100755 src/main/java/org/kpmp/geneExpressionSummary/SCRNAGeneExpressionExpressionSummaryValue.java delete mode 100755 src/main/java/org/kpmp/geneExpressionSummary/SCRNAGeneExpressionSummaryRepository.java delete mode 100755 src/main/java/org/kpmp/geneExpressionSummary/SCRNAParticipantRepository.java delete mode 100755 src/main/java/org/kpmp/geneExpressionSummary/SCRNAParticipantValue.java delete mode 100755 src/main/java/org/kpmp/geneExpressionSummary/SNRNAGeneExpressionExpressionSummaryValue.java delete mode 100755 src/main/java/org/kpmp/geneExpressionSummary/SNRNAGeneExpressionSummaryRepository.java delete mode 100755 src/main/java/org/kpmp/geneExpressionSummary/SNRNAParticipantRepository.java delete mode 100755 src/main/java/org/kpmp/geneExpressionSummary/SNRNAParticipantValue.java 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..74049e5 100755 --- a/src/main/java/org/kpmp/Query.java +++ b/src/main/java/org/kpmp/Query.java @@ -95,9 +95,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; diff --git a/src/main/java/org/kpmp/geneExpressionSummary/GeneExpressionSummaryService.java b/src/main/java/org/kpmp/geneExpressionSummary/GeneExpressionSummaryService.java index 9ebccc9..928b3ac 100755 --- a/src/main/java/org/kpmp/geneExpressionSummary/GeneExpressionSummaryService.java +++ b/src/main/java/org/kpmp/geneExpressionSummary/GeneExpressionSummaryService.java @@ -10,6 +10,12 @@ import org.kpmp.TissueTypeEnum; import org.kpmp.dataSummary.DataTypeSummary; 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 +26,8 @@ public class GeneExpressionSummaryService { private SCRNAParticipantRepository scrnaParticipantRepository; private SNRNAParticipantRepository snrnaParticipantRepository; private RTParticipantRepository rtParticipantRepository; + + private RPParticipantRepository rpParticipantRepository; RTExpressionDataAllSegmentsRepository rtExpressionDataAllSegmentsRepository; @Autowired @@ -110,9 +118,9 @@ public List findDataTypesByGene(String gene) { 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 +128,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 +136,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 +145,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/RTParticipantRepository.java b/src/main/java/org/kpmp/geneExpressionSummary/RTParticipantRepository.java deleted file mode 100755 index 08dd2cd..0000000 --- a/src/main/java/org/kpmp/geneExpressionSummary/RTParticipantRepository.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.kpmp.geneExpressionSummary; - -import org.springframework.cache.annotation.Cacheable; -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.CrudRepository; - -public interface RTParticipantRepository extends CrudRepository { - - @Cacheable("rtCounts") - @Query(value = "SELECT COUNT(DISTINCT rtp.redcap_id) FROM rt_participant_tissue_v rtp", nativeQuery = true) - Long getParticipantCount(); - - @Cacheable("rtCountsByTissue") - @Query(value = "SELECT COUNT(DISTINCT rtp.redcap_id) FROM rt_participant_tissue_v rtp WHERE rtp.tissue_type = :tissueType", nativeQuery = true) - Long getCountByTissueType(String tissueType); - - boolean existsByRedcapId(String redcapId); - -} diff --git a/src/main/java/org/kpmp/geneExpressionSummary/RTParticipantValue.java b/src/main/java/org/kpmp/geneExpressionSummary/RTParticipantValue.java deleted file mode 100755 index 62df11f..0000000 --- a/src/main/java/org/kpmp/geneExpressionSummary/RTParticipantValue.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.kpmp.geneExpressionSummary; - -import java.io.Serializable; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.IdClass; -import javax.persistence.Table; - -@Entity -@Table(name = "rt_participant_tissue_v") -@IdClass(ParticipantId.class) -class RTParticipantValue implements Participant, Serializable { - - private static final long serialVersionUID = 5368734102102552073L; - - @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/SCRNAGeneExpressionExpressionSummaryValue.java b/src/main/java/org/kpmp/geneExpressionSummary/SCRNAGeneExpressionExpressionSummaryValue.java deleted file mode 100755 index 8cc08ef..0000000 --- a/src/main/java/org/kpmp/geneExpressionSummary/SCRNAGeneExpressionExpressionSummaryValue.java +++ /dev/null @@ -1,203 +0,0 @@ -package org.kpmp.geneExpressionSummary; - -import java.beans.Transient; -import java.io.Serializable; - -import javax.annotation.Nullable; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.IdClass; -import javax.persistence.Table; - -import org.kpmp.DataTypeEnum; - -@Entity -@Table(name = "sc_rnaseq") -@IdClass(GeneExpressionId.class) -public class SCRNAGeneExpressionExpressionSummaryValue implements GeneExpressionSummary, Serializable { - - private static final long serialVersionUID = 7265280085624504185L; - @Column(name = "id") - private Integer id; - @Column(name = "tissue_type") - private String tissueType; - @Id - @Column(name = "gene") - private String gene; - @Column(name = "p_val") - private Double pVal; - @Column(name = "p_val_adj") - private Double pValAdj; - @Column(name = "fold_change") - private Double foldChange; - @Column(name = "pct_1") - private Double pct1; - @Column(name = "pct_2") - private Double pct2; - @Column(name = "avg_exp") - private Double avgExp; - @Id - @Column(name = "cluster") - private String cluster; - - @Column(name = "cluster_name") - private String clusterName; - - @Column(name = "cell_count") - private Integer cellCount; - - @Override - @Transient - public String getDataType() { - return DataTypeEnum.SINGLE_CELL.getAbbreviation(); - } - - @Override - public void setCellCount(Integer cellCount) { - this.cellCount = cellCount; - } - - @Override - public Integer getCellCount() { - return this.cellCount; - } - - @Override - public void setClusterName(String clusterName) { - this.clusterName = clusterName; - } - - @Nullable - @Override - public String getClusterName() { - return this.clusterName; - } - - @Override - @Nullable - public Integer getId() { - return id; - } - - @Override - public void setId(Integer id) { - this.id = id; - } - - @Override - @Nullable - public String getTissueType() { - return tissueType; - } - - @Override - public void setTissueType(String tissueType) { - this.tissueType = tissueType; - } - - @Override - @Nullable - public String getGene() { - return gene; - } - - @Override - public void setGene(String gene) { - this.gene = gene; - } - - @Override - @Nullable - public Double getPVal() { - return pVal; - } - - @Override - public void setPVal(Double pVal) { - this.pVal = pVal; - } - - @Override - @Nullable - public Double getPValAdj() { - return pValAdj; - } - - @Override - public void setPValAdj(Double pValAdj) { - this.pValAdj = pValAdj; - } - - @Override - @Nullable - public Double getFoldChange() { - return foldChange; - } - - @Override - public void setFoldChange(Double foldChange) { - this.foldChange = foldChange; - } - - @Override - @Nullable - public Double getPct1() { - return pct1; - } - - @Override - public void setPct1(Double pct1) { - this.pct1 = pct1; - } - - @Override - @Nullable - public Double getPct2() { - return pct2; - } - - @Override - public void setPct2(Double pct2) { - this.pct2 = pct2; - } - - @Override - @Nullable - public Double getAvgExp() { - return avgExp; - } - - @Override - public void setAvgExp(Double avgExp) { - this.avgExp = avgExp; - } - - @Override - @Nullable - public String getCluster() { - return cluster; - } - - @Override - public void setCluster(String cluster) { - this.cluster = cluster; - } - - @Override - public int hashCode() { - return (gene + cluster).hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (obj == this) - return true; - if (!(obj instanceof SCRNAGeneExpressionExpressionSummaryValue)) - return false; - SCRNAGeneExpressionExpressionSummaryValue scrnaGeneExpressionExpressionSummaryValue = (SCRNAGeneExpressionExpressionSummaryValue) obj; - return (scrnaGeneExpressionExpressionSummaryValue.getGene().equals(this.getGene()) - && scrnaGeneExpressionExpressionSummaryValue.getCluster().equals(this.getCluster())); - } - -} diff --git a/src/main/java/org/kpmp/geneExpressionSummary/SCRNAGeneExpressionSummaryRepository.java b/src/main/java/org/kpmp/geneExpressionSummary/SCRNAGeneExpressionSummaryRepository.java deleted file mode 100755 index 1a13ca5..0000000 --- a/src/main/java/org/kpmp/geneExpressionSummary/SCRNAGeneExpressionSummaryRepository.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.kpmp.geneExpressionSummary; - -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.data.repository.query.Param; -import org.springframework.stereotype.Repository; - -@Repository -public interface SCRNAGeneExpressionSummaryRepository - extends CrudRepository { - - @Cacheable("scCountsAllClusters") - @Query(value = "SELECT DISTINCT scc.cluster, scc.cluster_name, scc.cell_count, scc.cluster_id as id, IF(isnull(scr.tissue_type), :tissueType, scr.tissue_type) as tissue_type, IF(isnull(scr.gene), :geneSymbol, scr.gene) as gene, scr.p_val as p_val, scr.p_val_adj as p_val_adj, scr.fold_change, scr.pct_1, scr.pct_2, scr.avg_exp as avg_exp " - + "FROM sc_cluster_v scc " - + "LEFT JOIN sc_rnaseq scr ON scc.cluster = scr.cluster AND scr.gene = :geneSymbol AND scr.tissue_type = LCASE(:tissueType) " - + "WHERE scc.tissue_type = LCASE(:tissueType) ORDER BY scr.p_val IS NULL, scr.p_val ASC", nativeQuery = true) - List findByTissueAndGeneAllClusters( - @Param("geneSymbol") String geneSymbol, @Param("tissueType") String tissueType); - - @Cacheable("scCountsSummaryPerGene") - @Query(value = "SELECT DISTINCT scr.cluster, c.cluster_name, 0 as cell_count, scr.id, scr.tissue_type, scr.gene, scr.p_val as p_val, scr.p_val_adj as p_val_adj, scr.fold_change, scr.pct_1, scr.pct_2, scr.avg_exp as avg_exp " - + "FROM sc_rnaseq scr " + "JOIN cluster c ON scr.cluster = c.abbreviation AND c.cluster_name = :cellType " - + "WHERE scr.tissue_type = LCASE(:tissueType) " + "ORDER BY scr.fold_change DESC", nativeQuery = true) - List findExpressionSummaryPerGeneByCellTypeAndTissueType( - @Param("cellType") String cellType, @Param("tissueType") String tissueType); - - @Cacheable("scCountsByGene") - @Query(value = "SELECT COUNT(*) FROM sc_rnaseq scr WHERE scr.gene= :gene", nativeQuery = true) - long getCountByGene(@Param("gene") String gene); - - @Cacheable("scCountsByTissue") - @Query(value = "select count(*) from (select p.redcap_id from sc_metadata sc " - + "join participant p on sc.specimen_id = p.redcap_id " - + "where p.tissue_type=:tissueType group by p.redcap_id) as mycount", nativeQuery = true) - long getCountByTissue(@Param("tissueType") String tissueType); -} \ No newline at end of file diff --git a/src/main/java/org/kpmp/geneExpressionSummary/SCRNAParticipantRepository.java b/src/main/java/org/kpmp/geneExpressionSummary/SCRNAParticipantRepository.java deleted file mode 100755 index 08c5e71..0000000 --- a/src/main/java/org/kpmp/geneExpressionSummary/SCRNAParticipantRepository.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.kpmp.geneExpressionSummary; - -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 -public interface SCRNAParticipantRepository extends CrudRepository { - @Cacheable("scParticipantCount") - @Query(value = "SELECT COUNT(DISTINCT scp.redcap_id) FROM sc_participant_tissue_v scp", nativeQuery = true) - Long getParticipantCount(); -} diff --git a/src/main/java/org/kpmp/geneExpressionSummary/SCRNAParticipantValue.java b/src/main/java/org/kpmp/geneExpressionSummary/SCRNAParticipantValue.java deleted file mode 100755 index a758ab5..0000000 --- a/src/main/java/org/kpmp/geneExpressionSummary/SCRNAParticipantValue.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.kpmp.geneExpressionSummary; - -import java.io.Serializable; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.IdClass; -import javax.persistence.Table; - -@Entity -@Table(name = "sn_participant_tissue_v") -@IdClass(ParticipantId.class) -public class SCRNAParticipantValue implements Serializable { - - private static final long serialVersionUID = 8746341469788157316L; - - @Column(name = "tissue_type") - private String tissueType; - - @Column(name = "redcap_id") - private String redcapId; - - @Id - public String getRedcapId() { - return redcapId; - } - - public void setRedcapId(String redcapId) { - this.redcapId = redcapId; - } - - public String getTissueType() { - return tissueType; - } - - public void setTissueType(String tissueType) { - this.tissueType = tissueType; - } -} diff --git a/src/main/java/org/kpmp/geneExpressionSummary/SNRNAGeneExpressionExpressionSummaryValue.java b/src/main/java/org/kpmp/geneExpressionSummary/SNRNAGeneExpressionExpressionSummaryValue.java deleted file mode 100755 index 7093151..0000000 --- a/src/main/java/org/kpmp/geneExpressionSummary/SNRNAGeneExpressionExpressionSummaryValue.java +++ /dev/null @@ -1,216 +0,0 @@ -package org.kpmp.geneExpressionSummary; - -import java.io.Serializable; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.IdClass; -import javax.persistence.Table; -import javax.persistence.Transient; - -import org.kpmp.DataTypeEnum; -import org.springframework.lang.Nullable; - -@Entity -@Table(name = "sn_rnaseq") -@IdClass(GeneExpressionId.class) -public class SNRNAGeneExpressionExpressionSummaryValue implements GeneExpressionSummary, Serializable { - - private static final long serialVersionUID = -443713903175981503L; - - @Column(name = "id") - private Integer id; - - @Column(name = "tissue_type") - private String tissueType; - - @Id - @Column(name = "gene") - private String gene; - - @Column(name = "p_val") - private Double pVal; - - @Column(name = "p_val_adj") - private Double pValAdj; - - @Column(name = "fold_change") - private Double foldChange; - - @Column(name = "pct_1") - private Double pct1; - - @Column(name = "pct_2") - private Double pct2; - - @Column(name = "avg_exp") - private Double avgExp; - - @Id - @Column(name = "cluster") - private String cluster; - - @Column(name = "cell_type") - private String cellType; - - @Override - @Transient - public String getDataType() { - return DataTypeEnum.SINGLE_NUCLEUS.getAbbreviation(); - } - - @Column(name = "cluster_name") - private String clusterName; - - @Column(name = "cell_count") - private Integer cellCount; - - @Override - @Nullable - public Integer getId() { - return id; - } - - @Override - public void setId(Integer id) { - this.id = id; - } - - @Override - @Nullable - public String getTissueType() { - return tissueType; - } - - @Override - public void setTissueType(String tissueType) { - this.tissueType = tissueType; - } - - @Override - @Nullable - public String getGene() { - return gene; - } - - @Override - public void setGene(String gene) { - this.gene = gene; - } - - @Override - @Nullable - public Double getPVal() { - return pVal; - } - - @Override - public void setPVal(Double pVal) { - this.pVal = pVal; - } - - @Override - @Nullable - public Double getPValAdj() { - return pValAdj; - } - - @Override - public void setPValAdj(Double pValAdj) { - this.pValAdj = pValAdj; - } - - @Override - @Nullable - public Double getFoldChange() { - return foldChange; - } - - @Override - public void setFoldChange(Double foldChange) { - this.foldChange = foldChange; - } - - @Override - @Nullable - public Double getPct1() { - return pct1; - } - - @Override - public void setPct1(Double pct1) { - this.pct1 = pct1; - } - - @Override - @Nullable - public Double getPct2() { - return pct2; - } - - @Override - public void setPct2(Double pct2) { - this.pct2 = pct2; - } - - @Override - @Nullable - public Double getAvgExp() { - return avgExp; - } - - @Override - @Nullable - public void setAvgExp(Double avgExp) { - this.avgExp = avgExp; - } - - @Id - @Override - public String getCluster() { - return cluster; - } - - @Override - public void setCluster(String cluster) { - this.cluster = cluster; - } - - @Override - public void setCellCount(Integer cellCount) { - this.cellCount = cellCount; - } - - @Override - public Integer getCellCount() { - return this.cellCount; - } - - @Override - public void setClusterName(String clusterName) { - this.clusterName = clusterName; - } - - @Nullable - @Override - public String getClusterName() { - return this.clusterName; - } - - @Override - public int hashCode() { - return (gene + cluster).hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (obj == this) - return true; - if (!(obj instanceof SNRNAGeneExpressionExpressionSummaryValue)) - return false; - SNRNAGeneExpressionExpressionSummaryValue snrnaGeneExpressionExpressionSummaryValue = (SNRNAGeneExpressionExpressionSummaryValue) obj; - return (snrnaGeneExpressionExpressionSummaryValue.getGene().equals(this.getGene()) - && snrnaGeneExpressionExpressionSummaryValue.getCluster().equals(this.getCluster())); - } -} diff --git a/src/main/java/org/kpmp/geneExpressionSummary/SNRNAGeneExpressionSummaryRepository.java b/src/main/java/org/kpmp/geneExpressionSummary/SNRNAGeneExpressionSummaryRepository.java deleted file mode 100755 index 9f79f93..0000000 --- a/src/main/java/org/kpmp/geneExpressionSummary/SNRNAGeneExpressionSummaryRepository.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.kpmp.geneExpressionSummary; - -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.data.repository.query.Param; -import org.springframework.stereotype.Repository; - -@Repository -public interface SNRNAGeneExpressionSummaryRepository - extends CrudRepository { - - @Cacheable("snCountsBy") - @Query(value = "SELECT DISTINCT snc.cluster, snc.cluster_name, snc.cell_count as cell_count, snc.cluster_id as id, IF(isnull(snr.tissue_type), :tissueType, snr.tissue_type) as tissue_type, IF(isnull(snr.gene), :geneSymbol, snr.gene) as gene, snr.p_val as pval, snr.p_val_adj as pval_adj, snr.fold_change, snr.pct_1 as pct1, snr.pct_2 as pct2, snr.avg_exp as avg_exp " - + "FROM sn_cluster_v snc " - + "LEFT JOIN sn_rnaseq snr ON snc.cluster = snr.cluster AND snr.gene = :geneSymbol AND snr.tissue_type = LCASE(:tissueType) " - + "WHERE snc.tissue_type = LCASE(:tissueType) ORDER BY snr.p_val IS NULL, snr.p_val ASC", nativeQuery = true) - List findByTissueAndGeneAllClusters( - @Param("geneSymbol") String geneSymbol, @Param("tissueType") String tissueType); - - @Cacheable("snCounts") - @Query(value = "SELECT DISTINCT snr.cluster, c.cluster_name, 0 as cell_count, snr.id, snr.tissue_type, snr.gene, snr.p_val as pval, snr.p_val_adj as pval_adj, snr.fold_change, snr.pct_1 as pct1, snr.pct_2 as pct2, snr.avg_exp as avg_exp " - + "FROM sn_rnaseq snr " + "JOIN cluster c ON snr.cluster = c.abbreviation AND c.cluster_name = :cellType " - + "WHERE snr.tissue_type = LCASE(:tissueType) " + "ORDER BY snr.fold_change DESC", nativeQuery = true) - List findExpressionSummaryPerGeneByCellTypeAndTissueType( - @Param("cellType") String cellType, @Param("tissueType") String tissueType); - - @Cacheable("snCounts") - @Query(value = "select count(*) from (select p.redcap_id from sn_metadata sn " - + "join participant p on sn.specimen_id = p.redcap_id " - + "where p.tissue_type=:tissueType group by p.redcap_id) as mycount", nativeQuery = true) - long getCountByTissue(@Param("tissueType") String tissueType); - - @Cacheable("snCounts") - @Query(value = "SELECT COUNT(*) FROM sn_rnaseq snr WHERE snr.gene= :gene", nativeQuery = true) - long getCountByGene(@Param("gene") String gene); -} diff --git a/src/main/java/org/kpmp/geneExpressionSummary/SNRNAParticipantRepository.java b/src/main/java/org/kpmp/geneExpressionSummary/SNRNAParticipantRepository.java deleted file mode 100755 index 6b306ba..0000000 --- a/src/main/java/org/kpmp/geneExpressionSummary/SNRNAParticipantRepository.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.kpmp.geneExpressionSummary; - -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 -public interface SNRNAParticipantRepository extends CrudRepository { - - @Cacheable("snParticipantCount") - @Query(value = "SELECT COUNT(DISTINCT snp.redcap_id) FROM sn_participant_tissue_v snp", nativeQuery = true) - Long getParticipantCount(); -} diff --git a/src/main/java/org/kpmp/geneExpressionSummary/SNRNAParticipantValue.java b/src/main/java/org/kpmp/geneExpressionSummary/SNRNAParticipantValue.java deleted file mode 100755 index 6c9dadc..0000000 --- a/src/main/java/org/kpmp/geneExpressionSummary/SNRNAParticipantValue.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.kpmp.geneExpressionSummary; - -import java.io.Serializable; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.IdClass; -import javax.persistence.Table; - -@Entity -@Table(name = "sn_participant_tissue_v") -@IdClass(ParticipantId.class) -public class SNRNAParticipantValue implements Participant, Serializable { - - private static final long serialVersionUID = -2404700991479961255L; - - @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/participant/ParticipantService.java b/src/main/java/org/kpmp/participant/ParticipantService.java index 2c63ac7..9fc8093 100755 --- a/src/main/java/org/kpmp/participant/ParticipantService.java +++ b/src/main/java/org/kpmp/participant/ParticipantService.java @@ -7,7 +7,7 @@ import org.kpmp.TissueTypeEnum; import org.kpmp.dataSummary.AtlasRepoSummaryLinkInformation; import org.kpmp.dataSummary.DataSummaryRepository; -import org.kpmp.geneExpressionSummary.RTParticipantRepository; +import org.kpmp.geneExpressionSummary.regionalTranscriptomics.RTParticipantRepository; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; diff --git a/src/main/resources/knowledge_environment.graphqls b/src/main/resources/knowledge_environment.graphqls index ddbece8..039027b 100755 --- a/src/main/resources/knowledge_environment.graphqls +++ b/src/main/resources/knowledge_environment.graphqls @@ -5,7 +5,7 @@ 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 getRTGeneExpressionByStructure(structure: String): [RTGeneExpression] getSummaryData: [GeneDatasetInformation] @@ -63,7 +63,7 @@ type ParticipantRepoDataTypeInformation { linkInformation: AtlasRepoSummaryLinkInformation } -type GeneDatasetInformation { +type SummaryDataTypeInformation { omicsType: String dataType: String dataTypeShort: String diff --git a/src/test/java/org/kpmp/QueryTest.java b/src/test/java/org/kpmp/QueryTest.java index f713d7d..04b22ad 100755 --- a/src/test/java/org/kpmp/QueryTest.java +++ b/src/test/java/org/kpmp/QueryTest.java @@ -28,8 +28,8 @@ 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; diff --git a/src/test/java/org/kpmp/geneExpressionSummary/GeneExpressionSummaryServiceTest.java b/src/test/java/org/kpmp/geneExpressionSummary/GeneExpressionSummaryServiceTest.java index e7f5054..b107344 100755 --- a/src/test/java/org/kpmp/geneExpressionSummary/GeneExpressionSummaryServiceTest.java +++ b/src/test/java/org/kpmp/geneExpressionSummary/GeneExpressionSummaryServiceTest.java @@ -14,6 +14,13 @@ import org.kpmp.DataTypeEnum; import org.kpmp.dataSummary.DataTypeSummary; import org.kpmp.geneExpression.RTExpressionDataAllSegmentsRepository; +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; 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..3f75320 100755 --- a/src/test/java/org/kpmp/participant/ParticipantServiceTest.java +++ b/src/test/java/org/kpmp/participant/ParticipantServiceTest.java @@ -11,7 +11,7 @@ import org.junit.Before; import org.junit.Test; import org.kpmp.dataSummary.DataSummaryRepository; -import org.kpmp.geneExpressionSummary.RTParticipantRepository; +import org.kpmp.geneExpressionSummary.regionalTranscriptomics.RTParticipantRepository; import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.MockitoAnnotations; From 158b22d053568517efcae820829cc69163c9a673 Mon Sep 17 00:00:00 2001 From: Zach Wright Date: Fri, 17 Nov 2023 15:04:14 -0500 Subject: [PATCH 02/34] KPMP-4430: RP repositories --- .../geneExpression/ExpressionDataService.java | 32 ------------------- .../GeneExpressionSummaryService.java | 10 +++++- .../java/org/kpmp/umap/UmapDataService.java | 6 ++-- .../ExpressionDataServiceTest.java | 4 +-- .../org/kpmp/umap/UmapDataServiceTest.java | 4 +-- 5 files changed, 16 insertions(+), 40 deletions(-) delete mode 100755 src/main/java/org/kpmp/geneExpression/ExpressionDataService.java diff --git a/src/main/java/org/kpmp/geneExpression/ExpressionDataService.java b/src/main/java/org/kpmp/geneExpression/ExpressionDataService.java deleted file mode 100755 index cd2f51a..0000000 --- a/src/main/java/org/kpmp/geneExpression/ExpressionDataService.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.kpmp.geneExpression; - -import org.json.JSONException; -import org.json.JSONObject; -import org.kpmp.DataTypeEnum; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -@Service -public class ExpressionDataService { - - private SNExpressionDataRepository snRepo; - private SCExpressionDataRepository scRepo; - - @Autowired - public ExpressionDataService(SNExpressionDataRepository snRepo, SCExpressionDataRepository scRepo) { - this.snRepo = snRepo; - this.scRepo = scRepo; - } - - public JSONObject getGeneExpressionValues(String dataType, String geneSymbol) throws JSONException, Exception { - if (dataType.equals(DataTypeEnum.SINGLE_NUCLEUS.getAbbreviation())) { - SNExpressionData expressionData = snRepo.findByGeneSymbol(geneSymbol); - return expressionData.getExpressionDataAsJson(); - } else if (dataType.equals(DataTypeEnum.SINGLE_CELL.getAbbreviation())) { - SCExpressionData expressionData = scRepo.findByGeneSymbol(geneSymbol); - return expressionData.getExpressionDataAsJson(); - } - throw new Exception("Invalid data type: " + dataType); - } - -} diff --git a/src/main/java/org/kpmp/geneExpressionSummary/GeneExpressionSummaryService.java b/src/main/java/org/kpmp/geneExpressionSummary/GeneExpressionSummaryService.java index 928b3ac..9c21970 100755 --- a/src/main/java/org/kpmp/geneExpressionSummary/GeneExpressionSummaryService.java +++ b/src/main/java/org/kpmp/geneExpressionSummary/GeneExpressionSummaryService.java @@ -9,6 +9,7 @@ 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; @@ -28,6 +29,7 @@ public class GeneExpressionSummaryService { private RTParticipantRepository rtParticipantRepository; private RPParticipantRepository rpParticipantRepository; + private RPExpressionDataRepository rpExpressionDataRepository; RTExpressionDataAllSegmentsRepository rtExpressionDataAllSegmentsRepository; @Autowired @@ -35,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; } @@ -115,6 +119,10 @@ 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; } 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/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/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 From 6893a666a05144bb3f7ccfacdd80a576b20c0e91 Mon Sep 17 00:00:00 2001 From: Zach Wright Date: Mon, 20 Nov 2023 11:11:54 -0500 Subject: [PATCH 03/34] KPMP-4430: Refactor --- .../kpmp/geneExpression/RPExpressionData.java | 156 +++++++++++++ .../RPExpressionDataRepository.java | 14 ++ .../SNSCExpressionDataService.java | 32 +++ .../RPParticipantRepository.java | 16 ++ .../RPParticipantValue.java | 41 ++++ .../RTParticipantRepository.java | 19 ++ .../RTParticipantValue.java | 48 ++++ ...AGeneExpressionExpressionSummaryValue.java | 205 ++++++++++++++++ .../SCRNAGeneExpressionSummaryRepository.java | 40 ++++ .../SCRNAParticipantRepository.java | 14 ++ .../singleCell/SCRNAParticipantValue.java | 42 ++++ ...AGeneExpressionExpressionSummaryValue.java | 218 ++++++++++++++++++ .../SNRNAGeneExpressionSummaryRepository.java | 40 ++++ .../SNRNAParticipantRepository.java | 15 ++ .../singleNucleus/SNRNAParticipantValue.java | 47 ++++ .../resources/knowledge_environment.graphqls | 2 +- 16 files changed, 948 insertions(+), 1 deletion(-) create mode 100755 src/main/java/org/kpmp/geneExpression/RPExpressionData.java create mode 100755 src/main/java/org/kpmp/geneExpression/RPExpressionDataRepository.java create mode 100755 src/main/java/org/kpmp/geneExpression/SNSCExpressionDataService.java create mode 100755 src/main/java/org/kpmp/geneExpressionSummary/regionalProteomics/RPParticipantRepository.java create mode 100755 src/main/java/org/kpmp/geneExpressionSummary/regionalProteomics/RPParticipantValue.java create mode 100755 src/main/java/org/kpmp/geneExpressionSummary/regionalTranscriptomics/RTParticipantRepository.java create mode 100755 src/main/java/org/kpmp/geneExpressionSummary/regionalTranscriptomics/RTParticipantValue.java create mode 100755 src/main/java/org/kpmp/geneExpressionSummary/singleCell/SCRNAGeneExpressionExpressionSummaryValue.java create mode 100755 src/main/java/org/kpmp/geneExpressionSummary/singleCell/SCRNAGeneExpressionSummaryRepository.java create mode 100755 src/main/java/org/kpmp/geneExpressionSummary/singleCell/SCRNAParticipantRepository.java create mode 100755 src/main/java/org/kpmp/geneExpressionSummary/singleCell/SCRNAParticipantValue.java create mode 100755 src/main/java/org/kpmp/geneExpressionSummary/singleNucleus/SNRNAGeneExpressionExpressionSummaryValue.java create mode 100755 src/main/java/org/kpmp/geneExpressionSummary/singleNucleus/SNRNAGeneExpressionSummaryRepository.java create mode 100755 src/main/java/org/kpmp/geneExpressionSummary/singleNucleus/SNRNAParticipantRepository.java create mode 100755 src/main/java/org/kpmp/geneExpressionSummary/singleNucleus/SNRNAParticipantValue.java 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..71c672f --- /dev/null +++ b/src/main/java/org/kpmp/geneExpression/RPExpressionData.java @@ -0,0 +1,156 @@ +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_chane") + private Double foldChange; + + @Column(name = "tissue_type") + private String tissueType; + + @Column(name = "region") + private String region; + + 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; + } + +} 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..aa3f902 --- /dev/null +++ b/src/main/java/org/kpmp/geneExpression/RPExpressionDataRepository.java @@ -0,0 +1,14 @@ +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; + +public interface RPExpressionDataRepository extends CrudRepository { + + @Cacheable("rpExpCountByGene") + @Query(value = "SELECT COUNT(*) FROM rp_expression WHERE gene_symbol = :gene", nativeQuery = true) + long getCountByGene(@Param("gene") String gene); + +} diff --git a/src/main/java/org/kpmp/geneExpression/SNSCExpressionDataService.java b/src/main/java/org/kpmp/geneExpression/SNSCExpressionDataService.java new file mode 100755 index 0000000..4723209 --- /dev/null +++ b/src/main/java/org/kpmp/geneExpression/SNSCExpressionDataService.java @@ -0,0 +1,32 @@ +package org.kpmp.geneExpression; + +import org.json.JSONException; +import org.json.JSONObject; +import org.kpmp.DataTypeEnum; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class SNSCExpressionDataService { + + private SNExpressionDataRepository snRepo; + private SCExpressionDataRepository scRepo; + + @Autowired + public SNSCExpressionDataService(SNExpressionDataRepository snRepo, SCExpressionDataRepository scRepo) { + this.snRepo = snRepo; + this.scRepo = scRepo; + } + + public JSONObject getGeneExpressionValues(String dataType, String geneSymbol) throws JSONException, Exception { + if (dataType.equals(DataTypeEnum.SINGLE_NUCLEUS.getAbbreviation())) { + SNExpressionData expressionData = snRepo.findByGeneSymbol(geneSymbol); + return expressionData.getExpressionDataAsJson(); + } else if (dataType.equals(DataTypeEnum.SINGLE_CELL.getAbbreviation())) { + SCExpressionData expressionData = scRepo.findByGeneSymbol(geneSymbol); + return expressionData.getExpressionDataAsJson(); + } + throw new Exception("Invalid data type: " + dataType); + } + +} 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..cb53b59 --- /dev/null +++ b/src/main/java/org/kpmp/geneExpressionSummary/regionalProteomics/RPParticipantRepository.java @@ -0,0 +1,16 @@ +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); + +} 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/regionalTranscriptomics/RTParticipantRepository.java b/src/main/java/org/kpmp/geneExpressionSummary/regionalTranscriptomics/RTParticipantRepository.java new file mode 100755 index 0000000..615c7cd --- /dev/null +++ b/src/main/java/org/kpmp/geneExpressionSummary/regionalTranscriptomics/RTParticipantRepository.java @@ -0,0 +1,19 @@ +package org.kpmp.geneExpressionSummary.regionalTranscriptomics; + +import org.springframework.cache.annotation.Cacheable; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.CrudRepository; + +public interface RTParticipantRepository extends CrudRepository { + + @Cacheable("rtCounts") + @Query(value = "SELECT COUNT(DISTINCT rtp.redcap_id) FROM rt_participant_tissue_v rtp", nativeQuery = true) + Long getParticipantCount(); + + @Cacheable("rtCountsByTissue") + @Query(value = "SELECT COUNT(DISTINCT rtp.redcap_id) FROM rt_participant_tissue_v rtp WHERE rtp.tissue_type = :tissueType", nativeQuery = true) + Long getCountByTissueType(String tissueType); + + boolean existsByRedcapId(String redcapId); + +} diff --git a/src/main/java/org/kpmp/geneExpressionSummary/regionalTranscriptomics/RTParticipantValue.java b/src/main/java/org/kpmp/geneExpressionSummary/regionalTranscriptomics/RTParticipantValue.java new file mode 100755 index 0000000..e14162a --- /dev/null +++ b/src/main/java/org/kpmp/geneExpressionSummary/regionalTranscriptomics/RTParticipantValue.java @@ -0,0 +1,48 @@ +package org.kpmp.geneExpressionSummary.regionalTranscriptomics; + +import org.kpmp.geneExpressionSummary.Participant; +import org.kpmp.geneExpressionSummary.ParticipantId; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.IdClass; +import javax.persistence.Table; + +@Entity +@Table(name = "rt_participant_tissue_v") +@IdClass(ParticipantId.class) +public +class RTParticipantValue implements Participant, Serializable { + + private static final long serialVersionUID = 5368734102102552073L; + + @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/singleCell/SCRNAGeneExpressionExpressionSummaryValue.java b/src/main/java/org/kpmp/geneExpressionSummary/singleCell/SCRNAGeneExpressionExpressionSummaryValue.java new file mode 100755 index 0000000..420c53c --- /dev/null +++ b/src/main/java/org/kpmp/geneExpressionSummary/singleCell/SCRNAGeneExpressionExpressionSummaryValue.java @@ -0,0 +1,205 @@ +package org.kpmp.geneExpressionSummary.singleCell; + +import java.beans.Transient; +import java.io.Serializable; + +import javax.annotation.Nullable; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.IdClass; +import javax.persistence.Table; + +import org.kpmp.DataTypeEnum; +import org.kpmp.geneExpressionSummary.GeneExpressionId; +import org.kpmp.geneExpressionSummary.GeneExpressionSummary; + +@Entity +@Table(name = "sc_rnaseq") +@IdClass(GeneExpressionId.class) +public class SCRNAGeneExpressionExpressionSummaryValue implements GeneExpressionSummary, Serializable { + + private static final long serialVersionUID = 7265280085624504185L; + @Column(name = "id") + private Integer id; + @Column(name = "tissue_type") + private String tissueType; + @Id + @Column(name = "gene") + private String gene; + @Column(name = "p_val") + private Double pVal; + @Column(name = "p_val_adj") + private Double pValAdj; + @Column(name = "fold_change") + private Double foldChange; + @Column(name = "pct_1") + private Double pct1; + @Column(name = "pct_2") + private Double pct2; + @Column(name = "avg_exp") + private Double avgExp; + @Id + @Column(name = "cluster") + private String cluster; + + @Column(name = "cluster_name") + private String clusterName; + + @Column(name = "cell_count") + private Integer cellCount; + + @Override + @Transient + public String getDataType() { + return DataTypeEnum.SINGLE_CELL.getAbbreviation(); + } + + @Override + public void setCellCount(Integer cellCount) { + this.cellCount = cellCount; + } + + @Override + public Integer getCellCount() { + return this.cellCount; + } + + @Override + public void setClusterName(String clusterName) { + this.clusterName = clusterName; + } + + @Nullable + @Override + public String getClusterName() { + return this.clusterName; + } + + @Override + @Nullable + public Integer getId() { + return id; + } + + @Override + public void setId(Integer id) { + this.id = id; + } + + @Override + @Nullable + public String getTissueType() { + return tissueType; + } + + @Override + public void setTissueType(String tissueType) { + this.tissueType = tissueType; + } + + @Override + @Nullable + public String getGene() { + return gene; + } + + @Override + public void setGene(String gene) { + this.gene = gene; + } + + @Override + @Nullable + public Double getPVal() { + return pVal; + } + + @Override + public void setPVal(Double pVal) { + this.pVal = pVal; + } + + @Override + @Nullable + public Double getPValAdj() { + return pValAdj; + } + + @Override + public void setPValAdj(Double pValAdj) { + this.pValAdj = pValAdj; + } + + @Override + @Nullable + public Double getFoldChange() { + return foldChange; + } + + @Override + public void setFoldChange(Double foldChange) { + this.foldChange = foldChange; + } + + @Override + @Nullable + public Double getPct1() { + return pct1; + } + + @Override + public void setPct1(Double pct1) { + this.pct1 = pct1; + } + + @Override + @Nullable + public Double getPct2() { + return pct2; + } + + @Override + public void setPct2(Double pct2) { + this.pct2 = pct2; + } + + @Override + @Nullable + public Double getAvgExp() { + return avgExp; + } + + @Override + public void setAvgExp(Double avgExp) { + this.avgExp = avgExp; + } + + @Override + @Nullable + public String getCluster() { + return cluster; + } + + @Override + public void setCluster(String cluster) { + this.cluster = cluster; + } + + @Override + public int hashCode() { + return (gene + cluster).hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (obj == this) + return true; + if (!(obj instanceof SCRNAGeneExpressionExpressionSummaryValue)) + return false; + SCRNAGeneExpressionExpressionSummaryValue scrnaGeneExpressionExpressionSummaryValue = (SCRNAGeneExpressionExpressionSummaryValue) obj; + return (scrnaGeneExpressionExpressionSummaryValue.getGene().equals(this.getGene()) + && scrnaGeneExpressionExpressionSummaryValue.getCluster().equals(this.getCluster())); + } + +} diff --git a/src/main/java/org/kpmp/geneExpressionSummary/singleCell/SCRNAGeneExpressionSummaryRepository.java b/src/main/java/org/kpmp/geneExpressionSummary/singleCell/SCRNAGeneExpressionSummaryRepository.java new file mode 100755 index 0000000..ce1c0b2 --- /dev/null +++ b/src/main/java/org/kpmp/geneExpressionSummary/singleCell/SCRNAGeneExpressionSummaryRepository.java @@ -0,0 +1,40 @@ +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; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + +@Repository +public interface SCRNAGeneExpressionSummaryRepository + extends CrudRepository { + + @Cacheable("scCountsAllClusters") + @Query(value = "SELECT DISTINCT scc.cluster, scc.cluster_name, scc.cell_count, scc.cluster_id as id, IF(isnull(scr.tissue_type), :tissueType, scr.tissue_type) as tissue_type, IF(isnull(scr.gene), :geneSymbol, scr.gene) as gene, scr.p_val as p_val, scr.p_val_adj as p_val_adj, scr.fold_change, scr.pct_1, scr.pct_2, scr.avg_exp as avg_exp " + + "FROM sc_cluster_v scc " + + "LEFT JOIN sc_rnaseq scr ON scc.cluster = scr.cluster AND scr.gene = :geneSymbol AND scr.tissue_type = LCASE(:tissueType) " + + "WHERE scc.tissue_type = LCASE(:tissueType) ORDER BY scr.p_val IS NULL, scr.p_val ASC", nativeQuery = true) + List findByTissueAndGeneAllClusters( + @Param("geneSymbol") String geneSymbol, @Param("tissueType") String tissueType); + + @Cacheable("scCountsSummaryPerGene") + @Query(value = "SELECT DISTINCT scr.cluster, c.cluster_name, 0 as cell_count, scr.id, scr.tissue_type, scr.gene, scr.p_val as p_val, scr.p_val_adj as p_val_adj, scr.fold_change, scr.pct_1, scr.pct_2, scr.avg_exp as avg_exp " + + "FROM sc_rnaseq scr " + "JOIN cluster c ON scr.cluster = c.abbreviation AND c.cluster_name = :cellType " + + "WHERE scr.tissue_type = LCASE(:tissueType) " + "ORDER BY scr.fold_change DESC", nativeQuery = true) + List findExpressionSummaryPerGeneByCellTypeAndTissueType( + @Param("cellType") String cellType, @Param("tissueType") String tissueType); + + @Cacheable("scCountsByGene") + @Query(value = "SELECT COUNT(*) FROM sc_rnaseq scr WHERE scr.gene= :gene", nativeQuery = true) + long getCountByGene(@Param("gene") String gene); + + @Cacheable("scCountsByTissue") + @Query(value = "select count(*) from (select p.redcap_id from sc_metadata sc " + + "join participant p on sc.specimen_id = p.redcap_id " + + "where p.tissue_type=:tissueType group by p.redcap_id) as mycount", nativeQuery = true) + long getCountByTissue(@Param("tissueType") String tissueType); +} \ No newline at end of file diff --git a/src/main/java/org/kpmp/geneExpressionSummary/singleCell/SCRNAParticipantRepository.java b/src/main/java/org/kpmp/geneExpressionSummary/singleCell/SCRNAParticipantRepository.java new file mode 100755 index 0000000..26b8933 --- /dev/null +++ b/src/main/java/org/kpmp/geneExpressionSummary/singleCell/SCRNAParticipantRepository.java @@ -0,0 +1,14 @@ +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; +import org.springframework.stereotype.Repository; + +@Repository +public interface SCRNAParticipantRepository extends CrudRepository { + @Cacheable("scParticipantCount") + @Query(value = "SELECT COUNT(DISTINCT scp.redcap_id) FROM sc_participant_tissue_v scp", nativeQuery = true) + Long getParticipantCount(); +} diff --git a/src/main/java/org/kpmp/geneExpressionSummary/singleCell/SCRNAParticipantValue.java b/src/main/java/org/kpmp/geneExpressionSummary/singleCell/SCRNAParticipantValue.java new file mode 100755 index 0000000..d5a6e26 --- /dev/null +++ b/src/main/java/org/kpmp/geneExpressionSummary/singleCell/SCRNAParticipantValue.java @@ -0,0 +1,42 @@ +package org.kpmp.geneExpressionSummary.singleCell; + +import org.kpmp.geneExpressionSummary.ParticipantId; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.IdClass; +import javax.persistence.Table; + +@Entity +@Table(name = "sn_participant_tissue_v") +@IdClass(ParticipantId.class) +public class SCRNAParticipantValue implements Serializable { + + private static final long serialVersionUID = 8746341469788157316L; + + @Column(name = "tissue_type") + private String tissueType; + + @Column(name = "redcap_id") + private String redcapId; + + @Id + public String getRedcapId() { + return redcapId; + } + + public void setRedcapId(String redcapId) { + this.redcapId = redcapId; + } + + public String getTissueType() { + return tissueType; + } + + public void setTissueType(String tissueType) { + this.tissueType = tissueType; + } +} diff --git a/src/main/java/org/kpmp/geneExpressionSummary/singleNucleus/SNRNAGeneExpressionExpressionSummaryValue.java b/src/main/java/org/kpmp/geneExpressionSummary/singleNucleus/SNRNAGeneExpressionExpressionSummaryValue.java new file mode 100755 index 0000000..294b99c --- /dev/null +++ b/src/main/java/org/kpmp/geneExpressionSummary/singleNucleus/SNRNAGeneExpressionExpressionSummaryValue.java @@ -0,0 +1,218 @@ +package org.kpmp.geneExpressionSummary.singleNucleus; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.IdClass; +import javax.persistence.Table; +import javax.persistence.Transient; + +import org.kpmp.DataTypeEnum; +import org.kpmp.geneExpressionSummary.GeneExpressionId; +import org.kpmp.geneExpressionSummary.GeneExpressionSummary; +import org.springframework.lang.Nullable; + +@Entity +@Table(name = "sn_rnaseq") +@IdClass(GeneExpressionId.class) +public class SNRNAGeneExpressionExpressionSummaryValue implements GeneExpressionSummary, Serializable { + + private static final long serialVersionUID = -443713903175981503L; + + @Column(name = "id") + private Integer id; + + @Column(name = "tissue_type") + private String tissueType; + + @Id + @Column(name = "gene") + private String gene; + + @Column(name = "p_val") + private Double pVal; + + @Column(name = "p_val_adj") + private Double pValAdj; + + @Column(name = "fold_change") + private Double foldChange; + + @Column(name = "pct_1") + private Double pct1; + + @Column(name = "pct_2") + private Double pct2; + + @Column(name = "avg_exp") + private Double avgExp; + + @Id + @Column(name = "cluster") + private String cluster; + + @Column(name = "cell_type") + private String cellType; + + @Override + @Transient + public String getDataType() { + return DataTypeEnum.SINGLE_NUCLEUS.getAbbreviation(); + } + + @Column(name = "cluster_name") + private String clusterName; + + @Column(name = "cell_count") + private Integer cellCount; + + @Override + @Nullable + public Integer getId() { + return id; + } + + @Override + public void setId(Integer id) { + this.id = id; + } + + @Override + @Nullable + public String getTissueType() { + return tissueType; + } + + @Override + public void setTissueType(String tissueType) { + this.tissueType = tissueType; + } + + @Override + @Nullable + public String getGene() { + return gene; + } + + @Override + public void setGene(String gene) { + this.gene = gene; + } + + @Override + @Nullable + public Double getPVal() { + return pVal; + } + + @Override + public void setPVal(Double pVal) { + this.pVal = pVal; + } + + @Override + @Nullable + public Double getPValAdj() { + return pValAdj; + } + + @Override + public void setPValAdj(Double pValAdj) { + this.pValAdj = pValAdj; + } + + @Override + @Nullable + public Double getFoldChange() { + return foldChange; + } + + @Override + public void setFoldChange(Double foldChange) { + this.foldChange = foldChange; + } + + @Override + @Nullable + public Double getPct1() { + return pct1; + } + + @Override + public void setPct1(Double pct1) { + this.pct1 = pct1; + } + + @Override + @Nullable + public Double getPct2() { + return pct2; + } + + @Override + public void setPct2(Double pct2) { + this.pct2 = pct2; + } + + @Override + @Nullable + public Double getAvgExp() { + return avgExp; + } + + @Override + @Nullable + public void setAvgExp(Double avgExp) { + this.avgExp = avgExp; + } + + @Id + @Override + public String getCluster() { + return cluster; + } + + @Override + public void setCluster(String cluster) { + this.cluster = cluster; + } + + @Override + public void setCellCount(Integer cellCount) { + this.cellCount = cellCount; + } + + @Override + public Integer getCellCount() { + return this.cellCount; + } + + @Override + public void setClusterName(String clusterName) { + this.clusterName = clusterName; + } + + @Nullable + @Override + public String getClusterName() { + return this.clusterName; + } + + @Override + public int hashCode() { + return (gene + cluster).hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (obj == this) + return true; + if (!(obj instanceof SNRNAGeneExpressionExpressionSummaryValue)) + return false; + SNRNAGeneExpressionExpressionSummaryValue snrnaGeneExpressionExpressionSummaryValue = (SNRNAGeneExpressionExpressionSummaryValue) obj; + return (snrnaGeneExpressionExpressionSummaryValue.getGene().equals(this.getGene()) + && snrnaGeneExpressionExpressionSummaryValue.getCluster().equals(this.getCluster())); + } +} diff --git a/src/main/java/org/kpmp/geneExpressionSummary/singleNucleus/SNRNAGeneExpressionSummaryRepository.java b/src/main/java/org/kpmp/geneExpressionSummary/singleNucleus/SNRNAGeneExpressionSummaryRepository.java new file mode 100755 index 0000000..2a52d87 --- /dev/null +++ b/src/main/java/org/kpmp/geneExpressionSummary/singleNucleus/SNRNAGeneExpressionSummaryRepository.java @@ -0,0 +1,40 @@ +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; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + +@Repository +public interface SNRNAGeneExpressionSummaryRepository + extends CrudRepository { + + @Cacheable("snCountsBy") + @Query(value = "SELECT DISTINCT snc.cluster, snc.cluster_name, snc.cell_count as cell_count, snc.cluster_id as id, IF(isnull(snr.tissue_type), :tissueType, snr.tissue_type) as tissue_type, IF(isnull(snr.gene), :geneSymbol, snr.gene) as gene, snr.p_val as pval, snr.p_val_adj as pval_adj, snr.fold_change, snr.pct_1 as pct1, snr.pct_2 as pct2, snr.avg_exp as avg_exp " + + "FROM sn_cluster_v snc " + + "LEFT JOIN sn_rnaseq snr ON snc.cluster = snr.cluster AND snr.gene = :geneSymbol AND snr.tissue_type = LCASE(:tissueType) " + + "WHERE snc.tissue_type = LCASE(:tissueType) ORDER BY snr.p_val IS NULL, snr.p_val ASC", nativeQuery = true) + List findByTissueAndGeneAllClusters( + @Param("geneSymbol") String geneSymbol, @Param("tissueType") String tissueType); + + @Cacheable("snCounts") + @Query(value = "SELECT DISTINCT snr.cluster, c.cluster_name, 0 as cell_count, snr.id, snr.tissue_type, snr.gene, snr.p_val as pval, snr.p_val_adj as pval_adj, snr.fold_change, snr.pct_1 as pct1, snr.pct_2 as pct2, snr.avg_exp as avg_exp " + + "FROM sn_rnaseq snr " + "JOIN cluster c ON snr.cluster = c.abbreviation AND c.cluster_name = :cellType " + + "WHERE snr.tissue_type = LCASE(:tissueType) " + "ORDER BY snr.fold_change DESC", nativeQuery = true) + List findExpressionSummaryPerGeneByCellTypeAndTissueType( + @Param("cellType") String cellType, @Param("tissueType") String tissueType); + + @Cacheable("snCounts") + @Query(value = "select count(*) from (select p.redcap_id from sn_metadata sn " + + "join participant p on sn.specimen_id = p.redcap_id " + + "where p.tissue_type=:tissueType group by p.redcap_id) as mycount", nativeQuery = true) + long getCountByTissue(@Param("tissueType") String tissueType); + + @Cacheable("snCounts") + @Query(value = "SELECT COUNT(*) FROM sn_rnaseq snr WHERE snr.gene= :gene", nativeQuery = true) + long getCountByGene(@Param("gene") String gene); +} diff --git a/src/main/java/org/kpmp/geneExpressionSummary/singleNucleus/SNRNAParticipantRepository.java b/src/main/java/org/kpmp/geneExpressionSummary/singleNucleus/SNRNAParticipantRepository.java new file mode 100755 index 0000000..c2e146b --- /dev/null +++ b/src/main/java/org/kpmp/geneExpressionSummary/singleNucleus/SNRNAParticipantRepository.java @@ -0,0 +1,15 @@ +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; +import org.springframework.stereotype.Repository; + +@Repository +public interface SNRNAParticipantRepository extends CrudRepository { + + @Cacheable("snParticipantCount") + @Query(value = "SELECT COUNT(DISTINCT snp.redcap_id) FROM sn_participant_tissue_v snp", nativeQuery = true) + Long getParticipantCount(); +} diff --git a/src/main/java/org/kpmp/geneExpressionSummary/singleNucleus/SNRNAParticipantValue.java b/src/main/java/org/kpmp/geneExpressionSummary/singleNucleus/SNRNAParticipantValue.java new file mode 100755 index 0000000..c6a0d3f --- /dev/null +++ b/src/main/java/org/kpmp/geneExpressionSummary/singleNucleus/SNRNAParticipantValue.java @@ -0,0 +1,47 @@ +package org.kpmp.geneExpressionSummary.singleNucleus; + +import org.kpmp.geneExpressionSummary.Participant; +import org.kpmp.geneExpressionSummary.ParticipantId; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.IdClass; +import javax.persistence.Table; + +@Entity +@Table(name = "sn_participant_tissue_v") +@IdClass(ParticipantId.class) +public class SNRNAParticipantValue implements Participant, Serializable { + + private static final long serialVersionUID = -2404700991479961255L; + + @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/resources/knowledge_environment.graphqls b/src/main/resources/knowledge_environment.graphqls index 039027b..e50e292 100755 --- a/src/main/resources/knowledge_environment.graphqls +++ b/src/main/resources/knowledge_environment.graphqls @@ -63,7 +63,7 @@ type ParticipantRepoDataTypeInformation { linkInformation: AtlasRepoSummaryLinkInformation } -type SummaryDataTypeInformation { +type DataTypeSummaryInformation { omicsType: String dataType: String dataTypeShort: String From 7c8228b6974ea217bc29ca6eeaf55970b20a3367 Mon Sep 17 00:00:00 2001 From: Zach Wright Date: Mon, 20 Nov 2023 11:15:40 -0500 Subject: [PATCH 04/34] KPMP-4430: no empty parens --- src/main/resources/knowledge_environment.graphqls | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/knowledge_environment.graphqls b/src/main/resources/knowledge_environment.graphqls index e50e292..84125f9 100755 --- a/src/main/resources/knowledge_environment.graphqls +++ b/src/main/resources/knowledge_environment.graphqls @@ -5,7 +5,7 @@ type Query { getClusterHieararchies(cellType: String!): [ClusterHierarchy] getUmapPlotData(dataType: String!, geneSymbol: String!, tissueType: String): PlotData dataTypesForConcept(geneSymbol: String, clusterName: String): [String] - getDataTypeSummaryInformation(): [DataTypeSummaryInformation] + getDataTypeSummaryInformation: [DataTypeSummaryInformation] getRTGeneExpressionByTissue(comparisonType: String, geneSymbol: String): RTGeneExpressionByTissue getRTGeneExpressionByStructure(structure: String): [RTGeneExpression] getSummaryData: [GeneDatasetInformation] From 7cf0bcdb4c123b330a1725502a89a9f0a9ba4232 Mon Sep 17 00:00:00 2001 From: Zach Wright Date: Mon, 20 Nov 2023 14:25:29 -0500 Subject: [PATCH 05/34] KPMP-4430: add tests --- .../resources/knowledge_environment.graphqls | 2 +- src/test/java/org/kpmp/DataTypeEnumTest.java | 4 ++- .../java/org/kpmp/FullDataTypeEnumTest.java | 5 +-- src/test/java/org/kpmp/QueryTest.java | 4 +-- .../GeneExpressionSummaryServiceTest.java | 33 ++++++++++++++++--- 5 files changed, 37 insertions(+), 11 deletions(-) diff --git a/src/main/resources/knowledge_environment.graphqls b/src/main/resources/knowledge_environment.graphqls index 84125f9..09482a8 100755 --- a/src/main/resources/knowledge_environment.graphqls +++ b/src/main/resources/knowledge_environment.graphqls @@ -8,7 +8,7 @@ type Query { getDataTypeSummaryInformation: [DataTypeSummaryInformation] getRTGeneExpressionByTissue(comparisonType: String, geneSymbol: String): RTGeneExpressionByTissue getRTGeneExpressionByStructure(structure: String): [RTGeneExpression] - getSummaryData: [GeneDatasetInformation] + getSummaryData: [DataTypeSummaryInformation] getDataTypeInformationByParticipant(redcapId: String!): ParticipantDataTypeSummary getRepoDataTypeInformationByParticipant(redcapId: String!): ParticipantRepoDataTypeSummary participantSummaryDataset(redcapId: String): ParticipantSummaryDataset 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 04b22ad..7b5cd04 100755 --- a/src/test/java/org/kpmp/QueryTest.java +++ b/src/test/java/org/kpmp/QueryTest.java @@ -211,9 +211,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); } diff --git a/src/test/java/org/kpmp/geneExpressionSummary/GeneExpressionSummaryServiceTest.java b/src/test/java/org/kpmp/geneExpressionSummary/GeneExpressionSummaryServiceTest.java index b107344..e788e8f 100755 --- a/src/test/java/org/kpmp/geneExpressionSummary/GeneExpressionSummaryServiceTest.java +++ b/src/test/java/org/kpmp/geneExpressionSummary/GeneExpressionSummaryServiceTest.java @@ -13,7 +13,9 @@ 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; @@ -40,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 @@ -141,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 @@ -196,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); @@ -210,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()); @@ -225,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()); } From 21c4f71fc3ffef68fc2fd1f75214a76753d76c62 Mon Sep 17 00:00:00 2001 From: Zach Wright Date: Mon, 27 Nov 2023 16:04:03 -0500 Subject: [PATCH 06/34] KPMP-4434: RP stuff --- src/main/java/org/kpmp/Query.java | 20 +++++-- .../RPExpressionByTissueType.java | 53 +++++++++++++++++++ .../kpmp/geneExpression/RPExpressionData.java | 9 ++++ .../RPExpressionDataRepository.java | 8 +++ .../RPExpressionDataService.java | 29 ++++++++++ .../resources/knowledge_environment.graphqls | 27 ++++++++++ 6 files changed, 142 insertions(+), 4 deletions(-) create mode 100755 src/main/java/org/kpmp/geneExpression/RPExpressionByTissueType.java create mode 100755 src/main/java/org/kpmp/geneExpression/RPExpressionDataService.java diff --git a/src/main/java/org/kpmp/Query.java b/src/main/java/org/kpmp/Query.java index 74049e5..f68ed8e 100755 --- a/src/main/java/org/kpmp/Query.java +++ b/src/main/java/org/kpmp/Query.java @@ -13,9 +13,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,6 +41,8 @@ public class Query implements GraphQLQueryResolver { private UmapDataService umapService; private ClusterHierarchyService clusterHierarchyService; private RTExpressionDataService rtExpressionDataService; + + private RPExpressionDataService rpExpressionDataService; private ParticipantService participantService; private Logger logger = LoggerFactory.getLogger(Query.class); @@ -50,7 +50,8 @@ public class Query implements GraphQLQueryResolver { public Query(AutocompleteService autocompleteService, CellTypeService cellTypeService, UmapDataService umapService, GeneExpressionSummaryService geneExpressionSummaryService, DataSummaryService dataSummaryService, ClusterHierarchyService clusterHierarchyService, - RTExpressionDataService rtExpressionDataService, ParticipantService participantService) { + RTExpressionDataService rtExpressionDataService, RPExpressionDataService rpExpressionDataService, + ParticipantService participantService) { this.autocompleteService = autocompleteService; this.cellTypeService = cellTypeService; @@ -59,6 +60,7 @@ public Query(AutocompleteService autocompleteService, CellTypeService cellTypeSe this.dataSummaryService = dataSummaryService; this.clusterHierarchyService = clusterHierarchyService; this.rtExpressionDataService = rtExpressionDataService; + this.rpExpressionDataService = rpExpressionDataService; this.participantService = participantService; } @@ -142,6 +144,16 @@ public List getRTGeneExpressionByStructure(String st } } + public RPExpressionByTissueType getRPGeneExpressionByTissue(String comparisonType, 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); } 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..c43538f --- /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 index 71c672f..a1c88cd 100755 --- a/src/main/java/org/kpmp/geneExpression/RPExpressionData.java +++ b/src/main/java/org/kpmp/geneExpression/RPExpressionData.java @@ -49,6 +49,8 @@ public class RPExpressionData { @Column(name = "region") private String region; + @Column(name = "sample_count") + private Integer sampleCount; public Integer getId() { return id; } @@ -153,4 +155,11 @@ 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 index aa3f902..59a81d5 100755 --- a/src/main/java/org/kpmp/geneExpression/RPExpressionDataRepository.java +++ b/src/main/java/org/kpmp/geneExpression/RPExpressionDataRepository.java @@ -5,8 +5,16 @@ 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 gene_symbol = :gene AND tissue_type = :tissueType " + + "GROUP BY rpe.region", nativeQuery = true) + List findByGeneSymbolAndTissueTypeWithCounts(String geneSymbol, String tissueType); @Cacheable("rpExpCountByGene") @Query(value = "SELECT COUNT(*) FROM rp_expression WHERE gene_symbol = :gene", nativeQuery = true) long getCountByGene(@Param("gene") String gene); 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..d664438 --- /dev/null +++ b/src/main/java/org/kpmp/geneExpression/RPExpressionDataService.java @@ -0,0 +1,29 @@ +package org.kpmp.geneExpression; + +import org.kpmp.TissueTypeEnum; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class RPExpressionDataService { + + RPExpressionDataRepository rpExpressionDataRepository; + + @Autowired + public RPExpressionDataService(RPExpressionDataRepository rpExpressionDataRepository) { + this.rpExpressionDataRepository = rpExpressionDataRepository; + } + + public RPExpressionByTissueType getByGeneSymbolPerTissue(String geneSymbol) { + RPExpressionByTissueType rpExpressionByTissueType = new RPExpressionByTissueType(); + + rpExpressionByTissueType.setAki(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeWithCounts(geneSymbol, TissueTypeEnum.AKI.getParticipantTissueType())); + rpExpressionByTissueType.setCkd(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeWithCounts(geneSymbol, TissueTypeEnum.CKD.getParticipantTissueType())); + rpExpressionByTissueType.setDmr(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeWithCounts(geneSymbol, TissueTypeEnum.DMR.getParticipantTissueType())); + rpExpressionByTissueType.setHrt(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeWithCounts(geneSymbol, TissueTypeEnum.HEALTHY_REFERENCE.getParticipantTissueType())); + rpExpressionByTissueType.setAll(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeWithCounts(geneSymbol, TissueTypeEnum.ALL.getParticipantTissueType())); + + return rpExpressionByTissueType; + + } +} diff --git a/src/main/resources/knowledge_environment.graphqls b/src/main/resources/knowledge_environment.graphqls index 09482a8..287160c 100755 --- a/src/main/resources/knowledge_environment.graphqls +++ b/src/main/resources/knowledge_environment.graphqls @@ -7,6 +7,7 @@ type Query { dataTypesForConcept(geneSymbol: String, clusterName: String): [String] getDataTypeSummaryInformation: [DataTypeSummaryInformation] getRTGeneExpressionByTissue(comparisonType: String, geneSymbol: String): RTGeneExpressionByTissue + getRPGeneExpressionByTissue(geneSymbol: String): RP getRTGeneExpressionByStructure(structure: String): [RTGeneExpression] getSummaryData: [DataTypeSummaryInformation] getDataTypeInformationByParticipant(redcapId: String!): ParticipantDataTypeSummary @@ -170,6 +171,32 @@ type RTGeneExpressionByTissue { aki: [RTGeneExpression] } +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 + stdDev: Float + tissueType: String + sampleCount: Int +} + +type RPGeneExpressionByTissue { + all: [RPGeneExpression] + hrt: [RPGeneExpression] + ckd: [RPGeneExpression] + dmr: [RPGeneExpression] + aki: [RPGeneExpression] +} + type ParticipantSummaryDataset { participantId: String redcapId: String From ea6f5f6c6aad1304bdac3abd43565e5a45a8f999 Mon Sep 17 00:00:00 2001 From: Zach Wright Date: Wed, 29 Nov 2023 13:34:23 -0500 Subject: [PATCH 07/34] KPMP-4434: Add tests --- src/main/java/org/kpmp/Query.java | 2 +- .../kpmp/geneExpression/RPExpressionData.java | 2 +- .../RPExpressionDataRepository.java | 2 +- .../resources/knowledge_environment.graphqls | 4 +- src/test/java/org/kpmp/QueryTest.java | 6 +- .../RPExpressionDataByTissueTypeTest.java | 71 +++++++++++++++++++ .../RPExpressionDataServiceTest.java | 64 +++++++++++++++++ .../geneExpression/RPExpressionDataTest.java | 57 +++++++++++++++ 8 files changed, 202 insertions(+), 6 deletions(-) create mode 100755 src/test/java/org/kpmp/geneExpression/RPExpressionDataByTissueTypeTest.java create mode 100755 src/test/java/org/kpmp/geneExpression/RPExpressionDataServiceTest.java create mode 100755 src/test/java/org/kpmp/geneExpression/RPExpressionDataTest.java diff --git a/src/main/java/org/kpmp/Query.java b/src/main/java/org/kpmp/Query.java index f68ed8e..4acd973 100755 --- a/src/main/java/org/kpmp/Query.java +++ b/src/main/java/org/kpmp/Query.java @@ -144,7 +144,7 @@ public List getRTGeneExpressionByStructure(String st } } - public RPExpressionByTissueType getRPGeneExpressionByTissue(String comparisonType, String geneSymbol) + public RPExpressionByTissueType getRPGeneExpressionByTissue(String geneSymbol) throws Exception { try { return rpExpressionDataService.getByGeneSymbolPerTissue(geneSymbol); diff --git a/src/main/java/org/kpmp/geneExpression/RPExpressionData.java b/src/main/java/org/kpmp/geneExpression/RPExpressionData.java index a1c88cd..0b67b29 100755 --- a/src/main/java/org/kpmp/geneExpression/RPExpressionData.java +++ b/src/main/java/org/kpmp/geneExpression/RPExpressionData.java @@ -40,7 +40,7 @@ public class RPExpressionData { @Column(name = "adj_p_val") private Double adjPVal; - @Column(name = "fold_chane") + @Column(name = "fold_change") private Double foldChange; @Column(name = "tissue_type") diff --git a/src/main/java/org/kpmp/geneExpression/RPExpressionDataRepository.java b/src/main/java/org/kpmp/geneExpression/RPExpressionDataRepository.java index 59a81d5..665d74a 100755 --- a/src/main/java/org/kpmp/geneExpression/RPExpressionDataRepository.java +++ b/src/main/java/org/kpmp/geneExpression/RPExpressionDataRepository.java @@ -12,7 +12,7 @@ public interface RPExpressionDataRepository extends CrudRepository findByGeneSymbolAndTissueTypeWithCounts(String geneSymbol, String tissueType); @Cacheable("rpExpCountByGene") diff --git a/src/main/resources/knowledge_environment.graphqls b/src/main/resources/knowledge_environment.graphqls index 287160c..92c054e 100755 --- a/src/main/resources/knowledge_environment.graphqls +++ b/src/main/resources/knowledge_environment.graphqls @@ -7,7 +7,7 @@ type Query { dataTypesForConcept(geneSymbol: String, clusterName: String): [String] getDataTypeSummaryInformation: [DataTypeSummaryInformation] getRTGeneExpressionByTissue(comparisonType: String, geneSymbol: String): RTGeneExpressionByTissue - getRPGeneExpressionByTissue(geneSymbol: String): RP + getRPGeneExpressionByTissue(geneSymbol: String): RPGeneExpressionByTissue getRTGeneExpressionByStructure(structure: String): [RTGeneExpression] getSummaryData: [DataTypeSummaryInformation] getDataTypeInformationByParticipant(redcapId: String!): ParticipantDataTypeSummary @@ -75,6 +75,7 @@ type DataTypeSummaryInformation { participantCount: Long } + type AutoCompleteResult { value: String name: String @@ -184,7 +185,6 @@ type RPGeneExpression { region: String foldChange: Float adjPVal: Float - stdDev: Float tissueType: String sampleCount: Int } diff --git a/src/test/java/org/kpmp/QueryTest.java b/src/test/java/org/kpmp/QueryTest.java index 7b5cd04..ea80cea 100755 --- a/src/test/java/org/kpmp/QueryTest.java +++ b/src/test/java/org/kpmp/QueryTest.java @@ -24,6 +24,7 @@ import org.kpmp.dataSummary.AtlasRepoSummaryResult; import org.kpmp.dataSummary.DataSummaryService; import org.kpmp.dataSummary.DataTypeSummary; +import org.kpmp.geneExpression.RPExpressionDataService; import org.kpmp.geneExpression.RTExpressionByTissueType; import org.kpmp.geneExpression.RTExpressionDataAllSegments; import org.kpmp.geneExpression.RTExpressionDataService; @@ -64,11 +65,14 @@ public class QueryTest { @Mock private ParticipantTissueTypeSummary participantTissueTypeSummary; + @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); } @After 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..c4ebdc4 --- /dev/null +++ b/src/test/java/org/kpmp/geneExpression/RPExpressionDataServiceTest.java @@ -0,0 +1,64 @@ +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.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 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.findByGeneSymbolAndTissueTypeWithCounts("gene", TissueTypeEnum.AKI.getParticipantTissueType())). + thenReturn(rpExpressionDataAki); + when(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeWithCounts("gene", TissueTypeEnum.CKD.getParticipantTissueType())). + thenReturn(rpExpressionDataCkd); + when(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeWithCounts("gene", TissueTypeEnum.HEALTHY_REFERENCE.getParticipantTissueType())). + thenReturn(rpExpressionDataHrt); + when(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeWithCounts("gene", TissueTypeEnum.DMR.getParticipantTissueType())). + thenReturn(rpExpressionDataDmr); + when(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeWithCounts("gene", TissueTypeEnum.AKI.getParticipantTissueType())). + thenReturn(rpExpressionDataAll); + + RPExpressionByTissueType rpExpressionByTissueType = rpExpressionDataService.getByGeneSymbolPerTissue("gene"); + + assertEquals(rpExpressionByTissueType.getAki(), rpExpressionDataAki); + assertEquals(rpExpressionByTissueType.getHrt(), rpExpressionDataHrt); + assertEquals(rpExpressionByTissueType.getCkd(), rpExpressionDataCkd); + assertEquals(rpExpressionByTissueType.getAll(), rpExpressionDataAll); + assertEquals(rpExpressionByTissueType.getDmr(), rpExpressionDataDmr); + + } +} 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"); + + } + +} From f994d0667e5ba9a0a813a43ff84b40dfe4b4f757 Mon Sep 17 00:00:00 2001 From: Zach Wright Date: Wed, 29 Nov 2023 14:07:22 -0500 Subject: [PATCH 08/34] KPMP-4434: Fix test --- .../org/kpmp/geneExpression/RPExpressionDataServiceTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/kpmp/geneExpression/RPExpressionDataServiceTest.java b/src/test/java/org/kpmp/geneExpression/RPExpressionDataServiceTest.java index c4ebdc4..49f84ee 100755 --- a/src/test/java/org/kpmp/geneExpression/RPExpressionDataServiceTest.java +++ b/src/test/java/org/kpmp/geneExpression/RPExpressionDataServiceTest.java @@ -49,7 +49,7 @@ public void testGetByGeneSymbolPerTissue() throws Exception { thenReturn(rpExpressionDataHrt); when(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeWithCounts("gene", TissueTypeEnum.DMR.getParticipantTissueType())). thenReturn(rpExpressionDataDmr); - when(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeWithCounts("gene", TissueTypeEnum.AKI.getParticipantTissueType())). + when(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeWithCounts("gene", TissueTypeEnum.ALL.getParticipantTissueType())). thenReturn(rpExpressionDataAll); RPExpressionByTissueType rpExpressionByTissueType = rpExpressionDataService.getByGeneSymbolPerTissue("gene"); @@ -59,6 +59,6 @@ public void testGetByGeneSymbolPerTissue() throws Exception { assertEquals(rpExpressionByTissueType.getCkd(), rpExpressionDataCkd); assertEquals(rpExpressionByTissueType.getAll(), rpExpressionDataAll); assertEquals(rpExpressionByTissueType.getDmr(), rpExpressionDataDmr); - + } } From 17071df621c57ac9d2c60385d4da320130250a59 Mon Sep 17 00:00:00 2001 From: Becky Reamy Date: Wed, 29 Nov 2023 16:55:35 -0500 Subject: [PATCH 09/34] KPMP-4442: Starting to set up code to get expression data for table at bottom of viz page --- src/main/java/org/kpmp/Query.java | 4 ++ .../RPExpressionByTissueType.java | 52 ++++++++++++++ .../RPExpressionByTissueTypeTest.java | 67 +++++++++++++++++++ 3 files changed, 123 insertions(+) create mode 100755 src/main/java/org/kpmp/geneExpression/RPExpressionByTissueType.java create mode 100644 src/test/java/org/kpmp/geneExpression/RPExpressionByTissueTypeTest.java diff --git a/src/main/java/org/kpmp/Query.java b/src/main/java/org/kpmp/Query.java index 74049e5..311556c 100755 --- a/src/main/java/org/kpmp/Query.java +++ b/src/main/java/org/kpmp/Query.java @@ -133,6 +133,10 @@ public RTExpressionByTissueType getRTGeneExpressionByTissue(String comparisonTyp } } + public void getRPGeneExpressionByTissue(String comparisonType, String geneSymbol, String protein) { + + } + public List getRTGeneExpressionByStructure(String structure) throws Exception { try { return rtExpressionDataService.getByStructure(structure); 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..6a3d79a --- /dev/null +++ b/src/main/java/org/kpmp/geneExpression/RPExpressionByTissueType.java @@ -0,0 +1,52 @@ +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/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 From cc5a3b4d50168d8cb5ee47ec5e46c33652d309d8 Mon Sep 17 00:00:00 2001 From: Zach Wright Date: Fri, 1 Dec 2023 11:11:38 -0500 Subject: [PATCH 10/34] KPMP-4434: handle multiple proteins --- .../org/kpmp/geneExpression/RPExpressionDataRepository.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/kpmp/geneExpression/RPExpressionDataRepository.java b/src/main/java/org/kpmp/geneExpression/RPExpressionDataRepository.java index 665d74a..1614184 100755 --- a/src/main/java/org/kpmp/geneExpression/RPExpressionDataRepository.java +++ b/src/main/java/org/kpmp/geneExpression/RPExpressionDataRepository.java @@ -13,7 +13,7 @@ public interface RPExpressionDataRepository extends CrudRepository findByGeneSymbolAndTissueTypeWithCounts(String geneSymbol, String tissueType); @Cacheable("rpExpCountByGene") @Query(value = "SELECT COUNT(*) FROM rp_expression WHERE gene_symbol = :gene", nativeQuery = true) From d83147588b0f4f40347827049e9018ef5c59e543 Mon Sep 17 00:00:00 2001 From: Becky Reamy Date: Fri, 1 Dec 2023 11:34:34 -0500 Subject: [PATCH 11/34] KPMP-4442: Add tests --- src/main/java/org/kpmp/Query.java | 9 +++++-- .../RPExpressionDataRepository.java | 7 +++++ .../RPExpressionDataService.java | 12 +++++++++ .../resources/knowledge_environment.graphqls | 1 + src/test/java/org/kpmp/QueryTest.java | 11 ++++++++ .../RPExpressionDataServiceTest.java | 27 +++++++++++++++++++ 6 files changed, 65 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/kpmp/Query.java b/src/main/java/org/kpmp/Query.java index 2c7ec65..051a58b 100755 --- a/src/main/java/org/kpmp/Query.java +++ b/src/main/java/org/kpmp/Query.java @@ -135,8 +135,13 @@ public RTExpressionByTissueType getRTGeneExpressionByTissue(String comparisonTyp } } - public void getRPGeneExpressionByTissue(String comparisonType, String geneSymbol, String protein) { - + 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 { diff --git a/src/main/java/org/kpmp/geneExpression/RPExpressionDataRepository.java b/src/main/java/org/kpmp/geneExpression/RPExpressionDataRepository.java index 665d74a..c39ba5c 100755 --- a/src/main/java/org/kpmp/geneExpression/RPExpressionDataRepository.java +++ b/src/main/java/org/kpmp/geneExpression/RPExpressionDataRepository.java @@ -15,8 +15,15 @@ public interface RPExpressionDataRepository extends CrudRepository findByGeneSymbolAndTissueTypeWithCounts(String geneSymbol, String tissueType); + @Cacheable("rpExpCountByGene") @Query(value = "SELECT COUNT(*) FROM rp_expression WHERE gene_symbol = :gene", nativeQuery = true) long getCountByGene(@Param("gene") String gene); + @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 index d664438..a9b2b33 100755 --- a/src/main/java/org/kpmp/geneExpression/RPExpressionDataService.java +++ b/src/main/java/org/kpmp/geneExpression/RPExpressionDataService.java @@ -26,4 +26,16 @@ public RPExpressionByTissueType getByGeneSymbolPerTissue(String geneSymbol) { return rpExpressionByTissueType; } + + 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; + } } diff --git a/src/main/resources/knowledge_environment.graphqls b/src/main/resources/knowledge_environment.graphqls index 92c054e..5e77fd4 100755 --- a/src/main/resources/knowledge_environment.graphqls +++ b/src/main/resources/knowledge_environment.graphqls @@ -8,6 +8,7 @@ type Query { getDataTypeSummaryInformation: [DataTypeSummaryInformation] getRTGeneExpressionByTissue(comparisonType: String, geneSymbol: String): RTGeneExpressionByTissue getRPGeneExpressionByTissue(geneSymbol: String): RPGeneExpressionByTissue + getRPGeneExpressionByTissueAndProtein(geneSymbol: String!, protein: String!): RPGeneExpressionByTissue getRTGeneExpressionByStructure(structure: String): [RTGeneExpression] getSummaryData: [DataTypeSummaryInformation] getDataTypeInformationByParticipant(redcapId: String!): ParticipantDataTypeSummary diff --git a/src/test/java/org/kpmp/QueryTest.java b/src/test/java/org/kpmp/QueryTest.java index ea80cea..c647019 100755 --- a/src/test/java/org/kpmp/QueryTest.java +++ b/src/test/java/org/kpmp/QueryTest.java @@ -24,6 +24,7 @@ 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; @@ -241,6 +242,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); diff --git a/src/test/java/org/kpmp/geneExpression/RPExpressionDataServiceTest.java b/src/test/java/org/kpmp/geneExpression/RPExpressionDataServiceTest.java index 49f84ee..dd195e3 100755 --- a/src/test/java/org/kpmp/geneExpression/RPExpressionDataServiceTest.java +++ b/src/test/java/org/kpmp/geneExpression/RPExpressionDataServiceTest.java @@ -61,4 +61,31 @@ public void testGetByGeneSymbolPerTissue() throws Exception { assertEquals(rpExpressionByTissueType.getDmr(), rpExpressionDataDmr); } + + @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); + } } From 893fc67c28118f162723f174bea8f13294cf8e44 Mon Sep 17 00:00:00 2001 From: Zach Wright Date: Fri, 1 Dec 2023 14:17:28 -0500 Subject: [PATCH 12/34] KPMP-4434: with maps --- .../RPExpressionByTissueType.java | 40 ++++++++++++------- .../RPExpressionDataRepository.java | 2 +- .../RPExpressionDataService.java | 24 ++++++++--- .../resources/knowledge_environment.graphqls | 15 ++++--- 4 files changed, 55 insertions(+), 26 deletions(-) diff --git a/src/main/java/org/kpmp/geneExpression/RPExpressionByTissueType.java b/src/main/java/org/kpmp/geneExpression/RPExpressionByTissueType.java index c43538f..819352c 100755 --- a/src/main/java/org/kpmp/geneExpression/RPExpressionByTissueType.java +++ b/src/main/java/org/kpmp/geneExpression/RPExpressionByTissueType.java @@ -1,52 +1,62 @@ package org.kpmp.geneExpression; import java.util.List; +import java.util.Map; public class RPExpressionByTissueType { - private List all; - private List aki; - private List ckd; - private List hrt; - private List dmr; + private class AccessionGroup { + private accession String; + private List expressionDataList; + } + + private Map> all; + + private Map> aki; + + private Map> ckd; + + private Map> hrt; + + private Map> dmr; - public List getAll() { + public Map> getAll() { return all; } - public void setAll(List all) { + public void setAll(Map> all) { this.all = all; } - public List getAki() { + public Map> getAki() { return aki; } - public void setAki(List aki) { + public void setAki(Map> aki) { this.aki = aki; } - public List getCkd() { + public Map> getCkd() { return ckd; } - public void setCkd(List ckd) { + public void setCkd(Map> ckd) { this.ckd = ckd; } - public List getHrt() { + public Map> getHrt() { return hrt; } - public void setHrt(List hrt) { + public void setHrt(Map> hrt) { this.hrt = hrt; } - public List getDmr() { + public Map> getDmr() { return dmr; } - public void setDmr(List dmr) { + public void setDmr(Map> dmr) { this.dmr = dmr; } } diff --git a/src/main/java/org/kpmp/geneExpression/RPExpressionDataRepository.java b/src/main/java/org/kpmp/geneExpression/RPExpressionDataRepository.java index 1614184..0c09209 100755 --- a/src/main/java/org/kpmp/geneExpression/RPExpressionDataRepository.java +++ b/src/main/java/org/kpmp/geneExpression/RPExpressionDataRepository.java @@ -13,7 +13,7 @@ public interface RPExpressionDataRepository extends CrudRepository findByGeneSymbolAndTissueTypeWithCounts(String geneSymbol, String tissueType); @Cacheable("rpExpCountByGene") @Query(value = "SELECT COUNT(*) FROM rp_expression WHERE gene_symbol = :gene", nativeQuery = true) diff --git a/src/main/java/org/kpmp/geneExpression/RPExpressionDataService.java b/src/main/java/org/kpmp/geneExpression/RPExpressionDataService.java index d664438..742f71c 100755 --- a/src/main/java/org/kpmp/geneExpression/RPExpressionDataService.java +++ b/src/main/java/org/kpmp/geneExpression/RPExpressionDataService.java @@ -4,6 +4,11 @@ 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 { @@ -17,13 +22,22 @@ public RPExpressionDataService(RPExpressionDataRepository rpExpressionDataReposi public RPExpressionByTissueType getByGeneSymbolPerTissue(String geneSymbol) { RPExpressionByTissueType rpExpressionByTissueType = new RPExpressionByTissueType(); - rpExpressionByTissueType.setAki(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeWithCounts(geneSymbol, TissueTypeEnum.AKI.getParticipantTissueType())); - rpExpressionByTissueType.setCkd(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeWithCounts(geneSymbol, TissueTypeEnum.CKD.getParticipantTissueType())); - rpExpressionByTissueType.setDmr(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeWithCounts(geneSymbol, TissueTypeEnum.DMR.getParticipantTissueType())); - rpExpressionByTissueType.setHrt(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeWithCounts(geneSymbol, TissueTypeEnum.HEALTHY_REFERENCE.getParticipantTissueType())); - rpExpressionByTissueType.setAll(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeWithCounts(geneSymbol, TissueTypeEnum.ALL.getParticipantTissueType())); + rpExpressionByTissueType.setAki(convertToMap(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeWithCounts(geneSymbol, TissueTypeEnum.AKI.getParticipantTissueType()))); + rpExpressionByTissueType.setCkd(convertToMap(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeWithCounts(geneSymbol, TissueTypeEnum.CKD.getParticipantTissueType()))); + rpExpressionByTissueType.setDmr(convertToMap(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeWithCounts(geneSymbol, TissueTypeEnum.DMR.getParticipantTissueType()))); + rpExpressionByTissueType.setHrt(convertToMap(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeWithCounts(geneSymbol, TissueTypeEnum.HEALTHY_REFERENCE.getParticipantTissueType()))); + rpExpressionByTissueType.setAll(convertToMap(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeWithCounts(geneSymbol, TissueTypeEnum.ALL.getParticipantTissueType()))); return rpExpressionByTissueType; } + + public Map> convertToMap(List expressionDataList) { + Map> returnMap = new HashMap<>(); + for (RPExpressionData expressionData : expressionDataList) { + returnMap.computeIfAbsent(expressionData.getAccession(), k -> new ArrayList<>()).add(expressionData); + } + return returnMap; + } + } diff --git a/src/main/resources/knowledge_environment.graphqls b/src/main/resources/knowledge_environment.graphqls index 92c054e..f0a6f5e 100755 --- a/src/main/resources/knowledge_environment.graphqls +++ b/src/main/resources/knowledge_environment.graphqls @@ -172,6 +172,11 @@ type RTGeneExpressionByTissue { aki: [RTGeneExpression] } +type RPExpressionTuple { + accession: String + expressionValues: [RPGeneExpression] +} + type RPGeneExpression { id: ID geneSymbol: String @@ -190,11 +195,11 @@ type RPGeneExpression { } type RPGeneExpressionByTissue { - all: [RPGeneExpression] - hrt: [RPGeneExpression] - ckd: [RPGeneExpression] - dmr: [RPGeneExpression] - aki: [RPGeneExpression] + all: [RPExpressionTuple] + hrt: [RPExpressionTuple] + ckd: [RPExpressionTuple] + dmr: [RPExpressionTuple] + aki: [RPExpressionTuple] } type ParticipantSummaryDataset { From d23832092bd0e07335e32b253bceddf048364a17 Mon Sep 17 00:00:00 2001 From: dert1129 Date: Fri, 1 Dec 2023 15:19:01 -0500 Subject: [PATCH 13/34] create atlas banner message endpoint --- src/main/java/org/kpmp/Query.java | 15 ++++- .../org/kpmp/atlasMessage/AtlasMessage.java | 59 +++++++++++++++++++ .../atlasMessage/AtlasMessageRepository.java | 16 +++++ .../atlasMessage/AtlasMessageService.java | 43 ++++++++++++++ .../resources/knowledge_environment.graphqls | 7 +++ src/test/java/org/kpmp/QueryTest.java | 27 ++++++++- .../atlasMessage/AtlasMessageServiceTest.java | 40 +++++++++++++ .../kpmp/atlasMessage/AtlasMessageTest.java | 46 +++++++++++++++ 8 files changed, 251 insertions(+), 2 deletions(-) create mode 100644 src/main/java/org/kpmp/atlasMessage/AtlasMessage.java create mode 100644 src/main/java/org/kpmp/atlasMessage/AtlasMessageRepository.java create mode 100644 src/main/java/org/kpmp/atlasMessage/AtlasMessageService.java create mode 100644 src/test/java/org/kpmp/atlasMessage/AtlasMessageServiceTest.java create mode 100644 src/test/java/org/kpmp/atlasMessage/AtlasMessageTest.java diff --git a/src/main/java/org/kpmp/Query.java b/src/main/java/org/kpmp/Query.java index 74049e5..31c176b 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; @@ -44,13 +46,14 @@ public class Query implements GraphQLQueryResolver { private ClusterHierarchyService clusterHierarchyService; private RTExpressionDataService rtExpressionDataService; 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, ParticipantService participantService, AtlasMessageService atlasMessageService) { this.autocompleteService = autocompleteService; this.cellTypeService = cellTypeService; @@ -60,6 +63,7 @@ public Query(AutocompleteService autocompleteService, CellTypeService cellTypeSe this.clusterHierarchyService = clusterHierarchyService; this.rtExpressionDataService = rtExpressionDataService; this.participantService = participantService; + this.atlasMessageService = atlasMessageService; } public List autocomplete(String searchTerm) throws IOException, Exception { @@ -192,4 +196,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..80395c1 --- /dev/null +++ b/src/main/java/org/kpmp/atlasMessage/AtlasMessage.java @@ -0,0 +1,59 @@ +package org.kpmp.atlasMessage; + +import java.util.Date; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; + +@Entity +@Table(name = "atlas_messages") +public class AtlasMessage{ + @Id + private int atlasMessageId; + private String message; + private String application; + private Date startDate; + private Date endDate; + + public int getAtlasMessageId() { + return this.atlasMessageId; + } + + public void setAtlasMessageId(int atlasMessageId) { + this.atlasMessageId = atlasMessageId; + } + + 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..343e37f --- /dev/null +++ b/src/main/java/org/kpmp/atlasMessage/AtlasMessageRepository.java @@ -0,0 +1,16 @@ +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{ + @Cacheable("messageByStartDate") + @Query(value = "SELECT message, start_date, end_date FROM atlas_messages 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..b282c36 --- /dev/null +++ b/src/main/java/org/kpmp/atlasMessage/AtlasMessageService.java @@ -0,0 +1,43 @@ +package org.kpmp.atlasMessage; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.time.ZoneId; + + +@Service +public class AtlasMessageService { + private AtlasMessage atlasMessage; + private AtlasMessageRepository atlasMessageRepo; + + @Autowired + public AtlasMessageService(AtlasMessageRepository atlasMessageRepo){ + this.atlasMessageRepo = atlasMessageRepo; + } + + public List getAtlasMessage(){ + LocalDate localDate = LocalDate.now(); + ZoneId defaultZoneId = ZoneId.systemDefault(); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + Date currentDate = Date.from(localDate.atStartOfDay(defaultZoneId).toInstant()); + List messages = new ArrayList<>(); + Map messageMap = new HashMap<>(); + messages.addAll(atlasMessageRepo.getAtlasMessages()); + for (AtlasMessage atlasmessage : messages){ + if(currentDate.compareTo(atlasmessage.getStartDate()) >= 0 && currentDate.compareTo(atlasmessage.getEndDate()) <= 0){ + messageMap.put(atlasmessage.getAtlasMessageId(), atlasmessage); + } + } + return new ArrayList<>(messageMap.values()); + + } + +} \ No newline at end of file diff --git a/src/main/resources/knowledge_environment.graphqls b/src/main/resources/knowledge_environment.graphqls index 09482a8..db59feb 100755 --- a/src/main/resources/knowledge_environment.graphqls +++ b/src/main/resources/knowledge_environment.graphqls @@ -16,6 +16,13 @@ type Query { getTotalParticipantFilesCount(redcapId: String): ParticipantRepoDataTypeInformation getTissueTypeSummaryData: [ParticipantTissueTypeSummary] getAtlasSummaryRows: AtlasRepoSummaryResult + getAtlasBannerMessage: [AtlasBannerMessage] +} + +type AtlasBannerMessage{ + message: String + startDate: Date + endDate: Date } type AtlasRepoSummaryResult { diff --git a/src/test/java/org/kpmp/QueryTest.java b/src/test/java/org/kpmp/QueryTest.java index 7b5cd04..d8efa6f 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; @@ -63,12 +68,14 @@ public class QueryTest { private ParticipantService participantService; @Mock private ParticipantTissueTypeSummary participantTissueTypeSummary; + @Mock + private AtlasMessageService atlasMessageService; @Before public void setUp() throws Exception { MockitoAnnotations.openMocks(this); query = new Query(autocompleteService, cellTypeService, umapDataService, geneExpressionService, - dataSummaryService, clusterHierarchyService, rtExpressionDataService, participantService); + dataSummaryService, clusterHierarchyService, rtExpressionDataService, participantService, atlasMessageService); } @After @@ -284,4 +291,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.setAtlasMessageId(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..c45fe0c --- /dev/null +++ b/src/test/java/org/kpmp/atlasMessage/AtlasMessageServiceTest.java @@ -0,0 +1,40 @@ +package org.kpmp.atlasMessage; + +import static org.junit.Assert.assertEquals; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; +import java.util.ArrayList; + +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 { + List expectedResult = new ArrayList<>(); + assertEquals(expectedResult, atlasMessageService.getAtlasMessage()); + } +} 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..f4272a9 --- /dev/null +++ b/src/test/java/org/kpmp/atlasMessage/AtlasMessageTest.java @@ -0,0 +1,46 @@ +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 testGetAtlasMessage() throws Exception { + AtlasMessage expectedResult = 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); + expectedResult.setApplication("Explorer"); + expectedResult.setAtlasMessageId(1); + expectedResult.setMessage("THE END IS NEAR"); + expectedResult.setEndDate(endDate); + expectedResult.setStartDate(startDate); + assertEquals("Explorer", expectedResult.getApplication()); + assertEquals(1, expectedResult.getAtlasMessageId()); + assertEquals("THE END IS NEAR", expectedResult.getMessage()); + assertEquals(startDate, expectedResult.getStartDate()); + assertEquals(endDate, expectedResult.getEndDate()); + } +} From 8fcea7051abf0535541a3fb995558c156c214034 Mon Sep 17 00:00:00 2001 From: Zach Wright Date: Fri, 1 Dec 2023 16:07:17 -0500 Subject: [PATCH 14/34] KPMP-4434: Accession group --- .../RPExpressionByTissueType.java | 37 +++++++++---------- .../RPExpressionDataService.java | 20 +++++++--- .../resources/knowledge_environment.graphqls | 14 +++---- 3 files changed, 39 insertions(+), 32 deletions(-) diff --git a/src/main/java/org/kpmp/geneExpression/RPExpressionByTissueType.java b/src/main/java/org/kpmp/geneExpression/RPExpressionByTissueType.java index 819352c..6d75775 100755 --- a/src/main/java/org/kpmp/geneExpression/RPExpressionByTissueType.java +++ b/src/main/java/org/kpmp/geneExpression/RPExpressionByTissueType.java @@ -1,63 +1,62 @@ package org.kpmp.geneExpression; +import java.util.ArrayList; import java.util.List; import java.util.Map; public class RPExpressionByTissueType { - private class AccessionGroup { - private accession String; - private List expressionDataList; - } - private Map> all; - private Map> aki; + private List all; + + private List aki; - private Map> ckd; + private List ckd; - private Map> hrt; + private List hrt; - private Map> dmr; + private List dmr; - public Map> getAll() { + public List getAll() { return all; } - public void setAll(Map> all) { + public void setAll(List all) { this.all = all; } - public Map> getAki() { + public List getAki() { return aki; } - public void setAki(Map> aki) { + public void setAki(List aki) { this.aki = aki; } - public Map> getCkd() { + public List getCkd() { return ckd; } - public void setCkd(Map> ckd) { + public void setCkd(List ckd) { this.ckd = ckd; } - public Map> getHrt() { + public List getHrt() { return hrt; } - public void setHrt(Map> hrt) { + public void setHrt(List hrt) { this.hrt = hrt; } - public Map> getDmr() { + public List getDmr() { return dmr; } - public void setDmr(Map> dmr) { + public void setDmr(List dmr) { this.dmr = dmr; } + } diff --git a/src/main/java/org/kpmp/geneExpression/RPExpressionDataService.java b/src/main/java/org/kpmp/geneExpression/RPExpressionDataService.java index 742f71c..31fca9e 100755 --- a/src/main/java/org/kpmp/geneExpression/RPExpressionDataService.java +++ b/src/main/java/org/kpmp/geneExpression/RPExpressionDataService.java @@ -22,17 +22,17 @@ public RPExpressionDataService(RPExpressionDataRepository rpExpressionDataReposi public RPExpressionByTissueType getByGeneSymbolPerTissue(String geneSymbol) { RPExpressionByTissueType rpExpressionByTissueType = new RPExpressionByTissueType(); - rpExpressionByTissueType.setAki(convertToMap(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeWithCounts(geneSymbol, TissueTypeEnum.AKI.getParticipantTissueType()))); - rpExpressionByTissueType.setCkd(convertToMap(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeWithCounts(geneSymbol, TissueTypeEnum.CKD.getParticipantTissueType()))); - rpExpressionByTissueType.setDmr(convertToMap(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeWithCounts(geneSymbol, TissueTypeEnum.DMR.getParticipantTissueType()))); - rpExpressionByTissueType.setHrt(convertToMap(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeWithCounts(geneSymbol, TissueTypeEnum.HEALTHY_REFERENCE.getParticipantTissueType()))); - rpExpressionByTissueType.setAll(convertToMap(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeWithCounts(geneSymbol, TissueTypeEnum.ALL.getParticipantTissueType()))); + rpExpressionByTissueType.setAki(mapToList(resultsToMap(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeWithCounts(geneSymbol, TissueTypeEnum.AKI.getParticipantTissueType())))); + rpExpressionByTissueType.setCkd(mapToList(resultsToMap(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeWithCounts(geneSymbol, TissueTypeEnum.CKD.getParticipantTissueType())))); + rpExpressionByTissueType.setDmr(mapToList(resultsToMap(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeWithCounts(geneSymbol, TissueTypeEnum.DMR.getParticipantTissueType())))); + rpExpressionByTissueType.setHrt(mapToList(resultsToMap(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeWithCounts(geneSymbol, TissueTypeEnum.HEALTHY_REFERENCE.getParticipantTissueType())))); + rpExpressionByTissueType.setAll(mapToList(resultsToMap(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeWithCounts(geneSymbol, TissueTypeEnum.ALL.getParticipantTissueType())))); return rpExpressionByTissueType; } - public Map> convertToMap(List expressionDataList) { + public Map> resultsToMap(List expressionDataList) { Map> returnMap = new HashMap<>(); for (RPExpressionData expressionData : expressionDataList) { returnMap.computeIfAbsent(expressionData.getAccession(), k -> new ArrayList<>()).add(expressionData); @@ -40,4 +40,12 @@ public Map> convertToMap(List e return returnMap; } + public List mapToList(Map> expressionDataMap) { + List accessionGroups = new ArrayList<>(); + for (Map.Entry> expressionDataEntry: expressionDataMap.entrySet()) { + accessionGroups.add(new RPAccessionGroup(expressionDataEntry.getKey(), expressionDataEntry.getValue())); + } + return accessionGroups; + } + } diff --git a/src/main/resources/knowledge_environment.graphqls b/src/main/resources/knowledge_environment.graphqls index f0a6f5e..55893c9 100755 --- a/src/main/resources/knowledge_environment.graphqls +++ b/src/main/resources/knowledge_environment.graphqls @@ -172,9 +172,9 @@ type RTGeneExpressionByTissue { aki: [RTGeneExpression] } -type RPExpressionTuple { +type RPAccessionGroup { accession: String - expressionValues: [RPGeneExpression] + expressionDataList: [RPGeneExpression] } type RPGeneExpression { @@ -195,11 +195,11 @@ type RPGeneExpression { } type RPGeneExpressionByTissue { - all: [RPExpressionTuple] - hrt: [RPExpressionTuple] - ckd: [RPExpressionTuple] - dmr: [RPExpressionTuple] - aki: [RPExpressionTuple] + all: [RPAccessionGroup] + hrt: [RPAccessionGroup] + ckd: [RPAccessionGroup] + dmr: [RPAccessionGroup] + aki: [RPAccessionGroup] } type ParticipantSummaryDataset { From bb746e5a32dcfe4b18543ca2a128b883882b9d40 Mon Sep 17 00:00:00 2001 From: dert1129 Date: Mon, 4 Dec 2023 14:37:19 -0500 Subject: [PATCH 15/34] change endpoint name to be less confusing --- src/main/resources/knowledge_environment.graphqls | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/knowledge_environment.graphqls b/src/main/resources/knowledge_environment.graphqls index db59feb..4bf3906 100755 --- a/src/main/resources/knowledge_environment.graphqls +++ b/src/main/resources/knowledge_environment.graphqls @@ -16,10 +16,10 @@ type Query { getTotalParticipantFilesCount(redcapId: String): ParticipantRepoDataTypeInformation getTissueTypeSummaryData: [ParticipantTissueTypeSummary] getAtlasSummaryRows: AtlasRepoSummaryResult - getAtlasBannerMessage: [AtlasBannerMessage] + getAtlasMessages: [AtlasMessages] } -type AtlasBannerMessage{ +type AtlasMessages { message: String startDate: Date endDate: Date From 6d4a13bb5293dbfcd7fc9405f8b80edb17943094 Mon Sep 17 00:00:00 2001 From: dert1129 Date: Mon, 4 Dec 2023 14:49:55 -0500 Subject: [PATCH 16/34] change graphql data type to String --- src/main/resources/knowledge_environment.graphqls | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/knowledge_environment.graphqls b/src/main/resources/knowledge_environment.graphqls index 4bf3906..462b9a5 100755 --- a/src/main/resources/knowledge_environment.graphqls +++ b/src/main/resources/knowledge_environment.graphqls @@ -21,8 +21,8 @@ type Query { type AtlasMessages { message: String - startDate: Date - endDate: Date + startDate: String + endDate: String } type AtlasRepoSummaryResult { From 43bee39782ad4d2eed0e614fff937f5021532802 Mon Sep 17 00:00:00 2001 From: dert1129 Date: Mon, 4 Dec 2023 14:58:37 -0500 Subject: [PATCH 17/34] rename variable to id --- src/main/java/org/kpmp/atlasMessage/AtlasMessage.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/kpmp/atlasMessage/AtlasMessage.java b/src/main/java/org/kpmp/atlasMessage/AtlasMessage.java index 80395c1..83c2b0d 100644 --- a/src/main/java/org/kpmp/atlasMessage/AtlasMessage.java +++ b/src/main/java/org/kpmp/atlasMessage/AtlasMessage.java @@ -10,18 +10,18 @@ @Table(name = "atlas_messages") public class AtlasMessage{ @Id - private int atlasMessageId; + private int id; private String message; private String application; private Date startDate; private Date endDate; public int getAtlasMessageId() { - return this.atlasMessageId; + return this.id; } - public void setAtlasMessageId(int atlasMessageId) { - this.atlasMessageId = atlasMessageId; + public void setAtlasMessageId(int id) { + this.id = id; } public String getMessage() { From 3ad93eda0c2aa845604f78b30ddb63ca7732cc34 Mon Sep 17 00:00:00 2001 From: Zach Wright Date: Mon, 4 Dec 2023 15:45:44 -0500 Subject: [PATCH 18/34] Changes --- .../org/kpmp/geneExpression/RPExpressionDataService.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/kpmp/geneExpression/RPExpressionDataService.java b/src/main/java/org/kpmp/geneExpression/RPExpressionDataService.java index 31fca9e..aa1c135 100755 --- a/src/main/java/org/kpmp/geneExpression/RPExpressionDataService.java +++ b/src/main/java/org/kpmp/geneExpression/RPExpressionDataService.java @@ -32,7 +32,12 @@ public RPExpressionByTissueType getByGeneSymbolPerTissue(String geneSymbol) { } - public Map> resultsToMap(List expressionDataList) { + public RPExpressionByTissueType getByGeneSymbolPerAccession(String geneSymbol) { + + + } + + public Map> resultsToMap(List expressionDataList) { Map> returnMap = new HashMap<>(); for (RPExpressionData expressionData : expressionDataList) { returnMap.computeIfAbsent(expressionData.getAccession(), k -> new ArrayList<>()).add(expressionData); From 54c6a1545b14067b8a2e344419b186c674836915 Mon Sep 17 00:00:00 2001 From: dert1129 Date: Tue, 5 Dec 2023 13:21:29 -0500 Subject: [PATCH 19/34] cleanup --- .../org/kpmp/atlasMessage/AtlasMessage.java | 7 ++++--- .../atlasMessage/AtlasMessageRepository.java | 2 +- .../atlasMessage/AtlasMessageService.java | 20 +------------------ src/test/java/org/kpmp/QueryTest.java | 2 +- .../kpmp/atlasMessage/AtlasMessageTest.java | 4 ++-- 5 files changed, 9 insertions(+), 26 deletions(-) diff --git a/src/main/java/org/kpmp/atlasMessage/AtlasMessage.java b/src/main/java/org/kpmp/atlasMessage/AtlasMessage.java index 83c2b0d..1e0cd8b 100644 --- a/src/main/java/org/kpmp/atlasMessage/AtlasMessage.java +++ b/src/main/java/org/kpmp/atlasMessage/AtlasMessage.java @@ -1,5 +1,6 @@ package org.kpmp.atlasMessage; +import java.io.Serializable; import java.util.Date; import javax.persistence.Entity; @@ -8,7 +9,7 @@ @Entity @Table(name = "atlas_messages") -public class AtlasMessage{ +public class AtlasMessage implements Serializable { @Id private int id; private String message; @@ -16,11 +17,11 @@ public class AtlasMessage{ private Date startDate; private Date endDate; - public int getAtlasMessageId() { + public int getId() { return this.id; } - public void setAtlasMessageId(int id) { + public void setId(int id) { this.id = id; } diff --git a/src/main/java/org/kpmp/atlasMessage/AtlasMessageRepository.java b/src/main/java/org/kpmp/atlasMessage/AtlasMessageRepository.java index 343e37f..fadc582 100644 --- a/src/main/java/org/kpmp/atlasMessage/AtlasMessageRepository.java +++ b/src/main/java/org/kpmp/atlasMessage/AtlasMessageRepository.java @@ -11,6 +11,6 @@ @Repository interface AtlasMessageRepository extends CrudRepository{ @Cacheable("messageByStartDate") - @Query(value = "SELECT message, start_date, end_date FROM atlas_messages ORDER BY start_date ASC", nativeQuery = true) + @Query(value = "SELECT * FROM atlas_messages am WHERE start_date <= CURRENT_DATE() AND end_date >= CURRENT_DATE()", nativeQuery = true) List getAtlasMessages(); } diff --git a/src/main/java/org/kpmp/atlasMessage/AtlasMessageService.java b/src/main/java/org/kpmp/atlasMessage/AtlasMessageService.java index b282c36..49970ea 100644 --- a/src/main/java/org/kpmp/atlasMessage/AtlasMessageService.java +++ b/src/main/java/org/kpmp/atlasMessage/AtlasMessageService.java @@ -4,18 +4,11 @@ import org.springframework.stereotype.Service; import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; import java.util.List; -import java.util.Map; -import java.time.LocalDate; -import java.time.format.DateTimeFormatter; -import java.time.ZoneId; @Service public class AtlasMessageService { - private AtlasMessage atlasMessage; private AtlasMessageRepository atlasMessageRepo; @Autowired @@ -24,20 +17,9 @@ public AtlasMessageService(AtlasMessageRepository atlasMessageRepo){ } public List getAtlasMessage(){ - LocalDate localDate = LocalDate.now(); - ZoneId defaultZoneId = ZoneId.systemDefault(); - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); - Date currentDate = Date.from(localDate.atStartOfDay(defaultZoneId).toInstant()); List messages = new ArrayList<>(); - Map messageMap = new HashMap<>(); messages.addAll(atlasMessageRepo.getAtlasMessages()); - for (AtlasMessage atlasmessage : messages){ - if(currentDate.compareTo(atlasmessage.getStartDate()) >= 0 && currentDate.compareTo(atlasmessage.getEndDate()) <= 0){ - messageMap.put(atlasmessage.getAtlasMessageId(), atlasmessage); - } - } - return new ArrayList<>(messageMap.values()); - + return messages; } } \ No newline at end of file diff --git a/src/test/java/org/kpmp/QueryTest.java b/src/test/java/org/kpmp/QueryTest.java index d8efa6f..c7481f3 100755 --- a/src/test/java/org/kpmp/QueryTest.java +++ b/src/test/java/org/kpmp/QueryTest.java @@ -300,7 +300,7 @@ public void testGetAtlasMessage() throws Exception { String startDateString = "2023-12-01"; Date endDate = dateFormat.parse(endDateString); Date startDate = dateFormat.parse(startDateString); - atlasMessage.setAtlasMessageId(0); + atlasMessage.setId(0); atlasMessage.setApplication("Explorer"); atlasMessage.setEndDate(endDate); atlasMessage.setStartDate(startDate); diff --git a/src/test/java/org/kpmp/atlasMessage/AtlasMessageTest.java b/src/test/java/org/kpmp/atlasMessage/AtlasMessageTest.java index f4272a9..7248313 100644 --- a/src/test/java/org/kpmp/atlasMessage/AtlasMessageTest.java +++ b/src/test/java/org/kpmp/atlasMessage/AtlasMessageTest.java @@ -33,12 +33,12 @@ public void testGetAtlasMessage() throws Exception { Date endDate = dateFormat.parse(endDateString); Date startDate = dateFormat.parse(startDateString); expectedResult.setApplication("Explorer"); - expectedResult.setAtlasMessageId(1); + expectedResult.setId(1); expectedResult.setMessage("THE END IS NEAR"); expectedResult.setEndDate(endDate); expectedResult.setStartDate(startDate); assertEquals("Explorer", expectedResult.getApplication()); - assertEquals(1, expectedResult.getAtlasMessageId()); + assertEquals(1, expectedResult.getId()); assertEquals("THE END IS NEAR", expectedResult.getMessage()); assertEquals(startDate, expectedResult.getStartDate()); assertEquals(endDate, expectedResult.getEndDate()); From 0397b05804dc5c738601c1bf6f940f535a90dff3 Mon Sep 17 00:00:00 2001 From: dert1129 Date: Tue, 5 Dec 2023 16:47:03 -0500 Subject: [PATCH 20/34] address comments --- .../atlasMessage/AtlasMessageRepository.java | 2 +- .../atlasMessage/AtlasMessageService.java | 4 +- .../resources/knowledge_environment.graphqls | 1 + .../atlasMessage/AtlasMessageServiceTest.java | 23 ++++++++-- .../kpmp/atlasMessage/AtlasMessageTest.java | 44 +++++++++++++------ 5 files changed, 52 insertions(+), 22 deletions(-) diff --git a/src/main/java/org/kpmp/atlasMessage/AtlasMessageRepository.java b/src/main/java/org/kpmp/atlasMessage/AtlasMessageRepository.java index fadc582..61c80a6 100644 --- a/src/main/java/org/kpmp/atlasMessage/AtlasMessageRepository.java +++ b/src/main/java/org/kpmp/atlasMessage/AtlasMessageRepository.java @@ -11,6 +11,6 @@ @Repository interface AtlasMessageRepository extends CrudRepository{ @Cacheable("messageByStartDate") - @Query(value = "SELECT * FROM atlas_messages am WHERE start_date <= CURRENT_DATE() AND end_date >= CURRENT_DATE()", nativeQuery = true) + @Query(value = "SELECT * FROM atlas_messages am WHERE start_date <= CURRENT_DATE() AND end_date >= CURRENT_DATE() ORDER BY start_date DESC", nativeQuery = true) List getAtlasMessages(); } diff --git a/src/main/java/org/kpmp/atlasMessage/AtlasMessageService.java b/src/main/java/org/kpmp/atlasMessage/AtlasMessageService.java index 49970ea..fafbfd8 100644 --- a/src/main/java/org/kpmp/atlasMessage/AtlasMessageService.java +++ b/src/main/java/org/kpmp/atlasMessage/AtlasMessageService.java @@ -17,9 +17,7 @@ public AtlasMessageService(AtlasMessageRepository atlasMessageRepo){ } public List getAtlasMessage(){ - List messages = new ArrayList<>(); - messages.addAll(atlasMessageRepo.getAtlasMessages()); - return messages; + return atlasMessageRepo.getAtlasMessages(); } } \ No newline at end of file diff --git a/src/main/resources/knowledge_environment.graphqls b/src/main/resources/knowledge_environment.graphqls index 462b9a5..a0fb062 100755 --- a/src/main/resources/knowledge_environment.graphqls +++ b/src/main/resources/knowledge_environment.graphqls @@ -20,6 +20,7 @@ type Query { } type AtlasMessages { + id: Int message: String startDate: String endDate: String diff --git a/src/test/java/org/kpmp/atlasMessage/AtlasMessageServiceTest.java b/src/test/java/org/kpmp/atlasMessage/AtlasMessageServiceTest.java index c45fe0c..c7db503 100644 --- a/src/test/java/org/kpmp/atlasMessage/AtlasMessageServiceTest.java +++ b/src/test/java/org/kpmp/atlasMessage/AtlasMessageServiceTest.java @@ -1,13 +1,13 @@ package org.kpmp.atlasMessage; import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.when; -import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; -import java.util.ArrayList; +import java.util.Arrays; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -34,7 +34,22 @@ public void tearDown() throws Exception { @Test public void testGetAtlasMessage() throws Exception { - List expectedResult = new ArrayList<>(); - assertEquals(expectedResult, atlasMessageService.getAtlasMessage()); + 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 index 7248313..d07668a 100644 --- a/src/test/java/org/kpmp/atlasMessage/AtlasMessageTest.java +++ b/src/test/java/org/kpmp/atlasMessage/AtlasMessageTest.java @@ -25,22 +25,38 @@ public void tearDown() throws Exception { } @Test - public void testGetAtlasMessage() throws Exception { - AtlasMessage expectedResult = new AtlasMessage(); + 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"; - String startDateString = "2023-12-01"; Date endDate = dateFormat.parse(endDateString); - Date startDate = dateFormat.parse(startDateString); - expectedResult.setApplication("Explorer"); - expectedResult.setId(1); - expectedResult.setMessage("THE END IS NEAR"); - expectedResult.setEndDate(endDate); - expectedResult.setStartDate(startDate); - assertEquals("Explorer", expectedResult.getApplication()); - assertEquals(1, expectedResult.getId()); - assertEquals("THE END IS NEAR", expectedResult.getMessage()); - assertEquals(startDate, expectedResult.getStartDate()); - assertEquals(endDate, expectedResult.getEndDate()); + 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()); } } From 09341e85fd4785be726e43321cec1b807f2e7dc5 Mon Sep 17 00:00:00 2001 From: dert1129 Date: Wed, 6 Dec 2023 11:25:08 -0500 Subject: [PATCH 21/34] switch order by to acending --- src/main/java/org/kpmp/atlasMessage/AtlasMessageRepository.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/kpmp/atlasMessage/AtlasMessageRepository.java b/src/main/java/org/kpmp/atlasMessage/AtlasMessageRepository.java index 61c80a6..ef9a433 100644 --- a/src/main/java/org/kpmp/atlasMessage/AtlasMessageRepository.java +++ b/src/main/java/org/kpmp/atlasMessage/AtlasMessageRepository.java @@ -11,6 +11,6 @@ @Repository interface AtlasMessageRepository extends CrudRepository{ @Cacheable("messageByStartDate") - @Query(value = "SELECT * FROM atlas_messages am WHERE start_date <= CURRENT_DATE() AND end_date >= CURRENT_DATE() ORDER BY start_date DESC", nativeQuery = true) + @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(); } From 66b6413b4e19c6f34a3fbf4d2047e9bd8760adfa Mon Sep 17 00:00:00 2001 From: dert1129 Date: Wed, 6 Dec 2023 13:19:14 -0500 Subject: [PATCH 22/34] change time zone --- src/main/resources/application.properties | 1 + 1 file changed, 1 insertion(+) 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 From b06e32272049f849eb1ca431bd70cd820048c0b3 Mon Sep 17 00:00:00 2001 From: Zach Wright Date: Wed, 6 Dec 2023 13:53:53 -0500 Subject: [PATCH 23/34] KPMP-4434: tests --- .../kpmp/geneExpression/RPAccessionGroup.java | 4 ++ .../RPExpressionDataServiceTest.java | 58 +++++++++++++++---- 2 files changed, 50 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/kpmp/geneExpression/RPAccessionGroup.java b/src/main/java/org/kpmp/geneExpression/RPAccessionGroup.java index d20621b..2bf554c 100755 --- a/src/main/java/org/kpmp/geneExpression/RPAccessionGroup.java +++ b/src/main/java/org/kpmp/geneExpression/RPAccessionGroup.java @@ -3,6 +3,10 @@ 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; diff --git a/src/test/java/org/kpmp/geneExpression/RPExpressionDataServiceTest.java b/src/test/java/org/kpmp/geneExpression/RPExpressionDataServiceTest.java index dd195e3..41bb264 100755 --- a/src/test/java/org/kpmp/geneExpression/RPExpressionDataServiceTest.java +++ b/src/test/java/org/kpmp/geneExpression/RPExpressionDataServiceTest.java @@ -9,6 +9,7 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -35,30 +36,63 @@ public void tearDown() throws Exception { @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()}); - when(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeWithCounts("gene", TissueTypeEnum.AKI.getParticipantTissueType())). + 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.findByGeneSymbolAndTissueTypeWithCounts("gene", TissueTypeEnum.CKD.getParticipantTissueType())). + when(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeAndProteinWithCounts("gene", TissueTypeEnum.CKD.getParticipantTissueType(), "a1")). thenReturn(rpExpressionDataCkd); - when(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeWithCounts("gene", TissueTypeEnum.HEALTHY_REFERENCE.getParticipantTissueType())). + when(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeAndProteinWithCounts("gene", TissueTypeEnum.HEALTHY_REFERENCE.getParticipantTissueType(), "a1")). thenReturn(rpExpressionDataHrt); - when(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeWithCounts("gene", TissueTypeEnum.DMR.getParticipantTissueType())). + when(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeAndProteinWithCounts("gene", TissueTypeEnum.DMR.getParticipantTissueType(), "a1")). thenReturn(rpExpressionDataDmr); - when(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeWithCounts("gene", TissueTypeEnum.ALL.getParticipantTissueType())). + when(rpExpressionDataRepository.findByGeneSymbolAndTissueTypeAndProteinWithCounts("gene", TissueTypeEnum.ALL.getParticipantTissueType(), "a1")). thenReturn(rpExpressionDataAll); - RPExpressionByTissueType rpExpressionByTissueType = rpExpressionDataService.getByGeneSymbolPerTissue("gene"); - - assertEquals(rpExpressionByTissueType.getAki(), rpExpressionDataAki); - assertEquals(rpExpressionByTissueType.getHrt(), rpExpressionDataHrt); - assertEquals(rpExpressionByTissueType.getCkd(), rpExpressionDataCkd); - assertEquals(rpExpressionByTissueType.getAll(), rpExpressionDataAll); - assertEquals(rpExpressionByTissueType.getDmr(), rpExpressionDataDmr); + 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); } From 2404d01da4386e7b6321529c6015f6579d2ae01a Mon Sep 17 00:00:00 2001 From: Zach Wright Date: Fri, 8 Dec 2023 11:22:01 -0500 Subject: [PATCH 24/34] KPMP-4606: add participant count --- .../RPParticipantRepository.java | 6 ++++++ .../org/kpmp/participant/ParticipantService.java | 14 +++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/kpmp/geneExpressionSummary/regionalProteomics/RPParticipantRepository.java b/src/main/java/org/kpmp/geneExpressionSummary/regionalProteomics/RPParticipantRepository.java index cb53b59..7baffb9 100755 --- a/src/main/java/org/kpmp/geneExpressionSummary/regionalProteomics/RPParticipantRepository.java +++ b/src/main/java/org/kpmp/geneExpressionSummary/regionalProteomics/RPParticipantRepository.java @@ -13,4 +13,10 @@ public interface RPParticipantRepository extends CrudRepository 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; } From 9eec76dbfc446cda22f8bfae199091fa9655d0e7 Mon Sep 17 00:00:00 2001 From: Zach Wright Date: Fri, 8 Dec 2023 13:21:39 -0500 Subject: [PATCH 25/34] KPMP-4606: tests --- .../regionalProteomics/RPParticipantRepository.java | 4 ---- .../org/kpmp/participant/ParticipantServiceTest.java | 9 +++++++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/kpmp/geneExpressionSummary/regionalProteomics/RPParticipantRepository.java b/src/main/java/org/kpmp/geneExpressionSummary/regionalProteomics/RPParticipantRepository.java index 7baffb9..e5ac8bc 100755 --- a/src/main/java/org/kpmp/geneExpressionSummary/regionalProteomics/RPParticipantRepository.java +++ b/src/main/java/org/kpmp/geneExpressionSummary/regionalProteomics/RPParticipantRepository.java @@ -13,10 +13,6 @@ public interface RPParticipantRepository extends CrudRepository 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()); From 1c83460db35186714ebcd4a8ebf7e5f9b1909c69 Mon Sep 17 00:00:00 2001 From: dert1129 Date: Fri, 8 Dec 2023 13:47:07 -0500 Subject: [PATCH 26/34] remove cache --- src/main/java/org/kpmp/atlasMessage/AtlasMessageRepository.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/org/kpmp/atlasMessage/AtlasMessageRepository.java b/src/main/java/org/kpmp/atlasMessage/AtlasMessageRepository.java index ef9a433..2fb9014 100644 --- a/src/main/java/org/kpmp/atlasMessage/AtlasMessageRepository.java +++ b/src/main/java/org/kpmp/atlasMessage/AtlasMessageRepository.java @@ -10,7 +10,6 @@ @Repository interface AtlasMessageRepository extends CrudRepository{ - @Cacheable("messageByStartDate") @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(); } From 2e65172f6244e14814d9b3eec75461fc2d8b7464 Mon Sep 17 00:00:00 2001 From: HaneenT Date: Thu, 14 Dec 2023 08:48:12 -0500 Subject: [PATCH 27/34] KPMP-4886: Added application field to graphql query --- src/main/resources/knowledge_environment.graphqls | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/resources/knowledge_environment.graphqls b/src/main/resources/knowledge_environment.graphqls index 62b2014..a73979b 100755 --- a/src/main/resources/knowledge_environment.graphqls +++ b/src/main/resources/knowledge_environment.graphqls @@ -26,6 +26,7 @@ type AtlasMessages { message: String startDate: String endDate: String + application: String } type AtlasRepoSummaryResult { From 36d7e6c4ec2f8da29159b953b89e37443ec25795 Mon Sep 17 00:00:00 2001 From: Zach Wright Date: Fri, 15 Dec 2023 12:11:03 -0500 Subject: [PATCH 28/34] KPMP-4944: RP values --- .../org/kpmp/cellTypeSummary/ClusterHierarchy.java | 10 ++++++++++ src/main/resources/knowledge_environment.graphqls | 1 + 2 files changed, 11 insertions(+) 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/resources/knowledge_environment.graphqls b/src/main/resources/knowledge_environment.graphqls index 62b2014..7347a64 100755 --- a/src/main/resources/knowledge_environment.graphqls +++ b/src/main/resources/knowledge_environment.graphqls @@ -137,6 +137,7 @@ type ClusterHierarchy { isSingleNucCluster: String isSingleCellCluster: String isRegionalTranscriptomics: String + isRegionalProteomics: String cellTypeOrder: Float } From da72b3470f5ee690e7f801d0b1304ccbf1969be5 Mon Sep 17 00:00:00 2001 From: Zach Wright Date: Fri, 15 Dec 2023 13:29:16 -0500 Subject: [PATCH 29/34] KPMP-4944: Fix tests --- .../kpmp/cellTypeSummary/ClusterHierarchyTest.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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()); + } } From 7376027d43beb11ae35de3b5b5f6da446ab2bd45 Mon Sep 17 00:00:00 2001 From: Zach Wright Date: Fri, 15 Dec 2023 14:12:31 -0500 Subject: [PATCH 30/34] KPMP-4953: RP by structure --- src/main/java/org/kpmp/Query.java | 9 +++++++++ .../kpmp/geneExpression/RPExpressionDataRepository.java | 3 +++ .../org/kpmp/geneExpression/RPExpressionDataService.java | 4 ++++ src/main/resources/knowledge_environment.graphqls | 1 + 4 files changed, 17 insertions(+) diff --git a/src/main/java/org/kpmp/Query.java b/src/main/java/org/kpmp/Query.java index 10b6527..05903cb 100755 --- a/src/main/java/org/kpmp/Query.java +++ b/src/main/java/org/kpmp/Query.java @@ -157,6 +157,15 @@ 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 { diff --git a/src/main/java/org/kpmp/geneExpression/RPExpressionDataRepository.java b/src/main/java/org/kpmp/geneExpression/RPExpressionDataRepository.java index 997c9e6..0695fdd 100755 --- a/src/main/java/org/kpmp/geneExpression/RPExpressionDataRepository.java +++ b/src/main/java/org/kpmp/geneExpression/RPExpressionDataRepository.java @@ -25,6 +25,9 @@ public interface RPExpressionDataRepository extends CrudRepository 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 " + diff --git a/src/main/java/org/kpmp/geneExpression/RPExpressionDataService.java b/src/main/java/org/kpmp/geneExpression/RPExpressionDataService.java index c8ebb8f..094bba7 100755 --- a/src/main/java/org/kpmp/geneExpression/RPExpressionDataService.java +++ b/src/main/java/org/kpmp/geneExpression/RPExpressionDataService.java @@ -41,4 +41,8 @@ public RPExpressionByTissueType getByGeneSymbolAndProteinPerTissue(String geneSy return rpExpressionByTissueType; } + + public List getByStructure(String structure) { + return rpExpressionDataRepository.findByStructure(structure); + } } diff --git a/src/main/resources/knowledge_environment.graphqls b/src/main/resources/knowledge_environment.graphqls index 7347a64..228ffea 100755 --- a/src/main/resources/knowledge_environment.graphqls +++ b/src/main/resources/knowledge_environment.graphqls @@ -10,6 +10,7 @@ type Query { getRPGeneExpressionByTissue(geneSymbol: String!): [RPAccessionGroup] getRPGeneExpressionByTissueAndProtein(geneSymbol: String!, protein: String!): RPExpressionByTissueType getRTGeneExpressionByStructure(structure: String): [RTGeneExpression] + getRPGeneExpressionByStructure(structure: String): [RPGeneExpression] getSummaryData: [DataTypeSummaryInformation] getDataTypeInformationByParticipant(redcapId: String!): ParticipantDataTypeSummary getRepoDataTypeInformationByParticipant(redcapId: String!): ParticipantRepoDataTypeSummary From 82bd16ab65b80a204c8e2b455b36331cabd6276d Mon Sep 17 00:00:00 2001 From: Zach Wright Date: Fri, 15 Dec 2023 14:36:48 -0500 Subject: [PATCH 31/34] KPMP-4953: Add test --- src/main/java/org/kpmp/Query.java | 3 +-- .../kpmp/geneExpression/RPExpressionDataRepository.java | 1 - .../org/kpmp/geneExpression/RPExpressionDataService.java | 2 +- .../kpmp/geneExpression/RPExpressionDataServiceTest.java | 7 +++++++ 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/kpmp/Query.java b/src/main/java/org/kpmp/Query.java index 05903cb..df1487a 100755 --- a/src/main/java/org/kpmp/Query.java +++ b/src/main/java/org/kpmp/Query.java @@ -157,7 +157,7 @@ public List getRTGeneExpressionByStructure(String st } } - public List getRPGeneExpressionByStructure(String structure) throws Exception { + public List getRPGeneExpressionByStructure(String structure) throws Exception { try { return rpExpressionDataService.getByStructure(structure); } catch (Exception e) { @@ -165,7 +165,6 @@ public List getRPGeneExpressionByStructure(String st throw e; } } - public List getRPGeneExpressionByTissue(String geneSymbol) throws Exception { try { diff --git a/src/main/java/org/kpmp/geneExpression/RPExpressionDataRepository.java b/src/main/java/org/kpmp/geneExpression/RPExpressionDataRepository.java index 0695fdd..68cd991 100755 --- a/src/main/java/org/kpmp/geneExpression/RPExpressionDataRepository.java +++ b/src/main/java/org/kpmp/geneExpression/RPExpressionDataRepository.java @@ -25,7 +25,6 @@ public interface RPExpressionDataRepository extends CrudRepository findByStructure(@Param("structure") String structure); @Query(value = "SELECT rpe.*, count(*) as sample_count FROM rp_expression rpe " + diff --git a/src/main/java/org/kpmp/geneExpression/RPExpressionDataService.java b/src/main/java/org/kpmp/geneExpression/RPExpressionDataService.java index 094bba7..42c3a6e 100755 --- a/src/main/java/org/kpmp/geneExpression/RPExpressionDataService.java +++ b/src/main/java/org/kpmp/geneExpression/RPExpressionDataService.java @@ -42,7 +42,7 @@ public RPExpressionByTissueType getByGeneSymbolAndProteinPerTissue(String geneSy return rpExpressionByTissueType; } - public List getByStructure(String structure) { + public List getByStructure(String structure) { return rpExpressionDataRepository.findByStructure(structure); } } diff --git a/src/test/java/org/kpmp/geneExpression/RPExpressionDataServiceTest.java b/src/test/java/org/kpmp/geneExpression/RPExpressionDataServiceTest.java index 41bb264..853b9a7 100755 --- a/src/test/java/org/kpmp/geneExpression/RPExpressionDataServiceTest.java +++ b/src/test/java/org/kpmp/geneExpression/RPExpressionDataServiceTest.java @@ -122,4 +122,11 @@ public void testGetByGeneSymbolAndProteinPerTissue() throws Exception { 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")); + } } From 33698ba2ffa4dfc42d0484b19ada2b64f84df6a6 Mon Sep 17 00:00:00 2001 From: Becky Reamy Date: Tue, 19 Dec 2023 12:01:17 -0500 Subject: [PATCH 32/34] KPMP-4960: Add regional proteomics for data type dropdown activation --- .gitignore | 1 + .../ClusterHierarchyService.java | 4 ++++ .../ClusterHierarchyServiceTest.java | 23 ++++++++++++++++++- 3 files changed, 27 insertions(+), 1 deletion(-) 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/cellTypeSummary/ClusterHierarchyService.java b/src/main/java/org/kpmp/cellTypeSummary/ClusterHierarchyService.java index 619e7af..6e13ff2 100755 --- a/src/main/java/org/kpmp/cellTypeSummary/ClusterHierarchyService.java +++ b/src/main/java/org/kpmp/cellTypeSummary/ClusterHierarchyService.java @@ -9,6 +9,7 @@ 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 @@ -61,6 +62,9 @@ public List findDataTypesByClusterName(String clusterName) { 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/test/java/org/kpmp/cellTypeSummary/ClusterHierarchyServiceTest.java b/src/test/java/org/kpmp/cellTypeSummary/ClusterHierarchyServiceTest.java index c303947..91e58e1 100755 --- a/src/test/java/org/kpmp/cellTypeSummary/ClusterHierarchyServiceTest.java +++ b/src/test/java/org/kpmp/cellTypeSummary/ClusterHierarchyServiceTest.java @@ -101,6 +101,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 +118,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 +134,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 +150,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,11 +165,29 @@ 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"); + + 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"); } } From 020b126ad9898575bfaa2389bf39ef775d72dbf2 Mon Sep 17 00:00:00 2001 From: Zach Wright Date: Thu, 21 Dec 2023 10:23:19 -0500 Subject: [PATCH 33/34] Handle TI cluster --- .../ClusterHierarchyService.java | 22 ++++++---- .../geneExpression/RPAccessionGroupTest.java | 41 +++++++++++++++++++ 2 files changed, 56 insertions(+), 7 deletions(-) create mode 100755 src/test/java/org/kpmp/geneExpression/RPAccessionGroupTest.java diff --git a/src/main/java/org/kpmp/cellTypeSummary/ClusterHierarchyService.java b/src/main/java/org/kpmp/cellTypeSummary/ClusterHierarchyService.java index 6e13ff2..8cba53b 100755 --- a/src/main/java/org/kpmp/cellTypeSummary/ClusterHierarchyService.java +++ b/src/main/java/org/kpmp/cellTypeSummary/ClusterHierarchyService.java @@ -1,11 +1,6 @@ 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; @@ -39,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 @@ -65,6 +69,10 @@ public List findDataTypesByClusterName(String clusterName) { if (clustersInDataTypes.getIsRegionalProteomics().equalsIgnoreCase("Y")) { dataTypesRepresented.add(DataTypeEnum.REGIONAL_PROTEOMICS.getAbbreviation()); } + if (clusterName.equals("Tubulo-interstitium")) { + dataTypesRepresented.add(DataTypeEnum.REGIONAL_PROTEOMICS.getAbbreviation()); + dataTypesRepresented.add(DataTypeEnum.REGIONAL_TRANSCRIPTOMICS.getAbbreviation()); + } return dataTypesRepresented; } } 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()); + } + + +} From e7f3334ab1cb904b10121a166f2d544375aed248 Mon Sep 17 00:00:00 2001 From: Zach Wright Date: Thu, 21 Dec 2023 11:17:51 -0500 Subject: [PATCH 34/34] Add tests --- .../ClusterHierarchyService.java | 27 ++++++++++--------- .../ClusterHierarchyServiceTest.java | 23 +++++++++++++++- 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/src/main/java/org/kpmp/cellTypeSummary/ClusterHierarchyService.java b/src/main/java/org/kpmp/cellTypeSummary/ClusterHierarchyService.java index 8cba53b..bb817dd 100755 --- a/src/main/java/org/kpmp/cellTypeSummary/ClusterHierarchyService.java +++ b/src/main/java/org/kpmp/cellTypeSummary/ClusterHierarchyService.java @@ -56,22 +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")) { - dataTypesRepresented.add(DataTypeEnum.REGIONAL_TRANSCRIPTOMICS.getAbbreviation()); - } - if (clustersInDataTypes.getIsRegionalProteomics().equalsIgnoreCase("Y")) { - dataTypesRepresented.add(DataTypeEnum.REGIONAL_PROTEOMICS.getAbbreviation()); - } 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/test/java/org/kpmp/cellTypeSummary/ClusterHierarchyServiceTest.java b/src/test/java/org/kpmp/cellTypeSummary/ClusterHierarchyServiceTest.java index 91e58e1..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; @@ -190,4 +191,24 @@ public void testFindDataTypesByClusterNameWhenRPY() throws Exception { 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())); + } }