Last active
December 11, 2015 03:28
-
-
Save dbolser/4537997 to your computer and use it in GitHub Desktop.
My attempted script.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
# Projects generic features ... hopefully | |
use strict; | |
use warnings; | |
use Data::Dumper; | |
use Bio::EnsEMBL::Registry; | |
my $registry_file = "./myreg.pm"; | |
my $feature = "VariationFeature"; | |
my $species = "hordeum_vulgare"; | |
my $type = "variation"; | |
warn "Loading the registry\n"; | |
Bio::EnsEMBL::Registry->load_all( $registry_file ) | |
or die; | |
warn "Getting a datbase adaptor\n"; | |
my $db_adaptor = Bio::EnsEMBL::Registry-> | |
get_DBAdaptor($species, $type) | |
or die; | |
warn "Getting a feature adaptor ($feature)\n"; | |
my $f_adaptor = $db_adaptor-> | |
get_adaptor($feature) | |
or die; | |
# warn "Counting features ($feature)\n"; | |
# warn "There are ", $f_adaptor->generic_count, " ", $feature, "s\n"; | |
warn "Getting a feature itterator ($feature)\n"; | |
my $f_iterator = $f_adaptor-> | |
fetch_Iterator | |
or die; | |
warn "Itterating over features ($feature)\n"; | |
while(my $f = $f_iterator->next){ | |
## debugging | |
next if $f->name eq "tmp_morex_contig_4_27"; | |
next if $f->name eq "tmp_morex_contig_4_478"; | |
warn "Working on ", $f->name, "\n"; | |
warn | |
join("\t", | |
$f->coord_system_name, | |
$f->seq_region_name, | |
$f->start, | |
$f->end, | |
$f->strand, | |
), "\n"; | |
warn "Projecting to toplevel\n"; | |
my $fp = $f->transform('toplevel') | |
or die; | |
warn | |
join("\t", | |
$fp->coord_system_name, | |
$fp->seq_region_name, | |
$fp->start, | |
$fp->end, | |
$fp->strand, | |
), "\n"; | |
## Store the new slice in the old feature | |
## This fails | |
# $f->slice( $fp->slice ) | |
# or die; | |
$f->start ( $fp->start ); | |
$f->end ( $fp->end ); | |
$f->strand ( $fp->strand ); | |
$f->slice ( $fp->slice ); # Does coord_system and seq_region.name | |
$f_adaptor->update( $f ) | |
or die; | |
warn | |
join("\t", | |
$f->coord_system_name, | |
$f->seq_region_name, | |
$f->start, | |
$f->end, | |
$fp->strand, | |
), "\n"; | |
warn "\n"; | |
exit; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment