Search in sources :

Example 6 with StudyImporterException

use of org.eol.globi.data.StudyImporterException in project eol-globi-data by jhpoelen.

the class GraphExporterImpl method export.

@Override
public void export(GraphDatabaseService graphService, String baseDir) throws StudyImporterException {
    try {
        FileUtils.forceMkdir(new File(baseDir));
    } catch (IOException e) {
        throw new StudyImporterException("failed to create output dir [" + baseDir + "]", e);
    }
    LOG.info("site maps generating... ");
    File siteMapDir = new File(baseDir, "sitemap");
    final File citations = new File(siteMapDir, "citations");
    LOG.info("site maps at [" + citations.getAbsolutePath() + "] generating... ");
    new ExporterSiteMapForCitations().export(graphService, citations.getAbsolutePath());
    LOG.info("site maps at [" + citations.getAbsolutePath() + "] generated.");
    final File names = new File(siteMapDir, "names");
    LOG.info("site maps at [" + names.getAbsolutePath() + "] generating... ");
    final GraphExporter exporter = new ExporterSiteMapForNames();
    exporter.export(graphService, names.getAbsolutePath());
    LOG.info("site maps at [" + names.getAbsolutePath() + "] generated.");
    LOG.info("site maps generated... ");
    List<Study> studies = NodeUtil.findAllStudies(graphService);
    exportNames(baseDir, studies);
    // export to taxa for now, to avoid additional assemblies
    new ExportFlatInteractions().export(graphService, "tsv");
    new ExportCitations().export(graphService, "tsv");
    exportNCBILinkOut(graphService, baseDir, studies);
    exportDataOntology(studies, baseDir);
    exportDarwinCoreAggregatedByStudy(baseDir, studies);
    exportDarwinCoreAll(baseDir, studies);
}
Also used : Study(org.eol.globi.domain.Study) StudyImporterException(org.eol.globi.data.StudyImporterException)

Example 7 with StudyImporterException

use of org.eol.globi.data.StudyImporterException in project eol-globi-data by jhpoelen.

the class SiteMapUtils method generateSiteMap.

public static void generateSiteMap(Set<String> names, String baseDirPath, String queryParamName, String siteMapLocation) throws StudyImporterException {
    try {
        final File baseDir = new File(baseDirPath);
        FileUtils.forceMkdir(baseDir);
        generateSiteMapFor(queryParamName, names, baseDir, siteMapLocation);
    } catch (IOException e) {
        throw new StudyImporterException("failed to generate site map", e);
    }
}
Also used : StudyImporterException(org.eol.globi.data.StudyImporterException) IOException(java.io.IOException) File(java.io.File)

Example 8 with StudyImporterException

use of org.eol.globi.data.StudyImporterException in project eol-globi-data by jhpoelen.

the class ExportNCBIResourceFile method export.

protected void export(GraphDatabaseService graphService, OutputStreamFactory fileFactory) throws StudyImporterException {
    String query = "START taxon = node:taxons('*:*') " + "MATCH taxon-[?:SAME_AS*0..1]->linkedTaxon " + "WHERE has(linkedTaxon.externalId) AND linkedTaxon.externalId =~ 'NCBI:.*'" + "RETURN distinct(linkedTaxon.externalId) as id";
    ExecutionResult rows = new ExecutionEngine(graphService).execute(query, new HashMap<String, Object>());
    int rowCount = 0;
    OutputStream os = null;
    try {
        List<String> columns = rows.columns();
        for (Map<String, Object> row : rows) {
            if (rowCount % getLinksPerResourceFile() == 0) {
                close(os);
                os = null;
            }
            for (String column : columns) {
                String taxonId = row.get(column).toString();
                String ncbiTaxonId = StringUtils.replace(taxonId, TaxonomyProvider.ID_PREFIX_NCBI, "");
                String aLink = String.format("         <ObjId>%s</ObjId>\n", ncbiTaxonId);
                IOUtils.write(aLink, os == null ? (os = open(fileFactory, rowCount)) : os);
            }
            rowCount++;
        }
        close(os);
    } catch (IOException e) {
        throw new StudyImporterException("failed to export ncbi resources", e);
    }
}
Also used : ExecutionEngine(org.neo4j.cypher.javacompat.ExecutionEngine) StudyImporterException(org.eol.globi.data.StudyImporterException) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) ExecutionResult(org.neo4j.cypher.javacompat.ExecutionResult) IOException(java.io.IOException)

Example 9 with StudyImporterException

use of org.eol.globi.data.StudyImporterException in project eol-globi-data by jhpoelen.

the class ExportCitations method export.

public static void export(GraphDatabaseService graphService, String baseDir, String tsvFilename, String cypherQuery) throws StudyImporterException {
    try {
        ExportUtil.mkdirIfNeeded(baseDir);
        final FileOutputStream out = new FileOutputStream(baseDir + tsvFilename);
        GZIPOutputStream os = new GZIPOutputStream(out);
        final Writer writer = new BufferedWriter(new OutputStreamWriter(os, "UTF-8"));
        export(graphService, writer, cypherQuery);
        writer.flush();
        os.finish();
        IOUtils.closeQuietly(writer);
        IOUtils.closeQuietly(os);
    } catch (IOException e) {
        throw new StudyImporterException("failed to export citations", e);
    }
}
Also used : GZIPOutputStream(java.util.zip.GZIPOutputStream) StudyImporterException(org.eol.globi.data.StudyImporterException) FileOutputStream(java.io.FileOutputStream) OutputStreamWriter(java.io.OutputStreamWriter) IOException(java.io.IOException) BufferedWriter(java.io.BufferedWriter) Writer(java.io.Writer) OutputStreamWriter(java.io.OutputStreamWriter) BufferedWriter(java.io.BufferedWriter)

Aggregations

StudyImporterException (org.eol.globi.data.StudyImporterException)9 IOException (java.io.IOException)3 Study (org.eol.globi.domain.Study)3 FileOutputStream (java.io.FileOutputStream)2 StudyImporter (org.eol.globi.data.StudyImporter)2 BufferedWriter (java.io.BufferedWriter)1 File (java.io.File)1 OutputStream (java.io.OutputStream)1 OutputStreamWriter (java.io.OutputStreamWriter)1 Writer (java.io.Writer)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 MalformedURLException (java.net.MalformedURLException)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 GZIPOutputStream (java.util.zip.GZIPOutputStream)1 BasicParser (org.apache.commons.cli.BasicParser)1