Package Bio :: Package EUtils :: Module Config
[hide private]
[frames] | no frames]

Source Code for Module Bio.EUtils.Config

 1  """Configuration information about NCBI's databases""" 
 2   
 3  # Used to figure out if efetch supports the start, stop, strand, and 
 4  # complexity fields 
 5  PUBLICATION_TYPE = 0 
 6  SEQUENCE_TYPE = 1 
 7   
 8  # Map from database name to database type 
9 -class DatabaseInfo:
10 """stores NCBI's name for the database and its type"""
11 - def __init__(self, db, dbtype):
12 self.db = db 13 self.dbtype = dbtype
14
15 -class DatabaseDict(dict):
16 """map from name to DatabaseInfo for that database name 17 18 Entries are also available through attributes like PUBMED, 19 OMIM, and NUCLEOTIDE. 20 """
21 - def gettype(self, db, dbtype = None):
22 """Given a database name and optional type, return the database type""" 23 if dbtype not in (None, SEQUENCE_TYPE, PUBLICATION_TYPE): 24 raise TypeError("Unknown database type: %r" % (dbtype,)) 25 if dbtype is None: 26 dbtype = self[db].dbtype 27 return dbtype
28 29 databases = DatabaseDict() 30
31 -def _add_db(x):
32 databases[x.db] = x 33 return x.db
34 35 # XXX Try these 36 # <option value="structure">Structure</option> 37 # <option value="pmc">PMC</option> 38 # <option value="taxonomy">Taxonomy</option> 39 # <option value="books">Books</option> 40 # <option value="geo">ProbeSet</option> 41 # <option value="domains">3D Domains</option> 42 # <option value="UniSts">UniSTS</option> 43 # <option value="cdd">Domains</option> 44 # <option value="snp">SNP</option> 45 # <option value="popset">PopSet</option> 46 47 databases.PUBMED = _add_db(DatabaseInfo("pubmed", 0)) 48 databases.OMIM = _add_db(DatabaseInfo("omim", 0)) 49 databases.JOURNALS = _add_db(DatabaseInfo("journals", 0)) 50 51 databases.GENOME = _add_db(DatabaseInfo("genome", 1)) 52 databases.NUCLEOTIDE = _add_db(DatabaseInfo("nucleotide", 1)) 53 databases.PROTEIN = _add_db(DatabaseInfo("protein", 1)) 54 databases.POPSET = _add_db(DatabaseInfo("popset", 1)) 55 databases.SEQUENCES = _add_db(DatabaseInfo("sequences", 1)) 56 databases.UNIGENE = _add_db(DatabaseInfo("unigene", 1)) 57 databases.GENE = _add_db(DatabaseInfo("gene", 1)) 58 59 60 # Someday I want to make it easier to get a given format. I would 61 # rather not have to specify the retmode/rettype pair, but I don't 62 # know what people want from this feature, so skip for now. Plus, 63 # it's harder than I thought. 64 65 ##class FormatInfo: 66 ## def __init__(self, name, retmode): 67 ## self.name = name 68 ## self.retmode = retmode 69 ## self.rettype = rettype 70