Search in sources :

Example 1 with CompositeSequenceValueObject

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

the class PlatformArg method getElements.

/**
 * Retrieves the Elements of the Platform that this argument represents.
 *
 * @param service service that will be used to retrieve the persistent AD object.
 * @return a collection of Composite Sequence VOs that the platform represented by this argument contains.
 */
public Collection<CompositeSequenceValueObject> getElements(ArrayDesignService service, CompositeSequenceService csService, int limit, int offset) {
    ArrayDesign ad = this.getPersistentObject(service);
    Collection<CompositeSequence> css = ad == null ? null : service.getCompositeSequences(ad, limit, offset);
    Collection<CompositeSequenceValueObject> csVos = new ArrayList<>(css != null ? css.size() : 0);
    if (css == null)
        return csVos;
    for (CompositeSequence cs : css) {
        CompositeSequenceValueObject csVo = csService.loadValueObject(cs);
        csVo.setGeneMappingSummaries(csService.getGeneMappingSummary(cs));
        csVos.add(csVo);
    }
    return csVos;
}
Also used : CompositeSequenceValueObject(ubic.gemma.model.expression.designElement.CompositeSequenceValueObject) ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) ArrayList(java.util.ArrayList) CompositeSequence(ubic.gemma.model.expression.designElement.CompositeSequence)

Example 2 with CompositeSequenceValueObject

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

the class GeneralSearchControllerImpl method fillValueObjects.

@SuppressWarnings("unchecked")
private void fillValueObjects(Class<?> entityClass, List<SearchResult> results, SearchSettings settings) {
    StopWatch timer = new StopWatch();
    timer.start();
    Collection<?> vos;
    if (ExpressionExperiment.class.isAssignableFrom(entityClass)) {
        vos = this.filterEE(expressionExperimentService.loadValueObjects(EntityUtils.getIds(results), false), settings);
        if (!SecurityUtil.isUserAdmin()) {
            auditableUtil.removeTroubledEes((Collection<ExpressionExperimentValueObject>) vos);
        }
    } else if (ArrayDesign.class.isAssignableFrom(entityClass)) {
        vos = this.filterAD(arrayDesignService.loadValueObjectsByIds(EntityUtils.getIds(results)), settings);
        if (!SecurityUtil.isUserAdmin()) {
            auditableUtil.removeTroubledArrayDesigns((Collection<ArrayDesignValueObject>) vos);
        }
    } else if (CompositeSequence.class.isAssignableFrom(entityClass)) {
        Collection<CompositeSequenceValueObject> css = new ArrayList<>();
        for (SearchResult sr : results) {
            CompositeSequenceValueObject csvo = compositeSequenceService.loadValueObject((CompositeSequence) sr.getResultObject());
            css.add(csvo);
        }
        vos = css;
    } else if (BibliographicReference.class.isAssignableFrom(entityClass)) {
        Collection<BibliographicReference> bss = bibliographicReferenceService.load(EntityUtils.getIds(results));
        bss = bibliographicReferenceService.thaw(bss);
        vos = bibliographicReferenceService.loadValueObjects(bss);
    } else if (Gene.class.isAssignableFrom(entityClass)) {
        Collection<Gene> genes = geneService.load(EntityUtils.getIds(results));
        genes = geneService.thawLite(genes);
        vos = geneService.loadValueObjects(genes);
    } else if (Characteristic.class.isAssignableFrom(entityClass)) {
        Collection<CharacteristicValueObject> cvos = new ArrayList<>();
        for (SearchResult sr : results) {
            Characteristic ch = (Characteristic) sr.getResultObject();
            cvos.add(new CharacteristicValueObject(ch));
        }
        vos = cvos;
    } else if (CharacteristicValueObject.class.isAssignableFrom(entityClass)) {
        Collection<CharacteristicValueObject> cvos = new ArrayList<>();
        for (SearchResult sr : results) {
            CharacteristicValueObject ch = (CharacteristicValueObject) sr.getResultObject();
            cvos.add(ch);
        }
        vos = cvos;
    } else if (BioSequenceValueObject.class.isAssignableFrom(entityClass)) {
        return;
    } else if (GeneSet.class.isAssignableFrom(entityClass)) {
        vos = geneSetService.getValueObjects(EntityUtils.getIds(results));
    } else if (ExpressionExperimentSet.class.isAssignableFrom(entityClass)) {
        vos = experimentSetService.loadValueObjects(experimentSetService.load(EntityUtils.getIds(results)));
    } else if (FactorValue.class.isAssignableFrom(entityClass)) {
        Collection<FactorValueValueObject> fvo = new ArrayList<>();
        for (SearchResult sr : results) {
            fvo.add(new FactorValueValueObject((FactorValue) sr.getResultObject()));
        }
        vos = fvo;
    } else {
        throw new UnsupportedOperationException("Don't know how to make value objects for class=" + entityClass);
    }
    if (vos == null || vos.isEmpty()) {
        // it causing front end errors, if vos is empty make sure to get rid of all search results
        for (Iterator<SearchResult> it = results.iterator(); it.hasNext(); ) {
            it.next();
            it.remove();
        }
        return;
    }
    // retained objects...
    Map<Long, Object> idMap = EntityUtils.getIdMap(vos);
    for (Iterator<SearchResult> it = results.iterator(); it.hasNext(); ) {
        SearchResult sr = it.next();
        if (!idMap.containsKey(sr.getId())) {
            it.remove();
            continue;
        }
        sr.setResultObject(idMap.get(sr.getId()));
    }
    if (timer.getTime() > 1000) {
        BaseFormController.log.info("Value object conversion after search: " + timer.getTime() + "ms");
    }
}
Also used : CharacteristicValueObject(ubic.gemma.model.genome.gene.phenotype.valueObject.CharacteristicValueObject) CompositeSequenceValueObject(ubic.gemma.model.expression.designElement.CompositeSequenceValueObject) Gene(ubic.gemma.model.genome.Gene) ExpressionExperimentValueObject(ubic.gemma.model.expression.experiment.ExpressionExperimentValueObject) BioSequenceValueObject(ubic.gemma.model.genome.sequenceAnalysis.BioSequenceValueObject) FactorValueValueObject(ubic.gemma.model.expression.experiment.FactorValueValueObject) FactorValue(ubic.gemma.model.expression.experiment.FactorValue) ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) Characteristic(ubic.gemma.model.common.description.Characteristic) SearchResult(ubic.gemma.core.search.SearchResult) BibliographicReference(ubic.gemma.model.common.description.BibliographicReference) StopWatch(org.apache.commons.lang3.time.StopWatch) ExpressionExperimentSet(ubic.gemma.model.analysis.expression.ExpressionExperimentSet) ArrayDesignValueObject(ubic.gemma.model.expression.arrayDesign.ArrayDesignValueObject) SearchSettingsValueObject(ubic.gemma.model.common.search.SearchSettingsValueObject) FactorValueValueObject(ubic.gemma.model.expression.experiment.FactorValueValueObject) BioSequenceValueObject(ubic.gemma.model.genome.sequenceAnalysis.BioSequenceValueObject) ExpressionExperimentValueObject(ubic.gemma.model.expression.experiment.ExpressionExperimentValueObject) CompositeSequenceValueObject(ubic.gemma.model.expression.designElement.CompositeSequenceValueObject) CharacteristicValueObject(ubic.gemma.model.genome.gene.phenotype.valueObject.CharacteristicValueObject)

