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);
}
}
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);
}
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);
}
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));
}
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;
}
Aggregations