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
7acbb8ee
Commit
7acbb8ee
authored
17 years ago
by
Patrick Meidl
Browse files
Options
Downloads
Patches
Plain Diff
added create_shrinked_matrix(), use BaseObject
parent
6da04658
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/IdMapping/ScoreBuilder.pm
+52
-50
52 additions, 50 deletions
modules/Bio/EnsEMBL/IdMapping/ScoreBuilder.pm
with
52 additions
and
50 deletions
modules/Bio/EnsEMBL/IdMapping/ScoreBuilder.pm
+
52
−
50
View file @
7acbb8ee
...
...
@@ -33,69 +33,65 @@ use strict;
use
warnings
;
no
warnings
'
uninitialized
';
use
Bio::EnsEMBL::Utils::
Exception
qw(throw warning)
;
use
Bio::EnsEMBL::Utils::
Argument
qw(rearrange)
;
=head2 new
Arg[1] :
Example :
Description : constructor
Return type :
Exceptions :
Caller : general
use
Bio::EnsEMBL::IdMapping::
BaseObject
;
our
@ISA
=
qw(Bio::EnsEMBL::IdMapping::BaseObject)
;
=cut
sub
new
{
my
$caller
=
shift
;
my
$class
=
ref
(
$caller
)
||
$caller
;
use
Bio::EnsEMBL::Utils::
Exception
qw(throw warning)
;
use
Bio::EnsEMBL::IdMapping::
ScoredMappingMatrix
;
my
(
$logger
,
$conf
,
$cache
)
=
rearrange
(['
LOGGER
',
'
CONF
',
'
CACHE
'],
@
_
);
#
# create a shrinked matrix which doesn't contain entries which were already
# mapped
#
sub
create_shrinked_matrix
{
my
$self
=
shift
;
my
$matrix
=
shift
;
my
$mappings
=
shift
;
my
$cache_file
=
shift
;
unless
(
$logger
->
isa
('
Bio::EnsEMBL::Utils::Logger
'))
{
throw
("
You must provide a Bio::EnsEMBL::Utils::Logger for logging.
");
}
unless
(
$conf
->
isa
('
Bio::EnsEMBL::Utils::ConfParser
'))
{
throw
("
You must provide configuration as a Bio::EnsEMBL::Utils::ConfParser object.
");
# argument checks
unless
(
$matrix
and
$matrix
->
isa
('
Bio::EnsEMBL::IdMapping::ScoredMappingMatrix
'))
{
throw
('
Need a Bio::EnsEMBL::IdMapping::ScoredMappingMatrix.
');
}
unless
(
$cache
->
isa
('
Bio::EnsEMBL::IdMapping::Cache
'))
{
throw
("
You must provide configuration as a Bio::EnsEMBL::IdMapping::Cache object.
");
unless
(
$mappings
and
$mappings
->
isa
('
Bio::EnsEMBL::IdMapping::MappingList
'))
{
throw
('
Need a gene Bio::EnsEMBL::IdMapping::MappingList.
');
}
my
$self
=
{};
bless
(
$self
,
$class
);
# initialise
$self
->
logger
(
$logger
);
$self
->
conf
(
$conf
);
$self
->
cache
(
$cache
);
return
$self
;
}
throw
('
Need a cache file name.
')
unless
(
$cache_file
);
my
$shrinked_matrix
=
Bio::EnsEMBL::IdMapping::
ScoredMappingMatrix
->
new
(
-
DUMP_PATH
=>
$self
->
conf
->
param
('
dumppath
'),
-
CACHE_FILE
=>
$cache_file
,
);
sub
logger
{
my
$self
=
shift
;
$self
->
{'
_logger
'}
=
shift
if
(
@
_
);
return
$self
->
{'
_logger
'};
}
# create lookup hashes for sources and targets in the MappingList
my
%sources
=
();
my
%targets
=
();
foreach
my
$entry
(
@
{
$mappings
->
get_all_Entries
})
{
$sources
{
$entry
->
source
}
=
1
;
$targets
{
$entry
->
target
}
=
1
;
}
sub
conf
{
my
$self
=
shift
;
$self
->
{'
_conf
'}
=
shift
if
(
@
_
);
return
$self
->
{'
_conf
'};
}
# add all entries to shrinked matrix which are not in the MappingList
foreach
my
$entry
(
@
{
$matrix
->
get_all_Entries
})
{
unless
(
$sources
{
$entry
->
source
}
or
$targets
{
$entry
->
target
})
{
$shrinked_matrix
->
add_Entry
(
$entry
);
}
}
# log shrinking stats
$self
->
logger
->
info
('
Sources
'
.
$matrix
->
get_source_count
.
'
-->
'
.
$shrinked_matrix
->
get_source_count
.
"
\n
");
$self
->
logger
->
info
('
Targets
'
.
$matrix
->
get_target_count
.
'
-->
'
.
$shrinked_matrix
->
get_target_count
.
"
\n
");
$self
->
logger
->
info
('
Entries
'
.
$matrix
->
get_entry_count
.
'
-->
'
.
$shrinked_matrix
->
get_entry_count
.
"
\n
");
sub
cache
{
my
$self
=
shift
;
$self
->
{'
_cache
'}
=
shift
if
(
@
_
);
return
$self
->
{'
_cache
'};
return
$shrinked_matrix
;
}
...
...
@@ -114,6 +110,12 @@ sub log_matrix_stats {
$self
->
logger
->
info
(
sprintf
(
$fmt1
,
"
Scoring matrix entries:
",
$matrix
->
get_entry_count
),
1
);
$self
->
logger
->
info
(
sprintf
(
$fmt1
,
"
Scoring matrix sources:
",
$matrix
->
get_source_count
),
1
);
$self
->
logger
->
info
(
sprintf
(
$fmt1
,
"
Scoring matrix targets:
",
$matrix
->
get_target_count
),
1
);
$self
->
logger
->
info
(
sprintf
(
$fmt2
,
"
Average score:
",
$matrix
->
get_average_score
),
1
);
...
...
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