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);
}
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);
}
}
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);
}
}
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);
}
}
Aggregations