use of ubic.gemma.model.genome.biosequence.BioSequence in project Gemma by PavlidisLab.
the class ProbeSequenceParser method parseOneLine.
@Override
public BioSequence parseOneLine(String line) {
if (line.startsWith(">")) {
throw new RuntimeException("FASTA format not supported - please use the tabular format for oligonucleotides");
}
if (StringUtils.isBlank(line)) {
return null;
}
String[] sArray = StringUtils.splitPreserveAllTokens(line);
if (sArray.length == 0) {
return null;
}
if (sArray.length != 3) {
throw new IllegalArgumentException("Expected 3 fields: probe name, sequence name, sequence; line=" + line);
}
String probeId = sArray[0].trim();
if (StringUtils.isBlank(probeId)) {
return null;
}
String sequenceName = sArray[1].trim();
String sequence = sArray[2].trim();
// Rarely there are extra junk characters. See bug 2719
sequence = sequence.replaceAll("[^a-yA-Y]", "");
if (StringUtils.isBlank(sequence)) {
return null;
}
BioSequence seq = BioSequence.Factory.newInstance();
seq.setSequence(sequence);
seq.setLength((long) sequence.length());
seq.setIsCircular(false);
seq.setIsApproximateLength(false);
seq.setName(sequenceName);
if (this.results.containsKey(probeId)) {
log.warn("Duplicated probe id: " + probeId);
}
this.put(probeId, seq);
return seq;
}
use of ubic.gemma.model.genome.biosequence.BioSequence in project Gemma by PavlidisLab.
the class DesignElementDataVectorDaoImpl method thaw.
@Override
public void thaw(T designElementDataVector) {
Session session = this.getHibernateTemplate().getSessionFactory().getCurrentSession();
BioSequence seq = designElementDataVector.getDesignElement().getBiologicalCharacteristic();
if (seq != null) {
session.buildLockRequest(LockOptions.NONE).lock(seq);
Hibernate.initialize(seq);
}
ArrayDesign arrayDesign = designElementDataVector.getDesignElement().getArrayDesign();
Hibernate.initialize(arrayDesign);
// thawRawAndProcessed the bioassays.
for (BioAssay ba : designElementDataVector.getBioAssayDimension().getBioAssays()) {
ba = (BioAssay) session.get(BioAssay.class, ba.getId());
Hibernate.initialize(ba.getArrayDesignUsed());
Hibernate.initialize(ba.getSampleUsed());
Hibernate.initialize(ba.getDerivedDataFiles());
}
}
use of ubic.gemma.model.genome.biosequence.BioSequence in project Gemma by PavlidisLab.
the class CompositeSequenceDaoImpl method thaw.
@Override
public void thaw(final Collection<CompositeSequence> compositeSequences) {
HibernateTemplate templ = this.getHibernateTemplate();
templ.executeWithNativeSession(new org.springframework.orm.hibernate3.HibernateCallback<Object>() {
@Override
public Object doInHibernate(org.hibernate.Session session) throws org.hibernate.HibernateException {
int i = 0;
int numToDo = compositeSequences.size();
for (CompositeSequence cs : compositeSequences) {
session.buildLockRequest(LockOptions.NONE).lock(cs);
Hibernate.initialize(cs.getArrayDesign());
BioSequence bs = cs.getBiologicalCharacteristic();
if (bs == null) {
continue;
}
session.buildLockRequest(LockOptions.NONE).lock(bs);
Hibernate.initialize(bs);
Hibernate.initialize(bs.getTaxon());
DatabaseEntry dbEntry = bs.getSequenceDatabaseEntry();
if (dbEntry != null) {
Hibernate.initialize(dbEntry);
Hibernate.initialize(dbEntry.getExternalDatabase());
session.evict(dbEntry);
session.evict(dbEntry.getExternalDatabase());
}
if (bs.getBioSequence2GeneProduct() == null) {
continue;
}
for (BioSequence2GeneProduct bs2gp : bs.getBioSequence2GeneProduct()) {
if (bs2gp == null) {
continue;
}
GeneProduct geneProduct = bs2gp.getGeneProduct();
if (geneProduct != null && geneProduct.getGene() != null) {
Gene g = geneProduct.getGene();
g.getAliases().size();
session.evict(g);
session.evict(geneProduct);
}
}
if (++i % 2000 == 0) {
AbstractDao.log.info("Progress: " + i + "/" + numToDo + "...");
try {
Thread.sleep(10);
} catch (InterruptedException e) {
//
}
}
session.evict(bs);
}
session.clear();
return null;
}
});
}
use of ubic.gemma.model.genome.biosequence.BioSequence in project Gemma by PavlidisLab.
the class CompositeSequenceServiceImpl method getGeneMappingSummary.
@Override
public Collection<GeneMappingSummary> getGeneMappingSummary(CompositeSequence cs) {
BioSequence biologicalCharacteristic = cs.getBiologicalCharacteristic();
biologicalCharacteristic = bioSequenceService.thaw(biologicalCharacteristic);
Map<Integer, GeneMappingSummary> results = new HashMap<>();
if (biologicalCharacteristic == null || biologicalCharacteristic.getBioSequence2GeneProduct() == null) {
return results.values();
}
Collection<BioSequence2GeneProduct> bs2gps = biologicalCharacteristic.getBioSequence2GeneProduct();
for (BioSequence2GeneProduct bs2gp : bs2gps) {
GeneProductValueObject geneProduct = new GeneProductValueObject(geneProductService.thaw(bs2gp.getGeneProduct()));
GeneValueObject gene = new GeneValueObject(bs2gp.getGeneProduct().getGene());
BlatResultValueObject blatResult = null;
if ((bs2gp instanceof BlatAssociation)) {
BlatAssociation blatAssociation = (BlatAssociation) bs2gp;
blatResult = new BlatResultValueObject(blatResultService.thaw(blatAssociation.getBlatResult()));
} else if (bs2gp instanceof AnnotationAssociation) {
/*
* Make a dummy blat result
*/
blatResult = new BlatResultValueObject();
blatResult.setQuerySequence(BioSequenceValueObject.fromEntity(biologicalCharacteristic));
blatResult.setId(biologicalCharacteristic.getId());
}
if (blatResult == null) {
continue;
}
if (results.containsKey(ProbeMapUtils.hashBlatResult(blatResult))) {
results.get(ProbeMapUtils.hashBlatResult(blatResult)).addGene(geneProduct, gene);
} else {
GeneMappingSummary summary = new GeneMappingSummary();
summary.addGene(geneProduct, gene);
summary.setBlatResult(blatResult);
summary.setCompositeSequence(this.loadValueObject(cs));
results.put(ProbeMapUtils.hashBlatResult(blatResult), summary);
}
}
this.addBlatResultsLackingGenes(cs, results);
if (results.size() == 0) {
// add a 'dummy' that at least contains the information about the CS. This is a bit of a hack...
GeneMappingSummary summary = new GeneMappingSummary();
summary.setCompositeSequence(this.loadValueObject(cs));
BlatResultValueObject newInstance = new BlatResultValueObject(-1L);
newInstance.setQuerySequence(BioSequenceValueObject.fromEntity(biologicalCharacteristic));
summary.setBlatResult(newInstance);
results.put(ProbeMapUtils.hashBlatResult(newInstance), summary);
}
return results.values();
}
use of ubic.gemma.model.genome.biosequence.BioSequence in project Gemma by PavlidisLab.
the class CompositeSequenceServiceImpl method addBlatResultsLackingGenes.
/**
* Note that duplicate hits will be ignored here. See bug 4037.
*/
private void addBlatResultsLackingGenes(CompositeSequence cs, Map<Integer, GeneMappingSummary> blatResults) {
/*
* Pick up blat results that didn't map to genes.
*/
BioSequence biologicalCharacteristic = bioSequenceService.thaw(cs.getBiologicalCharacteristic());
Collection<BlatResultValueObject> allBlatResultsForCs = blatResultService.loadValueObjects(blatResultService.thaw(blatResultService.findByBioSequence(biologicalCharacteristic)));
for (BlatResultValueObject blatResult : allBlatResultsForCs) {
if (!blatResults.containsKey(ProbeMapUtils.hashBlatResult(blatResult))) {
GeneMappingSummary summary = new GeneMappingSummary();
summary.setBlatResult(blatResult);
summary.setCompositeSequence(this.loadValueObject(cs));
// no gene...
blatResults.put(ProbeMapUtils.hashBlatResult(blatResult), summary);
}
}
}
Aggregations