Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ensembl
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ensembl-gh-mirror
ensembl
Commits
322b2043
Commit
322b2043
authored
20 years ago
by
Patrick Meidl
Browse files
Options
Downloads
Patches
Plain Diff
fixed config file parser, added get_taxonomy_id() and get_species_scientific_name()
parent
25e625fe
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/Bio/EnsEMBL/Utils/ConversionSupport.pm
+69
-4
69 additions, 4 deletions
modules/Bio/EnsEMBL/Utils/ConversionSupport.pm
with
69 additions
and
4 deletions
modules/Bio/EnsEMBL/Utils/ConversionSupport.pm
+
69
−
4
View file @
322b2043
...
...
@@ -106,6 +106,7 @@ sub parse_common_options {
'
driver|dbdriver|db_driver=s
',
'
conffile|conf=s
',
'
logfile|log=s
',
'
logpath=s
',
'
interactive|i=s
',
'
dry_run|dry|n=s
',
'
help|h|?
',
...
...
@@ -117,13 +118,16 @@ sub parse_common_options {
open
(
CONF
,
$conffile
)
or
throw
(
"
Unable to open configuration file
$conffile
for reading: $!
");
while
(
<
CONF
>
)
{
chomp
;
# remove comments
s/\s+[
;].*
$
//
;
s/^[#
;].*$//
;
s/^[#
;].*//
;
s/\s+[
;].*$//
;
# read options into internal parameter datastructure
$self
->
param
(
$
1
,
$
2
)
if
(
/(\w\S*)\s*=\s*(.*)/
);
}
next
unless
(
/(\w\S*)\s*=\s*(.*)/
);
$self
->
param
(
$
1
,
$
2
);
}
}
else
{
warning
("
Unable to open configuration file
$conffile
for reading: $!
");
}
...
...
@@ -533,6 +537,64 @@ sub get_chrlength {
return
\
%chr
;
}
=head2 get_taxonomy_id
Arg[1] : Bio::EnsEMBL::DBSQL::DBAdaptor $dba
Example : my $sid = $support->get_taxonony_id($dba);
Description : Retrieves the taxononmy ID from the meta table
Return type : Int - the taxonomy ID
Exceptions : thrown if no taxonomy ID is found in the database
Caller : general
=cut
sub
get_taxonomy_id
{
my
(
$self
,
$dba
)
=
@_
;
my
$sql
=
'
SELECT meta_value FROM meta WHERE meta_key = "species.taxonomy_id"
';
my
$sth
=
$dba
->
dbc
->
db_handle
->
prepare
(
$sql
);
$sth
->
execute
;
my
(
$tid
)
=
$sth
->
fetchrow_array
;
$sth
->
finish
;
$self
->
throw
("
Could not determine taxonomy_id from database.
")
unless
$tid
;
return
$tid
;
}
=head2 get_species_scientific_name
Arg[1] : Bio::EnsEMBL::DBSQL::DBAdaptor $dba
Example : my $species = $support->get_species_scientific_name($dba);
Description : Retrieves the species scientific name (Genus species) from the
meta table
Return type : String - species scientific name
Exceptions : thrown if species name can't be determined from db
Caller : general
=cut
sub
get_species_scientific_name
{
my
(
$self
,
$dba
)
=
@_
;
my
$sql
=
qq(
SELECT
meta_value
FROM
meta
WHERE meta_key = "species.classification"
ORDER BY meta_id
LIMIT 2
)
;
my
$sth
=
$dba
->
dbc
->
db_handle
->
prepare
(
$sql
);
$sth
->
execute
;
my
@sp
;
while
(
my
@row
=
$sth
->
fetchrow_array
)
{
push
@sp
,
$row
[
0
];
}
$sth
->
finish
;
my
$species
=
join
("
",
reverse
@sp
);
$self
->
throw
("
Could not determine species scientific name from database.
")
unless
$species
;
return
$species
;
}
=head2 sort_chromosomes
Arg[1] : Hashref $chr_hashref - Hashref with chr_name as keys
...
...
@@ -663,6 +725,9 @@ sub log_filehandle {
$mode
||=
"
>
";
my
$fh
=
\
*STDERR
;
if
(
my
$logfile
=
$self
->
param
('
logfile
'))
{
if
(
my
$logpath
=
$self
->
param
('
logpath
'))
{
$logfile
=
"
$logpath
/
$logfile
";
}
open
(
$fh
,
"
$mode
",
$logfile
)
or
throw
(
"
Unable to open
$logfile
for writing: $!
");
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment