1
2
3
4
5
6
7
8
9
10
11 """Update the Rebase emboss files used by Restriction to build the
12 Restriction_Dictionary.py module."""
13
14 import os
15 import sys
16 import sre
17 import time
18 import gzip
19 from urllib import FancyURLopener
20
21 from Bio.Restriction.RanaConfig import *
22
23
25
26 - def __init__(self, e_mail='', ftpproxy=''):
42
45
47 print '\n Please wait, trying to connect to Rebase\n'
48 try:
49 self.open(name)
50 except:
51 raise ConnectionError('Rebase')
52 return
53
55 print '\n',
56 for file in self.update(*files):
57 print 'copying', file
58 fn = os.path.basename(file)
59
60 filename = os.path.join(os.getcwd(), fn)
61 print 'to', filename
62 self.retrieve(file, filename)
63 self.close()
64 return
65
67 t = time.gmtime()
68 year = str(t.tm_year)[-1]
69 month = str(t.tm_mon)
70 if len(month) == 1 : month = '0'+month
71 return year+month
72
77
79 if hasattr(self, 'tmpcache') : self.close()
80
81
82
83 return
84
85
87
89 print " In order to connect to %s ftp server, you must provide a name.\
90 \n Please edit Bio.Restriction.RanaConfig\n" % which_server
91 sys.exit()
92
94
96 print "\n\
97 \n In order to connect to %s ftp server, you must provide a password.\
98 \n Use the --e-mail switch to enter your e-mail address.\
99 \n\n" % which_server
100 sys.exit()
101
102
104
106 print '\
107 \n Unable to connect to the %s ftp server, make sure your computer\
108 \n is connected to the internet and that you have correctly configured\
109 \n the ftp proxy.\
110 \n Use the --proxy switch to enter the address of your proxy\
111 \n' % which_server
112 sys.exit()
113
114
115
116 __all__ = ['RebaseUpdate', 'FtpNameError', 'FtpPasswordError']
117