scripts/parse_nagim.py
def _fix_sample_ids(samples: List[Sample], namespace: str = 'main'):
    """
    Some samples processed with Terra use CPG IDs, so checking if we already
    have them in the SMDB, and fixing the external IDs.
    """
    sm_proj_ids = [_get_sm_proj_id(proj, namespace) for proj in PROJECT_ID_MAP.values()]
    sapi = SampleApi()
    sm_sample_dicts = sapi.get_samples(
        body_get_samples_by_criteria_api_v1_sample_post={
            'project_ids': sm_proj_ids,
            'active': True,
        }
    )

    cpgid_to_extid = {s['id']: s['external_id'] for s in sm_sample_dicts}
    extid_to_cpgid = {s['external_id']: s['id'] for s in sm_sample_dicts}

    # Fixing sample IDs. Some samples (tob-wgs and acute-care)
    # have CPG IDs as nagim ids, some don't
    for sample in samples:
        if sample.nagim_id in extid_to_cpgid:
            sample.ext_id = sample.nagim_id
            sample.cpg_id = extid_to_cpgid[sample.nagim_id]
        elif sample.nagim_id in cpgid_to_extid:
            sample.ext_id = cpgid_to_extid[sample.nagim_id]
            sample.cpg_id = sample.nagim_id
        else:
            sample.ext_id = sample.nagim_id

    Some samples processed with Terra use CPG IDs, so checking if we already
    have them in the SMDB, and fixing the external IDs.
    
Some samples processed with Terra use CPG IDs, so checking if we already
have them in the SMDB, and fixing the external IDs.
Some samples processed with Terra use CPG IDs so checking if we already have them in the SMDB and fixing the external IDs .
def _fix_sample_ids(samples: List[Sample], namespace: str = 'main'):
    sm_proj_ids = [_get_sm_proj_id(proj, namespace) for proj in PROJECT_ID_MAP.values()]
    sapi = SampleApi()
    sm_sample_dicts = sapi.get_samples(
        body_get_samples_by_criteria_api_v1_sample_post={
            'project_ids': sm_proj_ids,
            'active': True,
        }
    )
    cpgid_to_extid = {s['id']: s['external_id'] for s in sm_sample_dicts}
    extid_to_cpgid = {s['external_id']: s['id'] for s in sm_sample_dicts}
    for sample in samples:
        if sample.nagim_id in extid_to_cpgid:
            sample.ext_id = sample.nagim_id
            sample.cpg_id = extid_to_cpgid[sample.nagim_id]
        elif sample.nagim_id in cpgid_to_extid:
            sample.ext_id = cpgid_to_extid[sample.nagim_id]
            sample.cpg_id = sample.nagim_id
        else:
            sample.ext_id = sample.nagim_id
def _fix_sample_ids ( samples : List [ Sample ] , namespace : str = 'main' ) : sm_proj_ids = [ _get_sm_proj_id ( proj , namespace ) for proj in PROJECT_ID_MAP . values ( ) ] sapi = SampleApi ( ) sm_sample_dicts = sapi . get_samples ( body_get_samples_by_criteria_api_v1_sample_post = { 'project_ids' : sm_proj_ids , 'active' : True , } ) cpgid_to_extid = { s [ 'id' ] : s [ 'external_id' ] for s in sm_sample_dicts } extid_to_cpgid = { s [ 'external_id' ] : s [ 'id' ] for s in sm_sample_dicts } for sample in samples : if sample . nagim_id in extid_to_cpgid : sample . ext_id = sample . nagim_id sample . cpg_id = extid_to_cpgid [ sample . nagim_id ] elif sample . nagim_id in cpgid_to_extid : sample . ext_id = cpgid_to_extid [ sample . nagim_id ] sample . cpg_id = sample . nagim_id else : sample . ext_id = sample . nagim_id
Some samples processed with Terra use CPG IDs, so checking if we already
have them in the SMDB, and fixing the external IDs.
Some samples processed with Terra use CPG IDs so checking if we already have them in the SMDB and fixing the external IDs .
"""
    Some samples processed with Terra use CPG IDs, so checking if we already
    have them in the SMDB, and fixing the external IDs.
    """ # Fixing sample IDs. Some samples (tob-wgs and acute-care) # have CPG IDs as nagim ids, some don't
samples
List[Sample]
namespace
str