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
dddeaffc
Commit
dddeaffc
authored
16 years ago
by
Steve Trevanion
Browse files
Options
Downloads
Patches
Plain Diff
date format method added
parent
ce47ceab
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
+75
-35
75 additions, 35 deletions
modules/Bio/EnsEMBL/Utils/ConversionSupport.pm
with
75 additions
and
35 deletions
modules/Bio/EnsEMBL/Utils/ConversionSupport.pm
+
75
−
35
View file @
dddeaffc
...
...
@@ -238,8 +238,10 @@ sub get_common_params {
=head2 get_loutre_params
Example : my @allowed_params = $self->get_loutre_params, 'extra_param';
Description : Returns a list of commonly used parameters in for working with a loutre db
Arg : (optional) return a list to parse or not
Example : $support->parse_extra_options($support->get_loutre_params('parse'))
Description : Returns a list of commonly used loutre db parameters - parse option is
simply used to distinguish between reporting and parsing parameters
Return type : Array - list of common parameters
Exceptions : none
Caller : general
...
...
@@ -247,13 +249,25 @@ sub get_common_params {
=cut
sub
get_loutre_params
{
return
qw(
loutrehost
loutreport
loutreuser
loutrepass
loutredbname
)
;
my
(
$self
,
$p
)
=
@_
;
if
(
$p
)
{
return
qw(
loutrehost=s
loutreport=s
loutreuser=s
loutrepass=s
loutredbname=s
)
;
}
else
{
return
qw(
loutrehost
loutreport
loutreuser
loutrepass
loutredbname
)
;
}
}
=head2 remove_vega_params
...
...
@@ -293,9 +307,9 @@ sub confirm_params {
print
"
Running script with these parameters:
\n\n
";
print
$self
->
list_all_params
;
if
(
$self
->
param
('
host
')
eq
'
w
eb-
4
-1
1
')
{
if
(
$self
->
param
('
host
')
eq
'
e
nsd
b-
1
-1
0
')
{
# ask user if he wants to proceed
exit
unless
$self
->
user_proceed
("
**************
\n\n
You're working on
w
eb-
4
-1
1
! Is that correct and you want to continue ?
\n\n
**************
");
exit
unless
$self
->
user_proceed
("
**************
\n\n
You're working on e
nsd
b-
1
-1
0
! Is that correct and you want to continue ?
\n\n
**************
");
}
else
{
# ask user if he wants to proceed
...
...
@@ -362,7 +376,6 @@ sub create_commandline_options {
if
(
$settings
->
{'
allowed_params
'})
{
# exclude params explicitly stated
my
%exclude
=
map
{
$_
=>
1
}
@
{
$settings
->
{'
exclude
'}
||
[]
};
foreach
my
$param
(
$self
->
allowed_params
)
{
unless
(
$exclude
{
$param
})
{
my
(
$first
,
@rest
)
=
$self
->
param
(
$param
);
...
...
@@ -387,7 +400,6 @@ sub create_commandline_options {
foreach
my
$param
(
keys
%param_hash
)
{
$options_string
.=
sprintf
("
--%s %s
",
$param
,
$param_hash
{
$param
});
}
return
$options_string
;
}
...
...
@@ -689,8 +701,17 @@ sub get_database {
-
dbname
=>
$self
->
param
("
${prefix}
dbname
"),
-
group
=>
$database
,
);
# explicitely set the dnadb to itself - by default the Registry assumes
#can use this approach to get dna from another db
# my $dna_db = $adaptors{$database}->new(
# -host => 'otterlive',
# -port => '3301',
# -user => $self->param("${prefix}user"),
# -pass => $self->param("${prefix}pass"),
# -dbname => 'loutre_human',
# );
# $dba->dnadb($dna_db);
# otherwise explicitely set the dnadb to itself - by default the Registry assumes
# a group 'core' for this now
$dba
->
dnadb
(
$dba
);
...
...
@@ -928,26 +949,25 @@ sub get_chrlength {
=cut
sub
get_ensembl_chr_mapping
{
my
(
$self
,
$dba
,
$version
)
=
@_
;
$dba
||=
$self
->
dba
;
throw
("
get_ensembl_chr_mapping should be passed a Bio::EnsEMBL::DBSQL::DBAdaptor
\n
")
unless
(
$dba
->
isa
('
Bio::EnsEMBL::DBSQL::DBAdaptor
'));
my
$sa
=
$dba
->
get_SliceAdaptor
;
my
@chromosomes
=
map
{
$_
->
seq_region_name
}
@
{
$sa
->
fetch_all
('
chromosome
',
$version
)
};
my
%chrs
;
foreach
my
$chr
(
@chromosomes
)
{
my
$sr
=
$sa
->
fetch_by_region
('
chromosome
',
$chr
,
undef
,
undef
,
undef
,
$version
);
my
(
$ensembl_name_attr
)
=
@
{
$sr
->
get_all_Attributes
('
ensembl_name
')
};
if
(
$ensembl_name_attr
)
{
$chrs
{
$chr
}
=
$ensembl_name_attr
->
value
;
}
else
{
$chrs
{
$chr
}
=
$chr
;
}
my
(
$self
,
$dba
,
$version
)
=
@_
;
$dba
||=
$self
->
dba
;
throw
("
get_ensembl_chr_mapping should be passed a Bio::EnsEMBL::DBSQL::DBAdaptor
\n
")
unless
(
$dba
->
isa
('
Bio::EnsEMBL::DBSQL::DBAdaptor
'));
my
$sa
=
$dba
->
get_SliceAdaptor
;
my
@chromosomes
=
map
{
$_
->
seq_region_name
}
@
{
$sa
->
fetch_all
('
chromosome
',
$version
)
};
my
%chrs
;
foreach
my
$chr
(
@chromosomes
)
{
my
$sr
=
$sa
->
fetch_by_region
('
chromosome
',
$chr
,
undef
,
undef
,
undef
,
$version
);
my
(
$ensembl_name_attr
)
=
@
{
$sr
->
get_all_Attributes
('
ensembl_name
')
};
if
(
$ensembl_name_attr
)
{
$chrs
{
$chr
}
=
$ensembl_name_attr
->
value
;
}
else
{
$chrs
{
$chr
}
=
$chr
;
}
return
\
%chrs
;
}
return
\
%chrs
;
}
=head2 get_taxonomy_id
...
...
@@ -1186,7 +1206,7 @@ sub log {
Arg[1] : String $txt - the warning text to log
Arg[2] : Int $indent - indentation level for log message
Arg[
2
] : Bool - add a line break before warning if true
Arg[
3
] : Bool - add a line break before warning if true
Example : my $log = $support->log_filehandle;
$support->log_warning('Log foo.\n', 1);
Description : Logs a message via $self->log and increases the warning counter.
...
...
@@ -1438,6 +1458,26 @@ sub date {
return
strftime
"
%Y-%m-%d %T
",
localtime
;
}
=head2 format_time
Example : print $support->format_time($gene->modifed_date) . "\n";
Description : Prints timestamps from the database
Return type : String - nicely formatted time stamp
Exceptions : none
Caller : general
=cut
sub
date_format
{
my
(
$self
,
$time
,
$format
)
=
@_
;
my
(
$d
,
$m
,
$y
)
=
(
localtime
(
$time
))[
3
,
4
,
5
];
my
%S
=
('
d
'
=>
sprintf
('
%02d
',
$d
),'
m
'
=>
sprintf
('
%02d
',
$m
+
1
),'
y
'
=>
$y
+
1900
);
(
my
$res
=
$format
)
=~
s/%(\w)/$S{$1}/g
e
;
return
$res
;
}
=head2 mem
Example : print "Memory usage: " . $support->mem . "\n";
...
...
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