Skip to content

Instantly share code, notes, and snippets.

@avrilcoghlan
Created December 17, 2013 10:33
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/8002931 to your computer and use it in GitHub Desktop.
Save avrilcoghlan/8002931 to your computer and use it in GitHub Desktop.
Use the Ensembl Compara Perl API to find and print the sequence of all the peptide Members corresponding to the human protein-coding gene(s) FRAS1.
#!/usr/bin/env perl
# Find and print the sequence of all the peptide Members corresponding to the human protein-coding gene(s) FRAS1.
# Print its attributes using the print_member() method.
# Get all the peptide members and print them as well.
# Print the sequence of these members.
use strict;
use warnings;
use Bio::EnsEMBL::Registry;
my $registry = 'Bio::EnsEMBL::Registry';
$registry->load_registry_from_db(
-host => 'ensembldb.ensembl.org',
-user => 'anonymous'
);
my $gene_adaptor = $registry->get_adaptor( 'Human', 'Core', 'Gene' );
my $gma = $registry->get_adaptor('multi', 'compara', 'GeneMember');
# Get the FRAS1 gene from the human Ensembl Core database and get its stable id.
my @genes = @{ $gene_adaptor->fetch_all_by_external_name('FRAS1') };
foreach my $gene (@genes) {
# print some information about this gene:
my $stable_id = $gene->stable_id();
my $source = $gene->source();
my $desc = $gene->description();
print "gene stable_id=$stable_id source=$source description=$desc\n";
# Use the fetch_by_source_stable_id() method from the Bio::EnsEMBL::Compara::DBSQL::GeneMemberAdaptor.
# The source in this case will be "ENSEMBLGENE".
my $gene_member = $gma->fetch_by_source_stable_id("ENSEMBLGENE", $stable_id);
# print some information for this gene member:
$gene_member->print_member();
# Then, use the get_all_SeqMembers() method from the Bio::EnsEMBL::Compara::GeneMember module.
my @pepMembers = @{$gene_member->get_all_SeqMembers}; # gets all proteins for the gene
foreach my $pepMember (@pepMembers) {
$pepMember->print_member(); # print some information for this protein member, eg. ENSEMBLPEP ENSP00000326330(8026793) 4 : 78979164-79366941
my $sequence = $pepMember->sequence();
print "$sequence\n";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment