use of ubic.gemma.model.genome.Gene in project Gemma by PavlidisLab.
the class CompositeSequenceMapSummary method toString.
@Override
public String toString() {
StringBuilder buf = new StringBuilder();
buf.append(compositeSequence.getName()).append("\t");
if (compositeSequence.getBiologicalCharacteristic() != null) {
buf.append(compositeSequence.getBiologicalCharacteristic().getName()).append("\t");
} else {
buf.append("\t");
}
buf.append(blatResults.size()).append("\t");
for (GeneProduct gp : geneProducts) {
buf.append(gp.getName()).append("|");
}
buf.append("\t");
for (Gene g : genes) {
buf.append(g.getOfficialSymbol()).append("|");
}
return buf.toString().replaceAll("\\|\t", "\t").replaceFirst("\\|$", "");
}
use of ubic.gemma.model.genome.Gene in project Gemma by PavlidisLab.
the class CompositeSequenceGeneMapperService method getGene2ProbeMapByOfficialSymbols.
/**
* @param arrayDesigns to look in
* @param officialSymbols official symbols
* @return map of gene to composite sequences
*/
public LinkedHashMap<Gene, Collection<CompositeSequence>> getGene2ProbeMapByOfficialSymbols(Collection<String> officialSymbols, Collection<ArrayDesign> arrayDesigns) {
LinkedHashMap<String, Collection<Gene>> genesMap = this.findGenesByOfficialSymbols(officialSymbols);
Set<String> geneOfficialSymbolKeySet = genesMap.keySet();
LinkedHashMap<Gene, Collection<CompositeSequence>> compositeSequencesForGeneMap = new LinkedHashMap<>();
for (String officialSymbol : geneOfficialSymbolKeySet) {
log.debug("official symbol: " + officialSymbol);
Collection<Gene> genes = genesMap.get(officialSymbol);
for (Gene g : genes) {
Collection<CompositeSequence> compositeSequences = geneService.getCompositeSequencesById(g.getId());
for (CompositeSequence sequence : compositeSequences) {
if (arrayDesigns.contains(sequence.getArrayDesign())) {
if (compositeSequencesForGeneMap.get(g) == null) {
compositeSequencesForGeneMap.put(g, new HashSet<CompositeSequence>());
}
compositeSequencesForGeneMap.get(g).add(sequence);
}
}
}
}
return compositeSequencesForGeneMap;
}
use of ubic.gemma.model.genome.Gene in project Gemma by PavlidisLab.
the class GenericGenelistDesignGenerator method getExistingGeneMap.
/**
* For gene symbols.
*/
private Map<Gene, CompositeSequence> getExistingGeneMap(ArrayDesign arrayDesign) {
Map<Gene, CompositeSequence> existingElements = new HashMap<>();
if (arrayDesign.getCompositeSequences().isEmpty())
return existingElements;
AbstractCLI.log.info("Loading genes for existing platform ...");
Map<CompositeSequence, Collection<Gene>> geneMap = compositeSequenceService.getGenes(arrayDesign.getCompositeSequences());
AbstractCLI.log.info("Platform has genes already for " + geneMap.size() + "/" + arrayDesign.getCompositeSequences().size() + " elements.");
for (CompositeSequence cs : geneMap.keySet()) {
Collection<Gene> genes = geneMap.get(cs);
/*
* Two genes with the same symbol, but might be a mistake from an earlier run.
*/
Gene g = null;
if (genes.size() > 1) {
AbstractCLI.log.warn("More than one gene for: " + cs + ": " + StringUtils.join(genes, ";"));
for (Gene cg : genes) {
if (cg.getOfficialSymbol().equals(cs.getName())) {
g = cg;
}
}
} else {
g = genes.iterator().next();
}
existingElements.put(g, cs);
}
return existingElements;
}
use of ubic.gemma.model.genome.Gene 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");
}
}
use of ubic.gemma.model.genome.Gene in project Gemma by PavlidisLab.
the class GeneServiceTest method testLoadGenes.
@Test
public void testLoadGenes() {
Taxon human = taxonService.findByCommonName("human");
Gene gene = Gene.Factory.newInstance();
Integer id = Integer.parseInt(RandomStringUtils.randomNumeric(5));
gene.setNcbiGeneId(id);
gene.setName("Ma_Gene");
gene.setDescription("Lost in space");
gene.setTaxon(human);
geneDao.create(gene);
Collection<Gene> genes = geneDao.loadAll(human);
assertNotNull(genes);
assertTrue(genes.contains(gene));
geneDao.remove(gene);
}
Aggregations