Example 3 with CompositeSequenceValueObject

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

the class ProcessedExpressionDataVectorDaoImpl method maskAndUnpack.

private Map<CompositeSequence, DoubleVectorValueObject> maskAndUnpack(Collection<RawExpressionDataVector> preferredData, Collection<RawExpressionDataVector> missingValueData) {
    Map<CompositeSequence, DoubleVectorValueObject> unpackedData = this.unpack(preferredData);
    if (missingValueData.size() == 0) {
        AbstractDao.log.info("There is no separate missing data information, simply using the data as is");
        for (DoubleVectorValueObject rv : unpackedData.values()) {
            rv.setMasked(true);
        }
        return unpackedData;
    }
    Collection<BooleanVectorValueObject> unpackedMissingValueData = this.unpackBooleans(missingValueData);
    Map<CompositeSequenceValueObject, BooleanVectorValueObject> missingValueMap = new HashMap<>();
    for (BooleanVectorValueObject bv : unpackedMissingValueData) {
        missingValueMap.put(bv.getDesignElement(), bv);
    }
    boolean warned = false;
    for (DoubleVectorValueObject rv : unpackedData.values()) {
        double[] data = rv.getData();
        CompositeSequenceValueObject de = rv.getDesignElement();
        BooleanVectorValueObject mv = missingValueMap.get(de);
        if (mv == null) {
            if (!warned && AbstractDao.log.isWarnEnabled())
                AbstractDao.log.warn("No mask vector for " + de + ", additional warnings for missing masks for this job will be skipped");
            // we're missing a mask vector for it for some reason, but still flag it as effectively masked.
            rv.setMasked(true);
            warned = true;
            continue;
        }
        boolean[] mvData = mv.getData();
        if (mvData.length != data.length) {
            throw new IllegalStateException("Missing value data didn't match data length");
        }
        for (int i = 0; i < data.length; i++) {
            if (!mvData[i]) {
                data[i] = Double.NaN;
            }
        }
        rv.setMasked(true);
    }
    return unpackedData;
}
Also used : CompositeSequence(ubic.gemma.model.expression.designElement.CompositeSequence) CompositeSequenceValueObject(ubic.gemma.model.expression.designElement.CompositeSequenceValueObject)

