Search in sources :

Example 1 with GeoBrowserService

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;
}
Also used : IOException(java.io.IOException) IOException(java.io.IOException) ParseException(java.text.ParseException) GeoRecord(ubic.gemma.core.loader.expression.geo.model.GeoRecord) GeoBrowserService(ubic.gemma.core.loader.expression.geo.service.GeoBrowserService) ExpressionExperimentService(ubic.gemma.persistence.service.expression.experiment.ExpressionExperimentService) ParseException(java.text.ParseException) HashSet(java.util.HashSet)

Aggregations

IOException (java.io.IOException)1 ParseException (java.text.ParseException)1 HashSet (java.util.HashSet)1 GeoRecord (ubic.gemma.core.loader.expression.geo.model.GeoRecord)1 GeoBrowserService (ubic.gemma.core.loader.expression.geo.service.GeoBrowserService)1 ExpressionExperimentService (ubic.gemma.persistence.service.expression.experiment.ExpressionExperimentService)1