Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mhc_rank
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
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
Patrick Skillman-Lawrence
mhc_rank
Commits
57edfb49
Commit
57edfb49
authored
5 years ago
by
Tim O'Donnell
Browse files
Options
Downloads
Patches
Plain Diff
fix
parent
24985286
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.travis.yml
+0
-2
0 additions, 2 deletions
.travis.yml
mhcflurry/class1_affinity_predictor.py
+10
-4
10 additions, 4 deletions
mhcflurry/class1_affinity_predictor.py
test/test_network_merging.py
+6
-2
6 additions, 2 deletions
test/test_network_merging.py
with
16 additions
and
8 deletions
.travis.yml
+
0
−
2
View file @
57edfb49
...
...
@@ -35,8 +35,6 @@ install:
env
:
global
:
-
PYTHONHASHSEED=0
-
CUDA_VISIBLE_DEVICES=""
# for tensorflow
matrix
:
-
KERAS_BACKEND=tensorflow
script
:
# download data and models, then run tests
...
...
This diff is collapsed.
Click to expand it.
mhcflurry/class1_affinity_predictor.py
+
10
−
4
View file @
57edfb49
...
...
@@ -418,7 +418,7 @@ class Class1AffinityPredictor(object):
logging
.
info
(
"
Wrote: %s
"
,
percent_ranks_path
)
@staticmethod
def
load
(
models_dir
=
None
,
max_models
=
None
):
def
load
(
models_dir
=
None
,
max_models
=
None
,
optimization_level
=
None
):
"""
Deserialize a predictor from a directory on disk.
...
...
@@ -431,12 +431,18 @@ class Class1AffinityPredictor(object):
max_models : int, optional
Maximum number of `Class1NeuralNetwork` instances to load
optimization_level : int
If >0, model optimization will be attempted. Defaults to value of
environment variable MHCFLURRY_OPTIMIZATION_LEVEL.
Returns
-------
`Class1AffinityPredictor` instance
"""
if
models_dir
is
None
:
models_dir
=
get_default_class1_models_dir
()
if
optimization_level
is
None
:
optimization_level
=
OPTIMIZATION_LEVEL
manifest_path
=
join
(
models_dir
,
"
manifest.csv
"
)
manifest_df
=
pandas
.
read_csv
(
manifest_path
,
nrows
=
max_models
)
...
...
@@ -497,11 +503,11 @@ class Class1AffinityPredictor(object):
manifest_df
=
manifest_df
,
allele_to_percent_rank_transform
=
allele_to_percent_rank_transform
,
)
if
OPTIMIZATION_LEVEL
>=
1
:
logging
.
info
(
"
Optimizing models
"
)
if
optimization_level
>=
1
:
optimized
=
result
.
optimize
()
logging
.
info
(
"
Optimization %s
"
,
(
"
succeeded
"
if
optimized
else
"
failed
"
))
"
Model optimization %s
"
,
"
succeeded
"
if
optimized
else
"
not supported for these models
"
)
return
result
def
optimize
(
self
):
...
...
This diff is collapsed.
Click to expand it.
test/test_network_merging.py
+
6
−
2
View file @
57edfb49
...
...
@@ -14,13 +14,16 @@ from mhcflurry.common import random_peptides
from
mhcflurry.downloads
import
get_path
ALLELE_SPECIFIC_PREDICTOR
=
Class1AffinityPredictor
.
load
(
get_path
(
"
models_class1
"
,
"
models
"
))
get_path
(
"
models_class1
"
,
"
models
"
)
,
optimization_level
=
0
)
PAN_ALLELE_PREDICTOR
=
Class1AffinityPredictor
.
load
(
get_path
(
"
models_class1_pan
"
,
"
models.with_mass_spec
"
))
get_path
(
"
models_class1_pan
"
,
"
models.with_mass_spec
"
),
optimization_level
=
0
)
def
test_merge
():
assert
len
(
PAN_ALLELE_PREDICTOR
.
class1_pan_allele_models
)
>
1
peptides
=
random_peptides
(
100
,
length
=
9
)
peptides
.
extend
(
random_peptides
(
100
,
length
=
10
))
peptides
=
pandas
.
Series
(
peptides
).
sample
(
frac
=
1.0
)
...
...
@@ -40,3 +43,4 @@ def test_merge():
)
predictions2
=
merged_predictor
.
predict
(
peptides
=
peptides
,
alleles
=
alleles
)
numpy
.
testing
.
assert_allclose
(
predictions1
,
predictions2
,
atol
=
0.1
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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