Skip to content

Commit

Permalink
Merge branch 'release-1.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobsonMT committed Apr 24, 2018
2 parents 06c2e06 + d3cee38 commit c32cb19
Show file tree
Hide file tree
Showing 25 changed files with 546 additions and 712 deletions.
2 changes: 1 addition & 1 deletion gotrack/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>ubc.pavlab</groupId>
<artifactId>gotrack</artifactId>
<packaging>war</packaging>
<version>1.3</version>
<version>1.4</version>
<name>gotrack</name>
<url>http://maven.apache.org</url>

Expand Down
408 changes: 113 additions & 295 deletions gotrack/src/main/java/ubc/pavlab/gotrack/beans/GeneView.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ public class GraphFactory implements Serializable {
* Entry point for fetching data necessary to create an ancestry DAG for a term
*/
public void fetchGraph( GeneOntologyTerm term ) {
Graph graph = Graph.fromGO( term );
fetchGraph( term, true );
}

public void fetchGraph( GeneOntologyTerm term, boolean showChildren ) {
Graph graph = Graph.fromGO( term, showChildren );
RequestContext.getCurrentInstance().addCallbackParam( "graph_data", graph.getJsonString() );
}

Expand Down
32 changes: 5 additions & 27 deletions gotrack/src/main/java/ubc/pavlab/gotrack/beans/TermView.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.google.gson.Gson;
import lombok.Getter;
import lombok.Setter;
Expand All @@ -32,6 +31,7 @@
import ubc.pavlab.gotrack.model.*;
import ubc.pavlab.gotrack.model.chart.ChartValues;
import ubc.pavlab.gotrack.model.chart.Series;
import ubc.pavlab.gotrack.model.chart.SeriesExtra;
import ubc.pavlab.gotrack.model.go.GeneOntologyTerm;
import ubc.pavlab.gotrack.model.go.Relation;
import ubc.pavlab.gotrack.model.go.RelationshipType;
Expand All @@ -56,7 +56,6 @@
* Backing bean for the term tracking functionality.
*
* @author mjacobson
* @version $Id$
*/
@Log4j
@Named
Expand Down Expand Up @@ -134,7 +133,8 @@ public String init() throws TermNotFoundException {
}

public boolean displayInferred() {
return cache.getInferredAnnotationCount( cache.getCurrentEditions( session.getSpecies() ), currentTerm ) <= MAX_INFERRED_GENES_DISPLAY_COUNT;
Integer cnt = cache.getInferredAnnotationCount( cache.getCurrentEditions( session.getSpecies() ), currentTerm );
return cnt == null || cnt <= MAX_INFERRED_GENES_DISPLAY_COUNT;
}

public Map<Gene, Boolean> fetchCurrentGenesMap() {
Expand Down Expand Up @@ -162,29 +162,6 @@ public List<Relation<GeneOntologyTerm>> getChildTerms( GeneOntologyTerm term ) {
.collect( Collectors.toList() );
}

/**
* entry point to fetch data to create the most current ancestry DAG
*/
public void fetchDAGData() {

// Collection<String> goids = Sets.newHashSet("GO:0005783","GO:0005886","GO:0005887","GO:0008021","GO:0009986","GO:0014069","GO:0017146","GO:0030054","GO:0030425","GO:0043005","GO:0043083","GO:0043195","GO:0043197","GO:0045202","GO:0045211","GO:0060076");


Set<GeneOntologyTerm> terms = Sets.newHashSet();
terms.add( currentTerm );

// for ( String goid : goids ) {
// GeneOntologyTerm t = cache.getCurrentTerm( goid );
// if (t != null) {
// terms.add( t );
// }
// }

Graph eles = Graph.fromGO( terms );

RequestContext.getCurrentInstance().addCallbackParam( "graph_data", eles.getJsonString() );
}

private Map<String, Object> createHCCallbackParamMap( ChartValues chart ) {
Map<String, Object> hcGsonMap = Maps.newHashMap();
hcGsonMap.put( "success", true );
Expand Down Expand Up @@ -286,7 +263,8 @@ public void fetchGeneChart() {

if ( eds != null ) {

Series s = new Series( allSpecies ? sp.getScientificName() : "All" );
SeriesExtra s = new SeriesExtra( allSpecies ? sp.getScientificName() : "All" );
s.putExtra( "visible", false );
Series s2 = new Series( allSpecies ? sp.getScientificName() + " Direct" : "Direct Only" );
series.put( sp, s );
directSeries.put( sp, s2 );
Expand Down
12 changes: 5 additions & 7 deletions gotrack/src/main/java/ubc/pavlab/gotrack/beans/Trends.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import ubc.pavlab.gotrack.model.Species;
import ubc.pavlab.gotrack.model.chart.ChartValues;
import ubc.pavlab.gotrack.model.chart.Series;
import ubc.pavlab.gotrack.model.chart.SeriesExtra;
import ubc.pavlab.gotrack.model.go.GeneOntology;

import javax.annotation.PostConstruct;
Expand Down Expand Up @@ -81,21 +82,18 @@ public void postConstruct() {
multifunctionalityChart.setSubtitle( sp.getScientificName() );
geneJaccardChart.setSubtitle( sp.getScientificName() );

geneCountChart.setMin( 0 );
termsForGeneChart.setMin( 0 );
geneJaccardChart.setMin( 0 );
inferredGenesForTermChart.setMin( 0 );
multifunctionalityChart.setMin( 0 );

geneJaccardChart.setMax( 1 );

Series geneCountSeries = new Series( "Distinct Genes" );
Series directTermsForGeneSeries = new Series( "Direct" );
Series inferredTermsForGeneSeries = new Series( "Inferred" );
SeriesExtra inferredTermsForGeneSeries = new SeriesExtra( "Inferred" );
inferredTermsForGeneSeries.putExtra( "visible", false );
Series inferredGenesForTermSeries = new Series( "Group Size" );
Series multifunctionalitySeries = new Series( "Multifunctionality" );
Series geneDirectJaccardSeries = new Series( "Direct" );
Series geneInferredJaccardSeries = new Series( "Inferred" );
SeriesExtra geneInferredJaccardSeries = new SeriesExtra( "Inferred" );
geneInferredJaccardSeries.putExtra( "visible", false );

for ( Edition ed : cache.getAllEditions( sp ) ) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,12 @@ public Stream<Gene> fetchDirectGenes( GeneOntologyTerm term, Edition edition ) {
} ).filter( Objects::nonNull );
}

public Stream<Tuples.Tuple2<Gene, GeneOntologyTerm>> streamEditionSimple(Species species, Edition edition) {
return annotationDAO.simpleAnnotationSingleEditionCompleteSpecies( species, edition).stream()
.map( tup -> new Tuples.Tuple2<>( cache.getCurrentGene( tup.getT1() ), cache.getTerm( edition, tup.getT2()) ) )
.filter( t -> t.getT1() != null && t.getT2() != null && t.getT1().getSpecies().equals( species ) );
}

public Map<Gene, Set<GeneOntologyTerm>> fetchEditionSimple(Species species, Edition edition) {

List<Tuples.Tuple2<String, String>> resultset = annotationDAO.simpleAnnotationSingleEditionCompleteSpecies( species, edition);
Expand Down
54 changes: 6 additions & 48 deletions gotrack/src/main/java/ubc/pavlab/gotrack/model/Annotation.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,65 +19,23 @@

package ubc.pavlab.gotrack.model;

import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import ubc.pavlab.gotrack.model.go.GeneOntologyTerm;

/**
* Represents an annotation, only makes sense when used to connect a {@link GeneOntologyTerm} and {@link Gene}
*
* @author mjacobson
* @version $Id$
*/
@Getter
@RequiredArgsConstructor
@EqualsAndHashCode
public final class Annotation {

private final String qualifier;
private final Evidence evidence;
private final String reference;

public Annotation( String qualifier, Evidence evidence, String reference ) {
super();
this.qualifier = qualifier;
this.evidence = evidence;
this.reference = reference;
}

public String getQualifier() {
return qualifier;
}

public Evidence getEvidence() {
return evidence;
}

public String getReference() {
return reference;
}

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ( ( evidence == null ) ? 0 : evidence.hashCode() );
result = prime * result + ( ( qualifier == null ) ? 0 : qualifier.hashCode() );
result = prime * result + ( ( reference == null ) ? 0 : reference.hashCode() );
return result;
}

@Override
public boolean equals( Object obj ) {
if ( this == obj ) return true;
if ( obj == null ) return false;
if ( getClass() != obj.getClass() ) return false;
Annotation other = ( Annotation ) obj;
if ( evidence == null ) {
if ( other.evidence != null ) return false;
} else if ( !evidence.equals( other.evidence ) ) return false;
if ( qualifier == null ) {
if ( other.qualifier != null ) return false;
} else if ( !qualifier.equals( other.qualifier ) ) return false;
if ( reference == null ) {
if ( other.reference != null ) return false;
} else if ( !reference.equals( other.reference ) ) return false;
return true;
}

}
35 changes: 35 additions & 0 deletions gotrack/src/main/java/ubc/pavlab/gotrack/model/FullAnnotation.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* The gotrack project
*
* Copyright (c) 2015 University of British Columbia
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package ubc.pavlab.gotrack.model;

import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import ubc.pavlab.gotrack.model.go.GeneOntologyTerm;

@Getter
//@EqualsAndHashCode( exclude = ("direct") ) // Exclude direct as we only want a single term-annotation pair in a set at once
@EqualsAndHashCode
@RequiredArgsConstructor
public class FullAnnotation {
private final GeneOntologyTerm annotatedTerm;
private final Annotation annotation;
private final boolean direct;
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,15 @@
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
import ubc.pavlab.gotrack.model.Annotation;
import ubc.pavlab.gotrack.model.Aspect;
import ubc.pavlab.gotrack.model.FullAnnotation;
import ubc.pavlab.gotrack.model.dto.GOTermDTO;

import java.util.*;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;

Expand Down Expand Up @@ -179,19 +184,24 @@ static Stream<GeneOntologyTerm> propagate( Stream<GeneOntologyTerm> terms, boole
return terms.flatMap( t -> t.propagate( includePartOf ) );
}

public static <A> Map<GeneOntologyTerm, Set<A>> propagateAnnotations( Stream<Map.Entry<GeneOntologyTerm, Set<A>>> termEntries ) {
return propagateAnnotations( termEntries, true );

public static Map<GeneOntologyTerm, Set<FullAnnotation>> propagateAnnotations( Stream<Map.Entry<GeneOntologyTerm, Set<Annotation>>> annotations ) {
return propagateAnnotations( annotations, true );
}

/**
* Propagates terms and their annotations to parents terms
*
* @return Map of all propagated terms to their propagated annotations
*/
static <A> Map<GeneOntologyTerm, Set<A>> propagateAnnotations( Stream<Map.Entry<GeneOntologyTerm, Set<A>>> termEntries, boolean includePartOf ) {
Map<GeneOntologyTerm, Set<A>> propagatedAnnotations = new HashMap<>();
termEntries.forEach( entry -> entry.getKey().propagate(includePartOf)
.forEach( p -> propagatedAnnotations.computeIfAbsent( p, k -> new HashSet<>() ).addAll( entry.getValue() ) ) );
static Map<GeneOntologyTerm, Set<FullAnnotation>> propagateAnnotations( Stream<Map.Entry<GeneOntologyTerm, Set<Annotation>>> annotations, boolean includePartOf ) {
Map<GeneOntologyTerm, Set<FullAnnotation>> propagatedAnnotations = new HashMap<>();

annotations.forEach( entry -> entry.getKey().propagate(includePartOf)
.forEach( p -> propagatedAnnotations.computeIfAbsent( p, k -> new HashSet<>() )
.addAll( entry.getValue().stream()
.map( a -> new FullAnnotation( entry.getKey(), a, p.equals( entry.getKey() ) ) )
.collect( Collectors.toList()) ) ) );

return propagatedAnnotations;
}
Expand Down

This file was deleted.

Loading

0 comments on commit c32cb19

Please sign in to comment.