1
2
3 import warnings
4 warnings.warn("Bio.expressions was deprecated, as it does not work with recent versions of mxTextTools. If you want to continue to use this module, please get in contact with the Biopython developers at biopython-dev@biopython.org to avoid permanent removal of this module from Biopython", DeprecationWarning)
5
6
7
8 import operator
9 from Martel import *
10 from Bio import Std
11
12
13
14
15
16 -def make_2id(s, dbname, primary_name, secondary_name):
17 assert secondary_name is not None
18 if primary_name is None:
19 return Str(s + "||") + \
20 Std.dbxref_dbid(UntilSep(sep = "| "), {"dbname": dbname,
21 "type": secondary_name})
22
23 return Str(s + "|") + \
24 Std.dbxref_dbid(UntilSep(sep = "|"), {"dbname": dbname,
25 "type": primary_name}) + \
26 Str("|") + \
27 Std.dbxref_dbid(UntilSep(sep = "| "), {"dbname": dbname,
28 "type": secondary_name})
29
34
35 ids = []
36
37 ids.append(make_1id("gi", "x-gi", "primary"))
38
39
40
41 ids.append(make_2id("gb", "gb", "primary", "secondary"))
42
43
44
45 ids.append(make_2id("emb", "embl", "primary", "secondary"))
46
47
48 ids.append(make_2id("dbj", "ddbj", "primary", "secondary"))
49
50
51 ids.append(make_2id("pir", "pir", None, "primary"))
52
53
54 ids.append(make_2id("prf", "x-prf", None, "primary"))
55
56
57 ids.append(make_2id("sp", "sp", "primary", "secondary"))
58
59
60 ids.append(make_2id("pdb", "x-pdb", "primary", "secondary"))
61
62
63 ids.append(make_2id("pat", "x-pat", "primary", "secondary"))
64
65
66 ids.append(make_1id("bbs", "x-bbs", "primary"))
67
68
69 gnl_id = Str("gnl|") + \
70 Std.dbxref_dbname(UntilSep(sep = "| ")) + \
71 Str("|") + \
72 Std.dbxref_dbid(UntilSep(sep = "| "))
73 ids.append(gnl_id)
74
75
76 ids.append(make_2id("ref", "x-ref", "primary", "secondary"))
77
78
79 ids.append(make_1id("lcl", "local", "primary"))
80
81
82 ncbi_word = Std.dbxref(reduce(operator.or_, ids))
83
84
85 ncbi_term = ncbi_word + Rep(Str("|") + ncbi_word)
86
87
88 generic_term = Std.dbxref(
89 Std.dbxref_dbid(UntilSep(sep = " "), {"dbname": "local"})
90 )
91 id_term = ncbi_term | generic_term
92
93
94 comment_lines = Rep(Str("#") + ToEol())
95 title = Str(">") + Std.description_line(id_term + UntilEol()) + AnyEol()
96 seqline = AssertNot(Str(">")) + Std.sequence(UntilEol()) + AnyEol()
97
98 seqline_nonewline = AssertNot(Str(">")) + Std.sequence(Word())
99
100 sequence = Std.sequence_block(Rep(seqline | seqline_nonewline))
101
102 record = Std.record(comment_lines + title + sequence + Rep(AnyEol()))
103
104
105
106 format = HeaderFooter("dataset", {"format": "fasta"},
107 comment_lines, RecordReader.Until, (">",),
108 record, RecordReader.StartsWith, (">",),
109 comment_lines, RecordReader.Everything, ()
110 )
111