Example 4 with CompositeSequenceValueObject

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

the class CompositeSequenceDaoImpl method loadValueObjectsPreFilter.

@Override
public Collection<CompositeSequenceValueObject> loadValueObjectsPreFilter(int offset, int limit, String orderBy, boolean asc, ArrayList<ObjectFilter[]> filter) {
    // Compose query
    Query query = this.getLoadValueObjectsQueryString(filter, orderBy, !asc);
    query.setCacheable(true);
    if (limit > 0)
        query.setMaxResults(limit);
    query.setFirstResult(offset);
    // noinspection unchecked
    List<Object[]> list = query.list();
    List<CompositeSequenceValueObject> vos = new ArrayList<>(list.size());
    for (Object[] row : list) {
        CompositeSequence cs = (CompositeSequence) row[1];
        cs.setArrayDesign((ArrayDesign) row[2]);
        CompositeSequenceValueObject vo = new CompositeSequenceValueObject(cs);
        vos.add(vo);
    }
    return vos;
}
Also used : CompositeSequenceValueObject(ubic.gemma.model.expression.designElement.CompositeSequenceValueObject) CompositeSequenceValueObject(ubic.gemma.model.expression.designElement.CompositeSequenceValueObject) CompositeSequence(ubic.gemma.model.expression.designElement.CompositeSequence)

Example 5 with CompositeSequenceValueObject

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

the class ProcessedExpressionDataCreateServiceTest method testComputeDevRankForExpressionExperimentMultiArrayWithGaps.

/**
 * Three platforms, one sample was not run on GPL81. It's 'Norm-1a', but the name we use for the sample is random.
 */
