Skip to content
Snippets Groups Projects
Commit 91ec38aa authored by Glenn Proctor's avatar Glenn Proctor
Browse files

Read new format file: tab separated, and with display_label as 3rd column.

parent 9404819a
No related branches found
No related tags found
No related merge requests found
......@@ -16,21 +16,21 @@
The script reads the analysis description file also found in this directory
analysis.descriptions and loads the descriptions which match the logic names in
the analysis table
the analysis table. Display labels are also set from this file.
It will warn about analyses present in the database which don't have descriptions
in the file
in the file.
=head1 OPTIONS
Database options
Database options
-dbhost host name for database (gets put as host= in locator)
-dbport For RDBs, what port to connect to (port= in locator)
-dbname For RDBs, what name to connect to (dbname= in locator)
-dbuser For RDBs, what username to connect as (dbuser= in locator)
-dbpass For RDBs, what password to use (dbpass= in locator)
-description_file path to file containing descriptions. The file
-file Path to file containing descriptions. The file
analysis.descriptions in this directory can be used and is an
example of the format
-help print out documentation
......@@ -58,15 +58,13 @@ my $dbname = '';
my $file;
my $help = 0;
&GetOptions(
'host|dbhost=s' => \$dbhost,
'dbname=s' => \$dbname,
'user|dbuser=s' => \$dbuser,
'pass|dbpass=s' => \$dbpass,
'port|dbport=s' => \$dbport,
&GetOptions('host|dbhost=s' => \$dbhost,
'dbname=s' => \$dbname,
'user|dbuser=s' => \$dbuser,
'pass|dbpass=s' => \$dbpass,
'port|dbport=s' => \$dbport,
'file|descriptions=s' => \$file,
'h|help!' => \$help,
);
'h|help!' => \$help);
if(!$dbhost || !$dbname){
print ("Need to pass in -dbhost $dbhost and -dbname $dbname\n");
......@@ -85,55 +83,52 @@ if($help){
useage();
}
my $db = new Bio::EnsEMBL::DBSQL::DBAdaptor
(
-host => $dbhost,
-user => $dbuser,
-dbname => $dbname,
-pass => $dbpass,
-port => $dbport,
);
my $db = new Bio::EnsEMBL::DBSQL::DBAdaptor(-host => $dbhost,
-user => $dbuser,
-dbname => $dbname,
-pass => $dbpass,
-port => $dbport);
open(FH, $file) or throw("Failed to open $file $@");
my $aa = $db->get_AnalysisAdaptor;
my $analyses = $aa->fetch_all;
my $aa = $db->get_AnalysisAdaptor();
my $analyses = $aa->fetch_all();
my %hash;
foreach my $analysis(@$analyses){
$hash{lc($analysis->logic_name)} = $analysis;
$hash{lc($analysis->logic_name())} = $analysis;
}
LINE:while(<FH>){
/^(\S+)\s+(\S+)\s+(.+)/ and do {
my ($displayable, $logic_name, $description) = ($1, $2, $3);
#print "Parsed ".$displayable." ".$logic_name." ".$description."\n";
$description =~ s/^\s+//;
$description =~ s/\s+$//;
next if not $description;
if (exists $hash{lc($logic_name)}) {
my $analysis = $hash{lc($logic_name)};
$analysis->description($description);
$analysis->displayable($displayable);
my $display_label = $logic_name;
$display_label =~ s/_//g;
$analysis->display_label($display_label);
$aa->update($analysis);
delete $hash{lc($logic_name)};
}
LINE:while(my $row = <FH>){
chomp($row);
next if ($row =~ /^#/); # skip comments
next if ($row =~ /^$/); # and blank lines
next if ($row =~ /^\s+$/); # and whitespace-only lines
my ($displayable, $logic_name, $display_label, $description) = split(/\t/, $row);
#print join("\t", $displayable, $logic_name, $display_label, $description, "\n");
$description =~ s/^\s+//;
$description =~ s/\s+$//;
next if not $description;
if (exists $hash{lc($logic_name)}) {
my $analysis = $hash{lc($logic_name)};
$analysis->description($description);
$analysis->displayable($displayable);
$analysis->display_label($display_label);
$aa->update($analysis);
delete $hash{lc($logic_name)};
}
}
close(FH) or throw("Failed to close $file $@");
if ( scalar(keys %hash)==0) {
print "\nAll analysis descriptions have been updated, every analysis has a description now\n" ;
if ( scalar(keys %hash)==0) {
print "\nAll analysis descriptions have been updated, every analysis has a description now\n" ;
}else{
foreach my $k (keys %hash) {
warning "No description was found for logic name $k ( ".$hash{$k}->dbID." ) \n";
......
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