use of ubic.gemma.model.expression.experiment.BioAssaySet in project Gemma by PavlidisLab.
the class ExpressionExperimentManipulatingCLI method removeTroubledEes.
/**
* removes EEs that are troubled, or their parent Array design is troubled.
*/
private void removeTroubledEes(Collection<BioAssaySet> ees) {
if (ees == null || ees.size() == 0) {
AbstractCLI.log.warn("No experiments to remove troubled from");
return;
}
BioAssaySet theOnlyOne = null;
if (ees.size() == 1) {
theOnlyOne = ees.iterator().next();
}
int size = ees.size();
CollectionUtils.filter(ees, new Predicate() {
@Override
public boolean evaluate(Object object) {
return !((ExpressionExperiment) object).getCurationDetails().getTroubled();
}
});
int newSize = ees.size();
if (newSize != size) {
assert newSize < size;
if (size == 1 && theOnlyOne != null) {
AbstractCLI.log.info(theOnlyOne.getName() + " has an active trouble flag");
} else {
AbstractCLI.log.info("Removed " + (size - newSize) + " experiments with 'trouble' flags, leaving " + newSize);
}
}
}
use of ubic.gemma.model.expression.experiment.BioAssaySet in project Gemma by PavlidisLab.
the class ExpressionExperimentManipulatingCLI method readExpressionExperimentListFile.
/**
* Load expression experiments based on a list of short names or IDs in a file. Only the first column of the file is
* used, comments (#) are allowed.
*/
private Set<BioAssaySet> readExpressionExperimentListFile(String fileName) throws IOException {
Set<BioAssaySet> ees = new HashSet<>();
for (String eeName : AbstractCLIContextCLI.readListFileToStrings(fileName)) {
ExpressionExperiment ee = eeService.findByShortName(eeName);
if (ee == null) {
try {
Long id = Long.parseLong(eeName);
ee = eeService.load(id);
if (ee == null) {
AbstractCLI.log.error("No experiment " + eeName + " found");
continue;
}
} catch (NumberFormatException e) {
AbstractCLI.log.error("No experiment " + eeName + " found");
continue;
}
}
ees.add(ee);
}
return ees;
}
use of ubic.gemma.model.expression.experiment.BioAssaySet in project Gemma by PavlidisLab.
the class ExpressionExperimentManipulatingCLI method findExpressionExperimentsByQuery.
/**
* Use the search engine to locate expression experiments.
*/
private Set<BioAssaySet> findExpressionExperimentsByQuery(String query) {
Set<BioAssaySet> ees = new HashSet<>();
Collection<SearchResult> eeSearchResults = searchService.search(SearchSettingsImpl.expressionExperimentSearch(query)).get(ExpressionExperiment.class);
AbstractCLI.log.info(ees.size() + " Expression experiments matched '" + query + "'");
// Filter out all the ee that are not of correct taxon
for (SearchResult sr : eeSearchResults) {
ExpressionExperiment ee = (ExpressionExperiment) sr.getResultObject();
Taxon t = eeService.getTaxon(ee);
if (t != null && t.getCommonName().equalsIgnoreCase(taxon.getCommonName())) {
ees.add(ee);
}
}
return ees;
}
use of ubic.gemma.model.expression.experiment.BioAssaySet in project Gemma by PavlidisLab.
the class ExpressionExperimentPrimaryPubCli method doWork.
@Override
protected Exception doWork(String[] args) {
Exception err = processCommandLine(args);
if (err != null)
return err;
ExpressionExperimentService ees = this.getBean(ExpressionExperimentService.class);
Persister ph = this.getPersisterHelper();
PubMedXMLFetcher fetcher = new PubMedXMLFetcher();
// collect some statistics
Collection<String> nullPubCount = new ArrayList<>();
Collection<String> samePubCount = new ArrayList<>();
Collection<String> diffPubCount = new ArrayList<>();
Collection<String> failedEe = new ArrayList<>();
ExpressionExperimentBibRefFinder finder = new ExpressionExperimentBibRefFinder();
for (BioAssaySet bioassay : expressionExperiments) {
if (!(bioassay instanceof ExpressionExperiment)) {
log.info(bioassay.getName() + " is not an ExpressionExperiment");
continue;
}
ExpressionExperiment experiment = (ExpressionExperiment) bioassay;
// if ( experiment.getPrimaryPublication() != null ) continue;
if (experiment.getPrimaryPublication() == null) {
log.warn(experiment + " has no existing primary publication");
}
experiment = ees.thawLite(experiment);
// get from GEO or get from a file
BibliographicReference ref = fetcher.retrieveByHTTP(pubmedIds.get(experiment.getShortName()));
if (ref == null) {
if (this.pubmedIdFilename != null) {
log.warn("Pubmed ID for " + experiment.getShortName() + " was not found in " + this.pubmedIdFilename);
}
ref = finder.locatePrimaryReference(experiment);
if (ref == null) {
log.error("No ref for " + experiment);
failedEe.add(experiment.getShortName());
continue;
}
}
// collect some statistics
if (experiment.getPrimaryPublication() == null) {
nullPubCount.add(experiment.getShortName());
} else if (experiment.getPrimaryPublication().getPubAccession().getAccession().equals(pubmedIds.get(experiment.getShortName()).toString())) {
samePubCount.add(experiment.getShortName());
} else {
diffPubCount.add(experiment.getShortName());
}
try {
log.info("Found pubAccession " + ref.getPubAccession().getAccession() + " for " + experiment);
ref = (BibliographicReference) ph.persist(ref);
experiment.setPrimaryPublication(ref);
ees.update(experiment);
} catch (Exception e) {
log.error(experiment.getShortName() + " (id=" + experiment.getId() + ") update failed.");
e.printStackTrace();
}
}
// print statistics
log.info("\n\n========== Summary ==========");
log.info("Total number of experiments: " + expressionExperiments.size());
log.info("Same publication: " + samePubCount.size());
log.info("Diff publication: " + diffPubCount.size());
log.info("No initial publication: " + nullPubCount.size());
log.info("No publications found: " + failedEe.size());
log.info("\n\n========== Details ==========");
log.info("Diff publication: " + Arrays.toString(diffPubCount.toArray()));
log.info("No initial publication: " + Arrays.toString(nullPubCount.toArray()));
log.info("No publications found: " + Arrays.toString(failedEe.toArray()));
return null;
}
use of ubic.gemma.model.expression.experiment.BioAssaySet in project Gemma by PavlidisLab.
the class MakeExperimentsPublicCli method doWork.
@Override
protected Exception doWork(String[] args) {
Exception e = super.processCommandLine(args);
if (e != null)
return e;
SecurityService securityService = this.getBean(SecurityService.class);
for (BioAssaySet ee : this.expressionExperiments) {
securityService.makePublic(ee);
this.auditTrailService.addUpdateEvent(ee, MakePublicEvent.class, "Made public from command line", null);
}
return null;
}
Aggregations