001/*
002 *                    BioJava development code
003 *
004 * This code may be freely distributed and modified under the
005 * terms of the GNU Lesser General Public Licence.  This should
006 * be distributed with the code.  If you do not have a copy,
007 * see:
008 *
009 *      http://www.gnu.org/copyleft/lesser.html
010 *
011 * Copyright for this code is held jointly by the individual
012 * authors.  These should be listed in @author doc comments.
013 *
014 * For more information on the BioJava project and its aims,
015 * or to join the biojava-l mailing list, visit the home page
016 * at:
017 *
018 *      http://www.biojava.org/
019 *
020 */
021
022package org.biojava.bio.seq.db.biofetch;
023
024import java.util.Map;
025
026import org.biojava.bio.BioException;
027import org.biojava.bio.seq.db.SequenceDBLite;
028import org.biojava.directory.RegistryException;
029import org.biojava.directory.SequenceDBProvider;
030
031/**
032 * Directory-services plugin for biofetch databases.
033 *
034 * This class is instantiated automatically by the
035 *                directory-services code, and is not of direct
036 *                interest to users.
037 *
038 * @author Thomas Down
039 * @author Keith James
040 * @since 1.3
041 */
042public class BioFetchSequenceDBProvider implements SequenceDBProvider {
043    public String getName() {
044        return "biofetch";
045    }
046
047    public SequenceDBLite getSequenceDB(Map config)
048        throws RegistryException, BioException
049    {
050        String location = (String) config.get("location");
051        if (location == null) {
052            throw new RegistryException("BioFetch provider requires"
053                                        + " a location parameter");
054        }
055
056        String dbName = (String) config.get("dbname");
057        if (dbName == null) {
058            throw new RegistryException("BioFetch provider requires"
059                                        + " a dbname parameter");
060        }
061
062        return new BioFetchSequenceDB(location, dbName);
063    }
064}