Skip to content
Snippets Groups Projects
Commit 7e23676f authored by Amy Tang's avatar Amy Tang
Browse files

Added options to specify details for connecting to a DNA DB. If your source

(gene) DB contains no DNA, script will throw because it won't be able to
check the translation of transcripts later.

Also print gene stable IDs only when they are present.
parent 8b0ebe4b
No related branches found
No related tags found
No related merge requests found
...@@ -65,6 +65,9 @@ my $port; ...@@ -65,6 +65,9 @@ my $port;
my $dbname; my $dbname;
my $user; my $user;
my $pass; my $pass;
my $dnahost;
my $dnadbname;
my $dnauser;
my $coord_system; my $coord_system;
my $seq_region_name; my $seq_region_name;
my $write = 0; my $write = 0;
...@@ -76,6 +79,9 @@ GetOptions( 'dbhost:s' => \$host, ...@@ -76,6 +79,9 @@ GetOptions( 'dbhost:s' => \$host,
'dbname:s' => \$dbname, 'dbname:s' => \$dbname,
'dbuser:s' => \$user, 'dbuser:s' => \$user,
'dbpass:s' => \$pass, 'dbpass:s' => \$pass,
'dnahost:s' => \$dnahost,
'dnadbname:s' => \$dnadbname,
'dnauser:s' => \$dnauser,
'coord_system_name:s' => \$coord_system, 'coord_system_name:s' => \$coord_system,
'seq_region_name:s' => \$seq_region_name, 'seq_region_name:s' => \$seq_region_name,
'write!' => \$write, 'write!' => \$write,
...@@ -95,6 +101,21 @@ my $db = ...@@ -95,6 +101,21 @@ my $db =
-pass => $pass ); -pass => $pass );
my $geneDB_has_DNA = check_if_DB_contains_DNA($db);
my $dnadb;
if ($geneDB_has_DNA == 0 && !$dnadbname) {
throw ("Your gene DB contains no DNA. You must provide a DNA_DB to connect to");
} elsif ($geneDB_has_DNA == 0 && $dnadbname) {
$dnadb = new Bio::EnsEMBL::DBSQL::DBAdaptor(
'-host' => $dnahost,
'-user' => $dnauser,
'-dbname' => $dnadbname,
'-port' => $port,
);
$db->dnadb($dnadb);
}
my $sa = $db->get_SliceAdaptor; my $sa = $db->get_SliceAdaptor;
my $dea = $db->get_DBEntryAdaptor; my $dea = $db->get_DBEntryAdaptor;
my $slices; my $slices;
...@@ -118,7 +139,11 @@ SLICE: foreach my $slice (@$slices) { ...@@ -118,7 +139,11 @@ SLICE: foreach my $slice (@$slices) {
my %canonical; my %canonical;
GENE: foreach my $gene (@$genes) { GENE: foreach my $gene (@$genes) {
print "Looking at gene: (" . $gene->dbID . ") :: " . $gene->stable_id . "\n"; print "Looking at gene: (dbID " . $gene->dbID . ")";
if ($gene->stable_id) {
print " :: " . $gene->stable_id ;
}
print "\n";
my $transcripts = $gene->get_all_Transcripts; my $transcripts = $gene->get_all_Transcripts;
if ( @$transcripts == 1 ) { if ( @$transcripts == 1 ) {
$canonical{ $gene->dbID } = $transcripts->[0]->dbID; $canonical{ $gene->dbID } = $transcripts->[0]->dbID;
...@@ -271,3 +296,21 @@ GENE: foreach my $gene (@$genes) { ...@@ -271,3 +296,21 @@ GENE: foreach my $gene (@$genes) {
} }
} ## end foreach my $slice (@$slices) } ## end foreach my $slice (@$slices)
sub check_if_DB_contains_DNA {
my ($db) = @_;
my $sql_command = "select count(*) from dna";
my $sth = $db->dbc->prepare($sql_command);
$sth->execute();
my @dna_array = $sth->fetchrow_array;
if ($dna_array[0] > 0) {
print "Your DB ". $db->dbc->dbname ." contains DNA sequences. No need to attach a ".
"DNA_DB to it.\n" if ($verbose);
return 1;
} else {
print "Your DB ". $db->dbc->dbname ." does not contain DNA sequences.\n"
if ($verbose);
return 0;
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment