use of ubic.gemma.model.common.description.VocabCharacteristic in project Gemma by PavlidisLab.
the class BatchInfoPopulationHelperServiceImpl method getBatchFactorCategory.
private VocabCharacteristic getBatchFactorCategory() {
VocabCharacteristic c = VocabCharacteristic.Factory.newInstance();
c.setCategory(ExperimentalDesignUtils.BATCH_FACTOR_CATEGORY_NAME);
c.setValue(ExperimentalDesignUtils.BATCH_FACTOR_CATEGORY_NAME);
c.setValueUri(ExperimentalDesignUtils.BATCH_FACTOR_CATEGORY_URI);
c.setCategoryUri(ExperimentalDesignUtils.BATCH_FACTOR_CATEGORY_URI);
c.setEvidenceCode(GOEvidenceCode.IIA);
return c;
}
use of ubic.gemma.model.common.description.VocabCharacteristic in project Gemma by PavlidisLab.
the class BatchInfoPopulationServiceImpl method isBatchFactor.
/**
* @param ef ef
* @return true if the factor seems to be a 'batch' factor.
*/
public static boolean isBatchFactor(ExperimentalFactor ef) {
Characteristic c = ef.getCategory();
boolean isBatchFactor = false;
boolean looksLikeBatch = ef.getName().equals(ExperimentalDesignUtils.BATCH_FACTOR_NAME);
if (c != null && c instanceof VocabCharacteristic) {
VocabCharacteristic v = (VocabCharacteristic) c;
if (v.getCategory() != null && v.getCategory().equals(ExperimentalDesignUtils.BATCH_FACTOR_CATEGORY_NAME)) {
isBatchFactor = true;
}
} else if (looksLikeBatch) {
isBatchFactor = true;
}
return isBatchFactor;
}
use of ubic.gemma.model.common.description.VocabCharacteristic in project Gemma by PavlidisLab.
the class DatabaseViewGeneratorImpl method generateDatasetTissueView.
private void generateDatasetTissueView(Integer limit, Collection<ExpressionExperiment> experiments) throws IOException {
DatabaseViewGeneratorImpl.log.info("Generating dataset tissue view");
/*
* Get handle to output file
*/
File file = this.getViewFile(DatabaseViewGeneratorImpl.DATASET_TISSUE_VIEW_BASENAME);
DatabaseViewGeneratorImpl.log.info("Writing to " + file);
try (Writer writer = new OutputStreamWriter(new GZIPOutputStream(new FileOutputStream(file)))) {
/*
* For all of their annotations... if it's a tissue, print out a line
*/
writer.write("GemmaDsId\tTerm\tTermURI\n");
int i = 0;
for (ExpressionExperiment ee : experiments) {
ee = expressionExperimentService.thawLite(ee);
DatabaseViewGeneratorImpl.log.info("Processing: " + ee.getShortName());
Long gemmaId = ee.getId();
for (Characteristic c : ee.getCharacteristics()) {
if (StringUtils.isBlank(c.getValue())) {
continue;
}
if (c.getCategory().equals("OrganismPart")) {
// or tissue? check URI
String uri = "";
if (c instanceof VocabCharacteristic) {
VocabCharacteristic vocabCharacteristic = (VocabCharacteristic) c;
if (StringUtils.isNotBlank(vocabCharacteristic.getValueUri()))
uri = vocabCharacteristic.getValueUri();
}
writer.write(String.format("%d\t%s\t%s\n", gemmaId, c.getValue(), uri));
}
}
if (limit != null && (limit > 0 && ++i > limit))
break;
}
}
}
use of ubic.gemma.model.common.description.VocabCharacteristic in project Gemma by PavlidisLab.
the class ArrayDesignAnnotationServiceImpl method getGoTerms.
/**
* @param ty Configures which GO terms to return: With all parents, biological process only, or direct annotations
* only.
* @return the goTerms for a given gene, as configured
*/
private Collection<OntologyTerm> getGoTerms(Collection<VocabCharacteristic> ontologyTerms, OutputType ty) {
Collection<OntologyTerm> results = new HashSet<>();
if (ontologyTerms == null || ontologyTerms.size() == 0)
return results;
for (VocabCharacteristic vc : ontologyTerms) {
results.add(GeneOntologyServiceImpl.getTermForId(vc.getValue()));
}
if (ty.equals(OutputType.SHORT))
return results;
if (ty.equals(OutputType.LONG)) {
Collection<OntologyTerm> oes = goService.getAllParents(results);
results.addAll(oes);
} else if (ty.equals(OutputType.BIOPROCESS)) {
Collection<OntologyTerm> toRemove = new HashSet<>();
for (OntologyTerm ont : results) {
if ((ont == null)) {
// / shouldn't happen!
continue;
}
if (!goService.isBiologicalProcess(ont)) {
toRemove.add(ont);
}
}
for (OntologyTerm toRemoveOnto : toRemove) {
results.remove(toRemoveOnto);
}
}
return results;
}
use of ubic.gemma.model.common.description.VocabCharacteristic in project Gemma by PavlidisLab.
the class GeneMultifunctionalityPopulationServiceImpl method fetchGoAnnotations.
private Map<Gene, Collection<String>> fetchGoAnnotations(Collection<Gene> genes) {
if (!goService.isRunning()) {
goService.init(true);
}
while (!goService.isReady()) {
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
//
}
GeneMultifunctionalityPopulationServiceImpl.log.info("Waiting for GO to load");
}
/*
* Build the GO 'matrix'.
*/
int count = 0;
Map<Gene, Collection<String>> gomap = new HashMap<>();
for (Gene gene : genes) {
Collection<VocabCharacteristic> annots = gene2GOService.findByGene(gene);
Collection<String> termsForGene = new HashSet<>();
// noinspection StatementWithEmptyBody // TODO we just count it as a gene with lowest multifunctionality
if (annots.isEmpty()) {
// continue;
}
for (VocabCharacteristic t : annots) {
if (ontologyService.isObsolete(t.getValueUri())) {
GeneMultifunctionalityPopulationServiceImpl.log.warn("Obsolete term annotated to " + gene + " : " + t);
continue;
}
termsForGene.add(t.getValue());
Collection<OntologyTerm> parents = goService.getAllParents(GeneOntologyServiceImpl.getTermForURI(t.getValueUri()));
for (OntologyTerm p : parents) {
termsForGene.add(p.getTerm());
}
}
// noinspection StatementWithEmptyBody // TODO we just count it as a gene with lowest multifunctionality
if (termsForGene.isEmpty()) {
// continue;
}
gomap.put(gene, termsForGene);
if (++count % 1000 == 0) {
GeneMultifunctionalityPopulationServiceImpl.log.info("Fetched GO annotations for: " + count + "/" + genes.size() + " genes");
}
}
return gomap;
}
Aggregations