强大的NCBI接口
刚才小玩了下,不错,。net确实很方便,很强大
Using Entrez Utilities Web Service with C# and MS Visual Studio 2005
Updated: May 20, 2008
Entrez Utilities Web Service has been tested with:
- Microsoft Windows XP Professional (Service Pack2)
- Microsoft .NET Framework Version 2.0.50727
- Microsoft Visual Studio 2005 Version 8.0.50727.42
NCBI Entrez Utilities Web Service using MS Visual Studio 2005.
To create Windows application:
- Press Ctrl+Shift+N or Select File menu, then New, and then click Project to open the New Project dialog.
- Select Visual C# in Project types list.
- Select Windows Application in Templates list.
- Click OK to create a new project.
- Select View menu and then Toolbox to open a Toolbox window.
- From the Toolbox, drag a Textbox and a Button to the design surface of Form1.
- On the Project menu, click Add Web Reference.
- In the URL field of the Add Web Reference dialog, type the URL http://eutils.ncbi.nlm.nih.gov/entrez/eutils/soap/v2.0/eutils.wsdl
- Click the Go button to retrieve information about the XML Web service.
- In the Web reference name field, rename the Web reference to eUtils.
- Click Add Reference to add a Web reference for the target XML Web service.
- Double-click the button on Form1 to create an event-handling method for this button.
- In the button1_Click method enter the following code:
// eInfo utility returns a list of available databases
try
{
eUtils.eUtilsService serv = new eUtils.eUtilsService();
// call NCBI EInfo utility
eUtils.eInfoResult res = serv.run_eInfo(new eUtils.eInfoRequest());
// results output
textBox1.Text = "";
for(int i=0; i<res.DbList.Items.Length; i++) textBox1.Text += res.DbList.Items[i]+"\r\n";
}
catch (Exception eee)
{
textBox1.Text = eee.ToString();
}
- Build and run application.
eutils_MS.wsdl file.
Click on parameter to get its description.
Click on method name to see the example of use.
public Result run_eGquery(eGqueryRequest params)eGqueryRequest class properties: - String term - String tool - String emailpublic eInfoResult run_eInfo(eInfoRequest params)eInfoRequest class properties: - String db - String tool - String emailpublic eLinkResult run_eLink(eLinkRequest params)eLinkRequest class properties: - String db- String[] id- String reldate- String mindate- String maxdate- String datetype- String term- String dbfrom- String WebEnv- String query_key- String cmd- String tool- String emailpublic ePostResult run_ePost(ePostRequest params) ePostRequest class properties: - String db - String id - String tool - String emailpublic eSearchResult run_eSearch(eSearchRequest params)eSearchRequest class properties: - String db - String term - String WebEnv - String query_key - String usehistory - String tool - String email - String field - String reldate - String mindate - String maxdate - String datetype - String retstart - String retmax - String rettype - String sort public eSpellResult run_eSpell(eSpellRequest params) eSpellRequest class properties: - String db - String term - String tool - String emailpublic eSummaryResult run_eSummary(eSummaryRequest params)eSummaryRequest class properties: - String db - String id - String WebEnv - String query_key - String retstart - String retmax - String tool - String emailpublic eFetchResult run_eFetch(eFetchRequest params)eFetchRequest class properties: - String db - String id - String WebEnv - String query_key - String tool - String email - String retstart - String retmax - String rettype燩roperties available for Sequence databases: - String rettype - String strand - String seq_start - String seq_stop - String complexity - String report
|
|
|
|
|
|
|
To fetch data from one of the supported databases add the corresponding Web Reference to project. For example, for taxonomy database in Add Web Reference dialog type http://eutils.ncbi.nlm.nih.gov/entrez/eutils/soap/v2.0/efetch_taxon.wsdl in URL field and eFetchTaxon in Web Reference Name.
Taxonomy database example:
|
Add two Web References to project for http://eutils.ncbi.nlm.nih.gov/entrez/eutils/soap/v2.0/eutils.wsdl and http://eutils.ncbi.nlm.nih.gov/entrez/eutils/soap/v2.0/efetch_seq.wsdl files. Name them eUtils and eFetchSeq correspondingly.
String[] ids = { "" }; String fetchIds = ""; // STEP #1: search in PubMed for "cat" // try { eUtils.eUtilsService serv = new eUtils.eUtilsService(); // call NCBI ESearch utility // NOTE: search term should be URL encoded eUtils.eSearchRequest req = new eUtils.eSearchRequest(); req.db = "pubmed"; req.sort = "PublicationDate"; req.term = "cat+AND+pubmed_nuccore[sb]"; req.RetMax = "5"; eUtils.eSearchResult res = serv.run_eSearch(req); // store UIDs for use in ELink int N = res.IdList.Length; for (int i = 0; i < N; i++) { if (i > 0) ids[0] += ","; ids[0] += res.IdList[i]; } textBox1.Text = "Search in PubMed for \"cat\" returned " + res.Count + " hits\r\n"; textBox1.Text += "Search links in nuccore for the first 5 UIDs: " + ids[0]+"\r\n\r\n"; } catch (Exception eee) { textBox1.Text += eee.ToString(); } // STEP #2: get links in nucleotide database (nuccore) try { eUtils.eUtilsService serv = new eUtils.eUtilsService(); // call NCBI ELink utility eUtils.eLinkRequest req = new eUtils.eLinkRequest(); req.db = "nuccore"; req.id = ids; req.dbfrom = "pubmed"; eUtils.eLinkResult res = serv.run_eLink(req); // read result and create a list of UIDs to fetch for (int i = 0; i < res.LinkSet[0].LinkSetDb[0].Link.Length; i++) { if (i > 0) fetchIds += ","; fetchIds += res.LinkSet[0].LinkSetDb[0].Link[i].Id.Value; 爙 textBox1.Text += "ELink returned the following UIDs from nuccore: " + fetchIds + "\r\n\r\n"; } catch (Exception eee) { textBox1.Text += eee.ToString(); } // STEP #3: fetch records from nuccore // try { eFetchSeq.eFetchSequenceService serv = new eFetchSeq.eFetchSequenceService(); // call NCBI ESpell utility eFetchSeq.eFetchRequest req = new eFetchSeq.eFetchRequest(); req.db = "nuccore"; req.id = fetchIds; eFetchSeq.eFetchResult res = serv.run_eFetch(req); // results output for (int i = 0; i < res.GBSet.GBSeq.Length; i++) { textBox1.Text += "Organism: " + res.GBSet.GBSeq[i].GBSeq_organism + "\r\n"; textBox1.Text += "Locus: " + res.GBSet.GBSeq[i].GBSeq_locus + "\r\n"; textBox1.Text += "Definition: " + res.GBSet.GBSeq[i].GBSeq_definition + "\r\n"; textBox1.Text += "----------------------\r\n\r\n"; } } catch (Exception eee) { textBox1.Text += eee.ToString(); } |
Using WebEnv & QueryKey example
Add two Web References to project for http://eutils.ncbi.nlm.nih.gov/entrez/eutils/soap/v2.0/eutils.wsdl and http://eutils.ncbi.nlm.nih.gov/entrez/eutils/soap/v2.0/efetch_pubmed.wsdl files. Name them eUtils and eFetchPubmed correspondingly.
String WebEnv = ""; String query_key = ""; // STEP #1: search in PubMed for "cat" // try { eUtils.eUtilsService serv = new eUtils.eUtilsService(); // call NCBI ESearch utility // NOTE: search term should be URL encoded eUtils.eSearchRequest req = new eUtils.eSearchRequest(); req.db = "pubmed"; req.term = "cat"; req.usehistory = "y"; eUtils.eSearchResult res = serv.run_eSearch(req); // store WebEnv & QueryKey for use in eFetch WebEnv = res.WebEnv; query_key = res.QueryKey; textBox1.Text = "Search in PubMed for \"cat\" returned " + res.Count + " hits\r\n"; textBox1.Text += "WebEnv: " + WebEnv + "\r\n"; textBox1.Text += "QueryKey: " + query_key + "\r\n\r\n"; } catch (Exception eee) { textBox1.Text += eee.ToString(); } // STEP #2: fetch 5 records from pubmed starting from record #10 // try { eFetchPubmed.eFetchPubmedService serv = new eFetchPubmed.eFetchPubmedService(); // call NCBI EFetch utility eFetchPubmed.eFetchRequest req = new eFetchPubmed.eFetchRequest(); req.WebEnv = WebEnv; req.query_key = query_key; req.retstart = "10"; req.retmax = "5"; eFetchPubmed.eFetchResult res = serv.run_eFetch(req); // results output for (int i = 0; i < res.PubmedArticleSet.Length; i++) { textBox1.Text += "Title: " + res.PubmedArticleSet[i].MedlineCitation.Article.ArticleTitle + "\r\n"; textBox1.Text += "Abstract: " + res.PubmedArticleSet[i].MedlineCitation.Article.Abstract.AbstractText + "\r\n"; textBox1.Text += "--------------------------\r\n\r\n"; } } catch (Exception eee) { textBox1.Text += eee.ToString(); } |
强大的NCBI接口的更多相关文章
- Postman - 功能强大的 API 接口请求调试和管理工具
Postman 是一款功能强大的的 Chrome 应用,可以便捷的调试接口.前端开发人员在开发或者调试 Web 程序的时候是需要一些方法来跟踪网页请求的,用户可以使用一些网络的监视工具比如著名的 Fi ...
- 国内强大的API接口文档写作网站showdoc
传送门:https://www.showdoc.cc/ 思思今天使用了一下,真是非常方便,瞬间爱上呀,哈哈. 赶紧去试试吧...
- Scala:类,对象和特征(接口)
http://blog.csdn.net/pipisorry/article/details/52902609 Scala类和对象 类是对象的抽象,而对象是类的具体实例.类是抽象的,不占用内存,而对象 ...
- [二] java8 函数式接口详解 函数接口详解 lambda表达式 匿名函数 方法引用使用含义 函数式接口实例 如何定义函数式接口
函数式接口详细定义 package java.lang; import java.lang.annotation.*; /** * An informative annotation type use ...
- [六] 函数式接口的复合方法示例 predicate 谓词逻辑运算 Function接口 组合运算 比较器 逆序 比较链
复合的方法 有些函数式接口提供了允许复合的方法 也就是可以将Lambda表达式复合成为一个更加复杂的方法 之前的章节中有说到: 接口中的compose, andThen, and, or, negat ...
- linux 上部署 YApi 可视化接口管理平台
linux 上部署 YApi 可视化接口管理平台: YApi 是一个高效.易用.功能强大的可视化接口管理平台,官方地址 : http://yapi.demo.qunar.com/ 环境要求 nodej ...
- 最实用的IT类网站及工具大集合
1.聚合数据 大家在开发过程中,可能会用到各种各样的数据,想找一些接口来提供一些数据.比如天气预报查询,火车时刻表查询,彩票查询,身份证查询等等.有了这个接口,直接调用即可.各种各样的API接口满足你 ...
- C# 开源框架
一.AOP框架 Encase 是C#编写开发的为.NET平台提供的AOP框架.Encase 独特的提供了把方面(aspects)部署到运行时代码,而其它AOP框架依赖配置文件的方式.这种 ...
- 闲聊——浅谈前端js模块化演变
function时代 前端这几年发展太快了,我学习的速度都跟不上演变的速度了(门派太多了,后台都是大牛公司支撑类似于facebook的react.google的angular,angular的1.0还 ...
随机推荐
- ASP.NET后台怎么输出方法中间调试信息?
后台方法,不止是aspx.cs,而是页面调用的一些其它方法.想调试这些方法,我以前winform都是MessageBox.Show一些中间结果,现在我也想用这种方式.但想想,网页会触发 Message ...
- Java property 的加载读取
方法一 Properties properties = new Properties(); InputStream stream = PropertiesUtil.class.getClassLoad ...
- 我也说说Emacs吧(2) - Emacs其实就是函数的组合
Emacs本质上是函数的组合 从帮助上看emacs有何不同 Vim和Sublime Text等编辑器,本质上是一个编辑器. 比如我们看看vim的帮助,是这个风格的,比如我要看i命令的帮助: <i ...
- 前端神器!!gulp livereload实现浏览器自动刷新
首先gulp是基于Node的,所以确保你已经安装 node.js,在Nodejs官方网站下载跟自己操作系统相对应的安装包. 先说一下gulp安装流程: 1:全局安装gulp,操作为: npm inst ...
- gdi+ 中发生一般性错误 wpf解决方法
错误背景:原来在winform程序中写了一个窗口,在wpf应用程序中调用显示了这个窗口,有个头像功能,加载本地的一个图片文件,加载前进行了各种逻辑判断,效果如下: 而加载的关键代码如下面: pictu ...
- OK335xS 系统启动配置解析
OK335xS 系统启动配置解析 一.参考文档: AM335x ARM® Cortex™-A8 Microprocessors (MPUs) Technical Reference Manual 二. ...
- 【剑指offer】不使用新变量,交换两个变量的值,C++实现
# 题目 不使用新变量,交换两个变量的值. # 思路 方法一:使用加减法操作,交换两个变量的值. A = A+B B = A-B A = A-B 方法二:使用异或运算,交换两个变量的值 A = A^B ...
- Android学习笔记之Android Studio添加新的Activity
1.创建Android项目工程:AndroidTest 创建过程可参考网上诸多教程. 2.添加新的Activity,步骤如下 a. 在layout文件夹上右键,New-Activity-相应Activ ...
- 用两个stack实现一个队列
class Queue { stack<int> input, output; public: void push(int x) { input.push(x); } void pop(v ...
- iOS Webview打开不受信的URL
在我们开发过程中经常会碰到直接访问开发人员的私有地址, 这样在app 上是无法打开指定的网页的. 在iOS中需要对WKWebView 进行如下设置: 1.在工程的Plist 文件中添加一下选项 App ...