Search in sources :

Example 1 with Taxon

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;
}
Also used : Taxon(ubic.gemma.model.genome.Taxon) Element(org.w3c.dom.Element) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) StopWatch(org.apache.commons.lang3.time.StopWatch) HashSet(java.util.HashSet)

Example 2 with Taxon

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();
}
Also used : BioMaterial(ubic.gemma.model.expression.biomaterial.BioMaterial) ExperimentalDesign(ubic.gemma.model.expression.experiment.ExperimentalDesign) Taxon(ubic.gemma.model.genome.Taxon) BioAssay(ubic.gemma.model.expression.bioAssay.BioAssay) Before(org.junit.Before)

Example 3 with Taxon

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;
}
Also used : Taxon(ubic.gemma.model.genome.Taxon)

Example 4 with Taxon

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;
}
Also used : GeneValueObject(ubic.gemma.model.genome.gene.GeneValueObject) Taxon(ubic.gemma.model.genome.Taxon) Chromosome(ubic.gemma.model.genome.Chromosome) WellComposedErrorBody(ubic.gemma.web.services.rest.util.WellComposedErrorBody) GemmaApiException(ubic.gemma.web.services.rest.util.GemmaApiException) PhysicalLocation(ubic.gemma.model.genome.PhysicalLocation)

Example 5 with Taxon

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;
}
Also used : Gene(ubic.gemma.model.genome.Gene) Taxon(ubic.gemma.model.genome.Taxon) Element(org.w3c.dom.Element) StopWatch(org.apache.commons.lang3.time.StopWatch) HashSet(java.util.HashSet)

Aggregations

Taxon (ubic.gemma.model.genome.Taxon)161 Gene (ubic.gemma.model.genome.Gene)34 Test (org.junit.Test)31 BaseSpringContextTest (ubic.gemma.core.testing.BaseSpringContextTest)29 HashSet (java.util.HashSet)23 ArrayDesign (ubic.gemma.model.expression.arrayDesign.ArrayDesign)23 InputStream (java.io.InputStream)17 Before (org.junit.Before)16 BioSequence (ubic.gemma.model.genome.biosequence.BioSequence)15 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)14 CompositeSequence (ubic.gemma.model.expression.designElement.CompositeSequence)12 StopWatch (org.apache.commons.lang3.time.StopWatch)11 Transactional (org.springframework.transaction.annotation.Transactional)11 ArrayList (java.util.ArrayList)10 File (java.io.File)9 SimpleExpressionExperimentMetaData (ubic.gemma.core.loader.expression.simple.model.SimpleExpressionExperimentMetaData)9 Chromosome (ubic.gemma.model.genome.Chromosome)8 Collection (java.util.Collection)7 Element (org.w3c.dom.Element)7 PhysicalLocation (ubic.gemma.model.genome.PhysicalLocation)7