Search in sources :

Example 51 with CompositeSequence

use of ubic.gemma.model.expression.designElement.CompositeSequence in project Gemma by PavlidisLab.

the class ExpressionExperimentServiceTest method testGetRawExpressionDataVectors.

@Test
public final void testGetRawExpressionDataVectors() {
    ExpressionExperiment eel = this.getTestPersistentCompleteExpressionExperiment(false);
    Collection<CompositeSequence> designElements = new HashSet<>();
    QuantitationType quantitationType = eel.getRawExpressionDataVectors().iterator().next().getQuantitationType();
    Collection<RawExpressionDataVector> allv = eel.getRawExpressionDataVectors();
    assertNotNull(quantitationType);
    assertTrue(allv.size() > 1);
    for (RawExpressionDataVector anAllv : allv) {
        CompositeSequence designElement = anAllv.getDesignElement();
        assertNotNull(designElement);
        designElements.add(designElement);
        if (designElements.size() == 2)
            break;
    }
    assertEquals(2, designElements.size());
    Collection<? extends DesignElementDataVector> vectors = rawExpressionDataVectorService.find(designElements, quantitationType);
    assertEquals(2, vectors.size());
}
Also used : RawExpressionDataVector(ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector) QuantitationType(ubic.gemma.model.common.quantitationtype.QuantitationType) CompositeSequence(ubic.gemma.model.expression.designElement.CompositeSequence) HashSet(java.util.HashSet) Test(org.junit.Test) BaseSpringContextTest(ubic.gemma.core.testing.BaseSpringContextTest)

Example 52 with CompositeSequence

use of ubic.gemma.model.expression.designElement.CompositeSequence in project Gemma by PavlidisLab.

the class ArrayDesignServiceTest method testThaw.

@Test
public void testThaw() {
    ad = super.getTestPersistentArrayDesign(5, true);
    ad = arrayDesignService.load(ad.getId());
    ad = arrayDesignService.thaw(ad);
    // make sure we can do this...
    // noinspection ResultOfMethodCallIgnored
    ad.getPrimaryTaxon().equals(this.taxonService.load(1L));
    auditTrailService.addUpdateEvent(ad, "testing");
    for (CompositeSequence cs : ad.getCompositeSequences()) {
        // noinspection ResultOfMethodCallIgnored
        cs.getBiologicalCharacteristic().getName();
    }
}
Also used : CompositeSequence(ubic.gemma.model.expression.designElement.CompositeSequence) Test(org.junit.Test) BaseSpringContextTest(ubic.gemma.core.testing.BaseSpringContextTest)

Example 53 with CompositeSequence

use of ubic.gemma.model.expression.designElement.CompositeSequence in project Gemma by PavlidisLab.

the class ArrayDesignServiceTest method testCascadeCreateCompositeSequences.

@Test
public void testCascadeCreateCompositeSequences() {
    ad = (ArrayDesign) persisterHelper.persist(ad);
    ad = arrayDesignService.find(ad);
    ad = arrayDesignService.thaw(ad);
    CompositeSequence cs = ad.getCompositeSequences().iterator().next();
    assertNotNull(cs.getId());
    assertNotNull(cs.getArrayDesign().getId());
}
Also used : CompositeSequence(ubic.gemma.model.expression.designElement.CompositeSequence) Test(org.junit.Test) BaseSpringContextTest(ubic.gemma.core.testing.BaseSpringContextTest)

Example 54 with CompositeSequence

use of ubic.gemma.model.expression.designElement.CompositeSequence in project Gemma by PavlidisLab.

the class ArrayDesignServiceTest method testDelete.

@Test
public void testDelete() {
    ad = (ArrayDesign) persisterHelper.persist(ad);
    Collection<CompositeSequence> seqs = ad.getCompositeSequences();
    Collection<Long> seqIds = new ArrayList<>();
    for (CompositeSequence seq : seqs) {
        if (seq.getId() == null) {
            // why?
            continue;
        }
        seqIds.add(seq.getId());
    }
    // just a wrinkle to this test -- ensure ACLs are there
    securityService.isPublic(ad);
    arrayDesignService.remove(ad);
    ad = null;
    for (Long id : seqIds) {
        try {
            CompositeSequence cs = compositeSequenceService.load(id);
            if (cs != null)
                fail(cs + " was still in the system");
        } catch (HibernateObjectRetrievalFailureException e) {
        // ok
        }
    }
}
Also used : HibernateObjectRetrievalFailureException(org.springframework.orm.hibernate3.HibernateObjectRetrievalFailureException) ArrayList(java.util.ArrayList) CompositeSequence(ubic.gemma.model.expression.designElement.CompositeSequence) Test(org.junit.Test) BaseSpringContextTest(ubic.gemma.core.testing.BaseSpringContextTest)

