use of ubic.gemma.core.loader.expression.geo.DataUpdater in project Gemma by PavlidisLab.
the class AffyDataFromCelCli method doWork.
@Override
protected Exception doWork(String[] args) {
Exception e = super.processCommandLine(args);
if (e != null)
return e;
DataUpdater serv = this.getBean(DataUpdater.class);
// This can be done for multiple experiments under some conditions; we get this one just to test for some multi-platform situations
Collection<ArrayDesign> arrayDesignsUsed = this.eeService.getArrayDesignsUsed(this.expressionExperiments.iterator().next());
if (StringUtils.isNotBlank(aptFile)) {
if (this.expressionExperiments.size() > 1) {
throw new IllegalArgumentException("Can't use " + AffyDataFromCelCli.APT_FILE_OPT + " unless you are doing just one experiment");
}
ExpressionExperiment thawedEe = (ExpressionExperiment) this.expressionExperiments.iterator().next();
thawedEe = this.eeService.thawLite(thawedEe);
if (arrayDesignsUsed.size() > 1) {
throw new IllegalArgumentException("Cannot use " + AffyDataFromCelCli.APT_FILE_OPT + " for experiment that uses multiple platforms");
}
ArrayDesign ad = arrayDesignsUsed.iterator().next();
try {
AbstractCLI.log.info("Loading data from " + aptFile);
if ((ad.getTechnologyType().equals(TechnologyType.ONECOLOR) && GeoPlatform.isAffymetrixExonArray(ad.getShortName())) || ad.getName().toLowerCase().contains("exon")) {
serv.addAffyExonArrayData(thawedEe, aptFile);
} else if (ad.getTechnologyType().equals(TechnologyType.ONECOLOR) && ad.getName().toLowerCase().contains("affy")) {
serv.addAffyData(thawedEe, aptFile);
} else {
throw new IllegalArgumentException("Option " + AffyDataFromCelCli.APT_FILE_OPT + " only valid if you are using an exon array.");
}
} catch (Exception exception) {
return exception;
}
return null;
}
if (StringUtils.isNotBlank(cdfFile)) {
if (arrayDesignsUsed.size() > 1) {
throw new IllegalArgumentException("Cannot use " + AffyDataFromCelCli.CDF_FILE_OPT + " for experiment that uses multiple platforms");
}
}
for (BioAssaySet ee : this.expressionExperiments) {
try {
Collection<ArrayDesign> adsUsed = this.eeService.getArrayDesignsUsed(ee);
/*
* if the audit trail already has a DataReplacedEvent, skip it, unless --force. Ignore this for
* multiplatform studies (at our peril)
*/
if (adsUsed.size() == 1 && !force && this.checkForAlreadyDone(ee)) {
AbstractCLI.log.warn(ee + ": Already has been recomputed from raw data, skipping (use 'force' to override')");
this.errorObjects.add(ee + ": Already has been computed from raw data");
continue;
}
ExpressionExperiment thawedEe = (ExpressionExperiment) ee;
thawedEe = this.eeService.thawLite(thawedEe);
ArrayDesign ad = adsUsed.iterator().next();
/*
* Even if there are multiple platforms, we assume they are all the same type. If not, that's your
* problem :) (seriously, we could check...)
*/
if ((ad.getTechnologyType().equals(TechnologyType.ONECOLOR) && GeoPlatform.isAffymetrixExonArray(ad.getShortName())) || ad.getName().toLowerCase().contains("exon")) {
AbstractCLI.log.info(thawedEe + " looks like affy exon array");
serv.addAffyExonArrayData(thawedEe);
this.successObjects.add(thawedEe.toString());
AbstractCLI.log.info("Successfully processed: " + thawedEe);
} else if (ad.getTechnologyType().equals(TechnologyType.ONECOLOR) && ad.getName().toLowerCase().contains("affy")) {
AbstractCLI.log.info(thawedEe + " looks like a affy 3-prime array");
serv.reprocessAffyThreePrimeArrayData(thawedEe);
this.successObjects.add(thawedEe.toString());
AbstractCLI.log.info("Successfully processed: " + thawedEe);
} else {
AbstractCLI.log.warn(ee + ": This CLI can only deal with Affymetrix platforms (exon or 3' probe designs)");
this.errorObjects.add(ee + ": This CLI can only deal with Affymetrix platforms (exon or 3' probe designs)");
}
} catch (Exception exception) {
AbstractCLI.log.error(exception, exception);
this.errorObjects.add(ee + " " + exception.getLocalizedMessage());
}
}
super.summarizeProcessing();
return null;
}
use of ubic.gemma.core.loader.expression.geo.DataUpdater 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.core.loader.expression.geo.DataUpdater in project Gemma by PavlidisLab.
the class ReplaceDataCli method doWork.
@Override
protected Exception doWork(String[] args) {
Exception exception = super.processCommandLine(args);
if (exception != null) {
return exception;
}
DataUpdater dataUpdater = this.getBean(DataUpdater.class);
if (this.expressionExperiments.size() > 1) {
throw new IllegalArgumentException("Sorry, This CLI can only deal with one experiment at a time.");
}
ExpressionExperiment ee = (ExpressionExperiment) this.expressionExperiments.iterator().next();
Collection<ArrayDesign> arrayDesignsUsed = this.eeService.getArrayDesignsUsed(ee);
if (arrayDesignsUsed.size() > 1) {
throw new IllegalArgumentException("Sorry, can only process single-platform data sets with this tool.");
}
ArrayDesign targetArrayDesign = arrayDesignsUsed.iterator().next();
Collection<QuantitationType> qts = eeService.getPreferredQuantitationType(ee);
if (qts.size() > 1) {
throw new IllegalArgumentException("Experiment must have just one preferred quantitation type to replace data for");
}
QuantitationType qt = qts.iterator().next();
if (qt == null) {
throw new IllegalArgumentException("Experiment must have a preferred quantitation type to replace data for");
}
try {
DoubleMatrixReader reader = new DoubleMatrixReader();
DoubleMatrix<String, String> data = reader.read(file);
dataUpdater.replaceData(ee, targetArrayDesign, qt, data);
} catch (IOException e) {
AbstractCLI.log.error("Failed while processing " + ee, e);
return e;
}
return null;
}
Aggregations