main.py
def clean_valid_ids(valid_ids, valid_ids_lables):
    '''remove concepts with same label as entity and phenotypes with same label as disease'''
    valid_ids_lower = [i.lower() for i in valid_ids.keys()]
    disease_labels = []
    for ent in valid_ids.values():
        if ent['category'] == 'DISEASE':
            disease_labels.append(ent['label'].lower())
            disease_labels.append(ent['label'].lower().replace('-', ''))
    for k, v, in valid_ids.items():
        if v['category'] == 'CONCEPT':
            lower_label = v['label'].lower()
            if lower_label in valid_ids_lables or \
                            v['label'] in valid_ids_lables or \
                            lower_label.replace('-', '') in valid_ids_lables:
                valid_ids.pop(k)
            if v['label'][-1] == 's' and \
                            v['label'][:-1] in valid_ids:
                valid_ids.pop(k)
                # if v['label'] != lower_label and lower_label in valid_ids_lower and k in valid_ids:
                #     valid_ids.pop(k)
        elif v['category'] == 'PHENOTYPE' and disease_labels:
            if v['label'].lower() in disease_labels or \
                            v['label'].lower().replace('-', '') in disease_labels:
                valid_ids.pop(k)
remove concepts with same label as entity and phenotypes with same label as disease
remove concepts with same label as entity and phenotypes with same label as disease
remove concepts with same label as entity and phenotypes with same label as disease
def clean_valid_ids(valid_ids, valid_ids_lables):
    valid_ids_lower = [i.lower() for i in valid_ids.keys()]
    disease_labels = []
    for ent in valid_ids.values():
        if ent['category'] == 'DISEASE':
            disease_labels.append(ent['label'].lower())
            disease_labels.append(ent['label'].lower().replace('-', ''))
    for k, v, in valid_ids.items():
        if v['category'] == 'CONCEPT':
            lower_label = v['label'].lower()
            if lower_label in valid_ids_lables or \
                            v['label'] in valid_ids_lables or \
                            lower_label.replace('-', '') in valid_ids_lables:
                valid_ids.pop(k)
            if v['label'][-1] == 's' and \
                            v['label'][:-1] in valid_ids:
                valid_ids.pop(k)
        elif v['category'] == 'PHENOTYPE' and disease_labels:
            if v['label'].lower() in disease_labels or \
                            v['label'].lower().replace('-', '') in disease_labels:
                valid_ids.pop(k)
def clean_valid_ids ( valid_ids , valid_ids_lables ) : valid_ids_lower = [ i . lower ( ) for i in valid_ids . keys ( ) ] disease_labels = [ ] for ent in valid_ids . values ( ) : if ent [ 'category' ] == 'DISEASE' : disease_labels . append ( ent [ 'label' ] . lower ( ) ) disease_labels . append ( ent [ 'label' ] . lower ( ) . replace ( '-' , '' ) ) for k , v , in valid_ids . items ( ) : if v [ 'category' ] == 'CONCEPT' : lower_label = v [ 'label' ] . lower ( ) if lower_label in valid_ids_lables or v [ 'label' ] in valid_ids_lables or lower_label . replace ( '-' , '' ) in valid_ids_lables : valid_ids . pop ( k ) if v [ 'label' ] [ - 1 ] == 's' and v [ 'label' ] [ : - 1 ] in valid_ids : valid_ids . pop ( k ) elif v [ 'category' ] == 'PHENOTYPE' and disease_labels : if v [ 'label' ] . lower ( ) in disease_labels or v [ 'label' ] . lower ( ) . replace ( '-' , '' ) in disease_labels : valid_ids . pop ( k )
remove concepts with same label as entity and phenotypes with same label as disease
remove concepts with same label as entity and phenotypes with same label as disease
'''remove concepts with same label as entity and phenotypes with same label as disease''' # if v['label'] != lower_label and lower_label in valid_ids_lower and k in valid_ids: #     valid_ids.pop(k)
valid_ids
valid_ids_lables