Skip to content

Commit

Permalink
🐛 Merge visibility info into FR df before load
Browse files Browse the repository at this point in the history
  • Loading branch information
znatty22 committed Mar 11, 2024
1 parent 7d65489 commit 0cbed61
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions kf_lib_data_ingest/target_api_plugins/kids_first_dataservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from d3b_utils.requests_retry import Session
from kf_utils.dataservice.scrape import yield_entities, yield_kfids
from pandas import DataFrame
from pandas import DataFrame, merge
from requests import RequestException

from kf_lib_data_ingest.common import constants
Expand Down Expand Up @@ -695,9 +695,19 @@ class FamilyRelationship:

@classmethod
def transform_records_list(cls, records_list):
FR = CONCEPT.FAMILY_RELATIONSHIP
original = DataFrame(records_list)

# Convert participant, mother, father to generic family relationships
df = convert_relationships_to_p1p2(
DataFrame(records_list), infer_genders=True, bidirect=True
original, infer_genders=True, bidirect=True
)
# Add back in the visibility info from original df
vis_df = original[
[FR.PERSON1.ID, FR.VISIBILTIY_REASON, FR.VISIBILITY_COMMENT]
]
df = merge(df, vis_df, how="left", on=FR.PERSON1.ID)

return df.to_dict("records")

@classmethod
Expand Down Expand Up @@ -898,7 +908,8 @@ class SequencingExperimentGenomicFile:
class_name = "sequencing_experiment_genomic_file"
api_path = "sequencing-experiment-genomic-files"
target_id_concept = CONCEPT.SEQUENCING_GENOMIC_FILE.TARGET_SERVICE_ID
service_id_fields = {"kf_id", "sequencing_experiment_id", "genomic_file_id"}
service_id_fields = {
"kf_id", "sequencing_experiment_id", "genomic_file_id"}

@classmethod
def get_key_components(cls, record, get_target_id_from_record):
Expand Down

0 comments on commit 0cbed61

Please sign in to comment.