<div dir="ltr"><div class="gmail_default" style="font-family:tahoma,sans-serif">Dear Mag,</div><div class="gmail_default" style="font-family:tahoma,sans-serif">The following code</div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">my $gene_adaptor = $registry->get_adaptor('human', 'core', 'Gene');<br>my @genes = @{ $gene_adaptor->fetch_all_by_external_name("HLA-DRB1") };<br>while (my $gene = shift @genes) {<br>  my $d_id = $gene->display_xref->display_id;<br>  print "display_id=" . $d_id . " ";<br>  print "stable_id=" . $gene->stable_id . " ";<br>  print "is_reference=" . $gene->slice->is_reference() . "\n";<br>}  <br></div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">generates the following output</div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif"></div><div class="gmail_default" style="font-family:tahoma,sans-serif">display_id=HLA-A stable_id=ENSG00000206503 is_reference=1<br>display_id=HLA-B stable_id=ENSG00000234745 is_reference=1<br>display_id=HLA-DRB1 stable_id=ENSG00000196126 is_reference=1<br>display_id=HLA-DRB5 stable_id=ENSG00000198502 is_reference=1<br>display_id=HLA-DRB3$0301 stable_id=ENSG00000230463 is_reference=0<br>display_id=HLA-B stable_id=ENSG00000224608 is_reference=0<br>display_id=DRB4 stable_id=ENSG00000231021 is_reference=0<br>display_id=HLA-DRB1 stable_id=ENSG00000206306 is_reference=0<br>display_id=HLA-B stable_id=ENSG00000232126 is_reference=0<br>display_id=HLA-A stable_id=ENSG00000206505 is_reference=0<br>display_id=HLA-A stable_id=ENSG00000231834 is_reference=0<br>display_id=HLA-DRB1 stable_id=ENSG00000228080 is_reference=0<br>display_id=DRB4 stable_id=ENSG00000227826 is_reference=0<br>display_id=HLA-B stable_id=ENSG00000223532 is_reference=0<br>display_id=HLA-B stable_id=ENSG00000206450 is_reference=0<br>display_id=HLA-DRB1 stable_id=ENSG00000206240 is_reference=0<br>display_id=HLA-DRB1 stable_id=ENSG00000236884 is_reference=0<br>display_id=HLA-A stable_id=ENSG00000227715 is_reference=0<br>display_id=HLA-A stable_id=ENSG00000229215 is_reference=0<br>display_id=HLA-A stable_id=ENSG00000235657 is_reference=0<br>display_id=HLA-DRB3 stable_id=ENSG00000196101 is_reference=0<br>display_id=HLA-A stable_id=ENSG00000223980 is_reference=0<br>display_id=HLA-DRB4 stable_id=ENSG00000227357 is_reference=0<br>display_id=HLA-A stable_id=ENSG00000224320 is_reference=0<br>display_id=HLA-B stable_id=ENSG00000228964 is_reference=0<br>display_id=HLA-DRB1 stable_id=ENSG00000229074 is_reference=0<br><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif">Some points:</div><div class="gmail_default" style="font-family:tahoma,sans-serif">1- ENSG00000196126 is the reference and I verified that with the web frontend.</div><div class="gmail_default" style="font-family:tahoma,sans-serif">2- HLA-DRB5 (ENSG00000198502) is retrieved as a reference while I queried HLA-DRB1. Is that something important that I have to consider? Is it safe to ignore that and stick to the ENSG00000196126.</div><div class="gmail_default" style="font-family:tahoma,sans-serif">3- There are many alternatives for what I queried. You said that it is better to consider the alternatives. So, which one to pick up?<br> </div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><font face="tahoma,sans-serif">Regards,<br>Mahmood</font><br><br><br></div></div></div>
<br><div class="gmail_quote">On Mon, Nov 20, 2017 at 12:16 PM, mag <span dir="ltr"><<a href="mailto:mr6@ebi.ac.uk" target="_blank">mr6@ebi.ac.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div text="#000000" bgcolor="#FFFFFF">
    Hi Mahmood,<br>
    <br>
    What you call the main instance of a gene is a gene located on a
    chromosome or scaffold. These can be identified with the following
    API call:<br>
    $gene->slice->is_reference<br>
    <br>
    The "Human alternative sequence Gene" are genes located on alternate
    sequences, either patch fixes or haplotypes.<br>
    In some cases, there is a sequencing error on the reference
    chromosome and the gene on the alternate sequence is a better
    choice.<br>
    You can select these with the following API call:<br>
    <br>
    my $aag_adaptor =
