def registry_with_biosources_and_biomaterials() -> CentralSubjectRegistry: individuals = [Individual(individual_id='P1', birth_date='1950-05-05')] diagnoses = [ Diagnosis(diagnosis_id='D1', individual_id='P1', diagnosis_date='2010-03-31') ] biosources = [ Biosource(biosource_id='PMCBS000AAA', individual_id='P1', diagnosis_id='D1'), Biosource(biosource_id='PMCBS000AAB', individual_id='P1', diagnosis_id='D1') ] biomaterials = [ Biomaterial(biomaterial_id='PMCBM000AAA', src_biosource_id='PMCBS000AAA'), Biomaterial(biomaterial_id='PMCBM000AAB', src_biosource_id='PMCBS000AAB') ] return CentralSubjectRegistry.create({ 'Individual': individuals, 'Diagnosis': diagnoses, 'Biosource': biosources, 'Biomaterial': biomaterials })
def registry_with_diagnoses() -> CentralSubjectRegistry: individuals = [ Individual(individual_id='P1', birth_date='1950-05-05'), Individual(individual_id='P2', birth_date='2001-01-01'), Individual(individual_id='P3', birth_date='2001-01-01', age_first_diagnosis=5), Individual(individual_id='P4', birth_date='2001-01-01', diagnosis_count=3), ] diagnoses = [ Diagnosis(diagnosis_id='D1.1', individual_id='P1', diagnosis_date='2010-03-31'), Diagnosis(diagnosis_id='D1.2', individual_id='P1', diagnosis_date='2012-05-05'), Diagnosis(diagnosis_id='D2.1', individual_id='P2', diagnosis_date='2011-12-01'), Diagnosis(diagnosis_id='D3.1', individual_id='P3', diagnosis_date='2011-12-01'), Diagnosis(diagnosis_id='D4.1', individual_id='P4', diagnosis_date='2011-12-01'), ] return CentralSubjectRegistry.create({ 'Individual': individuals, 'Diagnosis': diagnoses })
def read_subject_data(self) -> CentralSubjectRegistry: logger.info('Reading subject registry data ...') subject_registry_data: Dict[str, Sequence[SubjectEntity]] = {} for entity_type in list(SubjectEntity.__args__): subject_registry_data[entity_type.__name__] = self.read_entity_data(entity_type) return CentralSubjectRegistry.create(subject_registry_data)
def read_subject_registry(self) -> CentralSubjectRegistry: try: entity_data = { entity_type.schema()['title']: self.read_entities( path.join(self.input_dir, entity_filename(entity_type)), entity_type) for entity_type in list(SubjectEntity.__args__) } return CentralSubjectRegistry(entity_data=entity_data) except FileNotFoundError as fnfe: raise FileNotFoundError('File not found. {}'.format(fnfe))
def registry_with_missing_diagnosis_data() -> CentralSubjectRegistry: individuals = [ Individual(individual_id='P1', birth_date='1950-05-05'), Individual(individual_id='P2', birth_date='2001-01-01'), Individual(individual_id='P3', birth_date='2002-07-07'), Individual(individual_id='P4') ] diagnoses = [ Diagnosis(diagnosis_id='D1.1', individual_id='P1', diagnosis_date='2010-03-31'), Diagnosis(diagnosis_id='D2.1', individual_id='P2'), Diagnosis(diagnosis_id='D2.2', individual_id='P2'), Diagnosis(diagnosis_id='D4.1', individual_id='P4', diagnosis_date='2012-02-15') ] return CentralSubjectRegistry.create({ 'Individual': individuals, 'Diagnosis': diagnoses })
def csr_subject_registry(csr_individuals) -> CentralSubjectRegistry: return CentralSubjectRegistry.create({'Individual': csr_individuals})