Пример #1
0
    mat = '0'
    if patient.get('gender') == 'M':
        sex = 1
    elif patient.get('gender') == 'F':
        sex = 2
    else:
        sex = 0
    if patient.get('case_or_control') == 'case':
        phenotype = 2
    elif patient.get('case_or_control') == 'control':
        phenotype = 1
    else:
        phenotype = 0

    for relative_num in bot.list_relatives(patient_id):
        relative_obj = bot.get_relative(patient_id, relative_num)
        relative_eid = relative_obj['relative_of']
        if not relative_eid:
            raise Exception('Relative ' + relative_num + ' of patient ' + patient_id + ' is malformed')
        relative = bot.get(bot.get_id(relative_eid))
        if relative_obj['relative_type'] == 'child':
            if relative['gender'] == 'M':
                if pat != '0':
                    raise Exception('Patient ' + iid + ' has two fathers: ' + pat + ' and ' + relative_eid)
                pat = relative_eid
            elif relative['gender'] == 'F':
                if mat != '0':
                    raise Exception('Patient ' + iid + ' has two mothers: ' + mat + ' and ' + relative_eid)
                mat = relative_eid
            else:
                raise Exception('Parent ' + relative_eid + ' is neither male nor female')