Skip to content

Commit 3d1b872

Browse files
committed
Merge branch 'release-1.2.8'
2 parents 099b89e + ab03c82 commit 3d1b872

File tree

8 files changed

+55
-4
lines changed

8 files changed

+55
-4
lines changed

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>ubc.pavlab</groupId>
77
<artifactId>rdp</artifactId>
8-
<version>1.2.7</version>
8+
<version>1.2.8</version>
99

1010
<parent>
1111
<groupId>org.springframework.boot</groupId>

src/main/java/ubc/pavlab/rdp/controllers/MainController.java

+7-2
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,13 @@ private boolean searchAuthorized(User user){
246246
}
247247

248248
private Stats getStats() {
249-
return new Stats( userService.countResearchers(), userGeneService.countUsersWithGenes(),
250-
userGeneService.countAssociations(), userGeneService.countUniqueAssociations(),
249+
return new Stats(
250+
userService.countResearchers(),
251+
userGeneService.countUsersWithGenes(),
252+
userGeneService.countAssociations(),
253+
userGeneService.countUniqueAssociations(),
254+
userGeneService.countUniqueAssociationsAllTiers(),
255+
userGeneService.countUniqueAssociationsToHumanAllTiers(),
251256
userGeneService.researcherCountByTaxon() );
252257
}
253258

src/main/java/ubc/pavlab/rdp/controllers/StatsController.java

+2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ public Map<String, Object> getAggregateStats(HttpServletResponse response) {
4343
stats.put( "researchers_registered_with_genes", userGeneService.countUsersWithGenes() );
4444
stats.put( "genes_added", userGeneService.countAssociations() );
4545
stats.put( "genes_added_unique", userGeneService.countUniqueAssociations() );
46+
stats.put( "researchers_registered_with_genes_alltiers", userGeneService.countUniqueAssociationsAllTiers() );
47+
stats.put( "human_genes_represented", userGeneService.countUniqueAssociationsToHumanAllTiers() );
4648
stats.put( "researcher_counts_by_taxon", userGeneService.researcherCountByTaxon() );
4749

4850
return stats;

src/main/java/ubc/pavlab/rdp/model/Stats.java

+2
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,7 @@ public class Stats {
1818
private Integer usersWithGenes;
1919
private Integer userGenes;
2020
private Integer uniqueUserGenes;
21+
private Integer uniqueUserGenesTAll; // Unique genes added, counting all TIERs
22+
private Integer uniqueUserGenesHumanTAll; // Unique genes mapped back to human, counting all TIERs
2123
private Map<String, Integer> researchersByTaxa;
2224
}

src/main/java/ubc/pavlab/rdp/model/enums/TierType.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ public enum TierType {
1010
TIER1, TIER2, TIER3, ANY, TIERS1_2;
1111

1212
public static final Set<TierType> MANUAL_TIERS = EnumSet.of(TIER1, TIER2);
13-
13+
public static final Set<TierType> ALL_TIERS = EnumSet.of(TIER1, TIER2, TIER3, ANY);
1414
}

src/main/java/ubc/pavlab/rdp/repositories/UserGeneRepository.java

+15
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import org.springframework.stereotype.Repository;
88
import ubc.pavlab.rdp.model.Taxon;
99
import ubc.pavlab.rdp.model.UserGene;
10+
import ubc.pavlab.rdp.model.Gene;
1011
import ubc.pavlab.rdp.model.enums.TierType;
1112

1213
import javax.persistence.QueryHint;
@@ -43,4 +44,18 @@ public interface UserGeneRepository extends JpaRepository<UserGene, Integer> {
4344
@QueryHints(@QueryHint(name = "org.hibernate.cacheable", value = "true"))
4445
Collection<UserGene> findBySymbolContainingIgnoreCaseAndTaxonAndTierIn(String symbolContaining, Taxon taxon, Set<TierType> tiers);
4546

47+
// Return gene IDs of all associations in tiers
48+
@QueryHints(@QueryHint(name = "org.hibernate.cacheable", value = "true"))
49+
@Query("select distinct geneId FROM UserGene WHERE tier IN (:tiers)")
50+
Collection<Integer> findDistinctGeneByTierIn( @Param("tiers") Collection<TierType> tiers );
51+
52+
// Return the reverse-mapped human gene(s) for a given ortholog target.
53+
@QueryHints(@QueryHint(name = "org.hibernate.cacheable", value = "true"))
54+
@Query("select sourceGene FROM Ortholog where targetGene IN (:target_gene) ")
55+
Collection<Integer> findHumanGenesForTarget(@Param("target_gene") Collection<Integer> targetGene);
56+
57+
// Return all human genes.
58+
@QueryHints(@QueryHint(name = "org.hibernate.cacheable", value = "true"))
59+
@Query("select geneId FROM UserGene where taxon = '9606'")
60+
Collection<Integer> findAllHumanGenes();
4661
}

src/main/java/ubc/pavlab/rdp/services/UserGeneService.java

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ public interface UserGeneService {
3838
Map<String, Integer> researcherCountByTaxon();
3939

4040
Integer countUsersWithGenes();
41+
Integer countUniqueAssociationsAllTiers();
42+
Integer countUniqueAssociationsToHumanAllTiers();
4143

4244
Collection<Integer> findOrthologs(Integer source_gene, Integer targetTaxon);
4345

src/main/java/ubc/pavlab/rdp/services/UserGeneServiceImpl.java

+25
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,31 @@ public Integer countUsersWithGenes() {
8080
return userGeneRepository.countDistinctUser();
8181
}
8282

83+
@Cacheable(cacheNames = "stats", key = "#root.methodName")
84+
@Override
85+
public Integer countUniqueAssociationsAllTiers() {
86+
return userGeneRepository.countDistinctGeneByTierIn( TierType.ALL_TIERS );
87+
}
88+
89+
@Cacheable(cacheNames = "stats", key = "#root.methodName")
90+
@Override
91+
public Integer countUniqueAssociationsToHumanAllTiers() {
92+
/* This is also called the "human gene coverage" */
93+
94+
Collection<Integer> humanGenes = new HashSet<Integer>();
95+
96+
// Add orthologs mapped to humans
97+
humanGenes.addAll( userGeneRepository.findHumanGenesForTarget(
98+
userGeneRepository.findDistinctGeneByTierIn( TierType.ALL_TIERS )
99+
));
100+
101+
// Add directly entered human genes
102+
humanGenes.addAll( userGeneRepository.findAllHumanGenes() );
103+
104+
return humanGenes.size();
105+
}
106+
107+
@Cacheable(cacheNames = "stats", key = "#root.methodName")
83108
@Override
84109
public Collection<Integer> findOrthologs( Integer sourceGene, Integer targetTaxon ) {
85110
return userGeneRepository.findOrthologs( sourceGene, targetTaxon );

0 commit comments

Comments
 (0)