File: genbank.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 (57 lines) | stat: -rw-r--r-- 1,911 bytes parent folder | download | duplicates (2)
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Copyright 2002 by Jeffrey Chang.  All rights reserved.
# This code is part of the Biopython distribution and governed by its
# license.  Please see the LICENSE file that should have been included
# as part of this package.

from Bio.config.DBRegistry import CGIDB, DBGroup, EUtilsDB
from _support import *

from Martel import *

proxy_error_expr = has_expr(Alt(Str("500"), Str("502")) + Str(" Proxy Error"))
diagnostic_error_expr = has_str("WWW Error 500 Diagnostic")
error_expr = Str("ERROR")

ncbi_failures=[
    (proxy_error_expr, "proxy error"),
    (diagnostic_error_expr, "diagnostic error"),
    (error_expr, "ERROR"),
    (html_expr, "I got HTML and shouldn't have"),
    (Str("Please try again later"), "Please try again later"),
    (Str("The sequence has been intentionally withdrawn"),
     "Sequence withdrawn"),
    (blank_expr, "No data returned")
    ]

nucleotide_genbank_eutils = EUtilsDB(
        name = "nucleotide-genbank-eutils",
        doc = "Retrieve nucleotide GenBank sequences from NCBI using EUtils",
        delay = 5.0,
        db = "nucleotide",
        rettype = "gb",
        failure_cases = ncbi_failures
        )

# If the id is not in the database, I get a message like:
# ERROR : GenPept does not exist for gi = 433174
not_exist_expr = Str("ERROR") + Re("[^d]*") + Str("does not exist for gi")

protein_genbank_eutils = EUtilsDB(
        name = "protein-genbank-eutils",
        doc = "Retrieve protein GenPept sequences from NCBI using EUtils",
        delay = 5.0,
        db = "protein",
        rettype = "gp",
        failure_cases = ncbi_failures+[(not_exist_expr, "GI does not exist")]
        )

gb_nucleotide = DBGroup(
        name = "genbank-nucleotide",
        behavior = "serial"
    )
gb_nucleotide.add(nucleotide_genbank_eutils)

gb_protein = DBGroup(
        name = "genbank-protein",
        behavior = "serial")
gb_protein.add(protein_genbank_eutils)