001/** 002 * Copyright (C) 2010-2015 The Roslin Institute <contact andy.law@roslin.ed.ac.uk> 003 * 004 * This file is part of JEnsembl: a Java API to Ensembl data sources developed by the 005 * Bioinformatics Group at The Roslin Institute, The Royal (Dick) School of 006 * Veterinary Studies, University of Edinburgh. 007 * 008 * Project hosted at: http://jensembl.sourceforge.net 009 * 010 * This is free software: you can redistribute it and/or modify 011 * it under the terms of the GNU General Public License (version 3) as published by 012 * the Free Software Foundation. 013 * 014 * This software is distributed in the hope that it will be useful, 015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 017 * GNU General Public License for more details. 018 * 019 * You should have received a copy of the GNU General Public License 020 * in this software distribution. If not, see: http://opensource.org/licenses/gpl-3.0.html 021 */ 022package uk.ac.roslin.ensembl.demo; 023 024 025import java.io.File; 026import java.nio.charset.Charset; 027import java.nio.file.Files; 028import java.nio.file.Paths; 029import java.util.List; 030import uk.ac.roslin.ensembl.config.DBConnection.DataSource; 031import uk.ac.roslin.ensembl.config.RegistryConfiguration; 032import uk.ac.roslin.ensembl.dao.database.DBRegistry; 033 034 035 036public class CommandLineConfiguration { 037 038 039 //script that can load db properties and schema version properties on commandline 040 //or that will default to use some demo files locally 041 042 public static void main(String[] args) throws Exception { 043 044 045 String mappingFilePath = "src/main/resources/test_new_mappings.properties"; 046 String dbConfigFilePath = "src/main/resources/example_genomes_config.properties"; 047 048 if (args != null && args.length==1) { 049 mappingFilePath = args[0]; 050 } 051 if (args != null && args.length==2) { 052 mappingFilePath = args[0]; 053 dbConfigFilePath = args[1]; 054 } 055 056 File fileM = new File(mappingFilePath); 057 File fileC = new File(dbConfigFilePath); 058 059 RegistryConfiguration conf = new RegistryConfiguration(DataSource.ENSEMBLDB); 060 conf.setSchemaByFile(fileM); 061 062 DBRegistry eReg = DBRegistry.createRegistryForConfiguration(conf); 063 File f = eReg.getRegistryReport(); 064 List<String> lines = Files.readAllLines(Paths.get(f.getCanonicalPath()), Charset.forName("UTF-8")); 065 for (String l:lines) { 066 System.out.println(l); 067 } 068 069 conf = new RegistryConfiguration(DataSource.ENSEMBLGENOMES); 070 conf.setSchemaByFile(fileM); 071 072 conf = new RegistryConfiguration(); 073 conf.setDBByFile(fileC); 074 conf.setSchemaByFile(fileM); 075 076 077 eReg = DBRegistry.createRegistryForConfiguration(conf); 078 079 f = eReg.getRegistryReport(); 080 lines = Files.readAllLines(Paths.get(f.getCanonicalPath()), Charset.forName("UTF-8")); 081 for (String l:lines) { 082 System.out.println(l); 083 } 084 085 086 } 087}