Skip to content

Commit

Permalink
Add skeleton for querying result sets
Browse files Browse the repository at this point in the history
  • Loading branch information
arteymix committed Feb 17, 2021
1 parent a1a98f1 commit 2f69665
Show file tree
Hide file tree
Showing 30 changed files with 475 additions and 52 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package ubic.gemma.core.analysis.service;

import ubic.gemma.model.analysis.AnalysisResultSet;
import ubic.gemma.model.analysis.AnalysisResultSetValueObject;
import ubic.gemma.persistence.service.BaseVoEnabledService;

/**
* Interface for services providing {@link AnalysisResultSet}.
*
* @param <O> the type of result set
* @param <V> a value object type to expose result sets
*/
public interface AnalysisResultSetService<O extends AnalysisResultSet, V extends AnalysisResultSetValueObject<O>> extends BaseVoEnabledService<O, V> {

/**
*
* @param i
* @return
*/
V loadValueObjectsLimit( int i );
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
import org.springframework.test.jdbc.JdbcTestUtils;
import ubic.gemma.model.analysis.Analysis;
import ubic.gemma.model.association.BioSequence2GeneProduct;
import ubic.gemma.model.common.auditAndSecurity.Contact;
import ubic.gemma.model.common.description.BibliographicReference;
Expand Down Expand Up @@ -181,8 +182,14 @@ public void setTaxonService( TaxonService taxonService ) {
this.taxonService = taxonService;
}

protected void addTestAnalyses( ExpressionExperiment ee ) {
testHelper.addTestAnalyses( ee );
/**
* Create test {@link Analysis} for the given expression experiment.
*
* @param ee expression experiment to use for creating test analyses
* @return a collection of persisted analyses that were created
*/
protected Collection<Analysis> addTestAnalyses( ExpressionExperiment ee ) {
return testHelper.addTestAnalyses( ee );
}

/**
Expand Down Expand Up @@ -490,7 +497,6 @@ protected ExpressionExperiment getTestPersistentExpressionExperiment() {
return testHelper.getTestPersistentExpressionExperiment();
}



/**
* Convenience method to provide an ExpressionExperiment that can be used to fill non-nullable associations in test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ubic.basecode.io.ByteArrayConverter;
import ubic.gemma.model.analysis.Analysis;
import ubic.gemma.model.analysis.expression.coexpression.CoexpressionAnalysis;
import ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysis;
import ubic.gemma.model.association.BioSequence2GeneProduct;
Expand Down Expand Up @@ -159,7 +160,8 @@ private static Taxon getTestNonPersistentTaxon() {
return t;
}

public void addTestAnalyses( ExpressionExperiment ee ) {
public Collection<Analysis> addTestAnalyses( ExpressionExperiment ee ) {
Collection<Analysis> analyses = new ArrayList<>();
/*
* Add analyses
*/
Expand All @@ -168,7 +170,7 @@ public void addTestAnalyses( ExpressionExperiment ee ) {

pca.setExperimentAnalyzed( ee );

persisterHelper.persist( pca );
analyses.add( ( Analysis ) persisterHelper.persist( pca ) );

/*
* Diff
Expand All @@ -180,12 +182,14 @@ public void addTestAnalyses( ExpressionExperiment ee ) {
expressionAnalysis.setProtocol( protocol );
expressionAnalysis.setExperimentAnalyzed( ee );

persisterHelper.persist( expressionAnalysis );
analyses.add( ( Analysis ) persisterHelper.persist( expressionAnalysis ) );

return analyses;
}

/**
* @param allFactorValues all factor values
* @return Non-persistent ED
* @return Non-persistent ED
*/
public ExperimentalDesign getExperimentalDesign( Collection<FactorValue> allFactorValues ) {
ExperimentalDesign ed = ExperimentalDesign.Factory.newInstance();
Expand Down Expand Up @@ -278,7 +282,7 @@ public ExpressionExperiment getTestExpressionExperimentWithAllDependencies( Expr
* Add an expressionExperiment to the database for testing purposes. Includes associations
*
* @param doSequence Should the array design get all the sequence information filled in? (true = slower)
* @return EE
* @return EE
*/
public ExpressionExperiment getTestExpressionExperimentWithAllDependencies( boolean doSequence ) {

Expand Down Expand Up @@ -366,7 +370,7 @@ public Gene getTestPersistentGene( Taxon t ) {
* 0_probe_at....N_probe_at
* @param doSequence If true, biosequences and biosequence2GeneProduct associations are filled in
* (slower).
* @return ArrayDesign
* @return ArrayDesign
*/
public ArrayDesign getTestPersistentArrayDesign( int numCompositeSequences, boolean randomNames,
boolean doSequence ) {
Expand Down Expand Up @@ -417,7 +421,7 @@ public ExpressionExperiment getTestPersistentBasicExpressionExperiment() {

/**
* @param arrayDesign AD
* @return A lighter-weight EE, with no data, and the ADs have no sequences.
* @return A lighter-weight EE, with no data, and the ADs have no sequences.
*/
public ExpressionExperiment getTestPersistentBasicExpressionExperiment( ArrayDesign arrayDesign ) {
ExpressionExperiment ee = ExpressionExperiment.Factory.newInstance();
Expand Down Expand Up @@ -479,7 +483,7 @@ public BioAssay getTestPersistentBioAssay( ArrayDesign ad ) {
*
* @param ad AD
* @param bm BM
* @return BA
* @return BA
*/
public BioAssay getTestPersistentBioAssay( ArrayDesign ad, BioMaterial bm ) {
if ( ad == null || bm == null ) {
Expand Down Expand Up @@ -513,7 +517,7 @@ public BioSequence getTestPersistentBioSequence( Taxon taxon ) {

/**
* @param bioSequence bio sequence
* @return bio sequence to gene products
* @return bio sequence to gene products
*/
@SuppressWarnings("unchecked")
public Collection<BioSequence2GeneProduct> getTestPersistentBioSequence2GeneProducts( BioSequence bioSequence ) {
Expand Down Expand Up @@ -574,7 +578,7 @@ public Contact getTestPersistentContact() {
* The accession is set to a random string
*
* @param ed ED
* @return db entry
* @return db entry
*/
public DatabaseEntry getTestPersistentDatabaseEntry( ExternalDatabase ed ) {
return this.getTestPersistentDatabaseEntry(
Expand All @@ -587,7 +591,7 @@ public DatabaseEntry getTestPersistentDatabaseEntry( ExternalDatabase ed ) {
*
* @param ed ED
* @param accession accession
* @return db entry
* @return db entry
*/
public DatabaseEntry getTestPersistentDatabaseEntry( String accession, ExternalDatabase ed ) {
DatabaseEntry result = DatabaseEntry.Factory.newInstance();
Expand All @@ -613,7 +617,7 @@ public DatabaseEntry getTestPersistentDatabaseEntry( String accession, ExternalD
/**
* @param databaseName GEO or PubMed (others could be supported)
* @param accession accession
* @return db entry
* @return db entry
*/
public DatabaseEntry getTestPersistentDatabaseEntry( String accession, String databaseName ) {
switch ( databaseName ) {
Expand Down Expand Up @@ -649,7 +653,7 @@ public ExpressionExperiment getTestPersistentExpressionExperiment() {
* persistent BioMaterials and BioAssays so that database taxon lookups for this experiment will work.
*
* @param taxon the experiment will have this taxon
* @return EE
* @return EE
*/
public ExpressionExperiment getTestPersistentExpressionExperiment( Taxon taxon ) {
BioAssay ba;
Expand Down Expand Up @@ -820,7 +824,7 @@ private Collection<BioMaterial> getBioMaterials( Collection<FactorValue> allFact
* @param ad AD
* @param ee EE
* @param quantitationTypes QTs
* @return These are non-persistent
* @return These are non-persistent
*/
private Collection<RawExpressionDataVector> getDesignElementDataVectors( ExpressionExperiment ee,
Collection<QuantitationType> quantitationTypes, List<BioAssay> bioAssays, ArrayDesign ad ) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package ubic.gemma.model.analysis;

import ubic.gemma.model.common.Identifiable;

/**
* Abstract class representing a single result from an {@link Analysis} and a typical part of an {@link AnalysisResultSet}.
*/
public abstract class AnalysisResult implements Identifiable {

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
/**
* An abstract class representing a related set of generic analysis results, part of an analysis.
*/
public abstract class AnalysisResultSet implements Identifiable, Serializable {
public abstract class AnalysisResultSet<R extends AnalysisResult> implements Identifiable, Serializable {

/**
* The serial version UID of this class. Needed for serialization.
Expand Down Expand Up @@ -83,6 +83,6 @@ public void setId( Long id ) {

@SuppressWarnings({ "unused", "WeakerAccess" }) // Possible external use
@Transient
public abstract Collection<?> getResults();
public abstract Collection<R> getResults();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package ubic.gemma.model.analysis;

import ubic.gemma.persistence.service.BaseVoEnabledDao;

/**
* Generic DAO for manipulating {@link AnalysisResultSet}.
*
* @param <O>
* @param <VO>
*/
public interface AnalysisResultSetDao<O extends AnalysisResultSet, VO extends AnalysisResultSetValueObject<O>> extends BaseVoEnabledDao<O, VO> {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* The Gemma project
*
* Copyright (c) 2006 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 ubic.gemma.model.analysis;

import ubic.gemma.model.IdentifiableValueObject;

import java.util.Collection;
import java.util.stream.Collectors;

/**
* Exposes an {@link AnalysisResultSet} to the public API.
*
* @param <R> type of analysis result set this is wrapping.
*/
public abstract class AnalysisResultSetValueObject<R extends AnalysisResultSet> extends IdentifiableValueObject<R> {

private final Collection<AnalysisResultValueObject> analysisResults;

public AnalysisResultSetValueObject( AnalysisResultSet<AnalysisResult> analysisResultSet ) {
super( analysisResultSet.getId() );
this.analysisResults = analysisResultSet.getResults()
.stream().map( AnalysisResultValueObject::new )
.collect( Collectors.toList() );
}

public Collection<AnalysisResultValueObject> getAnalysisResults() {
return analysisResults;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* The Gemma project
*
* Copyright (c) 2006 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 ubic.gemma.model.analysis;

import ubic.gemma.model.IdentifiableValueObject;

public class AnalysisResultValueObject<A extends AnalysisResult> extends IdentifiableValueObject<A> {

public AnalysisResultValueObject( AnalysisResult analysisResult ) {
super( analysisResult.getId() );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@
*/
package ubic.gemma.model.analysis.expression;

import ubic.gemma.model.analysis.AnalysisResult;
import ubic.gemma.model.analysis.AnalysisResultSet;
import ubic.gemma.model.expression.experiment.ExperimentalFactor;

import java.util.Collection;
import java.util.HashSet;

public abstract class FactorAssociatedAnalysisResultSet extends AnalysisResultSet {
public abstract class FactorAssociatedAnalysisResultSet<R extends AnalysisResult> extends AnalysisResultSet<R> {

/**
* The serial version UID of this class. Needed for serialization.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package ubic.gemma.model.analysis.expression.diff;

import ubic.gemma.model.analysis.AnalysisResult;
import ubic.gemma.model.common.Identifiable;
import ubic.gemma.model.expression.designElement.CompositeSequence;

Expand All @@ -31,7 +32,7 @@
* associated contrasts.
*/
@SuppressWarnings({ "unused", "WeakerAccess" }) // Possible external use
public class DifferentialExpressionAnalysisResult implements Identifiable, Serializable {
public class DifferentialExpressionAnalysisResult extends AnalysisResult implements Serializable {
/**
* The serial version UID of this class. Needed for serialization.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* The Gemma project
*
* Copyright (c) 2010 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 ubic.gemma.model.analysis.expression.diff;

import ubic.gemma.model.IdentifiableValueObject;

public class DifferentialExpressionAnalysisResultValueObject extends IdentifiableValueObject<DifferentialExpressionAnalysisResult> {

private final Double pValue;
private final Double correctedPvalue;
private final Double rank;

public DifferentialExpressionAnalysisResultValueObject( DifferentialExpressionAnalysisResult result ) {
super( result.getId() );
this.pValue = result.getPvalue();
this.correctedPvalue = result.getCorrectedPvalue();
this.rank = result.getRank();
}

public Double getPvalue() {
return pValue;
}

public Double getCorrectedPvalue() {
return correctedPvalue;
}

public Double getRank() {
return rank;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
/**
* A group of results for an ExpressionExperiment.
*/
public class ExpressionAnalysisResultSet extends FactorAssociatedAnalysisResultSet {
public class ExpressionAnalysisResultSet extends FactorAssociatedAnalysisResultSet<DifferentialExpressionAnalysisResult> {

private static final long serialVersionUID = 7226901182513177574L;
private Integer numberOfProbesTested;
Expand Down
Loading

0 comments on commit 2f69665

Please sign in to comment.