<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>Dear Duarte,<br>
      <br>
    </p>
    <p>Most of the "failed" variants don't have mapping data, therefore
      they don't get variation_feature entries.</p>
    <p>Here is a suggestion of code, using the method "is_failed" from
      the Variation object:<br>
    </p>
    use strict; 
    <div dir="ltr">use warnings; </div>
    <div dir="ltr">use Bio::EnsEMBL::Registry; </div>
    <div dir="ltr">my $registry = 'Bio::EnsEMBL::Registry'; </div>
    $registry->load_registry_from_db( -host => '<a
      href="http://ensembldb.ensembl.org">ensembldb.ensembl.org</a>',
    -user => 'anonymous' );
    <p>...<br>
    </p>
    <p>my $variation_adaptor = $registry->get_adaptor('human',
      'variation', 'variation');<br>
      $variation_adaptor->db->include_failed_variations(1);<br>
      <br>
      foreach my $id (@rsids){<br>
          if ($id =~ /^rs/i){<br>
              my $variation = $variation_adaptor->fetch_by_name($id);<br>
              if ($variation){<br>
                  if ($variation->is_failed) {<br>
                      $progress->message("FAILED: $id -
      ".$variation->failed_description()."\n");<br>
                  } else {<br>
                      foreach my $vf
      (@{$variation->get_all_VariationFeatures()}){<br>
                          ...<br>
                      }<br>
                  }<br>
              } else {<br>
                  $progress->message("FAILED: $id - No variation
      found in DB\n");<br>
              }<br>
          }<br>
      }</p>
    <p>Best regards,<br>
    </p>
    <pre class="moz-signature" cols="72">Laurent
Ensembl Variation
</pre>
    <div class="moz-cite-prefix">On 08/10/2018 11:01, Duarte Molha
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAGqkoEKe2bJzB+ZmOtf7k+6v1qe7FCqNy-Kd9YicmAVbhbCu1Q@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">
        <div dir="ltr">
          <div dir="ltr">
            <div dir="ltr">Dear Developers
              <div><br>
              </div>
              <div>I created a script to query the database and retrieve
                details of some SNPs ( taking as input the RS id of
                those SNPS)</div>
              <div><br>
              </div>
              <div>I wanted to change it so that I could also obtain
                information for Failed SNPS. </div>
              <div><br>
              </div>
              <div>the script is really simple the gist being :</div>
              <div><br>
              </div>
              use strict; </div>
            <div dir="ltr">use warnings; </div>
            <div dir="ltr">use Bio::EnsEMBL::Registry; </div>
            <div dir="ltr">my $registry = 'Bio::EnsEMBL::Registry'; </div>
            <div dir="ltr">$registry->load_registry_from_db( -host
              => '<a href="http://ensembldb.ensembl.org"
                moz-do-not-send="true">ensembldb.ensembl.org</a>', -user
              => 'anonymous' );
              <div><br>
              </div>
              <div>
                <div>
                  <div>foreach my $id (@rsids){</div>
                  <div><span style="white-space:pre">     </span>chomp $id;</div>
                  <div><span style="white-space:pre">     </span>if ($id =~
                    /^rs/i){</div>
                  <div><span style="white-space:pre">             </span>my
                    $variation =
                    $variation_adaptor->fetch_by_name($id);</div>
                  <div><span style="white-space:pre">             </span>if
                    ($variation){</div>
                  <div><span style="white-space:pre">                             </span>foreach
                    my $vf
                    (@{$vf_adaptor->fetch_all_by_Variation($variation)}){</div>
                  <div><span style="white-space:pre">                                     </span>my
                    $varClass= $vf->class_SO_term();</div>
                  <div><span style="white-space:pre">                                     </span>my
                    $start = $vf->seq_region_start()-1;</div>
                  <div><span style="white-space:pre">                                     </span>my $end
                    = $vf->seq_region_end();</div>
                  <div><span style="white-space:pre">                                     </span>if($varClass
                    eq "insertion"){</div>
                  <div><span style="white-space:pre">                                             </span>$end++;</div>
                  <div><span style="white-space:pre">                                     </span>}</div>
                  <div><span style="white-space:pre">                                     </span>my
                    $allele_string = $vf->allele_string;</div>
                  <div><br>
                  </div>
                  <div><span style="white-space:pre">                                     </span>if
                    ($vf->strand eq "-1"){</div>
                  <div><span style="white-space:pre">                                             </span>my
                    $strand ="-";</div>
                  <div><span style="white-space:pre">                                             </span>my
                    $allele_string = $vf->allele_string;</div>
                  <div><span style="white-space:pre">                                             </span>$allele_string
                    =~ tr/ATGCatgc/TACGtacg/;</div>
                  <div><span style="white-space:pre">                                             </span>print
                    "chr".$vf->seq_region_name, $start, $end,
                    $vf->variation_name().";".$varClass.";".$allele_string,"0",
                    $strand."\n";</div>
                  <div><span style="white-space:pre">                                     </span>}else{</div>
                  <div><span style="white-space:pre">                                             </span>my
                    $strand ="+";</div>
                  <div><span style="white-space:pre">                                             </span>print
                    "chr".$vf->seq_region_name, $start, $end,
                    $vf->variation_name().";".$varClass.";".$allele_string,"0",
                    $strand."\n";</div>
                  <div><span style="white-space:pre">                                     </span>}</div>
                  <div><span style="white-space:pre">                             </span>}</div>
                  <div><span style="white-space:pre">             </span>}else{</div>
                  <div><span style="white-space:pre">                     </span>$progress->message("FAILED:
                    $id\n");</div>
                  <div><span style="white-space:pre">             </span>}</div>
                  <div><span style="white-space:pre">     </span>}</div>
                  <div>}</div>
                </div>
              </div>
              <div><br>
              </div>
              <div>I looked at the documentation and you indicate I
                should use  something like:</div>
              <div><br>
              </div>
              <div>
                <pre class="gmail-code gmail-sh_perl gmail-sh_sourceCode" style="font-family:Consolas,"Bitstream Vera Sans Mono","Courier New",Courier,monospace;font-size:12.8px;margin-top:0px;margin-bottom:16px;border:1px solid rgb(204,204,204);background:rgb(250,250,250);overflow:auto;color:rgb(51,51,51);line-height:16px;padding:8px"><span class="gmail-sh_variable" style="font-size:1em;color:rgb(170,119,0)">$vf_adaptor</span><span class="gmail-sh_symbol" style="font-size:1em;color:rgb(127,0,85)">-></span><span class="gmail-sh_function" style="font-size:1em;color:rgb(255,20,147)">db</span><span class="gmail-sh_symbol" style="font-size:1em;color:rgb(127,0,85)">-></span><span class="gmail-sh_function" style="font-size:1em;color:rgb(255,20,147)">include_failed_variations</span><span class="gmail-sh_symbol" style="font-size:1em;color:rgb(127,0,85)">(</span><span class="gmail-sh_number" style="font-size:1em;color:rgb(13,163,68)">1</span><span class="gmail-sh_symbol" style="font-size:1em;color:rgb(127,0,85)">);</span>
</pre>
                <br class="gmail-Apple-interchange-newline">
              </div>
              <div>But for a failed variation </div>
              <div><br>
              </div>
              <div>this part of the code:</div>
              <div>
                <div><span style="white-space:pre">               </span>my
                  $variation =
                  $variation_adaptor->fetch_by_name($id);</div>
                <br class="gmail-Apple-interchange-newline">
              </div>
              <div><br>
              </div>
              <div>would return undef therefore I would not reach the vf
                adaptor in my code</div>
              <div>
                <div><br>
                </div>
                <div>I also tried </div>
                <div><br>
                </div>
                <div>
                  <div><span class="gmail-sh_variable" style="font-family:Consolas,"Bitstream Vera Sans Mono","Courier New",Courier,monospace;font-size:1em;white-space:pre;color:rgb(170,119,0)">$</span>variation_adaptor<span class="gmail-sh_symbol" style="font-family:Consolas,"Bitstream Vera Sans Mono","Courier New",Courier,monospace;font-size:1em;white-space:pre;color:rgb(127,0,85)">-></span><span class="gmail-sh_function" style="font-family:Consolas,"Bitstream Vera Sans Mono","Courier New",Courier,monospace;font-size:1em;white-space:pre;color:rgb(255,20,147)">db</span><span class="gmail-sh_symbol" style="font-family:Consolas,"Bitstream Vera Sans Mono","Courier New",Courier,monospace;font-size:1em;white-space:pre;color:rgb(127,0,85)">-></span><span class="gmail-sh_function" style="font-family:Consolas,"Bitstream Vera Sans Mono","Courier New",Courier,monospace;font-size:1em;white-space:pre;color:rgb(255,20,147)">include_failed_variations</span><span class="gmail-sh_symbol" style="font-family:Consolas,"Bitstream Vera Sans Mono","Courier New",Courier,monospace;font-size:1em;white-space:pre;color:rgb(127,0,85)">(</span><span class="gmail-sh_number" style="font-family:Consolas,"Bitstream Vera Sans Mono","Courier New",Courier,monospace;font-size:1em;white-space:pre;color:rgb(13,163,68)">1</span><span class="gmail-sh_symbol" style="font-family:Consolas,"Bitstream Vera Sans Mono","Courier New",Courier,monospace;font-size:1em;white-space:pre;color:rgb(127,0,85)">);</span></div>
                  <div><span style="font-family:Consolas,"Bitstream Vera Sans Mono","Courier New",Courier,monospace;white-space:pre;background-color:rgb(250,250,250)">
</span></div>
                  But this does not seem to work as well.<br>
                  What I am missing?<br>
                  <br>
                  Thanks<br>
                  <br>
                  Duarte</div>
                <div><br>
                </div>
                <br class="gmail-Apple-interchange-newline">
              </div>
              <div><br>
              </div>
              <div><br>
              </div>
            </div>
          </div>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
Dev mailing list    <a class="moz-txt-link-abbreviated" href="mailto:Dev@ensembl.org">Dev@ensembl.org</a>
Posting guidelines and subscribe/unsubscribe info: <a class="moz-txt-link-freetext" href="http://lists.ensembl.org/mailman/listinfo/dev">http://lists.ensembl.org/mailman/listinfo/dev</a>
Ensembl Blog: <a class="moz-txt-link-freetext" href="http://www.ensembl.info/">http://www.ensembl.info/</a>
</pre>
    </blockquote>
  </body>
</html>