I can't get the data on the E. coli genome from NCBI.For this purpose I used two documentations for obtaining data http://biopython.org/DIST/docs/tutorial/Tutorial.html#sec149 http://biopython.org/DIST/docs/tutorial/Tutorial.html#sec37
So I've written a code:
from Bio import Entrez
from Bio import SeqIO
Entrez.email = "may mail"
organism_id = "NC_000913"
handle = Entrez.efetch(db="nucleotide", id=organism_id, rettype="gbwithparts", retmode="text")
record = SeqIO.read(handle, "genbank")
handle.close()
genome_length = len(record.seq)
But, I'm receiving a strange error. For example:
File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/urllib/request.py:1348, in AbstractHTTPHandler.do_open(self, http_class, req, **http_conn_args)
1347 try:
-> 1348 h.request(req.get_method(), req.selector, req.data, headers,
1349 encode_chunked=req.has_header('Transfer-encoding'))
1350 except OSError as err: # timeout error
File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/client.py:1282, in HTTPConnection.request(self, method, url, body, headers, encode_chunked)
1281 """Send a complete request to the server."""
-> 1282 self._send_request(method, url, body, headers, encode_chunked)
File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/client.py:1328, in HTTPConnection._send_request(self, method, url, body, headers, encode_chunked)
1327 body = _encode(body, 'body')
-> 1328 self.endheaders(body, encode_chunked=encode_chunked)
File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/client.py:1277, in HTTPConnection.endheaders(self, message_body, encode_chunked)
1276 raise CannotSendHeader()
-> 1277 self._send_output(message_body, encode_chunked=encode_chunked)
File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/client.py:1037, in HTTPConnection._send_output(self, message_body, encode_chunked)
1036 del self._buffer[:]
-> 1037 self.send(msg)
1039 if message_body is not None:
1040
...
-> 1351 raise URLError(err)
1352 r = h.getresponse()
1353 except:
URLError:
Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings...
And I don't how I can manage with this problem? Could you help me please? Thanks in advance.
try this