Package Bio :: Package expressions :: Package swissprot :: Module sprot40
[hide private]
[frames] | no frames]

Source Code for Module Bio.expressions.swissprot.sprot40

 1  import warnings 
 2  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) 
 3   
 4   
 5  import Martel 
 6  from Martel import Time 
 7  import sprot38 
 8   
 9  # HAS2_CHICK has a DT line like this 
10  # DT   30-MAY-2000 (REL. 39, Created) 
11  #                   ^^^ Note the upper-case "REL" instead of "Rel" ! 
12  DT_created_exp = (Martel.Str("DT   ") + 
13                    Time.make_expression("%(DD)-%(Jan)-%(YYYY)") + \ 
14                    Martel.Re(" \(R[Ee][Ll]. (?P<release>\d\d), Created\)\R")) 
15   
16   
17  OX_start = (Martel.Str("OX   NCBI_TaxID=") + 
18              Martel.Rep1(Martel.Digits("ncbi_taxid") + 
19                          Martel.Re("[,; ]+")) + 
20              Martel.AnyEol()) 
21  OX_cont = (Martel.Str("OX   ") + 
22             Martel.Rep1(Martel.Digits("ncbi_taxid") + 
23                         Martel.Re("[,; ]+")) + 
24             Martel.AnyEol()) 
25   
26  OX_exp = OX_start + Martel.Rep(OX_cont) 
27   
28  # 0 or 1 
29  # in 40 the line changed to look like this 
30  #  RX   MEDLINE=93305731; PubMed=7916637; 
31  #  RX   PubMed=11001938; 
32  bib = (Martel.Word("bibliographic_database_name") + Martel.Str("=") + 
33         Martel.ToSep("bibliographic_identifier", ";") 
34         ) 
35  RX_exp = (Martel.Str("RX   ") + bib + 
36            Martel.Opt(Martel.Str(" ") + bib) + 
37            Martel.AnyEol()) 
38   
39  # Here's the neq SQ line format -- uses a CRC64 
40  # SQ   SEQUENCE   889 AA;  100368 MW;  ABD7E3CD53961B78 CRC64; 
41  SQ_exp = Martel.Re("SQ   SEQUENCE +(?P<sequence_length>\d+) AA;" \ 
42                     " +(?P<molecular_weight>\d+) MW;" \ 
43                     " +(?P<crc?type=64>\w+) CRC64;\R") 
44   
45  replacements = [ 
46      ("DT_created", DT_created_exp), 
47      ("OX_block", OX_exp), 
48      ("RX", RX_exp), 
49      ("SQ", SQ_exp), 
50      ] 
51  record = Martel.replace_groups(sprot38.record, replacements) 
52   
53   
54  format_expression = Martel.replace_groups( 
55      sprot38.format_expression, replacements) 
56   
57   
58  format = Martel.replace_groups(sprot38.format, replacements) 
59   
60  if __name__ == "__main__": 
61      parser = format.make_parser() 
62      filename = "/home/dalke/ftps/databases/swiss-prot/release_compressed/sprot40.dat" 
63  ##    import os 
64  ##    infile = os.popen("zcat " + filename) 
65      infile = open(filename) 
66      infile.seek(107976062) 
67      parser.parseFile(infile) 
68