use of ubic.gemma.model.expression.experiment.BioAssaySet in project Gemma by PavlidisLab.
the class RelationshipPersister method persistExpressionExperimentSet.
private ExpressionExperimentSet persistExpressionExperimentSet(ExpressionExperimentSet entity) {
if (!this.isTransient(entity))
return entity;
Collection<BioAssaySet> setMembers = new HashSet<>();
for (BioAssaySet baSet : entity.getExperiments()) {
if (this.isTransient(baSet)) {
baSet = (BioAssaySet) this.persist(baSet);
}
setMembers.add(baSet);
}
entity.getExperiments().clear();
entity.getExperiments().addAll(setMembers);
return expressionExperimentSetDao.create(entity);
}
use of ubic.gemma.model.expression.experiment.BioAssaySet in project Gemma by PavlidisLab.
the class ExpressionExperimentSetValueObjectHelperImpl method convertToEntity.
/*
* @see
* ubic.gemma.core.expression.experiment.ExpressionExperimentSetValueObjectHelper#convertToLightValueObject(ubic.gemma
* .model.analysis.expression.ExpressionExperimentSet)
*/
@Override
public ExpressionExperimentSet convertToEntity(ExpressionExperimentSetValueObject setVO) {
if (setVO == null) {
return null;
}
ExpressionExperimentSet entity;
if (setVO.getId() == null || setVO.getId() < 0) {
entity = ExpressionExperimentSet.Factory.newInstance();
entity.setId(null);
} else {
entity = expressionExperimentSetService.load(setVO.getId());
}
entity.setDescription(setVO.getDescription());
Collection<ExpressionExperiment> experiments = expressionExperimentService.load(setVO.getExpressionExperimentIds());
if (experiments.isEmpty()) {
throw new IllegalArgumentException("The value object must have some experiments associated before it can be converted and persisted");
}
Collection<BioAssaySet> bas = new HashSet<BioAssaySet>(experiments);
entity.setExperiments(bas);
entity.setName(setVO.getName());
if (setVO.getTaxonId() != null && setVO.getTaxonId() >= 0) {
Taxon tax = taxonService.load(setVO.getTaxonId());
entity.setTaxon(tax);
} else {
Log.debug("Trying to convert DatabaseBackedExpressionExperimentSetValueObject with id =" + setVO.getId() + " to ExpressionExperimentSet entity. Unmatched ValueObject.getTaxonId() was :" + setVO.getTaxonId());
}
return entity;
}
use of ubic.gemma.model.expression.experiment.BioAssaySet in project Gemma by PavlidisLab.
the class RNASeqDataAddCli method doWork.
@Override
protected Exception doWork(String[] args) {
Exception exception = super.processCommandLine(args);
if (exception != null)
return exception;
DataUpdater serv = this.getBean(DataUpdater.class);
if (this.justbackfillLog2cpm) {
for (BioAssaySet bas : this.expressionExperiments) {
try {
ExpressionExperiment ee = (ExpressionExperiment) bas;
Collection<QuantitationType> pqts = this.eeService.getPreferredQuantitationType(ee);
if (pqts.size() > 1)
throw new IllegalArgumentException("Cannot process when there is more than one preferred QT");
if (pqts.isEmpty())
throw new IllegalArgumentException("No preferred quantitation type for " + ee.getShortName());
QuantitationType qt = pqts.iterator().next();
if (!qt.getType().equals(StandardQuantitationType.COUNT)) {
AbstractCLI.log.warn("Preferred data is not counts for " + ee);
this.errorObjects.add(ee.getShortName() + ": Preferred data is not counts");
continue;
}
serv.log2cpmFromCounts(ee, qt);
this.successObjects.add(ee);
} catch (Exception e) {
AbstractCLI.log.error(e, e);
this.errorObjects.add(((ExpressionExperiment) bas).getShortName() + ": " + e.getMessage());
}
}
this.summarizeProcessing();
return null;
}
/*
* Usual cases.
*/
if (this.expressionExperiments.size() > 1) {
throw new IllegalArgumentException("Sorry, can only process one experiment with this tool.");
}
ArrayDesign targetArrayDesign = this.locateArrayDesign(this.platformName);
ExpressionExperiment ee = (ExpressionExperiment) this.expressionExperiments.iterator().next();
if (this.expressionExperiments.size() > 1) {
AbstractCLI.log.warn("This CLI can only deal with one experiment at a time; only the first one will be processed");
}
DoubleMatrixReader reader = new DoubleMatrixReader();
try {
DoubleMatrix<String, String> countMatrix = null;
DoubleMatrix<String, String> rpkmMatrix = null;
if (this.countFile != null) {
countMatrix = reader.read(countFile);
}
if (this.rpkmFile != null) {
rpkmMatrix = reader.read(rpkmFile);
}
serv.addCountData(ee, targetArrayDesign, countMatrix, rpkmMatrix, readLength, isPairedReads, allowMissingSamples);
} catch (IOException e) {
AbstractCLI.log.error("Failed while processing " + ee, e);
return e;
}
return null;
}
use of ubic.gemma.model.expression.experiment.BioAssaySet in project Gemma by PavlidisLab.
the class SVDCli method doWork.
@Override
protected Exception doWork(String[] args) {
Exception err = super.processCommandLine(args);
if (err != null)
return err;
SVDService svdService = this.getBean(SVDService.class);
for (BioAssaySet bas : this.expressionExperiments) {
if (!force && this.noNeedToRun(bas, PCAAnalysisEvent.class)) {
this.errorObjects.add(bas + ": Already has PCA; use -force to override");
continue;
}
try {
AbstractCLI.log.info("Processing: " + bas);
ExpressionExperiment ee = (ExpressionExperiment) bas;
svdService.svd(ee.getId());
this.successObjects.add(bas.toString());
} catch (Exception e) {
AbstractCLI.log.error(e, e);
this.errorObjects.add(bas + ": " + e.getMessage());
}
}
this.summarizeProcessing();
return null;
}
use of ubic.gemma.model.expression.experiment.BioAssaySet in project Gemma by PavlidisLab.
the class TwoChannelMissingValueCLI method doWork.
@Override
protected Exception doWork(String[] args) {
Exception err = this.processCommandLine(args);
if (err != null)
return err;
for (BioAssaySet ee : expressionExperiments) {
if (ee instanceof ExpressionExperiment) {
this.processForMissingValues((ExpressionExperiment) ee);
} else {
throw new UnsupportedOperationException("Can't do two-channel missing values on " + ee.getClass().getName());
}
}
this.summarizeProcessing();
return null;
}
Aggregations