Search in sources :

Example 96 with BioSequence

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

the class BlatAssociationServiceTest method setup.

@Before
public void setup() {
    int numSequencesToCreate = 20;
    for (int i = 0; i < numSequencesToCreate; i++) {
        BioSequence bs = this.getTestPersistentBioSequence();
        if (i == 11) {
            bs.setSequence(testSequence);
            bs.setName(testSequenceName);
            this.bioSequenceService.update(bs);
        }
        BlatResult br = this.getTestPersistentBlatResult(bs);
        br.setQuerySequence(bs);
        blatResultService.update(br);
        BlatAssociation ba = BlatAssociation.Factory.newInstance();
        Gene g = this.getTestPersistentGene();
        GeneProduct gp = this.getTestPersistentGeneProduct(g);
        if (i == 10) {
            g.setOfficialName(testGeneIdentifier);
            gp.setGene(g);
            gp.setName(testGeneIdentifier);
            this.geneProductService.update(gp);
        }
        ba.setGeneProduct(gp);
        ba.setBlatResult(br);
        ba.setBioSequence(bs);
        blatAssociationService.create(ba);
    }
}
Also used : GeneProduct(ubic.gemma.model.genome.gene.GeneProduct) Gene(ubic.gemma.model.genome.Gene) BioSequence(ubic.gemma.model.genome.biosequence.BioSequence) Before(org.junit.Before)

Example 97 with BioSequence

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

the class ArrayDesignServiceTest method setup.

@Before
public void setup() {
    // Create Array design, don't persist it.
    ad = ArrayDesign.Factory.newInstance();
    ad.setName(RandomStringUtils.randomAlphabetic(20) + "_arraydesign");
    ad.setShortName(ad.getName());
    // Create the composite Sequences
    CompositeSequence c1 = CompositeSequence.Factory.newInstance();
    c1.setName(RandomStringUtils.randomAlphabetic(20) + "_cs");
    CompositeSequence c2 = CompositeSequence.Factory.newInstance();
    c2.setName(RandomStringUtils.randomAlphabetic(20) + "_cs");
    CompositeSequence c3 = CompositeSequence.Factory.newInstance();
    c3.setName(RandomStringUtils.randomAlphabetic(20) + "_cs");
    // Fill in associations between compositeSequences and arrayDesign
    c1.setArrayDesign(ad);
    c2.setArrayDesign(ad);
    c3.setArrayDesign(ad);
    Taxon tax = this.getTaxon("mouse");
    ad.setPrimaryTaxon(tax);
    BioSequence bs = BioSequence.Factory.newInstance(tax);
    bs.setName(RandomStringUtils.randomAlphabetic(10));
    bs.setSequence(RandomStringUtils.random(40, "ATCG"));
    bs.setTaxon(tax);
    c1.setBiologicalCharacteristic(bs);
    c2.setBiologicalCharacteristic(bs);
    c3.setBiologicalCharacteristic(bs);
    ad.getCompositeSequences().add(c1);
    ad.getCompositeSequences().add(c2);
    ad.getCompositeSequences().add(c3);
}
Also used : BioSequence(ubic.gemma.model.genome.biosequence.BioSequence) Taxon(ubic.gemma.model.genome.Taxon) CompositeSequence(ubic.gemma.model.expression.designElement.CompositeSequence) Before(org.junit.Before)

Example 98 with BioSequence

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

the class ArrayDesignServiceTest method testUpdateSubsumingStatusTrue.

@Test
public void testUpdateSubsumingStatusTrue() {
    ad = ArrayDesign.Factory.newInstance();
    ad.setName("subsuming_arraydesign");
    // Create the composite Sequences
    CompositeSequence c1 = CompositeSequence.Factory.newInstance();
    c1.setName("bar");
    Taxon tax = this.getTaxon("mouse");
    BioSequence bs = BioSequence.Factory.newInstance(tax);
    bs.setName("fred");
    bs.setSequence("CG");
    bs.setTaxon(tax);
    c1.setBiologicalCharacteristic(bs);
    ad.getCompositeSequences().add(c1);
    CompositeSequence c3 = CompositeSequence.Factory.newInstance();
    c3.setName("foo");
    BioSequence bsb = BioSequence.Factory.newInstance(tax);
    bsb.setName("barney");
    bsb.setSequence("CAAAAG");
    bsb.setTaxon(tax);
    c3.setBiologicalCharacteristic(bsb);
    ad.getCompositeSequences().add(c3);
    ad.setPrimaryTaxon(tax);
    ad = (ArrayDesign) persisterHelper.persist(ad);
    ad = arrayDesignService.thaw(ad);
    ArrayDesign subsumedArrayDesign = ArrayDesign.Factory.newInstance();
    subsumedArrayDesign.setName("subsumed_arraydesign");
    subsumedArrayDesign.setPrimaryTaxon(tax);
    // Create the composite Sequences
    CompositeSequence c2 = CompositeSequence.Factory.newInstance();
    // same as one on other AD.
    c2.setName("bar");
    // same as one on other AD.
    c2.setBiologicalCharacteristic(bs);
    subsumedArrayDesign.getCompositeSequences().add(c2);
    c2.setArrayDesign(subsumedArrayDesign);
    subsumedArrayDesign = (ArrayDesign) persisterHelper.persist(subsumedArrayDesign);
    subsumedArrayDesign = arrayDesignService.thaw(subsumedArrayDesign);
    // flushAndClearSession();
    boolean actualValue = arrayDesignService.updateSubsumingStatus(ad, subsumedArrayDesign);
    assertTrue(actualValue);
    actualValue = arrayDesignService.updateSubsumingStatus(subsumedArrayDesign, ad);
    assertTrue(!actualValue);
}
Also used : BioSequence(ubic.gemma.model.genome.biosequence.BioSequence) Taxon(ubic.gemma.model.genome.Taxon) CompositeSequence(ubic.gemma.model.expression.designElement.CompositeSequence) Test(org.junit.Test) BaseSpringContextTest(ubic.gemma.core.testing.BaseSpringContextTest)