Example 55 with CompositeSequence

use of ubic.gemma.model.expression.designElement.CompositeSequence in project Gemma by PavlidisLab.

the class ExpressionExperimentPlatformSwitchService method processVector.

/**
 * @param designElementMap   Mapping of sequences to probes for the platform that is being switch from. This is used
 *                           to identify new candidates.
 * @param usedDesignElements probes from the new design that have already been assigned to probes from the old
 *                           design. If things are done correctly (the old design was merged into the new) then there should be enough.
 *                           Map is of the new design probe to the old design probe it was used for (this is debugging information)
 * @param vector             vector
 * @param bad                BioAssayDimension to use, if necessary. If this is null or already the one used, it's igored.
 *                           Otherwise the vector data will be rewritten to match it.
 * @throws IllegalStateException if there is no (unused) design element matching the vector's biosequence
 */
private void processVector(Map<BioSequence, Collection<CompositeSequence>> designElementMap, Map<CompositeSequence, Collection<BioAssayDimension>> usedDesignElements, DesignElementDataVector vector, BioAssayDimension bad) {
    CompositeSequence oldDe = vector.getDesignElement();
    Collection<CompositeSequence> newElCandidates;
    BioSequence seq = oldDe.getBiologicalCharacteristic();
    if (seq == null) {
        newElCandidates = designElementMap.get(ExpressionExperimentPlatformSwitchService.NULL_BIOSEQUENCE);
    } else {
        newElCandidates = designElementMap.get(seq);
    }
    if (newElCandidates == null || newElCandidates.isEmpty()) {
        throw new IllegalStateException("There are no candidates probes for sequence: " + seq + "('null' should be okay)");
    }
    for (CompositeSequence newEl : newElCandidates) {
        if (!usedDesignElements.containsKey(newEl)) {
            vector.setDesignElement(newEl);
            usedDesignElements.put(newEl, new HashSet<BioAssayDimension>());
            usedDesignElements.get(newEl).add(vector.getBioAssayDimension());
            break;
        }
        if (!usedDesignElements.get(newEl).contains(vector.getBioAssayDimension())) {
            /*
                 * Then it's okay to use it.
                 */
            vector.setDesignElement(newEl);
            usedDesignElements.get(newEl).add(vector.getBioAssayDimension());
            break;
        }
    }
    if (bad != null && !vector.getBioAssayDimension().equals(bad)) {
        /*
             * 1. Check if they are already the same; then just switch it to the desired BAD
             * 2. If not, then the vector data has to be rewritten.
             */
        this.vectorReWrite(vector, bad);
    }
}
Also used : BioAssayDimension(ubic.gemma.model.expression.bioAssayData.BioAssayDimension) BioSequence(ubic.gemma.model.genome.biosequence.BioSequence) CompositeSequence(ubic.gemma.model.expression.designElement.CompositeSequence)

Aggregations

CompositeSequence (ubic.gemma.model.expression.designElement.CompositeSequence)206 ArrayDesign (ubic.gemma.model.expression.arrayDesign.ArrayDesign)43 BioSequence (ubic.gemma.model.genome.biosequence.BioSequence)40 Gene (ubic.gemma.model.genome.Gene)32 Test (org.junit.Test)30 BioMaterial (ubic.gemma.model.expression.biomaterial.BioMaterial)19 ExpressionDataDoubleMatrix (ubic.gemma.core.datastructure.matrix.ExpressionDataDoubleMatrix)18 BioAssay (ubic.gemma.model.expression.bioAssay.BioAssay)18 DesignElementDataVector (ubic.gemma.model.expression.bioAssayData.DesignElementDataVector)18 RawExpressionDataVector (ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector)18 StopWatch (org.apache.commons.lang3.time.StopWatch)17 HashSet (java.util.HashSet)15 BioAssayDimension (ubic.gemma.model.expression.bioAssayData.BioAssayDimension)15 CompositeSequenceValueObject (ubic.gemma.model.expression.designElement.CompositeSequenceValueObject)15 ArrayList (java.util.ArrayList)14 QuantitationType (ubic.gemma.model.common.quantitationtype.QuantitationType)14 BaseSpringContextTest (ubic.gemma.core.testing.BaseSpringContextTest)13 Taxon (ubic.gemma.model.genome.Taxon)12 Collection (java.util.Collection)11 ByteArrayConverter (ubic.basecode.io.ByteArrayConverter)11