File: __init__.py

package info (click to toggle)
python-biopython 1.42-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 17,584 kB
  • ctags: 12,272
  • sloc: python: 80,461; xml: 13,834; ansic: 7,902; cpp: 1,855; sql: 1,144; makefile: 203
file content (38 lines) | stat: -rw-r--r-- 1,068 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import os, sys

_open = open  # rename for internal use -- gets redefined below

def open(dbname, mode = "r"):
    text = _open(os.path.join(dbname, "config.dat"), "rb").read()
    line = text.split("\n")[0]
    if line == "index\tBerkeleyDB/1":
        import BerkeleyDB
        return BerkeleyDB.open(dbname, mode)
    elif line == "index\tflat/1":
        import FlatDB
        return FlatDB.open(dbname, mode)

    raise TypeError("Unknown index type: %r" % (line,))
    

def main():
    from Bio import Std
    import XPath
    import FlatDB
    XPath.xpath_index(
        #dbname = "sprot_flat",
        dbname = "sprot_small",
        filenames = ["/home/dalke/ftps/swissprot/smaller_sprot38.dat",
        #filenames = ["/home/dalke/ftps/swissprot/sprot38.dat",
                     ],
        primary_namespace = "entry",
        extract_info = [
        ("entry", "//entry_name"),
        ("accession", "//%s[@type='accession']" % (Std.dbid.tag,)),
        ],
        #creator_factory = FlatDB.CreateFlatDB,
        )


if __name__ == "__main__":
    main()