From 0e4e38852d09d24aad1b1c523c2d7ba56550495d Mon Sep 17 00:00:00 2001
From: peterjc
Date: Mon, 8 Apr 2013 17:47:51 +0100
Subject: [PATCH] Close SearchIO indexes in doctests to avoid ResourceWarning
---
Bio/SearchIO/__init__.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/Bio/SearchIO/__init__.py b/Bio/SearchIO/__init__.py
index 7d362bca482..096ab154e87 100644
--- a/Bio/SearchIO/__init__.py
+++ b/Bio/SearchIO/__init__.py
@@ -448,6 +448,7 @@ def index(filename, format=None, key_function=None, **kwargs):
['gi|156630997:105-1160', 'gi|195230749:301-1383', ..., 'gi|53729353:216-1313']
>>> search_idx['gi|195230749:301-1383']
QueryResult(id='gi|195230749:301-1383', 5 hits)
+ >>> search_idx.close()
If the file is BGZF compressed, this is detected automatically. Ordinary
GZIP files are not supported:
@@ -458,6 +459,7 @@ def index(filename, format=None, key_function=None, **kwargs):
SearchIO.index('Blast/wnts.xml.bgz', 'blast-xml', key_function=None)
>>> search_idx['gi|195230749:301-1383']
QueryResult(id='gi|195230749:301-1383', 5 hits)
+ >>> search_idx.close()
You can supply a custom callback function to alter the default identifier
string. This function should accept as its input the QueryResult ID string
@@ -472,6 +474,7 @@ def index(filename, format=None, key_function=None, **kwargs):
['156630997:105-1160', ..., '371502086:108-1205', '53729353:216-1313']
>>> search_idx['156630997:105-1160']
QueryResult(id='gi|156630997:105-1160', 5 hits)
+ >>> search_idx.close()
Note that the callback function does not change the QueryResult's ID value.
It only changes the key value used to retrieve the associated QueryResult.