use of ubic.gemma.model.common.description.DatabaseEntry in project Gemma by PavlidisLab.
the class ExpressionExperimentServiceTest method testFindByAccession.
@Test
public final void testFindByAccession() {
DatabaseEntry accessionEntry = DatabaseEntry.Factory.newInstance(ed);
accessionEntry.setAccession(accession);
Collection<ExpressionExperiment> expressionExperiment = expressionExperimentService.findByAccession(accessionEntry);
assertTrue(expressionExperiment.size() > 0);
}
use of ubic.gemma.model.common.description.DatabaseEntry in project Gemma by PavlidisLab.
the class ExpressionExperimentServiceTest method setup.
@Before
public void setup() {
if (!persisted) {
ee = this.getTestPersistentCompleteExpressionExperiment(false);
ee.setName(ExpressionExperimentServiceTest.EE_NAME);
DatabaseEntry accessionEntry = this.getTestPersistentDatabaseEntry();
accession = accessionEntry.getAccession();
ed = accessionEntry.getExternalDatabase();
ee.setAccession(accessionEntry);
Contact c = this.getTestPersistentContact();
ee.setOwner(c);
expressionExperimentService.update(ee);
ee = expressionExperimentService.thaw(ee);
persisted = true;
} else {
log.debug("Skipping making new ee for test");
}
}
use of ubic.gemma.model.common.description.DatabaseEntry in project Gemma by PavlidisLab.
the class GeneServiceTest method testFindByAccessionOther.
@Test
public void testFindByAccessionOther() {
Gene gene = Gene.Factory.newInstance();
Integer id = Integer.parseInt(RandomStringUtils.randomNumeric(5));
gene.setNcbiGeneId(id);
gene.setName(GeneServiceTest.TEST_GENE_NAME);
ExternalDatabase ensembl = edbs.findByName("Ensembl");
DatabaseEntry dbe = DatabaseEntry.Factory.newInstance();
dbe.setAccession("E129458");
dbe.setExternalDatabase(ensembl);
gene.getAccessions().add(dbe);
Taxon human = taxonService.findByCommonName("human");
gene.setTaxon(human);
geneDao.create(gene);
Gene g = geneDao.findByAccession("E129458", ensembl);
assertNotNull(g);
assertEquals(g, gene);
geneDao.remove(gene);
}
use of ubic.gemma.model.common.description.DatabaseEntry in project Gemma by PavlidisLab.
the class GeoBrowserServiceImpl method filterGeoRecords.
private List<GeoRecord> filterGeoRecords(List<GeoRecord> records) {
ExternalDatabase geo = externalDatabaseService.findByName("GEO");
Collection<GeoRecord> toRemove = new HashSet<>();
assert geo != null;
rec: for (GeoRecord record : records) {
if (record.getNumSamples() < GeoBrowserServiceImpl.MIN_SAMPLES) {
toRemove.add(record);
}
Collection<String> organisms = record.getOrganisms();
if (organisms == null || organisms.size() == 0) {
continue;
}
int i = 0;
for (String string : organisms) {
Taxon t = taxonService.findByCommonName(string);
if (t == null) {
t = taxonService.findByScientificName(string);
if (t == null) {
toRemove.add(record);
continue rec;
}
}
String acc = record.getGeoAccession();
if (organisms.size() > 1) {
acc = acc + "." + i;
}
DatabaseEntry de = DatabaseEntry.Factory.newInstance();
de.setExternalDatabase(geo);
de.setAccession(acc);
Collection<ExpressionExperiment> ee = expressionExperimentService.findByAccession(de);
if (!ee.isEmpty()) {
for (ExpressionExperiment expressionExperiment : ee) {
record.getCorrespondingExperiments().add(expressionExperiment.getId());
}
}
record.setPreviousClicks(localInfo.containsKey(acc) ? localInfo.get(acc).getPreviousClicks() : 0);
record.setUsable(!localInfo.containsKey(acc) || localInfo.get(acc).isUsable());
i++;
}
}
records.removeAll(toRemove);
return records;
}
use of ubic.gemma.model.common.description.DatabaseEntry in project Gemma by PavlidisLab.
the class GeoServiceImpl method fetchAndLoad.
/**
* Given a GEO GSE or GDS (or GPL, but support might not be complete)
* <ol>
* <li>Check that it doesn't already exist in the system</li>
* <li>Download and parse GDS files and GSE file needed</li>
* <li>Convert the GDS and GSE into a ExpressionExperiment (or just the ArrayDesigns)
* <li>Load the resulting ExpressionExperiment and/or ArrayDesigns into Gemma</li>
* </ol>
*/
@Override
public Collection<?> fetchAndLoad(String geoAccession, boolean loadPlatformOnly, boolean doSampleMatching, boolean splitByPlatform, boolean allowSuperSeriesImport, boolean allowSubSeriesImport) {
/*
* We do this to get a fresh instantiation of GeoConverter (prototype scope)
*/
GeoConverter geoConverter = (GeoConverter) this.beanFactory.getBean("geoConverter");
if (this.geoDomainObjectGenerator == null) {
this.geoDomainObjectGenerator = new GeoDomainObjectGenerator();
} else {
this.geoDomainObjectGenerator.initialize();
}
geoDomainObjectGenerator.setProcessPlatformsOnly(geoAccession.startsWith("GPL") || loadPlatformOnly);
geoDomainObjectGenerator.setDoSampleMatching(doSampleMatching && !splitByPlatform);
Collection<DatabaseEntry> projectedAccessions = geoDomainObjectGenerator.getProjectedAccessions(geoAccession);
this.checkForExisting(projectedAccessions);
if (loadPlatformOnly) {
Collection<? extends GeoData> platforms = geoDomainObjectGenerator.generate(geoAccession);
if (platforms.size() == 0) {
AbstractGeoService.log.warn("GeoService.fetchAndLoad( targetPlatformAcc, true, false, false, false );t no results");
return null;
}
geoConverter.setForceConvertElements(true);
Collection<Object> arrayDesigns = geoConverter.convert(platforms);
return persisterHelper.persist(arrayDesigns);
}
Collection<? extends GeoData> parseResult = geoDomainObjectGenerator.generate(geoAccession);
if (parseResult.size() == 0) {
AbstractGeoService.log.warn("Got no results");
return null;
}
AbstractGeoService.log.debug("Generated GEO domain objects for " + geoAccession);
Object obj = parseResult.iterator().next();
if (!(obj instanceof GeoSeries)) {
throw new RuntimeException("Got a " + obj.getClass().getName() + " instead of a " + GeoSeries.class.getName() + " (you may need to load platforms only).");
}
GeoSeries series = (GeoSeries) obj;
String seriesAccession = series.getGeoAccession();
if (series.isSuperSeries()) {
if (allowSuperSeriesImport) {
AbstractGeoService.log.info(" ========= SuperSeries Detected! =========");
AbstractGeoService.log.info("Please make sure you want to import this as a superseries and not the individual subseries");
} else {
throw new IllegalStateException("SuperSeries detected, set 'allowSuperSeriesImport' to 'true' to allow this dataset to load");
}
}
if (series.isSubSeries()) {
if (allowSubSeriesImport) {
AbstractGeoService.log.info(" ========= Subseries Detected! =========");
AbstractGeoService.log.info("Please make sure you want to import this as a subseries and not the superseries");
} else {
throw new IllegalStateException("SubSeries detected, set 'allowSubSeriesImport' to 'true' to allow this dataset to load");
}
}
this.confirmPlatformUniqueness(series, doSampleMatching && !splitByPlatform);
ArrayDesignsForExperimentCache c = new ArrayDesignsForExperimentCache();
this.matchToExistingPlatforms(geoConverter, series, c);
this.checkSamplesAreNew(series);
this.getSubSeriesInformation(series);
geoConverter.clear();
geoConverter.setSplitByPlatform(splitByPlatform);
// noinspection unchecked
Collection<ExpressionExperiment> result = (Collection<ExpressionExperiment>) geoConverter.convert(series);
this.check(result);
this.getPubMedInfo(result);
AbstractGeoService.log.debug("Converted " + seriesAccession);
assert persisterHelper != null;
Collection<ExpressionExperiment> persistedResult = new HashSet<>();
for (ExpressionExperiment ee : result) {
c = expressionExperimentPrePersistService.prepare(ee, c);
ee = persisterHelper.persist(ee, c);
persistedResult.add(ee);
AbstractGeoService.log.debug("Persisted " + seriesAccession);
}
this.updateReports(persistedResult);
return persistedResult;
}
Aggregations