@SuppressWarnings("unchecked")
@Test
public void testComputeDevRankForExpressionExperimentMultiArrayWithGaps() throws Exception {
    try {
        geoService.setGeoDomainObjectGenerator(new GeoDomainObjectGeneratorLocal(this.getTestFileBasePath("gse482short")));
        Collection<ExpressionExperiment> results = (Collection<ExpressionExperiment>) geoService.fetchAndLoad("GSE482", false, true, false);
        this.ee = results.iterator().next();
    } catch (AlreadyExistsInSystemException e) {
        this.ee = ((Collection<ExpressionExperiment>) e.getData()).iterator().next();
    }
    ee = this.eeService.thawLite(ee);
    processedExpressionDataVectorService.computeProcessedExpressionData(ee);
    Collection<ProcessedExpressionDataVector> preferredVectors = this.processedExpressionDataVectorService.getProcessedDataVectors(ee);
    ee = eeService.load(ee.getId());
    ee = this.eeService.thawLite(ee);
    processedExpressionDataVectorService.thaw(preferredVectors);
    ExpressionDataDoubleMatrix mat = new ExpressionDataDoubleMatrix(preferredVectors);
    assertEquals(10, mat.columns());
    boolean found = false;
    for (int i = 0; i < mat.rows(); i++) {
        Double[] row = mat.getRow(i);
        // debugging
        if (i == 0) {
            for (int j = 0; j < row.length; j++) {
                BioAssay ba = mat.getBioAssaysForColumn(j).iterator().next();
                System.err.println(ba.getName());
            }
        }
        System.err.print(mat.getRowElement(i).getDesignElement().getName() + "\t");
        for (double d : row) {
            System.err.print(String.format("%4.2f\t", d));
        }
        System.err.print("\n");
        CompositeSequence el = mat.getDesignElementForRow(i);
        for (int j = 0; j < row.length; j++) {
            BioAssay ba = mat.getBioAssaysForColumn(j).iterator().next();
            if (ba.getName().matches("PGA-MurLungHyper-Norm-1a[ABC]v2-s2") && (el.getName().equals("100001_at") || el.getName().equals("100002_at") || el.getName().equals("100003_at") || el.getName().equals("100004_at") || el.getName().equals("100005_at") || el.getName().equals("100006_at") || el.getName().equals("100007_at") || el.getName().equals("100009_r_at") || el.getName().equals("100010_at") || el.getName().equals("100011_at"))) {
                assertEquals(Double.NaN, row[j], 0.0001);
                found = true;
            } else {
                assertTrue("Got unexpected NA value for " + ba.getName() + " for " + el.getName(), !Double.isNaN(row[j]));
            }
        }
    }
    assertTrue(found);
    /*
         * Now do this through the processedExpressionDataVectorService
         */
    Collection<DoubleVectorValueObject> da = this.processedExpressionDataVectorService.getProcessedDataArrays(ee);
    assertEquals(30, da.size());
    found = false;
    boolean first = true;
    for (DoubleVectorValueObject v : da) {
        CompositeSequenceValueObject el = v.getDesignElement();
        double[] row = v.getData();
        // debugging
        if (first) {
            for (int j = 0; j < row.length; j++) {
                BioAssayValueObject ba = v.getBioAssays().get(j);
                System.err.println(ba.getName());
            }
            first = false;
        }
        System.err.print(el.getName() + "\t");
        for (double d : row) {
            System.err.print(String.format("%4.2f\t", d));
        }
        System.err.print("\n");
        assertEquals(10, row.length);
        for (int j = 0; j < row.length; j++) {
            assertNotNull(v.getBioAssays());
            BioAssayValueObject ba = v.getBioAssays().get(j);
            if (ba.getName().startsWith("Missing bioassay for biomaterial") && (el.getName().equals("100001_at") || el.getName().equals("100002_at") || el.getName().equals("100003_at") || el.getName().equals("100004_at") || el.getName().equals("100005_at") || el.getName().equals("100006_at") || el.getName().equals("100007_at") || el.getName().equals("100009_r_at") || el.getName().equals("100010_at") || el.getName().equals("100011_at"))) {
                assertEquals(Double.NaN, row[j], 0.0001);
                found = true;
            } else {
                assertTrue("Got unexpected NA value for " + ba.getName() + " for " + el.getName(), !Double.isNaN(row[j]));
            }
        }
    }
    assertTrue(found);
}
Also used : ExpressionDataDoubleMatrix(ubic.gemma.core.datastructure.matrix.ExpressionDataDoubleMatrix) ProcessedExpressionDataVector(ubic.gemma.model.expression.bioAssayData.ProcessedExpressionDataVector) CompositeSequence(ubic.gemma.model.expression.designElement.CompositeSequence) CompositeSequenceValueObject(ubic.gemma.model.expression.designElement.CompositeSequenceValueObject) BioAssayValueObject(ubic.gemma.model.expression.bioAssay.BioAssayValueObject) AlreadyExistsInSystemException(ubic.gemma.core.loader.util.AlreadyExistsInSystemException) DoubleVectorValueObject(ubic.gemma.model.expression.bioAssayData.DoubleVectorValueObject) BioAssay(ubic.gemma.model.expression.bioAssay.BioAssay) GeoDomainObjectGeneratorLocal(ubic.gemma.core.loader.expression.geo.GeoDomainObjectGeneratorLocal) AbstractGeoServiceTest(ubic.gemma.core.loader.expression.geo.AbstractGeoServiceTest) Test(org.junit.Test)

Aggregations

CompositeSequenceValueObject (ubic.gemma.model.expression.designElement.CompositeSequenceValueObject)5 CompositeSequence (ubic.gemma.model.expression.designElement.CompositeSequence)4 ArrayDesign (ubic.gemma.model.expression.arrayDesign.ArrayDesign)2 ArrayList (java.util.ArrayList)1 StopWatch (org.apache.commons.lang3.time.StopWatch)1 Test (org.junit.Test)1 ExpressionDataDoubleMatrix (ubic.gemma.core.datastructure.matrix.ExpressionDataDoubleMatrix)1 AbstractGeoServiceTest (ubic.gemma.core.loader.expression.geo.AbstractGeoServiceTest)1 GeoDomainObjectGeneratorLocal (ubic.gemma.core.loader.expression.geo.GeoDomainObjectGeneratorLocal)1 AlreadyExistsInSystemException (ubic.gemma.core.loader.util.AlreadyExistsInSystemException)1 SearchResult (ubic.gemma.core.search.SearchResult)1 ExpressionExperimentSet (ubic.gemma.model.analysis.expression.ExpressionExperimentSet)1 BibliographicReference (ubic.gemma.model.common.description.BibliographicReference)1 Characteristic (ubic.gemma.model.common.description.Characteristic)1 SearchSettingsValueObject (ubic.gemma.model.common.search.SearchSettingsValueObject)1 ArrayDesignValueObject (ubic.gemma.model.expression.arrayDesign.ArrayDesignValueObject)1 BioAssay (ubic.gemma.model.expression.bioAssay.BioAssay)1 BioAssayValueObject (ubic.gemma.model.expression.bioAssay.BioAssayValueObject)1 DoubleVectorValueObject (ubic.gemma.model.expression.bioAssayData.DoubleVectorValueObject)1 ProcessedExpressionDataVector (ubic.gemma.model.expression.bioAssayData.ProcessedExpressionDataVector)1