Exercise

Exercise 3

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

The number of chromosomes is probably not what you would expect! Why is this?

(b) 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).

(c) 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);

Answer

Magali explains the answers to these questions in this 5 min video. You can download her sample scripts and outputs:

a) sample script and output

b) sample script and output

c) sample script and output