Bio::EnsEMBL::Registry->get_<wbr>DBAdaptor("Human","core","<wbr>AltAlleleGroup");<br>
    my $aag = $aag_adaptor->fetch_Group_by_<wbr>dbID($gene->dbID);<br>
    my $reference_gene = $aag->get_representative_Gene;<br>
    <br>
    If you are looking at retrieving only one version of a gene name and
    are looking for the most representative, I would recommend the
    second solution rather than arbitrarily selecting the one on the
    reference chromosome.<br>
    <br>
    <br>
    I hope this helps,<br>
    Magali<div><div class="h5"><br>
    <br>
    <div class="m_8080469051774675082moz-cite-prefix">On 18/11/2017 17:37, Mahmood Naderan
      wrote:<br>
    </div>
    </div></div><blockquote type="cite"><div><div class="h5">
      <div dir="ltr">
        <div class="gmail_default" style="font-family:tahoma,sans-serif">Hi,</div>
        <div class="gmail_default" style="font-family:tahoma,sans-serif">I
          use the following code to retrieve all instances of a gene
          name. Then I compare each display_id with the gene name that I
          have and if they match, I go further to process them.</div>
        <div class="gmail_default" style="font-family:tahoma,sans-serif"><br>
        </div>
        <div class="gmail_default" style="font-family:tahoma,sans-serif">my
          @genes = @{
          $gene_adaptor->fetch_all_by_<wbr>external_name('HLA-DRB1') };<br>
          while (my $gene = shift @genes) {<br>
            my $big_string = $gene->display_xref->display_<wbr>id;<br>
            my $pat = "HLA-DRB1";<br>
            my $match_found = $big_string =~ /$pat/i;<br>
            if ($match_found) {<br>
               ..</div>
        <div class="gmail_default" style="font-family:tahoma,sans-serif"> 
          }</div>
        <div class="gmail_default" style="font-family:tahoma,sans-serif">}</div>
        <div class="gmail_default" style="font-family:tahoma,sans-serif"><br>
        </div>
        <div class="gmail_default" style="font-family:tahoma,sans-serif">Problem
          is that I get multiple items and they display_id are equal to
          what I have (HLA-DRB1). On the website, the main instance is
          named and the others are named "Human Alternative sequence
          Gene". I don't want to store them. I just need the main "Human
          Gene".</div>
        <div class="gmail_default" style="font-family:tahoma,sans-serif"><br>
        </div>
        <div class="gmail_default" style="font-family:tahoma,sans-serif">What
          is the correct attribute to distinguish that?</div>
        <div class="gmail_default" style="font-family:tahoma,sans-serif"><br>
        </div>
        <div class="gmail_default" style="font-family:tahoma,sans-serif"><br clear="all">
        </div>
        <div>
          <div class="m_8080469051774675082gmail_signature">
            <div dir="ltr"><font face="tahoma,sans-serif">Regards,<br>
                Mahmood</font><br>
              <br>
              <br>
            </div>
          </div>
        </div>
      </div>
      <br>
      <fieldset class="m_8080469051774675082mimeAttachmentHeader"></fieldset>
      <br>
      </div></div><pre>______________________________<wbr>_________________
Dev mailing list    <a class="m_8080469051774675082moz-txt-link-abbreviated" href="mailto:Dev@ensembl.org" target="_blank">Dev@ensembl.org</a>
Posting guidelines and subscribe/unsubscribe info: <a class="m_8080469051774675082moz-txt-link-freetext" href="http://lists.ensembl.org/mailman/listinfo/dev" target="_blank">http://lists.ensembl.org/<wbr>mailman/listinfo/dev</a>
Ensembl Blog: <a class="m_8080469051774675082moz-txt-link-freetext" href="http://www.ensembl.info/" target="_blank">http://www.ensembl.info/</a>
</pre>
    </blockquote>
    <br>
  </div>

<br>______________________________<wbr>_________________<br>
Dev mailing list    <a href="mailto:Dev@ensembl.org">Dev@ensembl.org</a><br>
Posting guidelines and subscribe/unsubscribe info: <a href="http://lists.ensembl.org/mailman/listinfo/dev" rel="noreferrer" target="_blank">http://lists.ensembl.org/<wbr>mailman/listinfo/dev</a><br>
Ensembl Blog: <a href="http://www.ensembl.info/" rel="noreferrer" target="_blank">http://www.ensembl.info/</a><br>
<br></blockquote></div><br></div>