generated from microsoft/python-package-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Gordon J. Köhn
committed
Dec 20, 2024
1 parent
bb5dff4
commit 9465f6e
Showing
6 changed files
with
58 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -136,3 +136,6 @@ poetry.lock | |
|
||
# Output folder | ||
output | ||
|
||
# Secret files | ||
secrets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"""Implements V-Pipe specific utilities. | ||
i.e. extracting metadata from V-Pipe Filenaming Conventions. | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
"""Extract metadata from V-Pipe Filenaming Conventions.""" | ||
|
||
from __future__ import annotations | ||
|
||
|
||
def sample_id_decoder(sample_id: str) -> dict: | ||
"""Decode the sample ID into individual components. | ||
Args: | ||
sample_id (str): The sample ID to decode. | ||
Returns: | ||
dict: A dictionary containing the decoded components. | ||
containing the following keys: | ||
- sequencing_well_position (str : sequencing well position) | ||
- location_code (int : code of the location) | ||
- sampling_date (str : date of the sampling) | ||
""" | ||
components = sample_id.split("_") | ||
# Assign components to meaningful variable names | ||
well_position = components[0] # A1 | ||
location_code = components[1] # 10 | ||
sampling_date = f"{components[2]}-{components[3]}-{components[4]}" # 2024-09-30 | ||
return { | ||
"sequencing_well_position": well_position, | ||
"location_code": location_code, | ||
"sampling_date": sampling_date, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
"""Implement tests for the metadata extraction functions.""" | ||
|
||
|
||
from __future__ import annotations | ||
|
||
from sr2silo.vpipe.metadata import sample_id_decoder | ||
|
||
|
||
def test_sample_id_decoder(): | ||
"""Test the sample_id_decoder function.""" | ||
sample_id = "A1_10_2024_09_30" | ||
result = sample_id_decoder(sample_id) | ||
expected = { | ||
"sequencing_well_position": "A1", | ||
"location_code": "10", | ||
"sampling_date": "2024-09-30", | ||
} | ||
assert result == expected |