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
64ffa8c0
Commit
64ffa8c0
authored
7 years ago
by
Tim O'Donnell
Browse files
Options
Downloads
Patches
Plain Diff
optimization
parent
b4f63aea
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
mhcflurry/class1_affinity_predictor.py
+31
-18
31 additions, 18 deletions
mhcflurry/class1_affinity_predictor.py
mhcflurry/encodable_sequences.py
+2
-0
2 additions, 0 deletions
mhcflurry/encodable_sequences.py
with
33 additions
and
18 deletions
mhcflurry/class1_affinity_predictor.py
+
31
−
18
View file @
64ffa8c0
...
...
@@ -848,20 +848,29 @@ class Class1AffinityPredictor(object):
(
min_peptide_length
,
max_peptide_length
)
=
(
self
.
supported_peptide_lengths
)
df
[
"
supported_peptide_length
"
]
=
(
(
df
.
peptide
.
str
.
len
()
>=
min_peptide_length
)
&
(
df
.
peptide
.
str
.
len
()
<=
max_peptide_length
))
if
(
~
df
.
supported_peptide_length
).
any
():
msg
=
(
"
%d peptides have lengths outside of supported range [%d, %d]:
"
"
%s
"
%
(
(
~
df
.
supported_peptide_length
).
sum
(),
min_peptide_length
,
max_peptide_length
,
str
(
df
.
ix
[
~
df
.
supported_peptide_length
].
peptide
.
unique
())))
logging
.
warning
(
msg
)
if
throw
:
raise
ValueError
(
msg
)
if
(
peptides
.
min_length
<
min_peptide_length
or
peptides
.
max_length
>
max_peptide_length
):
# Only compute this if needed
all_peptide_lengths_supported
=
False
df
[
"
supported_peptide_length
"
]
=
(
(
df
.
sequence_length
.
len
()
>=
min_peptide_length
)
&
(
df
.
sequence_length
.
len
()
<=
max_peptide_length
))
if
(
~
df
.
supported_peptide_length
).
any
():
msg
=
(
"
%d peptides have lengths outside of supported range [%d, %d]:
"
"
%s
"
%
(
(
~
df
.
supported_peptide_length
).
sum
(),
min_peptide_length
,
max_peptide_length
,
str
(
df
.
ix
[
~
df
.
supported_peptide_length
].
peptide
.
unique
())))
logging
.
warning
(
msg
)
if
throw
:
raise
ValueError
(
msg
)
else
:
# Handle common case efficiently.
df
[
"
supported_peptide_length
"
]
=
True
all_peptide_lengths_supported
=
True
if
self
.
class1_pan_allele_models
:
unsupported_alleles
=
[
...
...
@@ -904,12 +913,16 @@ class Class1AffinityPredictor(object):
logging
.
warning
(
msg
)
if
throw
:
raise
ValueError
(
msg
)
for
allele
in
query_alleles
:
models
=
self
.
allele_to_allele_specific_models
.
get
(
allele
,
[])
mask
=
(
(
df
.
normalized_allele
==
allele
)
&
df
.
supported_peptide_length
).
values
if
mask
.
all
():
if
len
(
query_alleles
)
==
1
and
all_peptide_lengths_supported
:
mask
=
None
else
:
mask
=
(
(
df
.
normalized_allele
==
allele
)
&
df
.
supported_peptide_length
).
values
if
mask
is
None
or
mask
.
all
():
# Common case optimization
for
(
i
,
model
)
in
enumerate
(
models
):
df
[
"
model_single_%d
"
%
i
]
=
model
.
predict
(
peptides
)
...
...
This diff is collapsed.
Click to expand it.
mhcflurry/encodable_sequences.py
+
2
−
0
View file @
64ffa8c0
...
...
@@ -39,6 +39,8 @@ class EncodableSequences(object):
"
sequence
"
:
numpy
.
array
(
sequences
),
"
sequence_length
"
:
numpy
.
array
(
sequences
),
})
self
.
min_length
=
self
.
sequences_df
.
sequence_length
.
min
()
self
.
max_length
=
self
.
sequences_df
.
sequence_length
.
max
()
self
.
sequences
=
self
.
sequences_df
.
sequence
.
values
self
.
encoding_cache
=
{}
self
.
fixed_sequence_length
=
None
...
...
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