Beispiel #1
0
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']}
Beispiel #2
0
def mip_sex(context, sample, case_id):
    """Parse out analysis determined sex of sample."""
    if sample and case_id is None:
        sample_obj = api.sample(sample)
        if sample_obj is None:
            log.warn('sorry, sample not found')
            context.abort()
        case_id = sample_obj.case_id

    qc_metrics = api.assets(case_id, category='qc').first()
    qcm_data = yaml.load(qc_metrics.path)
    sample_sexes = parse_mipsex(qcm_data)
    if sample:
        click.echo(sample_sexes[sample])
    else:
        for sample_id, sex in sample_sexes.items():
            click.echo("{}: {}".format(sample_id, sex))