Skip to content
Open
Show file tree
Hide file tree
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
10 changes: 5 additions & 5 deletions src/pmotools/pmo_builder/metatable_to_pmo.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def specimen_info_table_to_pmo(
has_travel_out_six_month_col: str = None,
host_age_col: str = None,
host_sex_col: str = None,
host_subject_id: str = None,
host_subject_name_col: str = None,
lat_lon_col: str = None,
parasite_density_col: str = None,
parasite_density_method_col: str = None,
Expand Down Expand Up @@ -281,8 +281,8 @@ def specimen_info_table_to_pmo(
:type host_age_col: str, optional
:param host_sex_col: if the specimen is from a person, the sex of that person
:type host_sex_col: str, optional
:param host_subject_id: ID for the individual a specimen was collected from
:type host_subject_id: str, optional
:param host_subject_name_col: identifier for the individual a specimen was collected from
:type host_subject_name_col: str, optional
:param lat_lon_col: latitude and longitude of the collection site
:type lat_lon_col: str, optional
:param parasite_density_col: the parasite density in parasites per microliter
Expand Down Expand Up @@ -353,7 +353,7 @@ def specimen_info_table_to_pmo(
geo_admin3_col: "geo_admin3",
host_age_col: "host_age",
host_sex_col: "host_sex",
host_subject_id: "host_subject_id",
host_subject_name_col: "host_subject_name",
lat_lon_col: "lat_lon",
specimen_accession_col: "specimen_accession",
specimen_type_col: "specimen_type",
Expand Down Expand Up @@ -392,7 +392,7 @@ def specimen_info_table_to_pmo(
geo_admin3_col,
host_age_col,
host_sex_col,
host_subject_id,
host_subject_name_col,
lat_lon_col,
specimen_accession_col,
specimen_type_col,
Expand Down
16 changes: 8 additions & 8 deletions tests/test_pmo_builder/test_metatable_to_pmo.py
Original file line number Diff line number Diff line change
Expand Up @@ -1028,7 +1028,7 @@ def test_specimen_info_table_to_pmo_with_host_fields(self):
"project_name": ["project1", "project2", "project3"],
"host_age": [25, None, 30],
"host_sex": ["M", "F", ""],
"host_subject_id": ["SUB001", "", "SUB003"],
"host_subject_name": ["SUB001", "", "SUB003"],
"gravid": [True, None, False],
"gravidity": [2, None, 0],
}
Expand All @@ -1044,33 +1044,33 @@ def test_specimen_info_table_to_pmo_with_host_fields(self):
project_name_col="project_name",
host_age_col="host_age",
host_sex_col="host_sex",
host_subject_id="host_subject_id",
host_subject_name_col="host_subject_name",
gravid_col="gravid",
gravidity_col="gravidity",
)

# sample1: all fields have values
self.assertEqual(result[0]["host_age"], 25)
self.assertEqual(result[0]["host_sex"], "M")
self.assertEqual(result[0]["host_subject_id"], "SUB001")
self.assertEqual(result[0]["host_subject_name"], "SUB001")
self.assertEqual(result[0]["gravid"], True)
self.assertEqual(result[0]["gravidity"], 2)

# sample2: host_age is None, host_subject_id is empty string, gravid is None, gravidity is None
# Should remove: host_age, host_subject_id, gravid, gravidity
# sample2: host_age is None, host_subject_name is empty string, gravid is None, gravidity is None
# Should remove: host_age, host_subject_name, gravid, gravidity
# Should keep: host_sex
self.assertNotIn("host_age", result[1])
self.assertEqual(result[1]["host_sex"], "F")
self.assertNotIn("host_subject_id", result[1])
self.assertNotIn("host_subject_name", result[1])
self.assertNotIn("gravid", result[1])
self.assertNotIn("gravidity", result[1])

# sample3: host_sex is empty string
# Should remove: host_sex
# Should keep: host_age, host_subject_id, gravid, gravidity
# Should keep: host_age, host_subject_name, gravid, gravidity
self.assertEqual(result[2]["host_age"], 30)
self.assertNotIn("host_sex", result[2])
self.assertEqual(result[2]["host_subject_id"], "SUB003")
self.assertEqual(result[2]["host_subject_name"], "SUB003")
self.assertEqual(result[2]["gravid"], False)
self.assertEqual(result[2]["gravidity"], 0)

Expand Down
Loading