Search in sources :

Example 21 with Taxon

use of ubic.gemma.model.genome.Taxon in project Gemma by PavlidisLab.

the class ExperimentalDesignImporterTestC method setup.

@Before
public void setup() throws Exception {
    /*
         * Have to add ssal for this platform.
         */
    super.executeSqlScript("/script/sql/add-fish-taxa.sql", false);
    Taxon salmon = taxonService.findByCommonName("atlantic salmon");
    assertNotNull(salmon);
    /*
         * Load the array design (platform).
         */
    geoService.setGeoDomainObjectGenerator(new GeoDomainObjectGeneratorLocal(this.getTestFileBasePath("designLoadTests")));
    geoService.fetchAndLoad("GPL2899", true, true, false);
    ArrayDesign ad = arrayDesignService.findByShortName("GPL2899");
    assertNotNull(ad);
    SimpleExpressionExperimentMetaData metaData = new SimpleExpressionExperimentMetaData();
    metaData.setShortName(RandomStringUtils.randomAlphabetic(10));
    metaData.setDescription("bar");
    metaData.setIsRatio(false);
    metaData.setTaxon(salmon);
    metaData.setQuantitationTypeName("value");
    metaData.setScale(ScaleType.LOG2);
    metaData.setType(StandardQuantitationType.AMOUNT);
    metaData.getArrayDesigns().add(ad);
    try (InputStream data = this.getClass().getResourceAsStream("/data/loader/expression/geo/designLoadTests/expressionDataBrain2003TestFile.txt")) {
        ee = simpleExpressionDataLoaderService.create(metaData, data);
    }
// ee = this.eeService.thawLite( ee );
}
Also used : ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) InputStream(java.io.InputStream) Taxon(ubic.gemma.model.genome.Taxon) SimpleExpressionExperimentMetaData(ubic.gemma.core.loader.expression.simple.model.SimpleExpressionExperimentMetaData) GeoDomainObjectGeneratorLocal(ubic.gemma.core.loader.expression.geo.GeoDomainObjectGeneratorLocal) Before(org.junit.Before)

Example 22 with Taxon

use of ubic.gemma.model.genome.Taxon in project Gemma by PavlidisLab.

the class GeoConverterTest method testMultipleTaxaIdentifiedBYAbbreviationsOnArrayWithOrganismColumn.

/*
     * Method to test that an array design can have multiple taxa stored against it and that if abbreviations used as
     * probe names mapped to the scientific names correctly if the abbreviation is stored in DB.
     */
@Test
public void testMultipleTaxaIdentifiedBYAbbreviationsOnArrayWithOrganismColumn() throws Exception {
    Taxon rainbowTroat = taxonService.findByAbbreviation("omyk");
    Taxon whiteFish = taxonService.findByAbbreviation("cclu");
    Taxon rainbowSmelt = taxonService.findByAbbreviation("omor");
    Taxon atlanticSalm = taxonService.findByAbbreviation("ssal");
    assertNotNull(atlanticSalm);
    // prototype bean.
    gc = this.getBean(GeoConverter.class);
    InputStream is = new GZIPInputStream(this.getClass().getResourceAsStream("/data/loader/expression/geo/GPL2899_family.soft.gz"));
    GeoFamilyParser parser = new GeoFamilyParser();
    // parse only the plaform
    parser.setProcessPlatformsOnly(true);
    parser.parse(is);
    GeoPlatform platform = ((GeoParseResult) parser.getResults().iterator().next()).getPlatformMap().get("GPL2899");
    Object result = gc.convert(platform);
    ArrayDesign ad = (ArrayDesign) result;
    assertNotNull(ad);
    Set<Taxon> taxa = new HashSet<>();
    BioSequence bs;
    for (CompositeSequence cs : ad.getCompositeSequences()) {
        bs = cs.getBiologicalCharacteristic();
        if (bs != null) {
            assertNotNull(bs.getTaxon());
            taxa.add(bs.getTaxon());
        }
    }
    assertEquals(4, taxa.size());
    // original file has five taxa, test file just kept four.
    assertTrue(taxa.contains(atlanticSalm));
    assertTrue(taxa.contains(rainbowTroat));
    assertTrue(taxa.contains(whiteFish));
    assertTrue(taxa.contains(rainbowSmelt));
}
Also used : GZIPInputStream(java.util.zip.GZIPInputStream) BioSequence(ubic.gemma.model.genome.biosequence.BioSequence) GZIPInputStream(java.util.zip.GZIPInputStream) InputStream(java.io.InputStream) ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) Taxon(ubic.gemma.model.genome.Taxon) CompositeSequence(ubic.gemma.model.expression.designElement.CompositeSequence) GeoPlatform(ubic.gemma.core.loader.expression.geo.model.GeoPlatform) Test(org.junit.Test) BaseSpringContextTest(ubic.gemma.core.testing.BaseSpringContextTest)

