<div dir="ltr"><div><font face="arial, helvetica, sans-serif" color="#000000"><span style="line-height:18px;white-space:pre-wrap">Hi,</span></font></div><div><font face="arial, helvetica, sans-serif" color="#000000"><span style="line-height:18px;white-space:pre-wrap"><br>
</span></font></div><div><span style="line-height:18px;white-space:pre-wrap;color:rgb(0,0,0);font-family:arial,helvetica,sans-serif">I am interested in getting wide cross references to ensembl gene IDs. I found two programmatic ways to do that which give consistent results but different amount of details. Using ENSG00000223972 as an example:</span><br>
</div><div><font face="arial, helvetica, sans-serif" color="#000000"><span style="line-height:18px;white-space:pre-wrap">(1)</span></font></div><div><font face="arial, helvetica, sans-serif" color="#000000"><span style="line-height:18px;white-space:pre-wrap">Using this rest API Endpoint python code (<a href="http://beta.rest.ensembl.org/documentation/info/xref_id">http://beta.rest.ensembl.org/documentation/info/xref_id</a>)</span></font></div>
<div><br></div><ol class="" style="padding:0px;margin:0px 0px 0px 33px;color:rgb(51,51,51);font-family:Monaco,Menlo,Consolas,'Courier New',monospace;font-size:13px;line-height:20px;white-space:pre-wrap"><li class="" style="line-height:18px;list-style-type:decimal;color:rgb(190,190,197);padding-left:12px">
<span class="" style="color:rgb(0,0,136)">import</span><span class="" style="color:rgb(0,0,0)"> httplib2</span><span class="" style="color:rgb(102,102,0)">,</span><span class="" style="color:rgb(0,0,0)"> sys</span></li><li class="" style="line-height:18px;list-style-type:decimal;background-color:rgb(238,238,238);color:rgb(190,190,197);padding-left:12px">
<span class="" style="color:rgb(0,0,0)"> </span></li><li class="" style="line-height:18px;list-style-type:decimal;color:rgb(190,190,197);padding-left:12px"><span class="" style="color:rgb(0,0,0)">http </span><span class="" style="color:rgb(102,102,0)">=</span><span class="" style="color:rgb(0,0,0)"> httplib2</span><span class="" style="color:rgb(102,102,0)">.</span><span class="" style="color:rgb(102,0,102)">Http</span><span class="" style="color:rgb(102,102,0)">(</span><span class="" style="color:rgb(0,136,0)">".cache"</span><span class="" style="color:rgb(102,102,0)">)</span></li>
<li class="" style="line-height:18px;list-style-type:decimal;background-color:rgb(238,238,238);color:rgb(190,190,197);padding-left:12px"><span class="" style="color:rgb(0,0,0)"> </span></li><li class="" style="line-height:18px;color:rgb(190,190,197);list-style-type:decimal;padding-left:12px">
<span class="" style="color:rgb(0,0,0)">server </span><span class="" style="color:rgb(102,102,0)">=</span><span class="" style="color:rgb(0,0,0)"> </span><span class="" style="color:rgb(0,136,0)">"<a href="http://beta.rest.ensembl.org">http://beta.rest.ensembl.org</a>"</span></li>
<li class="" style="line-height:18px;list-style-type:decimal;background-color:rgb(238,238,238);color:rgb(190,190,197);padding-left:12px"><span class="" style="color:rgb(0,0,0)">ext </span><span class="" style="color:rgb(102,102,0)">=</span><span class="" style="color:rgb(0,0,0)"> </span><span class="" style="color:rgb(0,136,0)">"/xrefs/id/ENSG00000157764?"</span></li>
<li class="" style="line-height:18px;list-style-type:decimal;color:rgb(190,190,197);padding-left:12px"><span class="" style="color:rgb(0,0,0)">resp</span><span class="" style="color:rgb(102,102,0)">,</span><span class="" style="color:rgb(0,0,0)"> content </span><span class="" style="color:rgb(102,102,0)">=</span><span class="" style="color:rgb(0,0,0)"> http</span><span class="" style="color:rgb(102,102,0)">.</span><span class="" style="color:rgb(0,0,0)">request</span><span class="" style="color:rgb(102,102,0)">(</span><span class="" style="color:rgb(0,0,0)">server</span><span class="" style="color:rgb(102,102,0)">+</span><span class="" style="color:rgb(0,0,0)">ext</span><span class="" style="color:rgb(102,102,0)">,</span><span class="" style="color:rgb(0,0,0)"> method</span><span class="" style="color:rgb(102,102,0)">=</span><span class="" style="color:rgb(0,136,0)">"GET"</span><span class="" style="color:rgb(102,102,0)">,</span><span class="" style="color:rgb(0,0,0)"> headers</span><span class="" style="color:rgb(102,102,0)">={</span><span class="" style="color:rgb(0,136,0)">"Content-Type"</span><span class="" style="color:rgb(102,102,0)">:</span><span class="" style="color:rgb(0,136,0)">"application/json"</span><span class="" style="color:rgb(102,102,0)">})</span></li>
<li class="" style="line-height:18px;list-style-type:decimal;background-color:rgb(238,238,238);color:rgb(190,190,197);padding-left:12px"><span class="" style="color:rgb(0,0,0)"> </span></li><li class="" style="line-height:18px;list-style-type:decimal;color:rgb(190,190,197);padding-left:12px">
<span class="" style="color:rgb(0,0,136)">if</span><span class="" style="color:rgb(0,0,0)"> </span><span class="" style="color:rgb(0,0,136)">not</span><span class="" style="color:rgb(0,0,0)"> resp</span><span class="" style="color:rgb(102,102,0)">.</span><span class="" style="color:rgb(0,0,0)">status </span><span class="" style="color:rgb(102,102,0)">==</span><span class="" style="color:rgb(0,0,0)"> </span><span class="" style="color:rgb(0,102,102)">200</span><span class="" style="color:rgb(102,102,0)">:</span></li>
<li class="" style="line-height:18px;background-color:rgb(238,238,238);color:rgb(190,190,197);list-style-type:decimal;padding-left:12px"><span class="" style="color:rgb(0,0,0)">  </span><span class="" style="color:rgb(0,0,136)">print</span><span class="" style="color:rgb(0,0,0)"> </span><span class="" style="color:rgb(0,136,0)">"Invalid response: "</span><span class="" style="color:rgb(102,102,0)">,</span><span class="" style="color:rgb(0,0,0)"> resp</span><span class="" style="color:rgb(102,102,0)">.</span><span class="" style="color:rgb(0,0,0)">status</span></li>
<li class="" style="line-height:18px;list-style-type:decimal;color:rgb(190,190,197);padding-left:12px"><span class="" style="color:rgb(0,0,0)">  sys</span><span class="" style="color:rgb(102,102,0)">.</span><span class="" style="color:rgb(0,0,136)">exit</span><span class="" style="color:rgb(102,102,0)">()</span></li>
<li class="" style="line-height:18px;list-style-type:decimal;background-color:rgb(238,238,238);color:rgb(190,190,197);padding-left:12px"><span class="" style="color:rgb(0,0,136)">import</span><span class="" style="color:rgb(0,0,0)"> json</span></li>
<li class="" style="line-height:18px;list-style-type:decimal;color:rgb(190,190,197);padding-left:12px"><span class="" style="color:rgb(0,0,0)"> </span></li><li class="" style="line-height:18px;list-style-type:decimal;background-color:rgb(238,238,238);color:rgb(190,190,197);padding-left:12px">
<span class="" style="color:rgb(0,0,0)">decoded </span><span class="" style="color:rgb(102,102,0)">=</span><span class="" style="color:rgb(0,0,0)"> json</span><span class="" style="color:rgb(102,102,0)">.</span><span class="" style="color:rgb(0,0,0)">loads</span><span class="" style="color:rgb(102,102,0)">(</span><span class="" style="color:rgb(0,0,0)">content</span><span class="" style="color:rgb(102,102,0)">)</span></li>
<li class="" style="line-height:18px;color:rgb(190,190,197);list-style-type:decimal;padding-left:12px"><span class="" style="color:rgb(0,0,136)">print</span><span class="" style="color:rgb(0,0,0)"> repr</span><span class="" style="color:rgb(102,102,0)">(</span><span class="" style="color:rgb(0,0,0)">decoded</span><span class="" style="color:rgb(102,102,0)">)</span></li>
</ol><div><br></div><div>I get:</div><div><br></div><div><div>{"display_id":"OTTHUMG00000000961","primary_id":"OTTHUMG00000000961","version":"2","description":null,"dbname":"OTTG","synonyms":[],"info_type":"NONE","info_text":"","db_display_name":"Havana gene"}</div>
<div><br></div><div>{"primary_id":"Hs.714157","dbname":"UniGene","ensembl_identity":98,"synonyms":[],"ensembl_start":6,"xref_start":1,"xref_end":1639,"db_display_name":"UniGene","display_id":"Hs.714157","ensembl_end":1657,"version":"0","score":8055,"cigar_line":"1200M1D299M12D140M","description":"DEAD/H (Asp-Glu-Ala-Asp/His) box helicase 11 like 1","xref_identity":97,"evalue":null,"info_text":"","info_type":"SEQUENCE_MATCH"}</div>
<div><br></div><div>{"primary_id":"Hs.618434","dbname":"UniGene","ensembl_identity":58,"synonyms":[],"ensembl_start":669,"xref_start":1,"xref_end":974,"db_display_name":"UniGene","display_id":"Hs.618434","ensembl_end":1655,"version":"0","score":4757,"cigar_line":"537M1D299M12D138M","description":"Similar to DEAD/H (Asp-Glu-Ala-Asp/His) box polypeptide 11 isoform 1, mRNA (cDNA clone IMAGE:6103207)","xref_identity":96,"evalue":null,"info_text":"","info_type":"SEQUENCE_MATCH"}</div>
<div><br></div><div>{"display_id":"DDX11L1","primary_id":"37102","version":"0","description":"DEAD/H (Asp-Glu-Ala-Asp/His) box helicase 11 like 1","dbname":"HGNC","synonyms":[],"info_type":"DIRECT","info_text":"Generated via ensembl_manual","db_display_name":"HGNC Symbol"}</div>
<div><br></div><div>{"display_id":"DDX11L5","primary_id":"100287596","version":"0","description":"DEAD/H (Asp-Glu-Ala-Asp/His) box helicase 11 like 5","dbname":"EntrezGene","synonyms":[],"info_type":"DEPENDENT","info_text":"","db_display_name":"EntrezGene"}</div>
<div><br></div><div>{"display_id":"DDX11L1","primary_id":"100287102","version":"0","description":"DEAD/H (Asp-Glu-Ala-Asp/His) box helicase 11 like 1","dbname":"EntrezGene","synonyms":[],"info_type":"DEPENDENT","info_text":"","db_display_name":"EntrezGene"}</div>
<div><br></div><div>{"display_id":"ENSG00000223972","primary_id":"ENSG00000223972","version":"0","description":"","dbname":"ArrayExpress","synonyms":[],"info_type":"DIRECT","info_text":"","db_display_name":"ArrayExpress"}</div>
<div><br></div><div>{"display_id":"DDX11L5","primary_id":"100287596","version":"0","description":"DEAD/H (Asp-Glu-Ala-Asp/His) box helicase 11 like 5","dbname":"WikiGene","synonyms":[],"info_type":"DEPENDENT","info_text":"","db_display_name":"WikiGene"}</div>
<div><br></div><div>{"display_id":"DDX11L1","primary_id":"100287102","version":"0","description":"DEAD/H (Asp-Glu-Ala-Asp/His) box helicase 11 like 1","dbname":"WikiGene","synonyms":[],"info_type":"DEPENDENT","info_text":"","db_display_name":"WikiGene"}]</div>
<div><br></div></div><div>(2)</div><div><br></div><div>Using this perl API code (based on <a href="http://www.ensembl.org/info/docs/api/core/core_tutorial.html">http://www.ensembl.org/info/docs/api/core/core_tutorial.html</a>):</div>
<div><br></div><div><pre class="" style="margin-top:0px;margin-bottom:16px;border:1px solid rgb(204,204,204);background-color:rgb(240,240,240);padding:8px!important"><font color="#555555" face="courier new, monospace"><span style="line-height:16px"># Define a helper subroutine to print DBEntries
sub print_DBEntries
{
    my $db_entries = shift;

    foreach my $dbe ( @{$db_entries} ) {
        printf "\tXREF %s (%s)\n", $dbe->display_id(), $dbe->dbname();
    }
}

my $genes = $gene_adaptor->fetch_all_by_stable_id_list([@gene_list]);</span></font></pre><pre class="" style="margin-top:0px;margin-bottom:16px;border:1px solid rgb(204,204,204);background-color:rgb(240,240,240);line-height:16px;color:rgb(85,85,85);padding:8px!important">
<font face="courier new, monospace">
...</font></pre><pre class="" style="margin-top:0px;margin-bottom:16px;border:1px solid rgb(204,204,204);background-color:rgb(240,240,240);line-height:16px;color:rgb(85,85,85);padding:8px!important"><font face="courier new, monospace">
print "GENE ", $gene->stable_id(), "\n";
print_DBEntries( $gene->get_all_DBEntries() );</font></pre></div><div><div><span class="" style="white-space:pre">I get:</span></div><div><span class="" style="white-space:pre">        </span></div><div>XREF OTTHUMG00000000961 (OTTG)</div>
<div>XREF ENSG00000223972 (ArrayExpress)</div><div>XREF DDX11L1 (EntrezGene)</div><div>XREF DDX11L5 (EntrezGene)</div><div>XREF DDX11L1 (HGNC)</div><div>XREF Hs.618434 (UniGene)</div><div>XREF Hs.714157 (UniGene)</div><div>
XREF DDX11L1 (WikiGene)</div><div>XREF DDX11L5 (WikiGene)</div></div><div><br></div><div><br></div><div>Questions:</div><div><br></div><div>1. am I correct in saying that the Rest code uses the latest Ensembl release while the API code uses the Ensembl release currently installed as part of the VM (I am using release 74)?</div>
<div><br></div><div>2. Rest code gives more extensive details (which I like) compared to the perl API code. Could you suggest a simple way to use the API to get the same details?</div><div><br></div><div>3. The Rest code output format. Is tab separated text supported?<br>
</div><div><br></div><div>4. Is there a  file in the Ensembl ftp area which contains pre generated detailed cross ref mappings for all current Ensembl genes?</div>-- <div><br></div><div>Thanks,</div><div><br><div dir="ltr">
G.</div>
</div></div>