Example 99 with BioSequence

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

the class ArrayDesignServiceTest method testGetTaxaMultipleTaxonForArray.

/**
 * Test retrieving multiple taxa for an arraydesign where hibernate query is not restricted to return just 1 taxon.
 */
@Test
public void testGetTaxaMultipleTaxonForArray() {
    String taxonName2 = "Fish_" + RandomStringUtils.randomAlphabetic(4);
    Taxon secondTaxon = Taxon.Factory.newInstance();
    secondTaxon.setScientificName(taxonName2);
    secondTaxon.setNcbiId(Integer.parseInt(RandomStringUtils.randomNumeric(5)));
    secondTaxon.setIsSpecies(true);
    secondTaxon.setIsGenesUsable(true);
    for (int i = 0; i < 3; i++) {
        CompositeSequence c1 = CompositeSequence.Factory.newInstance();
        c1.setName(RandomStringUtils.randomAlphabetic(20));
        BioSequence bs = BioSequence.Factory.newInstance(secondTaxon);
        bs.setName(RandomStringUtils.randomAlphabetic(10));
        bs.setSequence(RandomStringUtils.random(40, "ATCG"));
        c1.setBiologicalCharacteristic(bs);
        c1.setArrayDesign(ad);
        ad.getCompositeSequences().add(c1);
    }
    ad = (ArrayDesign) persisterHelper.persist(ad);
    Collection<Taxon> taxa = arrayDesignService.getTaxa(ad.getId());
    assertEquals(2, taxa.size());
    Collection<String> list = new ArrayList<>();
    for (Taxon taxon : taxa) {
        list.add(taxon.getScientificName());
    }
    assertTrue("Should have found " + taxonName2, list.contains(taxonName2));
    assertTrue("Should have found " + ArrayDesignServiceTest.DEFAULT_TAXON, list.contains(ArrayDesignServiceTest.DEFAULT_TAXON));
}
Also used : BioSequence(ubic.gemma.model.genome.biosequence.BioSequence) Taxon(ubic.gemma.model.genome.Taxon) ArrayList(java.util.ArrayList) CompositeSequence(ubic.gemma.model.expression.designElement.CompositeSequence) Test(org.junit.Test) BaseSpringContextTest(ubic.gemma.core.testing.BaseSpringContextTest)

Example 100 with BioSequence

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

the class SearchServiceImpl method databaseBioSequenceSearch.

/**
 * A database search for biosequences. Biosequence names are already indexed by compass...
 */
private Collection<SearchResult> databaseBioSequenceSearch(SearchSettings settings) {
    if (!settings.getUseDatabase())
        return new HashSet<>();
    StopWatch watch = this.startTiming();
    String searchString = settings.getQuery();
    // replace * with % for inexact symbol search
    String inexactString = searchString;
    Pattern pattern = Pattern.compile("\\*");
    Matcher match = pattern.matcher(inexactString);
    inexactString = match.replaceAll("%");
    Collection<BioSequence> bs = bioSequenceService.findByName(inexactString);
    // bioSequenceService.thawRawAndProcessed( bs );
    Collection<SearchResult> bioSequenceList = new HashSet<>(this.dbHitsToSearchResult(bs, null));
    watch.stop();
    if (watch.getTime() > 1000)
        SearchServiceImpl.log.info("BioSequence DB search for " + searchString + " took " + watch.getTime() + " ms and found" + bioSequenceList.size() + " BioSequences");
    return bioSequenceList;
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) BioSequence(ubic.gemma.model.genome.biosequence.BioSequence) StopWatch(org.apache.commons.lang3.time.StopWatch)

Aggregations

BioSequence (ubic.gemma.model.genome.biosequence.BioSequence)105 CompositeSequence (ubic.gemma.model.expression.designElement.CompositeSequence)40 ArrayDesign (ubic.gemma.model.expression.arrayDesign.ArrayDesign)24 Test (org.junit.Test)18 HashSet (java.util.HashSet)17 Taxon (ubic.gemma.model.genome.Taxon)15 BlatResult (ubic.gemma.model.genome.sequenceAnalysis.BlatResult)12 InputStream (java.io.InputStream)11 Collection (java.util.Collection)11 HashMap (java.util.HashMap)10 BaseSpringContextTest (ubic.gemma.core.testing.BaseSpringContextTest)10 GZIPInputStream (java.util.zip.GZIPInputStream)7 Gene (ubic.gemma.model.genome.Gene)7 GeoPlatform (ubic.gemma.core.loader.expression.geo.model.GeoPlatform)6 DatabaseEntry (ubic.gemma.model.common.description.DatabaseEntry)6 StopWatch (org.apache.commons.lang3.time.StopWatch)5 GeneProduct (ubic.gemma.model.genome.gene.GeneProduct)5 BioSequenceValueObject (ubic.gemma.model.genome.sequenceAnalysis.BioSequenceValueObject)5 BlatAssociation (ubic.gemma.model.genome.sequenceAnalysis.BlatAssociation)5 AbstractGeoServiceTest (ubic.gemma.core.loader.expression.geo.AbstractGeoServiceTest)4