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 Jun 9, 2021
1 parent 1cf1565 commit 523e408
Show file tree
Hide file tree
Showing 32 changed files with 598 additions and 56 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package ubic.gemma.core.analysis.service;

import ubic.gemma.model.analysis.AnalysisResult;
import ubic.gemma.model.analysis.AnalysisResultSet;
import ubic.gemma.model.analysis.AnalysisResultSetValueObject;
import ubic.gemma.model.analysis.expression.diff.ExpressionAnalysisResultSet;
import ubic.gemma.model.expression.bioAssay.BioAssay;
import ubic.gemma.persistence.service.BaseVoEnabledService;

import java.util.Collection;

/**
* 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<K extends AnalysisResult, O extends AnalysisResultSet<K>, V extends AnalysisResultSetValueObject<K, O>> extends BaseVoEnabledService<O, V> {

/**
*
*
* @param datasets
* @param externalIds
* @param i
* @return
*/
Collection<O> findByDatasetInAndExternalIdsLimit( Collection<BioAssay> datasets, Collection<String> externalIds, 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,26 @@
package ubic.gemma.model.analysis;

import ubic.gemma.model.analysis.expression.diff.ExpressionAnalysisResultSet;
import ubic.gemma.model.expression.bioAssay.BioAssay;
import ubic.gemma.persistence.service.BaseVoEnabledDao;

import java.util.Collection;

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

/**
* Retrieve result sets associated to a set of {@link BioAssay} and external identifiers.
*
* @param bioAssayIds related {@link BioAssay}, or any if null
* @param externalIds related external identifier associated to the {@link BioAssay}, or any if null
* @param limit maximum number of results to return
* @return
*/
Collection<ExpressionAnalysisResultSet> findByDatasetInAndExternalIdsLimit( Collection<BioAssay> bioAssayIds, Collection<String> externalIds, int limit );
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* 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;

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

protected AnalysisResultSetValueObject( R analysisResultSet ) {
super( analysisResultSet.getId() );
}

public abstract Collection<AnalysisResultValueObject<K>> getAnalysisResults();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* 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;

/**
* Wraps an {@link AnalysisResult} to expose it on the public API.
*
* @param <A> type of {@link AnalysisResult} being wrapped by this value object
*/
public abstract 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
Loading

0 comments on commit 523e408

Please sign in to comment.