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

🐛 Don't assume sample_id exists, since fk is optional on BS #687

Merged
merged 4 commits into from
Jun 4, 2024
Merged
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
2 changes: 1 addition & 1 deletion kf_lib_data_ingest/common/concept_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ class SAMPLE(PropertyMixin):
TUMOR_DESCRIPTOR = None
EVENT_ID = None
EVENT_AGE_DAYS = None
STATUS = None

class EVENT_AGE(QuantityMixin):
pass
Expand Down Expand Up @@ -195,7 +196,6 @@ class CONCENTRATION(QuantityMixin):
CONSENT_SHORT_NAME = None

class SAMPLE_RELATIONSHIP(PropertyMixin):

class PARENT_SAMPLE(PropertyMixin):
pass

Expand Down
16 changes: 14 additions & 2 deletions kf_lib_data_ingest/target_api_plugins/kids_first_dataservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,12 @@ class Biospecimen:
class_name = "biospecimen"
api_path = "biospecimens"
target_id_concept = CONCEPT.BIOSPECIMEN.TARGET_SERVICE_ID
service_id_fields = {"kf_id", "participant_id"}
service_id_fields = {
"kf_id",
"participant_id",
"sample_id",
"sequencing_center_id",
}

@classmethod
def get_key_components(cls, record, get_target_id_from_record):
Expand All @@ -589,6 +594,12 @@ def query_target_ids(cls, host, key_components):

@classmethod
def build_entity(cls, record, get_target_id_from_record):
# sample foreign key is optional
try:
sample_id = get_target_id_from_record(Sample, record)
except Exception:
sample_id = None

secondary_components = {
"kf_id": get_target_id_from_record(cls, record),
"sequencing_center_id": record.get(
Expand Down Expand Up @@ -662,6 +673,7 @@ def build_entity(cls, record, get_target_id_from_record):
record.get(CONCEPT.SAMPLE.VOLUME_UL)
or record.get(CONCEPT.BIOSPECIMEN.VOLUME_UL)
),
"specimen_status": (record.get(CONCEPT.BIOSPECIMEN.STATUS)),
"visible": record.get(CONCEPT.BIOSPECIMEN.VISIBLE),
"visibility_comment": record.get(
CONCEPT.BIOSPECIMEN.VISIBILITY_COMMENT
Expand All @@ -677,7 +689,7 @@ def build_entity(cls, record, get_target_id_from_record):
CONCEPT.BIOSPECIMEN.DBGAP_STYLE_CONSENT_CODE
),
"consent_type": record.get(CONCEPT.BIOSPECIMEN.CONSENT_SHORT_NAME),
"sample_id": get_target_id_from_record(Sample, record),
"sample_id": sample_id,
}
return {
**cls.get_key_components(record, get_target_id_from_record),
Expand Down
Loading