python - 将 bool_list 传递给 pybiomart 包中的方法
问题描述
我正在使用pybiomart python包,我想使用此处提供的过滤器之一。其中一个过滤器是boolean_list类型。我不确定在使用该类型的过滤器值时如何传递参数。我通过显示以下内容的方法
知道它是boolean_list类型:dataset.list_filters()
我的查询如下:
from pybiomart import Server, Dataset
a=[False]*20
a[7]=True
dataset=Dataset(name='hsapiens_gene_ensembl', host='http://www.ensembl.org')
dataset.query(attributes=['uniprotswissprot'],filters={'id_list_protein_domain_and_feature_filters':a})
我在这里所做的是我将a作为过滤器dic中相应过滤器的值传递。我认为我将a定义为 boolean_list (这是我的想法)。我将 a 定义为 20 个布尔值的列表,False
除了我需要的那个之外,我都做了True
。请从biomart网站的 GUI 中查看下面的屏幕截图。我想选择With Pfam ID(s)作为该过滤器的值(id_list_protein_domain_and_feature_filters)问题是当我运行该查询时,我收到以下错误:
---------------------------------------------------------------------------
BiomartException Traceback (most recent call last)
<ipython-input-19-3b59f9b0b207> in <module>()
3 a[2]=True
4 dataset=Dataset(name='hsapiens_gene_ensembl', host='http://www.ensembl.org')
----> 5 dataset.query(attributes=['uniprotswissprot'],filters={'id_list_protein_domain_and_feature_filters':a})
/usr/local/lib/python3.7/dist-packages/pybiomart/dataset.py in query(self, attributes, filters, only_unique, use_attr_names)
264 # Raise exception if an error occurred.
265 if 'Query ERROR' in response.text:
--> 266 raise BiomartException(response.text)
267
268 # Parse results into a DataFrame.
BiomartException: Query ERROR: caught BioMart::Exception::Database: Error during query execution: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' ensembl_mart_103.hsapiens_gene_ensembl__translation__main main WHERE (. 'False' at line 1
解决方案
推荐阅读
- c# - 使动态创建的面板在 winform 响应式(与我的 flowlayoutPanel 大小相同) - C#
- android - 将数据插入具有外键约束的表时面临问题
- c# - 有人能告诉我为什么这段代码不起作用吗?我正在尝试找到第 10001 个素数
- theory - 找到以下的正则表达式?奇数长度的语言,不能包含长度倍数 3 超过 ={,}
- c++ - 在 pthread 中返回 void 指针
- google-apps-script - GoogleCloudVision API 我想提高数字的准确性 [GAS]
- java - Proguard - 找不到 apache cxf / java.lang.IllegalArgumentException 的常见超类异常
- django - 带有if条件的Django自定义ID字段
- python - 获取元素类型的名称在 Iron python for Revit 中不起作用
- swift - 在场景委托中更改主情节提要后,导航控制器无法正常工作