File: test_script.pl

package info (click to toggle)
r-bioc-ensembldb 2.30.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 2,844 kB
  • sloc: perl: 353; makefile: 5; sh: 3
file content (79 lines) | stat: -rw-r--r-- 2,549 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/perl
## uses environment variable ENS pointing to the
## ENSEMBL API on the computer
use lib $ENV{ENS} || $ENV{PERL5LIB};
use IO::File;
use Getopt::Std;
use strict;
use warnings;
use Bio::EnsEMBL::ApiVersion;
use Bio::EnsEMBL::Registry;
## unification function for arrays
use List::MoreUtils qw/ uniq /;
my $script_version = "0.2.2";

## connecting to the ENSEMBL data base
use Bio::EnsEMBL::Registry;
use Bio::EnsEMBL::ApiVersion;
my $user = "anonymous";
my $host = "ensembldb.ensembl.org";
my $port = 5306;
my $pass = "";
my $registry = 'Bio::EnsEMBL::Registry';
my $ensembl_version="none";
my $ensembl_database="core";
my $species = "human";
my $slice;
my $coord_system_version="unknown";
## get all gene ids defined in the database...
my @gene_ids = ();

my $gene_id = "ENSG00000109906";

$registry->load_registry_from_db(-host => $host, -user => $user,
				 -pass => $pass, -port => $port);
my $gene_adaptor = $registry->get_adaptor($species, $ensembl_database, "gene");
my $slice_adaptor = $registry->get_adaptor($species, $ensembl_database, "slice");

my $current_gene = $gene_adaptor->fetch_by_stable_id($gene_id);
print "Current gene: ".$current_gene->display_id()."\n";
my @transcripts = @{ $current_gene->get_all_Transcripts };

foreach my $transcript (@transcripts){
  print "Current tx: ".$transcript->display_id()."\n";
  my $transl = $transcript->translation();
  if (defined($transl)) {
    my $transl_id = $transl->stable_id();
    print "Current translation ".$transl_id."\n";
    my $attr = $transl->get_all_Attributes();
    foreach my $a (@{$attr}) {
      print "\tName: ", $a->name(), "\n";
      print "\tCode: ", $a->code(), "\n";
      print "\tDesc: ", $a->description(), "\n";
      print "\tValu: ", $a->value(), "\n";
    }
    my @unip = @{ $transl->get_all_DBLinks('Uniprot%') };
    if (scalar(@unip) > 0) {
      foreach my $uniprot (@unip) {
	my $unip_id = $uniprot->display_id();
	##print UNIPROT "$transl_id\t$unip_id\n";
	## OK, add also
	## o uniprot_db: $uniprot->dbname();
	## o uniprot_info: $uniprot->info_text();
	my $dbn = $uniprot->dbname();
	$dbn =~ s/Uniprot\///g;
	my $descr = $uniprot->description();
	my $infot = $uniprot->info_text();
	my $stat = $uniprot->status();
	my $infotype = $uniprot->info_type();
	## mapping type.
	print "uniprot: ".$unip_id."\n";
	print " dbname: ".$dbn."\n";
	print " info_text ".$infot."\n";
	## Defines the method by which this ID was mapped (Uniprot ID was
	## matched to the Ensembl protein ID).
	print " info_type ".$infotype."\n";
      }
    }
  }
}