{"id":91,"date":"2013-08-22T22:41:59","date_gmt":"2013-08-22T22:41:59","guid":{"rendered":"http:\/\/evolvedmicrobe.com\/blogs\/?p=91"},"modified":"2013-08-23T14:44:21","modified_gmt":"2013-08-23T14:44:21","slug":"accessing-dbsnp-with-c-and-the-net-platform","status":"publish","type":"post","link":"http:\/\/evolvedmicrobe.com\/blogs\/?p=91","title":{"rendered":"Accessing dbSNP with C# and the .NET Platform"},"content":{"rendered":"<p>NCBI Entrez can be accessed with many different platforms (python, R, etc.) , but I find .NET one of the best because the static typing makes it easy to infer what all the datafields mean, and navigate the data with much greater ease. <\/p> <p>Documentation is sparse for this task, but here is how to access NCBI from the .NET platform.&nbsp; The example steps\/program show how to query dbSNP for information about particular ids.<\/p> <ol> <li>Open visual studio, start a new project and add two Service References to the project<b>: <\/b><a href=\"http:\/\/eutils.ncbi.nlm.nih.gov\/soap\/v2.0\/eutils.wsdl\"><b>http:\/\/eutils.ncbi.nlm.nih.gov\/soap\/v2.0\/eutils.wsdl<\/b><\/a> and <a href=\"http:\/\/eutils.ncbi.nlm.nih.gov\/soap\/v2.0\/efetch_snp.wsdl\"><b>http:\/\/eutils.ncbi.nlm.nih.gov\/soap\/v2.0\/efetch_snp.wsdl<\/b><\/a> files. Note that the efetch depends on the database used, in this case \u201csnp\u201d other databases have different ones.&nbsp; You should now have two references:<a href=\"https:\/\/i0.wp.com\/evolvedmicrobe.com\/blogs\/wp-content\/uploads\/2013\/08\/image.png\"><img loading=\"lazy\" title=\"image\" style=\"border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; float: none; padding-top: 0px; padding-left: 0px; margin-left: auto; border-left: 0px; display: block; padding-right: 0px; margin-right: auto\" border=\"0\" alt=\"image\" src=\"https:\/\/i0.wp.com\/evolvedmicrobe.com\/blogs\/wp-content\/uploads\/2013\/08\/image_thumb.png?resize=195%2C129\" width=\"195\" height=\"129\"  data-recalc-dims=\"1\"><\/a><\/li><\/ol>  <p>More information is available here on setting up visual studio: <a title=\"http:\/\/www.ncbi.nlm.nih.gov\/books\/NBK55694\/\" href=\"http:\/\/www.ncbi.nlm.nih.gov\/books\/NBK55694\/\">http:\/\/www.ncbi.nlm.nih.gov\/books\/NBK55694\/<\/a><\/p> <p>2. Next up grab the data as shown in the example.&nbsp; Each SNP has A LOT more data, which can be inspected in the IDE.<\/p> \r\n\r\n <div class=\"csharpcode\"><pre class=\"alt\"><span class=\"lnum\">   1:  <\/span><span class=\"kwrd\">static<\/span> <span class=\"kwrd\">void<\/span> Main(<span class=\"kwrd\">string<\/span>[] args)<\/pre><pre><span class=\"lnum\">   2:  <\/span>{        <\/pre><pre class=\"alt\"><span class=\"lnum\">   3:  <\/span>        <span class=\"kwrd\">string<\/span> dbSNPid=<span class=\"str\">\"28357684\"<\/span>;<\/pre><pre><span class=\"lnum\">   4:  <\/span>        efetch.eFetchRequest re = <span class=\"kwrd\">new<\/span> efetch.eFetchRequest();<\/pre><pre class=\"alt\"><span class=\"lnum\">   5:  <\/span>        re.id = dbSNPid;<\/pre><pre><span class=\"lnum\">   6:  <\/span>        var serv=<span class=\"kwrd\">new<\/span> efetch.eUtilsServiceSoapClient();<\/pre><pre class=\"alt\"><span class=\"lnum\">   7:  <\/span>        var exchange = serv.run_eFetch(re);<\/pre><pre><span class=\"lnum\">   8:  <\/span>        var snpData = exchange.ExchangeSet.Rs[0];<\/pre><pre class=\"alt\"><span class=\"lnum\">   9:  <\/span>        <span class=\"kwrd\">object<\/span>[] dataToReport=<span class=\"kwrd\">new<\/span> <span class=\"kwrd\">object<\/span>[] {<\/pre><pre><span class=\"lnum\">  10:  <\/span>            snpData.Het.<span class=\"kwrd\">value<\/span>,<\/pre><pre class=\"alt\"><span class=\"lnum\">  11:  <\/span>            snpData.hgvs.First(),<\/pre><pre><span class=\"lnum\">  12:  <\/span>            snpData.PrimarySequence.First().accession,<\/pre><pre class=\"alt\"><span class=\"lnum\">  13:  <\/span>        };<\/pre><pre><span class=\"lnum\">  14:  <\/span>        Console.WriteLine( String.Join(<span class=\"str\">\"\\t\"<\/span>,dataToReport.Select(x=&gt;x.ToString()).ToArray())); <\/pre><pre class=\"alt\"><span class=\"lnum\">  15:  <\/span>        Console.ReadLine();<\/pre><pre><span class=\"lnum\">  16:  <\/span>}<\/pre><\/div>\r\n<style type=\"text\/css\">.csharpcode, .csharpcode pre\r\n{\r\n\tfont-size: small;\r\n\tcolor: black;\r\n\tfont-family: consolas, \"Courier New\", courier, monospace;\r\n\tbackground-color: #ffffff;\r\n        padding: 0px;\r\n\t\/*white-space: pre;*\/\r\n}\r\n.csharpcode pre { margin: 0em; }\r\n.csharpcode .rem { color: #008000; }\r\n.csharpcode .kwrd { color: #0000ff; }\r\n.csharpcode .str { color: #006080; }\r\n.csharpcode .op { color: #0000c0; }\r\n.csharpcode .preproc { color: #cc6633; }\r\n.csharpcode .asp { background-color: #ffff00; }\r\n.csharpcode .html { color: #800000; }\r\n.csharpcode .attr { color: #ff0000; }\r\n.csharpcode .alt \r\n{\r\n\tbackground-color: #f4f4f4;\r\n\twidth: 100%;\r\n\tmargin: 0em;\r\n}\r\n.csharpcode .lnum { color: #606060; }\r\n<\/style>\r\n\r\n\r\n<p>The following links contain other useful information for consuming the entrez webservice in C#.<\/p>\r\n<p>Setting up visual studio: <a title=\"http:\/\/www.ncbi.nlm.nih.gov\/books\/NBK55694\/\" href=\"http:\/\/www.ncbi.nlm.nih.gov\/books\/NBK55694\/\">http:\/\/www.ncbi.nlm.nih.gov\/books\/NBK55694\/<\/a><\/p>\r\n<p>Using efetch: <a href=\"http:\/\/www.ncbi.nlm.nih.gov\/books\/NBK55694\/#csharp_msvs.Call_HYPERLINK__chaptercha_8\">http:\/\/www.ncbi.nlm.nih.gov\/books\/NBK55694\/#csharp_msvs.Call_HYPERLINK__chaptercha_8<\/a><\/p>\r\n<p>Forming queries: <a href=\"http:\/\/www.biostars.org\/p\/3436\/\">http:\/\/www.biostars.org\/p\/3436\/<\/a><\/p>\r\n<p> More information: <a href=\"http:\/\/eutils.ncbi.nlm.nih.gov\/entrez\/eutils\/soap\/v2.0\/DOC\/esoap_help.html\">http:\/\/eutils.ncbi.nlm.nih.gov\/entrez\/eutils\/soap\/v2.0\/DOC\/esoap_help.html<\/a><\/p>\r\n\r\nAlso note that the first query takes much longer than subsequent ones, for reasons unknown to me at present.","protected":false},"excerpt":{"rendered":"NCBI Entrez can be accessed with many different platforms (python, R, etc.) , but I find .NET one of the best because the static typing makes it easy to infer what all the datafields mean, and navigate the data with much greater ease. Documentation is sparse for this task, but here is how to access [&hellip;]","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[14,8,3],"tags":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":398,"url":"http:\/\/evolvedmicrobe.com\/blogs\/?p=398","url_meta":{"origin":91,"position":0},"title":".NET Bio is Significantly Faster on .Net Core 2.0","date":"November 5, 2017","format":false,"excerpt":"Summary: With the release of .NET Core 2.0, .NET Bio is able to run significantly faster (~2X) on Mac OSX due to better compilation and memory mangement. The .NET Bio\u00a0library contains libraries for genomic data processing tasks like parsing, alignment, etc. that are too computationally intense to be\u00a0undertaken with interpreted\u2026","rel":"","context":"In \".NET Bio\"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/evolvedmicrobe.com\/blogs\/wp-content\/uploads\/2017\/11\/Benchmark-1.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":71,"url":"http:\/\/evolvedmicrobe.com\/blogs\/?p=71","url_meta":{"origin":91,"position":1},"title":"Java vs. C# Performance Comparison for Parsing VCF Files","date":"May 26, 2013","format":false,"excerpt":"Making a comparison with a reasonably complex program ported between the two languages. Update 3\/10\/2014: After writing this post I changed the C# parser to remove an extra List<> allocation in the C# code that was not in the Java code.\u00a0\u00a0After this, the Java\/C# versions are indistinguishable on speed, but\u2026","rel":"","context":"In &quot;Algorithms&quot;","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/evolvedmicrobe.com\/blogs\/wp-content\/uploads\/2013\/05\/image_thumb1.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":188,"url":"http:\/\/evolvedmicrobe.com\/blogs\/?p=188","url_meta":{"origin":91,"position":2},"title":"The .NET Bio BAM Parser is Smoking Fast","date":"October 12, 2013","format":false,"excerpt":"The .NET Bio library has an improved version of it's BAM file\u00a0parser, which makes it significantly faster and easily competitive with the\u00a0current standard C coded SAMTools for obtaining\u00a0sequencing data and working with it. The chart below compares the time it\u00a0takes in seconds for the old version of the parser and\u2026","rel":"","context":"In &quot;.NET Bio&quot;","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/evolvedmicrobe.com\/blogs\/wp-content\/uploads\/2013\/10\/img5.gif?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":6,"url":"http:\/\/evolvedmicrobe.com\/blogs\/?p=6","url_meta":{"origin":91,"position":3},"title":"Not All Poisson Random Variables Are Created Equally","date":"January 30, 2013","format":false,"excerpt":"Spurred by a slow running program, I spent an afternoon researching what algorithms are available for generating Poisson random variables and figuring out which methods are used by R, Matlab, NumPy, the GNU Science Libraray and various other available packages. I learned some things that I think would be useful\u2026","rel":"","context":"In &quot;Algorithms&quot;","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/evolvedmicrobe.com\/blogs\/wp-content\/uploads\/2013\/01\/img34-300x239.jpg?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":153,"url":"http:\/\/evolvedmicrobe.com\/blogs\/?p=153","url_meta":{"origin":91,"position":4},"title":"Using Selectome with .NET Bio, F# and R","date":"September 16, 2013","format":false,"excerpt":"The Bio.Selectome namespace has features to query\u00a0Selectome.Selectome is a database that merges data from Ensembl\u00a0and the programs in PAML used to compute the ratio of non-synonymous to synonymous (dN\/dS)\u00a0mutations along various branches of the phylogenetic tree. A low dN\/dS ratio\u00a0indicates that the protein sequence is under strong selective constraint, while\u2026","rel":"","context":"In &quot;.NET Bio&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":112,"url":"http:\/\/evolvedmicrobe.com\/blogs\/?p=112","url_meta":{"origin":91,"position":5},"title":"Mono.Simd and the Mandlebrot Set.","date":"September 10, 2013","format":false,"excerpt":"C# and .NET are some of the fastest high level languages, but still cannot truly compete with C\/C++ for low level speed, and C# code can be anywhere from 20%-300% slower. This is despite the fact that the C# compiler often gets as much information about a method as the\u2026","rel":"","context":"In &quot;Algorithms&quot;","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/evolvedmicrobe.com\/blogs\/wp-content\/uploads\/2013\/09\/img2_thumb.gif?resize=350%2C200","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"http:\/\/evolvedmicrobe.com\/blogs\/index.php?rest_route=\/wp\/v2\/posts\/91"}],"collection":[{"href":"http:\/\/evolvedmicrobe.com\/blogs\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/evolvedmicrobe.com\/blogs\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/evolvedmicrobe.com\/blogs\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/evolvedmicrobe.com\/blogs\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=91"}],"version-history":[{"count":15,"href":"http:\/\/evolvedmicrobe.com\/blogs\/index.php?rest_route=\/wp\/v2\/posts\/91\/revisions"}],"predecessor-version":[{"id":107,"href":"http:\/\/evolvedmicrobe.com\/blogs\/index.php?rest_route=\/wp\/v2\/posts\/91\/revisions\/107"}],"wp:attachment":[{"href":"http:\/\/evolvedmicrobe.com\/blogs\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=91"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/evolvedmicrobe.com\/blogs\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=91"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/evolvedmicrobe.com\/blogs\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=91"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}