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);
}
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;
}
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;
}
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);
}
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;
}
Aggregations