Example 23 with Taxon

use of ubic.gemma.model.genome.Taxon in project Gemma by PavlidisLab.

the class BioMartEnsemblNcbiFetcherTest method testGetBioMartTaxonName.

/*
     * Tests that given a scientific named taxon taxon name is formatted correctly for biomart
     */
@Test
public void testGetBioMartTaxonName() {
    Taxon taxon = Taxon.Factory.newInstance();
    taxon.setScientificName("Homo sapiens");
    String biomartFormatedString = biomartEnsemblNcbiFetcher.getBiomartTaxonName(taxon);
    assertNotNull(biomartFormatedString);
    assertTrue(biomartFormatedString.equals("hsapiens"));
}
Also used : Taxon(ubic.gemma.model.genome.Taxon) Test(org.junit.Test)

Example 24 with Taxon

use of ubic.gemma.model.genome.Taxon in project Gemma by PavlidisLab.

the class StringProteinLinksDetailedParserTest method setUp.

@Before
public void setUp() {
    // set up an array of taxon to process
    Taxon taxon = Taxon.Factory.newInstance();
    taxon.setNcbiId(882);
    Taxon taxon2 = Taxon.Factory.newInstance();
    taxon2.setNcbiId(10090);
    ArrayList<Taxon> taxa = new ArrayList<>();
    taxa.add(taxon);
    taxa.add(taxon2);
    parser = new StringProteinProteinInteractionFileParser();
    parser.setTaxa(taxa);
}
Also used : Taxon(ubic.gemma.model.genome.Taxon) ArrayList(java.util.ArrayList) Before(org.junit.Before)

Example 25 with Taxon

use of ubic.gemma.model.genome.Taxon in project Gemma by PavlidisLab.

the class StringProteinLoadCli method getValidTaxon.

/**
 * If a taxon is supplied on the command line then process protein interactions for that taxon. If no taxon is
 * supplied then create a list of valid taxon to process from those stored in gemma: Criteria are does this taxon
 * have usable genes and is it a species.
 *
 * @return Collection of Taxa to process
 */
private Collection<Taxon> getValidTaxon() {
    Taxon taxon;
    TaxonService taxonService = this.getBean(TaxonService.class);
    Collection<Taxon> taxa = new ArrayList<>();
    if (taxonName != null && StringUtils.isNotBlank(taxonName)) {
        taxon = taxonService.findByCommonName(taxonName);
        if (taxon == null || !(taxon.getIsSpecies()) || !(taxon.getIsGenesUsable())) {
            throw new IllegalArgumentException("The taxon common name supplied: " + taxonName + " Either does not match anything in GEMMA, or is not a species or does have usable genes");
        }
        taxa.add(taxon);
    } else {
        for (Taxon taxonGemma : taxonService.loadAll()) {
            // only those taxon that are species and have usable genes should be processed
            if (taxonGemma != null && taxonGemma.getIsSpecies() && taxonGemma.getIsGenesUsable() && (taxonGemma.getCommonName() != null) && !(taxonGemma.getCommonName().isEmpty())) {
                taxa.add(taxonGemma);
            }
        }
        if (taxa.isEmpty()) {
            throw new RuntimeException("There are no valid taxa in GEMMA to process. Valid taxon are those that are species and have usable genes.");
        }
        AbstractCLI.log.info("Processing " + taxa.size() + "taxa ");
    }
    return taxa;
}
Also used : TaxonService(ubic.gemma.persistence.service.genome.taxon.TaxonService) Taxon(ubic.gemma.model.genome.Taxon) ArrayList(java.util.ArrayList)

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