use of ubic.gemma.model.genome.Taxon in project Gemma by PavlidisLab.
the class ExperimentIDbyTaxonEndpoint method invokeInternal.
/**
* Reads the given <code>requestElement</code>, and sends the response back.
*
* @param requestElement the contents of the SOAP message as DOM elements
* @param document a DOM document to be used for constructing <code>Node</code>s
* @return the response element
*/
@Override
protected Element invokeInternal(Element requestElement, Document document) {
StopWatch watch = new StopWatch();
watch.start();
setLocalName(EXPERIMENT_LOCAL_NAME);
Collection<String> taxonResults = getSingleNodeValue(requestElement, "taxon_id");
String taxonId = "";
for (String id : taxonResults) {
taxonId = id;
}
log.debug("XML input read: taxon id, " + taxonId);
// Get EE matched with Taxon
Taxon tax = taxonService.load(Long.parseLong(taxonId));
if (tax == null) {
String msg = "No taxon with id, " + taxonId + " can be found.";
return buildBadResponse(document, msg);
}
Collection<ExpressionExperiment> eeCollection = expressionExperimentService.findByTaxon(tax);
// build results in the form of a collection
Collection<String> eeIds = new HashSet<String>();
for (ExpressionExperiment ee : eeCollection) {
eeIds.add(ee.getId().toString());
}
Element wrapper = buildWrapper(document, eeIds, "ee_ids");
watch.stop();
Long time = watch.getTime();
log.debug("XML response for Expression Experiment Id results built in " + time + "ms.");
return wrapper;
}
use of ubic.gemma.model.genome.Taxon in project Gemma by PavlidisLab.
the class CuratableValueObjectTest method setUp.
@Before
public void setUp() throws Exception {
arrayDesign = ArrayDesign.Factory.newInstance();
arrayDesign.setName("testing audit " + RandomStringUtils.randomAlphanumeric(32));
arrayDesign.setShortName(RandomStringUtils.randomAlphanumeric(8));
arrayDesign.setPrimaryTaxon(this.getTaxon("human"));
arrayDesign = (ArrayDesign) this.persisterHelper.persist(arrayDesign);
assertTrue(arrayDesign.getAuditTrail() != null);
Taxon taxon = Taxon.Factory.newInstance("text taxon scientific name " + RandomStringUtils.randomAlphanumeric(8), RandomStringUtils.randomAlphanumeric(8), "ttxn", 0, false, true);
this.persisterHelper.persist(taxon);
BioMaterial bm = BioMaterial.Factory.newInstance();
bm.setName(RandomStringUtils.randomAlphanumeric(8));
bm.setSourceTaxon(taxon);
this.persisterHelper.persist(bm);
BioAssay bioAssay = BioAssay.Factory.newInstance();
bioAssay.setArrayDesignUsed(arrayDesign);
bioAssay.setSampleUsed(bm);
this.persisterHelper.persist(bioAssay);
ExperimentalDesign ed = ExperimentalDesign.Factory.newInstance();
ed.setName(RandomStringUtils.randomAlphanumeric(8));
expressionExperiment = super.getTestPersistentBasicExpressionExperiment();
}
use of ubic.gemma.model.genome.Taxon in project Gemma by PavlidisLab.
the class TaxonStringArg method getPropertyName.
@Override
public String getPropertyName(TaxonService service) {
Taxon taxon = service.findByCommonName(this.value);
if (taxon != null) {
return "commonName";
}
taxon = service.findByScientificName(this.value);
if (taxon != null) {
return "scientificName";
}
taxon = service.findByAbbreviation(this.value);
if (taxon != null) {
return "abbreviation";
}
return null;
}
use of ubic.gemma.model.genome.Taxon in project Gemma by PavlidisLab.
the class TaxonArg method getGenesOnChromosome.
/**
* Lists Genes overlapping a location on a specific chromosome on a taxon that this TaxonArg represents.
*
* @param taxonService the service that will be used to retrieve the persistent Taxon object.
* @param chromosomeService the service that will be used to find the Chromosome object.
* @param geneService the service that will be used to retrieve the Gene VOs
* @param chromosomeName name of the chromosome to look on
* @param start the start nucleotide denoting the location to look for genes at.
* @param size the size (in nucleotides) of the location from the 'start' nucleotide.
* @return collection of Gene VOs overlapping the location defined by the 'start' and 'size' parameters.
*/
public Collection<GeneValueObject> getGenesOnChromosome(TaxonService taxonService, ChromosomeService chromosomeService, GeneService geneService, String chromosomeName, long start, int size) {
// Taxon argument
Taxon taxon = this.getPersistentObject(taxonService);
// Chromosome argument
Collection<Chromosome> chromosomes = chromosomeService.find(chromosomeName, taxon);
if (chromosomes.isEmpty()) {
WellComposedErrorBody errorBody = new WellComposedErrorBody(Response.Status.NOT_FOUND, "Chromosome " + chromosomeName + " not found for taxon " + taxon.getScientificName());
throw new GemmaApiException(errorBody);
}
Chromosome chromosome = chromosomes.iterator().next();
// Setup chromosome location
PhysicalLocation region = PhysicalLocation.Factory.newInstance(chromosome);
region.setNucleotide(start);
region.setNucleotideLength(size);
// region.setStrand( strand );
Collection<GeneValueObject> GVOs = geneService.loadValueObjects(geneService.find(region));
if (GVOs == null) {
WellComposedErrorBody errorBody = new WellComposedErrorBody(Response.Status.NOT_FOUND, "No genes found on chromosome " + chromosomeName + " between positions " + start + " and " + start + size + ".");
throw new GemmaApiException(errorBody);
}
return GVOs;
}
use of ubic.gemma.model.genome.Taxon in project Gemma by PavlidisLab.
the class GoTerm2GeneEndpoint method invokeInternal.
/**
* Reads the given <code>requestElement</code>, and sends a the response back.
*
* @param requestElement the contents of the SOAP message as DOM elements
* @param document a DOM document to be used for constructing <code>Node</code>s
* @return the response element
*/
@Override
protected Element invokeInternal(Element requestElement, Document document) {
StopWatch watch = new StopWatch();
watch.start();
setLocalName(GO2Gene_LOCAL_NAME);
String goId = "";
String taxonId = "";
// get GO id from request
Collection<String> goIdResult = getSingleNodeValue(requestElement, "go_id");
for (String id : goIdResult) {
goId = id;
}
// get taxon id from request
Collection<String> taxonIdResult = getSingleNodeValue(requestElement, "taxon_id");
for (String id : taxonIdResult) {
taxonId = id;
}
log.debug("XML input read: GO id, " + goId + " & taxon id, " + taxonId);
// get gene from GO term
Taxon taxon = taxonService.load(Long.parseLong(taxonId));
if (taxon == null) {
String msg = "No taxon with id, " + taxonId + " can be found.";
return buildBadResponse(document, msg);
}
Collection<Gene> genes = geneOntologyService.getGenes(goId, taxon);
if (genes == null || genes.isEmpty()) {
return buildBadResponse(document, "No genes associated with goId = " + goId + " and taxon = " + taxon.getCommonName());
}
// build results in the form of a collection
Collection<String> geneIds = new HashSet<String>();
for (Gene gene : genes) {
geneIds.add(gene.getId().toString());
}
Element wrapper = buildWrapper(document, geneIds, "gene_id");
watch.stop();
Long time = watch.getTime();
log.debug("XML response for gene id results built in " + time + "ms.");
return wrapper;
}
Aggregations