Tuesday, August 16, 2011

Retrieve Sequence Given a Region using EnsEMBL

my $db = Bio::EnsEMBL::DBSQL::DBAdaptor->new()
my $ta = $db->get_TranscriptAdaptor;
my $sa = $db->get_SliceAdaptor;
my $trans = $ta->fetch_by_stable_id($trans_id);
my $coord_sys_name = $trans->slice->coord_system->name;
my $myslice = $sa->fetch_by_region($coord_sys_name, $chr, $start, $end);
my $seq = Bio::LocatableSeq->new(-seq => $myslice->seq, ...)

http://doc.bioperl.org/releases/bioperl-1.0/Bio/LocatableSeq.html
http://biostar.stackexchange.com/questions/9891/get-ensembl-gene-by-species-strain-for-e-coli
http://www.ensembl.org/info/docs/api/core/core_tutorial.html

http://www.kokocinski.net/bioinformatics/ensembl
use Bio::EnsEMBL::DBSQL::DBAdaptor;
my $db = new Bio::EnsEMBL::DBSQL::DBAdaptor(
-host => 'ensembldb.ensembl.org',
-dbname => 'homo_sapiens_core_42_36b',
-user => 'anonymous',
);

my $chrom = "X";
my $start = 100000;
my $end = 200000;
my $strand = 1;
my $slice_adaptor = $db->get_SliceAdaptor;
my $slice = $slice_adaptor->fetch_by_region(
"chromosome",
$chrom,
$start,
$end,
$strand);
print "\nhave slice of ".$slice->seq_region_name()." ".$slice->start()."-".$slice->end();

No comments: