use of ubic.gemma.model.expression.arrayDesign.ArrayDesign in project Gemma by PavlidisLab.
the class ArrayDesignMergeCli method processOptions.
@Override
protected void processOptions() {
super.processOptions();
if (this.hasOption('o')) {
// required
String otherArrayDesignName = this.getOptionValue('o');
String[] names = StringUtils.split(otherArrayDesignName, ',');
this.otherArrayDesigns = new HashSet<>();
for (String string : names) {
ArrayDesign o = this.locateArrayDesign(string, arrayDesignService);
if (o == null) {
throw new IllegalArgumentException("Array design " + string + " not found");
}
o = this.thaw(o);
this.otherArrayDesigns.add(o);
}
}
if (this.arrayDesignsToProcess.size() > 1) {
throw new IllegalArgumentException("Cannot be applied to more than one array design given to the '-a' option");
}
arrayDesign = this.arrayDesignsToProcess.iterator().next();
arrayDesign = this.thaw(arrayDesign);
if (this.hasOption("add")) {
if (arrayDesign.getMergees().isEmpty()) {
throw new IllegalArgumentException("The array given must be a merged design when using -add");
}
} else {
if (this.hasOption("n")) {
this.newName = this.getOptionValue('n');
} else {
throw new IllegalArgumentException("You must provide a name for the new design unless using -add");
}
if (this.hasOption("s")) {
this.newShortName = this.getOptionValue('s');
} else {
throw new IllegalArgumentException("You must provide a short name for the new design unless using -add");
}
}
arrayDesignMergeService = this.getBean(ArrayDesignMergeService.class);
}
use of ubic.gemma.model.expression.arrayDesign.ArrayDesign in project Gemma by PavlidisLab.
the class ArrayDesignProbeMapperCli method batchRun.
private void batchRun(final Date skipIfLastRunLaterThan) {
Collection<ArrayDesign> allArrayDesigns;
if (this.taxon != null) {
allArrayDesigns = arrayDesignService.findByTaxon(this.taxon);
} else {
allArrayDesigns = arrayDesignService.loadAll();
}
final SecurityContext context = SecurityContextHolder.getContext();
class ADProbeMapperCliConsumer extends Consumer {
private ADProbeMapperCliConsumer(BlockingQueue<ArrayDesign> q) {
super(q, context);
}
@Override
void consume(ArrayDesign x) {
if (x.getCurationDetails().getTroubled()) {
AbstractCLI.log.warn("Skipping troubled platform: " + x);
errorObjects.add(x + ": " + "Skipped because it is troubled; run in non-batch-mode");
return;
}
/*
* Note that if the array design has multiple taxa, analysis will be run on all of the sequences, not
* just the ones from the taxon specified.
*/
ArrayDesignProbeMapperCli.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++) {
ADProbeMapperCliConsumer c1 = new ADProbeMapperCliConsumer(arrayDesigns);
Thread k = new Thread(c1);
threads.add(k);
k.start();
}
this.waitForThreadPoolCompletion(threads);
/*
* All done
*/
this.summarizeProcessing();
}
use of ubic.gemma.model.expression.arrayDesign.ArrayDesign in project Gemma by PavlidisLab.
the class LoadSimpleExpressionDataCli method configureArrayDesigns.
private void configureArrayDesigns(String[] fields, SimpleExpressionExperimentMetaData metaData) {
int i;
TechnologyType techType = TechnologyType.fromString(fields[LoadSimpleExpressionDataCli.TECHNOLOGY_TYPE_I]);
Collection<ArrayDesign> ads = new HashSet<>();
if (StringUtils.isBlank(fields[LoadSimpleExpressionDataCli.AD_SHORT_NAME_I])) {
// that's okay, so long as we get an array design name
ArrayDesign ad = this.getNewArrayDesignFromName(fields);
ad.setTechnologyType(techType);
ad.setPrimaryTaxon(metaData.getTaxon());
ads.add(ad);
} else if (fields[LoadSimpleExpressionDataCli.AD_SHORT_NAME_I].trim().equals("IMAGE")) {
ArrayDesign ad = this.getNewArrayDesignFromName(fields);
ad.setTechnologyType(techType);
ad.setPrimaryTaxon(metaData.getTaxon());
ads.add(ad);
metaData.setProbeIdsAreImageClones(true);
} else if (StringUtils.isNotBlank(fields[LoadSimpleExpressionDataCli.ARRAY_DESIGN_NAME_I])) {
// allow for the case where there is an additional new array design to be added.
ArrayDesign ad = this.getNewArrayDesignFromName(fields);
ad.setTechnologyType(techType);
ad.setPrimaryTaxon(metaData.getTaxon());
ads.add(ad);
} else {
String[] allADs = fields[LoadSimpleExpressionDataCli.AD_SHORT_NAME_I].split("\\+");
for (i = 0; i < allADs.length; i++) {
ArrayDesign ad = adService.findByShortName(allADs[i]);
if (ad == null) {
Collection<ArrayDesign> existingAds = adService.findByAlternateName(allADs[i]);
if (existingAds.size() == 1) {
ad = existingAds.iterator().next();
} else if (existingAds.size() > 1) {
throw new IllegalStateException("Array Design " + allADs[i] + " is ambiguous, it is an alternate name of more than one array design");
}
}
if (ad == null) {
throw new IllegalStateException("Array Design " + allADs[i] + " is not loaded into the system yet; load it and try again.");
}
ads.add(ad);
}
}
metaData.setArrayDesigns(ads);
}
use of ubic.gemma.model.expression.arrayDesign.ArrayDesign in project Gemma by PavlidisLab.
the class LoadSimpleExpressionDataCli method getNewArrayDesignFromName.
private ArrayDesign getNewArrayDesignFromName(String[] fields) {
this.checkForArrayDesignName(fields);
ArrayDesign ad = ArrayDesign.Factory.newInstance();
ad.setName(fields[LoadSimpleExpressionDataCli.ARRAY_DESIGN_NAME_I]);
ad.setShortName(ad.getName());
return ad;
}
use of ubic.gemma.model.expression.arrayDesign.ArrayDesign in project Gemma by PavlidisLab.
the class LoadExpressionDataCli method doWork.
@Override
protected Exception doWork(String[] args) {
Exception err = this.processCommandLine(args);
if (err != null) {
return err;
}
try {
GeoService geoService = this.getBean(GeoService.class);
geoService.setGeoDomainObjectGenerator(new GeoDomainObjectGenerator());
if (accessions == null && accessionFile == null) {
return new IllegalArgumentException("You must specific either a file or accessions on the command line");
}
if (accessions != null) {
AbstractCLI.log.info("Got accession(s) from command line " + accessions);
String[] accsToRun = StringUtils.split(accessions, ',');
for (String accession : accsToRun) {
accession = StringUtils.strip(accession);
if (StringUtils.isBlank(accession)) {
continue;
}
if (platformOnly) {
Collection<?> designs = geoService.fetchAndLoad(accession, true, true, false, true, true);
ArrayDesignService ads = this.getBean(ArrayDesignService.class);
for (Object object : designs) {
assert object instanceof ArrayDesign;
ArrayDesign ad = (ArrayDesign) object;
ad = ads.thawLite(ad);
successObjects.add(ad.getName() + " (" + ad.getExternalReferences().iterator().next().getAccession() + ")");
}
} else {
this.processAccession(geoService, accession);
}
}
}
if (accessionFile != null) {
AbstractCLI.log.info("Loading accessions from " + accessionFile);
InputStream is = new FileInputStream(accessionFile);
try (BufferedReader br = new BufferedReader(new InputStreamReader(is))) {
String accession;
while ((accession = br.readLine()) != null) {
if (StringUtils.isBlank(accession)) {
continue;
}
this.processAccession(geoService, accession);
}
}
}
this.summarizeProcessing();
} catch (Exception e) {
AbstractCLI.log.error(e);
return e;
}
return null;
}
Aggregations