use of ubic.gemma.model.genome.Gene in project Gemma by PavlidisLab.
the class GeneMultifunctionalityPopulationServiceTest method tearDown.
@After
public void tearDown() {
gene2GoService.removeAll();
Collection<Gene> genes = geneService.loadAll(testTaxon);
for (Gene gene : genes) {
try {
geneService.remove(gene);
} catch (Exception ignored) {
}
}
}
use of ubic.gemma.model.genome.Gene in project Gemma by PavlidisLab.
the class GeneMultifunctionalityPopulationServiceTest method setUp.
@Before
public void setUp() throws Exception {
if (goService.isRunning()) {
goService.shutDown();
}
gene2GoService.removeAll();
goService.loadTermsInNameSpace(new GZIPInputStream(this.getClass().getResourceAsStream("/data/loader/ontology/molecular-function.test.owl.gz")));
testTaxon = taxonService.findOrCreate(Taxon.Factory.newInstance("foobly" + RandomStringUtils.randomAlphabetic(2), "doobly" + RandomStringUtils.randomAlphabetic(2), "bar" + RandomStringUtils.randomAlphabetic(2), RandomUtils.nextInt(5000), true, true));
/*
* Create genes
*/
for (int i = 0; i < 120; i++) {
Gene gene = this.getTestPersistentGene(testTaxon);
// Some genes get no terms.
if (i >= 100)
continue;
/*
* Add up to 5 GO terms. Parents mean more will be added.
*/
for (int j = 0; j <= Math.floor(i / 20); j++) {
VocabCharacteristic oe = VocabCharacteristic.Factory.newInstance();
oe.setValueUri(GeneOntologyService.BASE_GO_URI + goTerms[j]);
oe.setValue(goTerms[j]);
Gene2GOAssociation g2Go1 = Gene2GOAssociation.Factory.newInstance(gene, oe, GOEvidenceCode.EXP);
gene2GoService.create(g2Go1);
}
}
}
use of ubic.gemma.model.genome.Gene in project Gemma by PavlidisLab.
the class GeneMultifunctionalityPopulationServiceTest method test.
@Test
public void test() {
log.info("Updating multifunctionality");
s.updateMultifunctionality(testTaxon);
Collection<Gene> genes = geneService.loadAll(testTaxon);
genes = geneService.thawLite(genes);
assertEquals(120, genes.size());
boolean found = false;
for (Gene gene : genes) {
Multifunctionality mf = gene.getMultifunctionality();
if (mf == null)
continue;
if (mf.getNumGoTerms() == 5) {
// assertEquals( 0.245833, mf.getRank(), 0.001 );
found = true;
}
}
assertTrue(found);
}
use of ubic.gemma.model.genome.Gene in project Gemma by PavlidisLab.
the class StringBiomartGene2GeneProteinLoaderTest method getTestPeristentGenesZebra.
public void getTestPeristentGenesZebra() {
Gene geneZebraOne = this.makeGene(zebraFish, "zgc.153184", "751652");
Gene geneZebraTwo = this.makeGene(zebraFish, "appl1", "571540");
Gene geneZebraThree = this.makeGene(zebraFish, "LOC568371", "568371");
Gene geneZebraFour = this.makeGene(zebraFish, "TESTGENE", "30425");
Gene geneZebraFive = this.makeGene(zebraFish, "TESTGENE2", "503936");
genesZebra.add(this.makeGene(zebraFish, "FOO1", "562059"));
genesZebra.add(geneZebraOne);
genesZebra.add(geneZebraTwo);
genesZebra.add(geneZebraThree);
genesZebra.add(geneZebraFour);
genesZebra.add(geneZebraFive);
Gene2GeneProteinAssociation existingGene2GeneProteinAssociationOne = Gene2GeneProteinAssociation.Factory.newInstance(geneZebraOne, geneZebraThree, null, null, null);
Gene2GeneProteinAssociation existingGene2GeneProteinAssociationTwo = Gene2GeneProteinAssociation.Factory.newInstance(geneZebraOne, geneZebraTwo, null, null, null);
// noinspection MismatchedQueryAndUpdateOfCollection
Collection<Gene2GeneProteinAssociation> geneAssociationZebra = new ArrayList<>();
geneAssociationZebra.add(existingGene2GeneProteinAssociationTwo);
geneAssociationZebra.add(existingGene2GeneProteinAssociationOne);
}
use of ubic.gemma.model.genome.Gene in project Gemma by PavlidisLab.
the class PhenotypeAssociationManagerServiceImpl method findGenesWithEvidence.
@Override
@Transactional(readOnly = true)
public Collection<GeneEvidenceValueObject> findGenesWithEvidence(String query, Long taxonId) {
if (query == null || query.length() == 0) {
throw new IllegalArgumentException("No search query provided");
}
// make sure it does an inexact search
String newQuery = query + "%";
Taxon taxon = null;
if (taxonId != null) {
taxon = this.taxonService.load(taxonId);
}
SearchSettings settings = SearchSettingsImpl.geneSearch(newQuery, taxon);
List<SearchResult> geneSearchResults = this.searchService.search(settings).get(Gene.class);
Collection<Gene> genes = new HashSet<>();
if (geneSearchResults == null || geneSearchResults.isEmpty()) {
return new HashSet<>();
}
for (SearchResult sr : geneSearchResults) {
genes.add((Gene) sr.getResultObject());
}
Collection<GeneEvidenceValueObject> geneEvidenceValueObjects = new HashSet<>();
for (Gene g : genes) {
GeneEvidenceValueObject geneEvidenceValueObject = new GeneEvidenceValueObject(g, this.convert2ValueObjects(g.getPhenotypeAssociations()));
geneEvidenceValueObjects.add(geneEvidenceValueObject);
}
Collection<GeneEvidenceValueObject> geneValueObjectsFilter = new ArrayList<>();
for (GeneEvidenceValueObject gene : geneEvidenceValueObjects) {
if (gene.getEvidence() != null && gene.getEvidence().size() != 0) {
geneValueObjectsFilter.add(gene);
}
}
return geneValueObjectsFilter;
}
Aggregations