def link_records(data): """Fetch existing information.""" case_obj = api.case(data['case']) if case_obj is None: raise ValueError("case not found: {}".format(data['case'])) for sample_id in data['samples']: sample_obj = api.sample(sample_id) if sample_obj is None: raise ValueError("sample not found: {}".format(sample_id)) data['run'].samples.append(sample_obj) for new_asset, sample_id in data['assets']: link_asset(data['run'], new_asset, sample=sample_id) return {'case': case_obj, 'run': data['run']}
def parse(config_data, reference_data, force=False): """Parse MIP analysis output.""" # 1. parse segments of input data segments = prepare_inputs(config_data) # 2. post-process the output a bit prepare_run(segments, force=force) # 3. build the records mip_version = segments['family'].get('MIPVersion', 'v2.x') new_objs = build_analysis(segments, version=mip_version) # 4. parse references new_refs = parse_references(reference_data, segments=segments) # 5. build assets from references + link to new records new_assets = build_assets(new_refs) for new_asset, sample in new_assets: link_asset(new_objs['run'], new_asset, sample=sample) return new_objs