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
No related branches found
Branches containing commit
No related tags found
Tags containing commit
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):
...
@@ -848,20 +848,29 @@ class Class1AffinityPredictor(object):
(
min_peptide_length
,
max_peptide_length
)
=
(
(
min_peptide_length
,
max_peptide_length
)
=
(
self
.
supported_peptide_lengths
)
self
.
supported_peptide_lengths
)
df
[
"
supported_peptide_length
"
]
=
(
(
df
.
peptide
.
str
.
len
()
>=
min_peptide_length
)
&
if
(
peptides
.
min_length
<
min_peptide_length
or
(
df
.
peptide
.
str
.
len
()
<=
max_peptide_length
))
peptides
.
max_length
>
max_peptide_length
):
if
(
~
df
.
supported_peptide_length
).
any
():
# Only compute this if needed
msg
=
(
all_peptide_lengths_supported
=
False
"
%d peptides have lengths outside of supported range [%d, %d]:
"
df
[
"
supported_peptide_length
"
]
=
(
"
%s
"
%
(
(
df
.
sequence_length
.
len
()
>=
min_peptide_length
)
&
(
~
df
.
supported_peptide_length
).
sum
(),
(
df
.
sequence_length
.
len
()
<=
max_peptide_length
))
min_peptide_length
,
if
(
~
df
.
supported_peptide_length
).
any
():
max_peptide_length
,
msg
=
(
str
(
df
.
ix
[
~
df
.
supported_peptide_length
].
peptide
.
unique
())))
"
%d peptides have lengths outside of supported range [%d, %d]:
"
logging
.
warning
(
msg
)
"
%s
"
%
(
if
throw
:
(
~
df
.
supported_peptide_length
).
sum
(),
raise
ValueError
(
msg
)
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
:
if
self
.
class1_pan_allele_models
:
unsupported_alleles
=
[
unsupported_alleles
=
[
...
@@ -904,12 +913,16 @@ class Class1AffinityPredictor(object):
...
@@ -904,12 +913,16 @@ class Class1AffinityPredictor(object):
logging
.
warning
(
msg
)
logging
.
warning
(
msg
)
if
throw
:
if
throw
:
raise
ValueError
(
msg
)
raise
ValueError
(
msg
)
for
allele
in
query_alleles
:
for
allele
in
query_alleles
:
models
=
self
.
allele_to_allele_specific_models
.
get
(
allele
,
[])
models
=
self
.
allele_to_allele_specific_models
.
get
(
allele
,
[])
mask
=
(
if
len
(
query_alleles
)
==
1
and
all_peptide_lengths_supported
:
(
df
.
normalized_allele
==
allele
)
&
mask
=
None
df
.
supported_peptide_length
).
values
else
:
if
mask
.
all
():
mask
=
(
(
df
.
normalized_allele
==
allele
)
&
df
.
supported_peptide_length
).
values
if
mask
is
None
or
mask
.
all
():
# Common case optimization
# Common case optimization
for
(
i
,
model
)
in
enumerate
(
models
):
for
(
i
,
model
)
in
enumerate
(
models
):
df
[
"
model_single_%d
"
%
i
]
=
model
.
predict
(
peptides
)
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):
...
@@ -39,6 +39,8 @@ class EncodableSequences(object):
"
sequence
"
:
numpy
.
array
(
sequences
),
"
sequence
"
:
numpy
.
array
(
sequences
),
"
sequence_length
"
:
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
.
sequences
=
self
.
sequences_df
.
sequence
.
values
self
.
encoding_cache
=
{}
self
.
encoding_cache
=
{}
self
.
fixed_sequence_length
=
None
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