<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">I answer myself because I found the solution. I guess that, apart from the "use_vcf(1)” to access to  phase 3 variations, I also need the use_vcf(1) in the population adaptor to obtain subpopulation from the phase 3<div class=""><br class=""></div><div class="">you can check the code that is now working:</div><div class=""><br class=""></div><div class=""><div class=""><br class=""></div><div class=""><div class="">use strict;</div><div class="">$|=1;</div><div class="">use IPC::Run;</div><div class="">use Bio::EnsEMBL::Registry;</div><div class="">use Bio::EnsEMBL::ApiVersion; </div><div class="">printf STDERR ( "The API version used is %s\n", software_version() ); </div><div class=""><br class=""></div><div class="">my $registry = 'Bio::EnsEMBL::Registry';</div><div class="">$registry->load_all();</div><div class="">$registry->set_reconnect_when_lost(1);</div><div class="">$registry->load_registry_from_db(</div><div class=""><span class="Apple-tab-span" style="white-space:pre">  </span>-host => '<a href="http://ensembldb.ensembl.org" class="">ensembldb.ensembl.org</a>', # alternatively ensembldb '<a href="http://useastdb.ensembl.org" class="">useastdb.ensembl.org</a>'</div><div class=""><span class="Apple-tab-span" style="white-space:pre">      </span>-user => 'anonymous'</div><div class="">);</div><div class=""><br class=""></div><div class="">my $snp = "rs79796976";</div><div class=""><br class=""></div><div class="">my $pop_adaptor = $registry->get_adaptor("human","variation","population");</div><div class=""><b class="">$pop_adaptor->db->use_vcf(1);</b></div><div class="">my $variation_adaptor = $registry->get_adaptor( 'human', 'variation', 'variation' );</div><div class=""><b class="">$variation_adaptor->db->use_vcf(1);</b></div><div class=""><span class="Apple-tab-span" style="white-space:pre">   </span></div><div class="">my $variation1 = $variation_adaptor->fetch_by_name($snp);</div><div class="">my $vfref1 = $variation1->get_all_VariationFeatures();</div><div class="">my $query_variation_feature1;</div><div class="">my $found=0;</div><div class="">foreach my $vf (@{$vfref1}) {</div><div class=""><span class="Apple-tab-span" style="white-space:pre">     </span>if($vf->seq_region_name !~ /^HG/){</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre">              </span>print "$snp\t" . $vf->display_consequence;</div><div class=""><span class="Apple-tab-span" style="white-space:pre">           </span>foreach my $allele (@{$vf->get_all_Alleles}){</div><div class=""><span class="Apple-tab-span" style="white-space:pre">                  </span>next unless (defined $allele->population);</div><div class=""><span class="Apple-tab-span" style="white-space:pre">                     </span>my $allele_string   = $allele->allele;</div><div class=""><span class="Apple-tab-span" style="white-space:pre">                    </span>my $frequency       = $allele->frequency || 'NA';</div><div class=""><span class="Apple-tab-span" style="white-space:pre">                       </span>my $population_name = $allele->population->name;</div><div class=""><span class="Apple-tab-span" style="white-space:pre">                    </span>my $pop<span class="Apple-tab-span" style="white-space:pre">                             </span>= $allele->population;</div><div class=""><span class="Apple-tab-span" style="white-space:pre">                 </span></div><div class=""><span class="Apple-tab-span" style="white-space:pre">                  </span> if($population_name eq "1000GENOMES:phase_3:IBS"){</div><div class=""><span class="Apple-tab-span" style="white-space:pre">                             </span>print "\t$allele_string\t$frequency ($population_name)";</div><div class=""><span class="Apple-tab-span" style="white-space:pre">                        </span> }elsif($population_name eq "1000GENOMES:phase_3:EUR"){</div><div class=""><span class="Apple-tab-span" style="white-space:pre">                         </span>print "\t$allele_string\t$frequency ($population_name)";<span class="Apple-tab-span" style="white-space:pre">                  </span></div><div class=""><span class="Apple-tab-span" style="white-space:pre">                  </span> }elsif($population_name eq "1000GENOMES:phase_3:ALL"){</div><div class=""><span class="Apple-tab-span" style="white-space:pre">                         </span>print "\t$allele_string\t$frequency ($population_name)";<span class="Apple-tab-span" style="white-space:pre">                  </span></div><div class=""><span class="Apple-tab-span" style="white-space:pre">                  </span> }else{</div><div class=""><span class="Apple-tab-span" style="white-space:pre">                           </span> next;</div><div class=""><span class="Apple-tab-span" style="white-space:pre">                    </span> }</div><div class=""><span class="Apple-tab-span" style="white-space:pre">                </span>}</div><div class=""><span class="Apple-tab-span" style="white-space:pre">         </span>print "\n";</div><div class=""><span class="Apple-tab-span" style="white-space:pre">     </span>}</div><div class="">}</div><div class=""><br class=""></div><div class="">
<div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">--------------------------------------------------------------------------------------------------------------------------------------</div><br class="Apple-interchange-newline" style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span><img apple-inline="yes" id="4BE507B8-69D2-4DAA-B195-33A72681825E" src="cid:79A17BCA-C1C4-410E-8343-1BD0440E7608" class=""></span>
</div>
<br class=""><div><blockquote type="cite" class=""><div class="">On 23 Apr 2017, at 13:25, Eduardo Andrés León <<a href="mailto:eduardo.andres@csic.es" class="">eduardo.andres@csic.es</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><br class="">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" class="">

<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
Dear all,
<div class="">I’m using an old script to obtain snp frequencies in different populations/subpolulations. I think it was made one year ago and obviously it is not working anymore. The think is that i made a few changes but I’m not able to update it correctly</div>
<div class=""><br class="">
</div>
<div class="">I hope any of you could help me.</div>
<div class=""><br class="">
</div>
<div class="">As an example, what I want is to obtain the frequency for the All population, EUR population and IBS sub-population (all from 1000 genomes):</div>
<div class=""><a href="http://www.ensembl.org/Homo_sapiens/Variation/Population?db=core;r=6:43769593-43770593;v=rs1570360;vdb=variation;vf=1121901" class="">http://www.ensembl.org/Homo_sapiens/Variation/Population?db=core;r=6:43769593-43770593;v=rs1570360;vdb=variation;vf=1121901</a></div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">My code was:</div>
<div class=""><br class="">
</div>
<div class="">
<div class="">my $variation = $variation_adaptor->fetch_by_name($snp);</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>if($variation){</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>foreach my $vf (@{$variation_adaptor_feature->fetch_all_by_Variation($variation)}) {</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>if($vf->seq_region_name !~ /^HG/){</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>print MAP $vf->seq_region_name() ." $snp 0 " .$vf->seq_region_start(),"\n";</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>print POB "$snp\t" . $vf->display_consequence;</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>foreach my $allele (@{$vf->get_all_Alleles}){</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>next unless (defined $allele->population);</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>my $allele_string   = $allele->allele;</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>my $frequency       = $allele->frequency || 'NA';</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>my $population_name = $allele->population->name;</div>
<div class=""><br class="">
</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span> if($population_name eq "1000GENOMES:phase_1_IBS"){</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span> <span class="Apple-tab-span" style="white-space:pre">
</span>print POB "\t$allele_string\t$frequency";</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span> }elsif($population_name eq "1000GENOMES:EUR"){</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span> <span class="Apple-tab-span" style="white-space:pre">
</span>print POB "\t$allele_string\t$frequency";</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span> }elsif($population_name eq "1000GENOMES:phase_1_ALL"){</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span> <span class="Apple-tab-span" style="white-space:pre">
</span>print POB "\t$allele_string\t$frequency”;</div>
</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">.....</div>
<div class=""><br class="">
</div>
<div class="">So from the snp, I obtained the alleles and from the allele object I obtain most of the information using the population_name</div>
<div class=""><br class="">
</div>
<div class="">Now I have tried a couple of things without success</div>
<div class=""><br class="">
</div>
<div class=""><b class="">Example1:</b></div>
<div class=""><br class="">
</div>
<div class="">my $pa = $registry->get_adaptor("human","variation","population");</div>
<div class="">my $pop<span class="Apple-tab-span" style="white-space:pre"> </span>
= $allele->population;</div>
<div class=""><br class="">
</div>
<div class="">
<div class="">
<div class="">foreach my $super_pop (@{$pa->fetch_all_by_sub_Population($pop)}) {</div>
<div class="">    print $pop->name(), " is a super population of ", $super_pop->name(), "\n";</div>
<div class="">  }</div>
<div class=""><br class="">
</div>
<div class=""># fetch all sub populations of a population</div>
<div class="">  foreach my $sub_pop (@{$pa->fetch_all_by_super_Population($pop)}) {</div>
<div class="">    print $sub_pop->name(), " is a sub population of ", $pop->name(), "\n";</div>
<div class="">}</div>
</div>
</div>
<div class=""><br class="">
</div>
<div class=""><b class="">Example 2:</b></div>
<div class=""><b class=""><br class="">
</b></div>
<div class="">
<div class="">my $pop<span class="Apple-tab-span" style="white-space: pre;"> </span>
= $allele->population;</div>
<div class="">my $sub_pops = $pop->get_all_sub_Populations();</div>
<div class=""><br class="">
</div>
<div class="">        foreach my $sp (@$sub_pops) {</div>
<div class="">            print </div>
<div class="">                  'name: ', $sp->name(),</div>
<div class="">                  'desc: ', $sp->description(),</div>
<div class="">                  'size: ', $sp->size(),"\n";</div>
<div class="">  }</div>
</div>
<div class=""><br class="">
</div>
<div class="">Any help ?</div>
<div class=""><br class=""></div>
</div><br class=""><br class=""><div class="">
<div style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-variant-east-asian: normal; font-variant-position: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">--------------------------------------------------------------------------------------------------------------------------------------</div><br class="Apple-interchange-newline" style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-variant-east-asian: normal; font-variant-position: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span class=""><span id="cid:79A17BCA-C1C4-410E-8343-1BD0440E7608"><Signature.jpg></span></span>
</div>
<br class=""></div>_______________________________________________<br class="">Dev mailing list    <a href="mailto:Dev@ensembl.org" class="">Dev@ensembl.org</a><br class="">Posting guidelines and subscribe/unsubscribe info: <a href="http://lists.ensembl.org/mailman/listinfo/dev" class="">http://lists.ensembl.org/mailman/listinfo/dev</a><br class="">Ensembl Blog: <a href="http://www.ensembl.info/" class="">http://www.ensembl.info/</a><br class=""></div></blockquote></div><br class=""></div></div></body></html>