Skip to content

Instantly share code, notes, and snippets.

@avrilcoghlan
Created December 17, 2013 11:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save avrilcoghlan/8003234 to your computer and use it in GitHub Desktop.
Save avrilcoghlan/8003234 to your computer and use it in GitHub Desktop.
Use the Ensembl Compara Perl API to get the multiple alignment corresponding to the family with the stable id ENSFM00250000006121
#!/usr/bin/env perl
# Get the multiple alignment corresponding to the family with the stable id ENSFM00250000006121
# Note: this prints some warnings about uninitialised values in the Compara api
use strict;
use warnings;
use Bio::EnsEMBL::Registry;
use Bio::AlignIO;
my $registry = 'Bio::EnsEMBL::Registry';
$registry->load_registry_from_db(
-host => 'ensembldb.ensembl.org',
-user => 'anonymous'
);
my $fa = $registry->get_adaptor( 'multi', 'compara', 'family' );
my $family = $fa->fetch_by_stable_id("ENSFM00250000006121");
my $desc = $family->description(); # a description of the family, based on a consensus of descriptions of its members
my $score = $family->description_score(); # a score for the description, saying how well it agrees between members
print "family desc_score=$score desc=$desc\n";
my $aln = $family->get_SimpleAlign(-APPEND_TAXON_ID => 'TRUE'); # gets the alignment. -APPEND_TAXON_ID => 'TRUE' appends the NCBI taxon id. to the sequence name
# Get the alignIO object from BioPerl
my $alignIO = Bio::AlignIO->newFh(-format => "clustalw"); # -format => 'fasta' would give fasta format
# Print the alignment
print $alignIO $aln;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment