use of ubic.gemma.core.loader.expression.geo.service.GeoBrowserService in project Gemma by PavlidisLab.
the class GeoGrabberCli method doWork.
@Override
protected Exception doWork(String[] args) {
Exception e = super.processCommandLine(args);
if (e != null)
return e;
Set<String> seen = new HashSet<>();
GeoBrowserService gbs = this.getBean(GeoBrowserService.class);
ExpressionExperimentService ees = this.getBean(ExpressionExperimentService.class);
try {
int start = 0;
int numfails = 0;
int chunksize = 100;
while (true) {
List<GeoRecord> recs = gbs.getRecentGeoRecords(start, chunksize);
if (recs.isEmpty()) {
AbstractCLI.log.info("No records received for start=" + start);
numfails++;
if (numfails > 10) {
AbstractCLI.log.info("Giving up");
break;
}
try {
Thread.sleep(500);
} catch (InterruptedException ignored) {
}
start++;
continue;
}
start++;
for (GeoRecord geoRecord : recs) {
if (seen.contains(geoRecord.getGeoAccession())) {
continue;
}
if (ees.findByShortName(geoRecord.getGeoAccession()) != null) {
continue;
}
if (!ees.findByAccession(geoRecord.getGeoAccession()).isEmpty()) {
continue;
}
System.out.println(geoRecord.getGeoAccession() + "\t" + geoRecord.getOrganisms().iterator().next() + "\t" + geoRecord.getNumSamples() + "\t" + geoRecord.getTitle() + "\t" + StringUtils.join(geoRecord.getCorrespondingExperiments(), ",") + "\t" + geoRecord.getSeriesType());
seen.add(geoRecord.getGeoAccession());
}
}
} catch (IOException | ParseException exception) {
return exception;
}
return null;
}
Aggregations