use of ubic.gemma.model.expression.arrayDesign.ArrayDesign in project Gemma by PavlidisLab.
the class ExpressionDataFileServiceImpl method getGeneAnnotationsAsStrings.
/**
* @return Map of composite sequence ids to an array of strings: [probe name, genes symbol(s), gene Name(s), gemma
* id(s), ncbi id(s)].
*/
private Map<Long, String[]> getGeneAnnotationsAsStrings(Collection<ArrayDesign> ads) {
Map<Long, String[]> annotations = new HashMap<>();
for (ArrayDesign arrayDesign : ads) {
arrayDesign = arrayDesignService.thaw(arrayDesign);
annotations.putAll(ArrayDesignAnnotationServiceImpl.readAnnotationFileAsString(arrayDesign));
}
return annotations;
}
use of ubic.gemma.model.expression.arrayDesign.ArrayDesign in project Gemma by PavlidisLab.
the class ExpressionDataFileServiceImpl method writeDataFile.
/**
* @param compress if true, file will be output in GZIP format.
*/
private File writeDataFile(ExpressionExperiment ee, boolean filtered, File f, boolean compress) throws IOException {
ExpressionDataFileServiceImpl.log.info("Creating new expression data file: " + f.getName());
ExpressionDataDoubleMatrix matrix = this.getDataMatrix(ee, filtered);
Collection<ArrayDesign> arrayDesigns = expressionExperimentService.getArrayDesignsUsed(ee);
Map<CompositeSequence, String[]> geneAnnotations = this.getGeneAnnotationsAsStringsByProbe(arrayDesigns);
this.writeMatrix(f, geneAnnotations, matrix, compress);
return f;
}
use of ubic.gemma.model.expression.arrayDesign.ArrayDesign in project Gemma by PavlidisLab.
the class ExpressionDataMatrixServiceImpl method getFilteredMatrix.
@Override
public ExpressionDataDoubleMatrix getFilteredMatrix(String arrayDesignName, FilterConfig filterConfig, Collection<ProcessedExpressionDataVector> dataVectors) {
ArrayDesign ad = arrayDesignService.findByShortName(arrayDesignName);
if (ad == null) {
throw new IllegalArgumentException("No platform named '" + arrayDesignName + "'");
}
Collection<ArrayDesign> arrayDesignsUsed = new HashSet<>();
arrayDesignsUsed.add(ad);
return this.getFilteredMatrix(filterConfig, dataVectors, arrayDesignsUsed);
}
use of ubic.gemma.model.expression.arrayDesign.ArrayDesign in project Gemma by PavlidisLab.
the class ArrayDesignAnnotationFileCli method processAllADs.
/**
* Goes over all the AD's in the database (possibly limited by taxon) and creates annotation 3 annotation files for
* each AD that is not merged into or subsumed by another AD. Uses the Accession ID (GPL???) for the name of the
* annotation file. Appends noParents, bioProcess, allParents to the file name.
*/
private void processAllADs() throws IOException {
Collection<ArrayDesign> allADs = this.arrayDesignService.loadAll();
for (ArrayDesign ad : allADs) {
ad = arrayDesignService.thawLite(ad);
if (ad.getCurationDetails().getTroubled()) {
AbstractCLI.log.warn("Troubled: " + ad + " (skipping)");
continue;
}
Taxon taxon = null;
if (this.taxonName != null) {
TaxonService taxonService = this.getBean(TaxonService.class);
taxon = taxonService.findByCommonName(taxonName);
if (taxon == null) {
throw new IllegalArgumentException("Unknown taxon: " + taxonName);
}
}
Collection<Taxon> adTaxa = arrayDesignService.getTaxa(ad.getId());
/*
* If using taxon, check it.
*/
if (taxon != null && !adTaxa.contains(taxon)) {
continue;
}
this.processOneAD(ad);
}
}
use of ubic.gemma.model.expression.arrayDesign.ArrayDesign in project Gemma by PavlidisLab.
the class ArrayDesignBlatCli method doWork.
@Override
protected Exception doWork(String[] args) {
Exception err = this.processCommandLine(args);
if (err != null)
return err;
final Date skipIfLastRunLaterThan = this.getLimitingDate();
if (!this.arrayDesignsToProcess.isEmpty()) {
if (this.blatResultFile != null && this.arrayDesignsToProcess.size() > 1) {
throw new IllegalArgumentException("Cannot provide a blat result file when multiple arrays are being analyzed");
}
for (ArrayDesign arrayDesign : this.arrayDesignsToProcess) {
if (!this.needToRun(skipIfLastRunLaterThan, arrayDesign, ArrayDesignSequenceAnalysisEvent.class)) {
AbstractCLI.log.warn(arrayDesign + " was last run more recently than " + skipIfLastRunLaterThan);
return null;
}
arrayDesign = this.thaw(arrayDesign);
Collection<BlatResult> persistedResults;
try {
if (this.blatResultFile != null) {
Collection<BlatResult> blatResults = this.getBlatResultsFromFile(arrayDesign);
if (blatResults == null || blatResults.size() == 0) {
throw new IllegalStateException("No blat results in file!");
}
AbstractCLI.log.info("Got " + blatResults.size() + " blat records");
persistedResults = arrayDesignSequenceAlignmentService.processArrayDesign(arrayDesign, taxon, blatResults);
this.audit(arrayDesign, "BLAT results read from file: " + blatResultFile);
} else {
// Run blat from scratch.
persistedResults = arrayDesignSequenceAlignmentService.processArrayDesign(arrayDesign, this.sensitive);
this.audit(arrayDesign, "Based on a fresh alignment analysis; BLAT score threshold was " + this.blatScoreThreshold + "; sensitive mode was " + this.sensitive);
}
AbstractCLI.log.info("Persisted " + persistedResults.size() + " results");
} catch (IOException e) {
this.errorObjects.add(e);
}
}
} else if (taxon != null) {
Collection<ArrayDesign> allArrayDesigns = arrayDesignService.findByTaxon(taxon);
AbstractCLI.log.warn("*** Running BLAT for all " + taxon.getCommonName() + " Array designs *** [" + allArrayDesigns.size() + " items]");
final SecurityContext context = SecurityContextHolder.getContext();
/*
* Here is our task runner.
*/
class BlatCliConsumer extends Consumer {
private BlatCliConsumer(BlockingQueue<ArrayDesign> q) {
super(q, context);
}
@Override
void consume(ArrayDesign x) {
x = arrayDesignService.thaw(x);
ArrayDesignBlatCli.this.processArrayDesign(skipIfLastRunLaterThan, x);
}
}
BlockingQueue<ArrayDesign> arrayDesigns = new ArrayBlockingQueue<>(allArrayDesigns.size());
arrayDesigns.addAll(allArrayDesigns);
Collection<Thread> threads = new ArrayList<>();
for (int i = 0; i < this.numThreads; i++) {
Consumer c1 = new BlatCliConsumer(arrayDesigns);
Thread k = new Thread(c1);
threads.add(k);
k.start();
}
this.waitForThreadPoolCompletion(threads);
/*
* All done
*/
this.summarizeProcessing();
} else {
this.bail(ErrorCode.MISSING_ARGUMENT);
}
return null;
}
Aggregations