Skip to content

Commit 25705bd

Browse files
committed
allow passing d percentage
1 parent 4bdaee5 commit 25705bd

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

pyhdx/datasets.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ def load_peptides(peptides):
5555
return output
5656

5757

58-
def parse_dataset_states(states: list[State], drop_first: int) -> list[tuple[pd.DataFrame, dict]]:
58+
def parse_dataset_states(
59+
states: list[State], drop_first: int, d_percentage: float | None = None
60+
) -> list[tuple[pd.DataFrame, dict]]:
5961
"""Parse an HDXDataSet into a list of tuples of (peptides, metadata) for pyhdx"""
6062

6163
output = []
@@ -83,13 +85,17 @@ def find_fd_control() -> tuple[int, pd.DataFrame]:
8385
pd_peptides = get_peptides_by_type(state.peptides, DeuterationType.partially_deuterated)
8486
assert pd_peptides is not None # this never happens due to previous checks
8587

88+
d_percentage = d_percentage or pd_peptides.d_percentage
89+
assert d_percentage is not None, (
90+
"Deuterium percentage must be specified either in the dataset or as a kwarg"
91+
)
8692
merged = merge_peptide_tables(**peptides) # type: ignore
8793
computed = compute_uptake_metrics(merged)
8894
adapted = adapt_for_pyhdx(computed).to_pandas()
8995
peptides_corrected = correct_d_uptake(
9096
adapted,
9197
drop_first=drop_first,
92-
d_percentage=pd_peptides.d_percentage or 100.0,
98+
d_percentage=d_percentage,
9399
)
94100

95101
metadata = {

0 commit comments

Comments
 (0)