use of ubic.gemma.model.genome.Taxon in project Gemma by PavlidisLab.
the class PhenotypeAssociationManagerServiceImpl method findGenesWithEvidence.
@Override
@Transactional(readOnly = true)
public Collection<GeneEvidenceValueObject> findGenesWithEvidence(String query, Long taxonId) {
if (query == null || query.length() == 0) {
throw new IllegalArgumentException("No search query provided");
}
// make sure it does an inexact search
String newQuery = query + "%";
Taxon taxon = null;
if (taxonId != null) {
taxon = this.taxonService.load(taxonId);
}
SearchSettings settings = SearchSettingsImpl.geneSearch(newQuery, taxon);
List<SearchResult> geneSearchResults = this.searchService.search(settings).get(Gene.class);
Collection<Gene> genes = new HashSet<>();
if (geneSearchResults == null || geneSearchResults.isEmpty()) {
return new HashSet<>();
}
for (SearchResult sr : geneSearchResults) {
genes.add((Gene) sr.getResultObject());
}
Collection<GeneEvidenceValueObject> geneEvidenceValueObjects = new HashSet<>();
for (Gene g : genes) {
GeneEvidenceValueObject geneEvidenceValueObject = new GeneEvidenceValueObject(g, this.convert2ValueObjects(g.getPhenotypeAssociations()));
geneEvidenceValueObjects.add(geneEvidenceValueObject);
}
Collection<GeneEvidenceValueObject> geneValueObjectsFilter = new ArrayList<>();
for (GeneEvidenceValueObject gene : geneEvidenceValueObjects) {
if (gene.getEvidence() != null && gene.getEvidence().size() != 0) {
geneValueObjectsFilter.add(gene);
}
}
return geneValueObjectsFilter;
}
use of ubic.gemma.model.genome.Taxon in project Gemma by PavlidisLab.
the class PhenotypeAssociationManagerServiceImpl method findCandidateGenes.
@Override
@Transactional(readOnly = true)
public Collection<GeneEvidenceValueObject> findCandidateGenes(EvidenceFilter evidenceFilter, Set<String> phenotypesValuesUri) {
this.addDefaultExcludedDatabases(evidenceFilter);
if (phenotypesValuesUri == null || phenotypesValuesUri.isEmpty()) {
throw new IllegalArgumentException("No phenotypes values uri provided");
}
Taxon taxon = null;
boolean showOnlyEditable = false;
Collection<Long> externalDatabaseIds = null;
if (evidenceFilter != null) {
taxon = this.checkAndGetTaxon(evidenceFilter);
showOnlyEditable = evidenceFilter.isShowOnlyEditable();
externalDatabaseIds = evidenceFilter.getExternalDatabaseIds();
}
Set<String> usedPhenotypes = this.phenoAssocService.loadAllUsedPhenotypeUris();
// map query phenotypes given to the set of possible children phenotypes in the database + query phenotype
Map<String, Set<String>> phenotypesWithChildren = this.findChildrenForEachPhenotype(phenotypesValuesUri, usedPhenotypes);
Set<String> possibleChildrenPhenotypes = this.findAllPossibleChildren(phenotypesWithChildren);
Collection<GeneEvidenceValueObject> genesPhenotypeHelperObject = this.phenoAssocService.findGenesWithPhenotypes(possibleChildrenPhenotypes, taxon, showOnlyEditable, externalDatabaseIds);
return this.filterGenesWithPhenotypes(genesPhenotypeHelperObject, phenotypesWithChildren);
}
use of ubic.gemma.model.genome.Taxon in project Gemma by PavlidisLab.
the class ArrayDesignAnnotationFileCli method processGeneList.
private void processGeneList() throws IOException {
AbstractCLI.log.info("Loading genes to annotate from " + geneFileName);
InputStream is = new FileInputStream(geneFileName);
try (BufferedReader br = new BufferedReader(new InputStreamReader(is))) {
String line;
GeneService geneService = this.getBean(GeneService.class);
TaxonService taxonService = this.getBean(TaxonService.class);
Taxon taxon = taxonService.findByCommonName(taxonName);
if (taxon == null) {
throw new IllegalArgumentException("Unknown taxon: " + taxonName);
}
Collection<Gene> genes = new HashSet<>();
while ((line = br.readLine()) != null) {
if (StringUtils.isBlank(line)) {
continue;
}
String[] arguments = StringUtils.split(line, '\t');
String gene = arguments[0];
Gene g = geneService.findByOfficialSymbol(gene, taxon);
if (g == null) {
AbstractCLI.log.info("Gene: " + gene + " not found.");
continue;
}
genes.add(g);
}
AbstractCLI.log.info("File contained " + genes.size() + " potential gene symbols");
int numProcessed = arrayDesignAnnotationService.generateAnnotationFile(new PrintWriter(System.out), genes, OutputType.SHORT);
AbstractCLI.log.info("Processed " + numProcessed + " genes that were found");
}
}
use of ubic.gemma.model.genome.Taxon in project Gemma by PavlidisLab.
the class ArrayDesignAnnotationFileCli method processAllADs.
/**
* Goes over all the AD's in the database (possibly limited by taxon) and creates annotation 3 annotation files for
* each AD that is not merged into or subsumed by another AD. Uses the Accession ID (GPL???) for the name of the
* annotation file. Appends noParents, bioProcess, allParents to the file name.
*/
private void processAllADs() throws IOException {
Collection<ArrayDesign> allADs = this.arrayDesignService.loadAll();
for (ArrayDesign ad : allADs) {
ad = arrayDesignService.thawLite(ad);
if (ad.getCurationDetails().getTroubled()) {
AbstractCLI.log.warn("Troubled: " + ad + " (skipping)");
continue;
}
Taxon taxon = null;
if (this.taxonName != null) {
TaxonService taxonService = this.getBean(TaxonService.class);
taxon = taxonService.findByCommonName(taxonName);
if (taxon == null) {
throw new IllegalArgumentException("Unknown taxon: " + taxonName);
}
}
Collection<Taxon> adTaxa = arrayDesignService.getTaxa(ad.getId());
/*
* If using taxon, check it.
*/
if (taxon != null && !adTaxa.contains(taxon)) {
continue;
}
this.processOneAD(ad);
}
}
use of ubic.gemma.model.genome.Taxon in project Gemma by PavlidisLab.
the class LoadSimpleExpressionDataCli method configureTaxon.
private void configureTaxon(String[] fields, SimpleExpressionExperimentMetaData metaData) {
Taxon existing = taxonService.findByCommonName(fields[LoadSimpleExpressionDataCli.SPECIES_I]);
if (existing == null) {
throw new IllegalArgumentException("There is no taxon with scientific name " + fields[LoadSimpleExpressionDataCli.SPECIES_I] + " in the system; please add it first before loading data.");
}
metaData.setTaxon(existing);
}
Aggregations