Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add filtering nanobodies #129

Merged
merged 2 commits into from
Dec 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions proteinflow/data/torch.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ def from_args(
cut_edges=False,
require_antigen=False,
require_light_chain=False,
require_no_light_chain=False,
require_heavy_chain=False,
*args,
**kwargs,
Expand Down Expand Up @@ -191,6 +192,8 @@ def from_args(
if `True`, only entries with an antigen will be included (used if the dataset is SAbDab)
require_light_chain : bool, default False
if `True`, only entries with a light chain will be included (used if the dataset is SAbDab)
require_no_light_chain : bool, default False
if `True`, only entries without a light chain will be included (used if the dataset is SAbDab)
require_heavy_chain : bool, default False
if `True`, only entries with a heavy chain will be included (used if the dataset is SAbDab)
*args
Expand Down Expand Up @@ -225,6 +228,7 @@ def from_args(
cut_edges=cut_edges,
require_antigen=require_antigen,
require_light_chain=require_light_chain,
require_no_light_chain=require_no_light_chain,
require_heavy_chain=require_heavy_chain,
)
return ProteinLoader(
Expand Down Expand Up @@ -323,6 +327,7 @@ def __init__(
antigen_patch_size=128,
require_antigen=False,
require_light_chain=False,
require_no_light_chain=False,
require_heavy_chain=False,
):
"""Initialize the dataset.
Expand Down Expand Up @@ -398,6 +403,8 @@ def __init__(
if `True`, only entries with an antigen will be included (used if the dataset is SAbDab)
require_light_chain : bool, default False
if `True`, only entries with a light chain will be included (used if the dataset is SAbDab)
require_no_light_chain : bool, default False
if `True`, only entries without a light chain will be included (used if the dataset is SAbDab)
requre_heavy_chain : bool, default False
if `True`, only entries with a heavy chain will be included (used if the dataset is SAbDab)

Expand Down Expand Up @@ -538,7 +545,10 @@ def __init__(
if require_antigen or require_light_chain:
to_exclude.update(
self._exclude_by_chains(
require_antigen, require_light_chain, require_heavy_chain
require_antigen,
require_light_chain,
require_no_light_chain,
require_heavy_chain,
)
)
if self.clusters is not None:
Expand Down Expand Up @@ -604,7 +614,11 @@ def _check_chain_types(self, file):
return chain_types

def _exclude_by_chains(
self, require_antigen, require_light_chain, require_heavy_chain
self,
require_antigen,
require_light_chain,
require_no_light_chain,
require_heavy_chain,
):
"""Exclude entries that do not have an antigen or a light chain."""
to_exclude = set()
Expand All @@ -617,6 +631,8 @@ def _exclude_by_chains(
to_exclude.add(id)
if require_light_chain and "light" not in chain_types:
to_exclude.add(id)
if require_no_light_chain and "light" in chain_types:
to_exclude.add(id)
if require_heavy_chain and "heavy" not in chain_types:
to_exclude.add(id)
return to_exclude
Expand Down
Loading