Created
December 18, 2013 11:49
-
-
Save avrilcoghlan/8021083 to your computer and use it in GitHub Desktop.
Perl script that uses the Ensembl Compara Perl API to count the number of “one2one” orthologues between human and mouse
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 | |
# Count the number of “one2one” orthologues between human and mouse | |
# Note: this script gives a warning about some variable declaration within the Compara API. | |
use strict; | |
use warnings; | |
use Bio::EnsEMBL::Registry; | |
my $registry = 'Bio::EnsEMBL::Registry'; | |
$registry->load_registry_from_db( | |
-host => 'ensembldb.ensembl.org', | |
-user => 'anonymous' | |
); | |
# A 'MethodLinkSpeciesSet' adaptor can be used to get orthologs between a pair of species. | |
my $mlss_adaptor = $registry->get_adaptor('Multi', 'compara', 'MethodLinkSpeciesSet'); | |
my $this_mlss = $mlss_adaptor->fetch_by_method_link_type_registry_aliases('ENSEMBL_ORTHOLOGUES', ['human', 'mouse']); | |
# Now get all the homology relationships for this 'MethodLinkSpeciesSet' object: | |
my $ha = $registry->get_adaptor('multi', 'compara', 'Homology'); | |
my @homologies = @{ $ha->fetch_all_by_MethodLinkSpeciesSet($this_mlss, -ORTHOLOGY_TYPE => 'ortholog_one2one')}; | |
my $num_one2one = 0; | |
foreach my $homology (@homologies){ | |
my $desc = $homology->description(); | |
if ($desc ne 'ortholog_one2one') { print STDERR "ERROR: desc $desc\n"; exit;} | |
$num_one2one++; | |
} | |
# Alternatively you could just do: | |
# $num_one2one = scalar(@homologies); | |
print "Total number of human-mouse one-2-one orthologs: $num_one2one\n"; | |
# get 15678 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment