Show
Ignore:
Timestamp:
02/24/10 15:41:07 (2 years ago)
Author:
martijn
Message:

Accidentally checked in old version of GdbProvider?, reverted. Adjusted server start scripts.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/org.bridgedb.rdb/src/org/bridgedb/rdb/GdbProvider.java

    r308 r315  
    2626import java.util.Map; 
    2727 
     28import org.bridgedb.BridgeDb; 
     29import org.bridgedb.IDMapper; 
    2830import org.bridgedb.IDMapperException; 
    2931import org.bridgedb.bio.Organism; 
    30  
    3132 
    3233/** 
     
    3940 */ 
    4041public class GdbProvider { 
    41         Map<Organism, List<IDMapperRdb>> organism2gdb = new HashMap<Organism, List<IDMapperRdb>>(); 
    42         List<IDMapperRdb> globalGdbs = new ArrayList<IDMapperRdb>(); 
     42        Map<Organism, List<IDMapper>> organism2gdb = new HashMap<Organism, List<IDMapper>>(); 
     43        List<IDMapper> globalGdbs = new ArrayList<IDMapper>(); 
    4344         
    44         public void addOrganismGdb(Organism organism, IDMapperRdb gdb) { 
    45                 List<IDMapperRdb> l = organism2gdb.get(organism); 
     45        public void addOrganismGdb(Organism organism, IDMapper gdb) { 
     46                List<IDMapper> l = organism2gdb.get(organism); 
    4647                if(l == null) { 
    47                         organism2gdb.put(organism, l = new ArrayList<IDMapperRdb>()); 
     48                        organism2gdb.put(organism, l = new ArrayList<IDMapper>()); 
    4849                } 
    4950                if(!l.contains(gdb)) { 
     
    5354         
    5455        public void removeOrganismGdb(Organism organism, IDMapperRdb gdb) { 
    55                 List<IDMapperRdb> l = organism2gdb.get(organism); 
     56                List<IDMapper> l = organism2gdb.get(organism); 
    5657                if(l != null) { 
    5758                        l.remove(gdb); 
     
    5960        } 
    6061         
    61         public void addGlobalGdb(IDMapperRdb gdb) { 
     62        public void addGlobalGdb(IDMapper gdb) { 
    6263                if(!globalGdbs.contains(gdb)) globalGdbs.add(gdb); 
    6364        } 
    6465         
    65         public void removeGlobalGdb(IDMapperRdb gdb) { 
     66        public void removeGlobalGdb(IDMapper gdb) { 
    6667                globalGdbs.remove(gdb); 
    6768        } 
    6869         
    69         public List<IDMapperRdb> getGdbs(Organism organism) { 
    70                 List<IDMapperRdb> gdbs = organism2gdb.get(organism); 
     70        public List<IDMapper> getGdbs(Organism organism) { 
     71                List<IDMapper> gdbs = organism2gdb.get(organism); 
    7172                if(gdbs == null) { 
    72                         gdbs = new ArrayList<IDMapperRdb>(); 
     73                        gdbs = new ArrayList<IDMapper>(); 
    7374                } 
    7475                gdbs.addAll(globalGdbs); 
     
    7879        static final String DB_GLOBAL = "*"; 
    7980         
    80         public static GdbProvider fromConfigFile(File f) throws IDMapperException, IOException { 
    81                 System.out.println("Parsing gene database configuration: " + f); 
     81        public static GdbProvider fromConfigFile(File f) throws IDMapperException, IOException, ClassNotFoundException { 
     82                System.out.println("Parsing gene database configuration: " + f.getAbsolutePath()); 
    8283                GdbProvider gdbs = new GdbProvider(); 
    8384                BufferedReader in = new BufferedReader(new FileReader(f)); 
    8485                String line = in.readLine(); 
     86                Class.forName ("org.bridgedb.rdb.IDMapperRdb"); 
     87                Class.forName("org.bridgedb.file.IDMapperText"); 
     88                try 
     89                { 
     90                        Class.forName ("com.mysql.jdbc.Driver"); 
     91                } 
     92                catch (ClassNotFoundException ex) 
     93                { 
     94                        System.out.println ("MySQL driver not in classpath, mysql backend unavailable"); 
     95                } 
    8596                while(line != null) { 
    8697                        String[] kv = line.split("\t"); 
     
    8899                                String key = kv[0]; 
    89100                                String value = kv[1]; 
     101                                 
     102                                if (!value.startsWith("idmapper")) value = "idmapper-pgdb:" + value; 
     103                                IDMapper mapper = BridgeDb.connect (value); 
    90104                                Organism org = Organism.fromLatinName(key); 
    91105                                if(org != null) { 
    92                                         DataDerby dbConn = new DataDerby(); 
    93                                         SimpleGdb gdb = SimpleGdbFactory.createInstance(value, dbConn, DBConnector.PROP_NONE); 
    94                                         gdbs.addOrganismGdb(org, gdb); 
     106                                        gdbs.addOrganismGdb(org, mapper); 
    95107                                } else if(DB_GLOBAL.equalsIgnoreCase(key)) { 
    96                                         DataDerby dbConn = new DataDerby(); 
    97                                         SimpleGdb gdb = SimpleGdbFactory.createInstance(value, dbConn, DBConnector.PROP_NONE); 
    98                                         gdbs.addGlobalGdb(gdb); 
     108                                        gdbs.addGlobalGdb(mapper); 
    99109                                } else { 
    100110                                        System.out.println("Unable to parse organism: " + key);