Coordinate systems and slices

This presentation demonstrates the different coordinate systems in the Ensembl database and how to access regions of the genome using slices.

Exercise 3

  1. Fetch all chromosomes for human. Determine their number and print the name and length for each of them.

    Hint: The number of chromosomes is probably not what you would expect! Why is this?
  2. Use the gene stable ID ENSG00000101266 to fetch a slice surrounding this gene with 2kb of flanking sequence.

    Hint: use the Ensembl API documentation to find an appropriate method in SliceAdaptor class which retrieves a slice given a gene stable id (pay attention to the method’s arguments).
  3. Fetch the sequence of the first 10MB of chromosome 20 and write it to a file in FASTA format. Print the number of genes in this region.

    Hint: Slice objects inherit from Bio::Seq so can be written to file easily using:
    Bio::SeqIO, e.g.: my $output = Bio::SeqIO->new( -file=>'>filename.fasta', -format=>'Fasta'); $output->write_seq($slice);

Magali explains the answers to these questions in this 5-minute video.
You can download her sample scripts and outputs:
a. sample script and output
b. sample script 
c. sample script and output