Skip to content

Instantly share code, notes, and snippets.

@jergosh
Created December 9, 2013 17:07
Show Gist options
  • Save jergosh/7876000 to your computer and use it in GitHub Desktop.
Save jergosh/7876000 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use strict;
use Bio::SeqIO;
use Bio::EnsEMBL::Registry;
Bio::EnsEMBL::Registry->load_registry_from_db(
-host => 'ensembldb.ensembl.org',
-user => 'anonymous'
);
open(SPECIES, "<species_list.txt");
my @species = <SPECIES>;
my $n = $ARGV[0];
my $s = $species[$n];
chomp $s;
open(OUTFILE, '>' . $s . '_cds.fa');
my $gene_adaptor =
Bio::EnsEMBL::Registry->get_adaptor( $s, 'Core',
'Gene' );
my @genes = @{ $gene_adaptor->fetch_all_by_biotype('protein_coding') };
foreach my $gene (@genes) {
my @transcripts = ( $gene->canonical_transcript() );
# my @transcripts = @{$gene->get_all_Transcripts()};
foreach my $transcript (@transcripts) {
print OUTFILE ">", $transcript->stable_id, "\n", $transcript->translateable_seq, "\n";
}
}
close(OUTFILE);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment