Search in sources :

Example 76 with CompositeSequence

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

the class CompositeSequenceServiceImpl method remove.

@Override
public void remove(Collection<CompositeSequence> sequencesToDelete) {
    // check the collection to make sure it contains no transitive entities (just check the id and make sure its
    // non-null
    Collection<CompositeSequence> filteredSequence = new Vector<>();
    for (Object sequence : sequencesToDelete) {
        if (((CompositeSequence) sequence).getId() != null)
            filteredSequence.add((CompositeSequence) sequence);
    }
    this.compositeSequenceDao.remove(filteredSequence);
}
Also used : GeneValueObject(ubic.gemma.model.genome.gene.GeneValueObject) BioSequenceValueObject(ubic.gemma.model.genome.sequenceAnalysis.BioSequenceValueObject) BlatResultValueObject(ubic.gemma.model.genome.sequenceAnalysis.BlatResultValueObject) CompositeSequenceValueObject(ubic.gemma.model.expression.designElement.CompositeSequenceValueObject) GeneProductValueObject(ubic.gemma.model.genome.gene.GeneProductValueObject) CompositeSequence(ubic.gemma.model.expression.designElement.CompositeSequence)

Example 77 with CompositeSequence

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

the class ArrayDesignDaoImpl method loadAlignments.

@Override
public Map<CompositeSequence, Collection<BlatResult>> loadAlignments(ArrayDesign arrayDesign) {
    // noinspection unchecked,JpaQlInspection - blatResult not visible because it is in a sub-class (BlatAssociation)
    List<Object[]> m = this.getSessionFactory().getCurrentSession().createQuery("select cs, br from CompositeSequence cs " + " join cs.biologicalCharacteristic bs join bs.bioSequence2GeneProduct bs2gp" + " join bs2gp.blatResult br " + "  where bs2gp.class='BlatAssociation' and cs.arrayDesign=:ad").setParameter("ad", arrayDesign).list();
    Map<CompositeSequence, Collection<BlatResult>> result = new HashMap<>();
    for (Object[] objects : m) {
        CompositeSequence cs = (CompositeSequence) objects[0];
        BlatResult br = (BlatResult) objects[1];
        if (!result.containsKey(cs)) {
            result.put(cs, new HashSet<BlatResult>());
        }
        result.get(cs).add(br);
    }
    return result;
}
Also used : PersistentCollection(org.hibernate.collection.PersistentCollection) ArrayDesignValueObject(ubic.gemma.model.expression.arrayDesign.ArrayDesignValueObject) CompositeSequence(ubic.gemma.model.expression.designElement.CompositeSequence) BlatResult(ubic.gemma.model.genome.sequenceAnalysis.BlatResult)

Example 78 with CompositeSequence

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

the class ArrayDesignDaoImpl method getBioSequences.

@Override
public Map<CompositeSequence, BioSequence> getBioSequences(ArrayDesign arrayDesign) {
    if (arrayDesign.getId() == null) {
        throw new IllegalArgumentException("Cannot fetch sequences for a non-persistent array design");
    }
    StopWatch timer = new StopWatch();
    timer.start();
    String queryString = "select ad from ArrayDesign ad inner join fetch ad.compositeSequences cs " + "left outer join fetch cs.biologicalCharacteristic bs where ad = :ad";
    // have to include ad in the select to be able to use fetch join
    Query query = this.getSessionFactory().getCurrentSession().createQuery(queryString).setParameter("ad", arrayDesign);
    List result = query.list();
    Map<CompositeSequence, BioSequence> bioSequences = new HashMap<>();
    if (result.isEmpty()) {
        return bioSequences;
    }
    for (CompositeSequence cs : ((ArrayDesign) result.get(0)).getCompositeSequences()) {
        bioSequences.put(cs, cs.getBiologicalCharacteristic());
    }
    if (timer.getTime() > 1000) {
        AbstractDao.log.info("Fetch sequences: " + timer.getTime() + "ms");
    }
    return bioSequences;
}
Also used : BioSequence(ubic.gemma.model.genome.biosequence.BioSequence) ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) CompositeSequence(ubic.gemma.model.expression.designElement.CompositeSequence) StopWatch(org.apache.commons.lang3.time.StopWatch)

Example 79 with CompositeSequence

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

the class ArrayDesignDaoImpl method remove.

@Override
public void remove(ArrayDesign arrayDesign) {
    arrayDesign = this.load(arrayDesign.getId());
    // getSession().buildLockRequest( LockOptions.NONE ).lock( arrayDesign );
    Hibernate.initialize(arrayDesign.getMergees());
    Hibernate.initialize(arrayDesign.getSubsumedArrayDesigns());
    arrayDesign.getMergees().clear();
    arrayDesign.getSubsumedArrayDesigns().clear();
    Iterator<CompositeSequence> iterator = arrayDesign.getCompositeSequences().iterator();
    while (iterator.hasNext()) {
        CompositeSequence cs = iterator.next();
        iterator.remove();
        this.getSession().delete(cs);
    }
    this.getSession().delete(arrayDesign);
}
Also used : CompositeSequence(ubic.gemma.model.expression.designElement.CompositeSequence)

Example 80 with CompositeSequence

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

the class ArrayDesignDaoImpl method thaw.

@Override
public ArrayDesign thaw(final ArrayDesign arrayDesign) {
    if (arrayDesign.getId() == null) {
        throw new IllegalArgumentException("Cannot thawRawAndProcessed a non-persistent array design");
    }
    /*
         * Thaw basic stuff
         */
    StopWatch timer = new StopWatch();
    timer.start();
    ArrayDesign result = this.thawLite(arrayDesign);
    if (timer.getTime() > 1000) {
        AbstractDao.log.info("Thaw array design stage 1: " + timer.getTime() + "ms");
    }
    timer.stop();
    timer.reset();
    timer.start();
    /*
         * Thaw the composite sequences.
         */
    AbstractDao.log.info("Start initialize composite sequences");
    Hibernate.initialize(result.getCompositeSequences());
    if (timer.getTime() > 1000) {
        AbstractDao.log.info("Thaw array design stage 2: " + timer.getTime() + "ms");
    }
    timer.stop();
    timer.reset();
    timer.start();
    /*
         * Thaw the biosequences in batches
         */
    Collection<CompositeSequence> thawed = new HashSet<>();
    Collection<CompositeSequence> batch = new HashSet<>();
    long lastTime = timer.getTime();
    for (CompositeSequence cs : result.getCompositeSequences()) {
        batch.add(cs);
        if (batch.size() == 1000) {
            long t = timer.getTime();
            if (t > 10000 && t - lastTime > 1000) {
                AbstractDao.log.info("Thaw Batch : " + t);
            }
            List bb = this.thawBatchOfProbes(batch);
            // noinspection unchecked
            thawed.addAll((Collection<? extends CompositeSequence>) bb);
            lastTime = timer.getTime();
            batch.clear();
        }
        this.getSessionFactory().getCurrentSession().evict(cs);
    }
    if (!batch.isEmpty()) {
        // tail end
        List bb = this.thawBatchOfProbes(batch);
        // noinspection unchecked
        thawed.addAll((Collection<? extends CompositeSequence>) bb);
    }
    result.getCompositeSequences().clear();
    result.getCompositeSequences().addAll(thawed);
    /*
         * This is a bit ugly, but necessary to avoid 'dirty collection' errors later.
         */
    if (result.getCompositeSequences() instanceof PersistentCollection)
        ((PersistentCollection) result.getCompositeSequences()).clearDirty();
    if (timer.getTime() > 1000) {
        AbstractDao.log.info("Thaw array design stage 3: " + timer.getTime());
    }
    return result;
}
Also used : PersistentCollection(org.hibernate.collection.PersistentCollection) ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) CompositeSequence(ubic.gemma.model.expression.designElement.CompositeSequence) StopWatch(org.apache.commons.lang3.time.StopWatch)

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