def add_annotation(
        self,
        term_ilx_id: str,
        annotation_type_ilx_id: str,
        annotation_value: str) -> dict:
        """ Adding an annotation value to a prexisting entity

        An annotation exists as 3 different parts:
            1. entity with type term, cde, fde, or pde
            2. entity with type annotation
            3. string value of the annotation

        Example:
            annotation = {
                'term_ilx_id': 'ilx_0101431', # brain ILX ID
                'annotation_type_ilx_id': 'ilx_0381360', # hasDbXref ILX ID
                'annotation_value': 'http://neurolex.org/wiki/birnlex_796',
            }
        """
        url = self.base_url + 'term/add-annotation'

        term_data = self.get_entity(term_ilx_id)
        if not term_data['id']:
            exit(
                'term_ilx_id: ' + term_ilx_id + ' does not exist'
            )
        anno_data = self.get_entity(annotation_type_ilx_id)
        if not anno_data['id']:
            exit(
                'annotation_type_ilx_id: ' + annotation_type_ilx_id +
                ' does not exist'
            )

        data = {
            'tid': term_data['id'],
            'annotation_tid': anno_data['id'],
            'value': annotation_value,
            'term_version': term_data['version'],
            'annotation_term_version': anno_data['version'],
            'orig_uid': self.user_id, # BUG: php lacks orig_uid update
        }

        output = self.post(
            url = url,
            data = data,
        )

        ### If already exists, we return the actual annotation properly ###
        if output.get('errormsg'):
            if 'already exists' in output['errormsg'].lower():
                term_annotations = self.get_annotation_via_tid(term_data['id'])
                for term_annotation in term_annotations:
                    if str(term_annotation['annotation_tid']) == str(anno_data['id']):
                        if term_annotation['value'] == data['value']:
                            print(
                                'Annotation: [' + term_data['label'] + ' -> ' + anno_data['label'] +
                                ' -> ' + data['value'] + '], already exists.'
                            )
                            return term_annotation
                exit(output)
            exit(output)

        return output
def add_annotation ( self , term_ilx_id : str , annotation_type_ilx_id : str , annotation_value : str ) -> dict : url = self . base_url + 'term/add-annotation' term_data = self . get_entity ( term_ilx_id ) if not term_data [ 'id' ] : exit ( 'term_ilx_id: ' + term_ilx_id + ' does not exist' ) anno_data = self . get_entity ( annotation_type_ilx_id ) if not anno_data [ 'id' ] : exit ( 'annotation_type_ilx_id: ' + annotation_type_ilx_id + ' does not exist' ) data = { 'tid' : term_data [ 'id' ] , 'annotation_tid' : anno_data [ 'id' ] , 'value' : annotation_value , 'term_version' : term_data [ 'version' ] , 'annotation_term_version' : anno_data [ 'version' ] , 'orig_uid' : self . user_id , } output = self . post ( url = url , data = data , ) if output . get ( 'errormsg' ) : if 'already exists' in output [ 'errormsg' ] . lower ( ) : term_annotations = self . get_annotation_via_tid ( term_data [ 'id' ] ) for term_annotation in term_annotations : if str ( term_annotation [ 'annotation_tid' ] ) == str ( anno_data [ 'id' ] ) : if term_annotation [ 'value' ] == data [ 'value' ] : print ( 'Annotation: [' + term_data [ 'label' ] + ' -> ' + anno_data [ 'label' ] + ' -> ' + data [ 'value' ] + '], already exists.' ) return term_annotation exit ( output ) exit ( output ) return output
Adding an annotation value to a prexisting entity

        An annotation exists as 3 different parts:
            1. entity with type term, cde, fde, or pde
            2. entity with type annotation
            3. string value of the annotation

        Example:
            annotation = {
                'term_ilx_id': 'ilx_0101431', # brain ILX ID
                'annotation_type_ilx_id': 'ilx_0381360', # hasDbXref ILX ID
                'annotation_value': 'http://neurolex.org/wiki/birnlex_796',
            }