[ensembl-dev] variation api - only get variation features that are snps

Pontus Larsson Pontus.Larsson at ebi.ac.uk
Mon Nov 29 12:29:27 GMT 2010


Hi Andrea,

You can filter the variation features by calling var_class, like so:


         foreach my $vf (@{$vfs}) {
             next if ($vf->var_class ne 'snp');

             # Variation feature representing a single nucleotide 
polymorphism
             #insert into my database

         }#end for each variation feature

Cheers
/Pontus - Ensembl Variation


On 29/11/2010 12:23, Andrea Edwards wrote:
> Hello
>
> I have some code below which gets all of the variation features for 
> cow that are mapped to know chromosomes. However this code gets all 
> variation features and I would like to get just snps. Could you 
> suggest how i do this? Also i'm new to the api so if you spot i'm 
> doing something in an inefficient manner and feel like pointing it out 
> then that's fine by me
>
> thanks a lot
>
> ======================================
>
> my $slice_adaptor = $registry->get_adaptor('bos_taurus', 'core', 
> 'slice'); #get the database adaptor for Slice objects
> my $vf_adaptor = $registry->get_adaptor('bos_taurus', 'variation', 
> 'variationfeature'); #get adaptor to VariationFeature object
>
>
>
> @slices = @{ $slice_adaptor->fetch_all('chromosome', undef, 0, 1) };
> foreach $slice (@slices) {
>
>     unless ($slice->seq_region_name() =~ /Un/) {
>
>         #return ALL variations defined in $slice
>         $vfs = $vf_adaptor->fetch_all_by_Slice($slice);
>
>
>
>         foreach my $vf (@{$vfs}) {
>             # Variation feature representing a single nucleotide 
> polymorphism
>             #insert into my database
>
>         }#end for each variation feature
>     }#end unless slice is a chromosome
> }#end for each slice
>
>
> _______________________________________________
> Dev mailing list
> Dev at ensembl.org
> http://lists.ensembl.org/mailman/listinfo/dev





More information about the Dev mailing list