scripts/support/update_go_terms.py
def modify_desc_go_terms(go_term_dict, desc_file_path):
    """
    List of GO term modifications for a specific family parse_go_term_validation_file
    The function reads the

    go_term_list: Family GO term list as generated by
    desc_file_path:
    :return:
    """

    # need to do the check for an empty list outside this function

    # get destination for new desc

    # read desc lines and delete DESC file
    desc_fp = open(desc_file_path, 'r')
    desc_lines = desc_fp.readlines()
    desc_fp.close()
    os.remove(desc_file_path)

    new_desc_fp = open(desc_file_path, 'w')

    for desc_line in desc_lines:
        if desc_line[0:2] != "DR":
            new_desc_fp.write(desc_line)
        else:
            # get go_term
            desc_go_term = desc_line.split(';')[1].strip()
            # if GO term is not in dictionary, write it to file as we are keeping it

            if desc_go_term not in go_term_dict.keys():
                new_desc_fp.write(desc_line)
            else:
                # check if empty and skip
                if bool(go_term_dict) is False:
                    continue

                # if go term is marked for deletion move to next iteration
                elif go_term_dict[desc_go_term]["FUNCTION"] == "DELETE":
                    continue

                elif go_term_dict[desc_go_term]["FUNCTION"] == "REPLACE":
                    new_go_line = desc_line.replace(go_term_dict[desc_go_term]["OLD"],
                                                    go_term_dict[desc_go_term]["NEW"])
                    new_desc_fp.write(new_go_line)

                elif go_term_dict[desc_go_term]["FUNCTION"] == "ADD":
                    # to be implemented
                    pass

    new_desc_fp.close()

    List of GO term modifications for a specific family parse_go_term_validation_file
    The function reads the

    go_term_list: Family GO term list as generated by
    desc_file_path:
    :return:
    
List of GO term modifications for a specific family parse_go_term_validation_file
The function reads the

Family GO term list as generated by
desc_file_path.
List of GO term modifications for a specific family parse_go_term_validation_file The function reads the Family GO term list as generated by desc_file_path .
def modify_desc_go_terms(go_term_dict, desc_file_path):
    desc_fp = open(desc_file_path, 'r')
    desc_lines = desc_fp.readlines()
    desc_fp.close()
    os.remove(desc_file_path)
    new_desc_fp = open(desc_file_path, 'w')
    for desc_line in desc_lines:
        if desc_line[0:2] != "DR":
            new_desc_fp.write(desc_line)
        else:
            desc_go_term = desc_line.split(';')[1].strip()
            if desc_go_term not in go_term_dict.keys():
                new_desc_fp.write(desc_line)
            else:
                if bool(go_term_dict) is False:
                    continue
                elif go_term_dict[desc_go_term]["FUNCTION"] == "DELETE":
                    continue
                elif go_term_dict[desc_go_term]["FUNCTION"] == "REPLACE":
                    new_go_line = desc_line.replace(go_term_dict[desc_go_term]["OLD"],
                                                    go_term_dict[desc_go_term]["NEW"])
                    new_desc_fp.write(new_go_line)
                elif go_term_dict[desc_go_term]["FUNCTION"] == "ADD":
                    pass
    new_desc_fp.close()
def modify_desc_go_terms ( go_term_dict , desc_file_path ) : desc_fp = open ( desc_file_path , 'r' ) desc_lines = desc_fp . readlines ( ) desc_fp . close ( ) os . remove ( desc_file_path ) new_desc_fp = open ( desc_file_path , 'w' ) for desc_line in desc_lines : if desc_line [ 0 : 2 ] != "DR" : new_desc_fp . write ( desc_line ) else : desc_go_term = desc_line . split ( ';' ) [ 1 ] . strip ( ) if desc_go_term not in go_term_dict . keys ( ) : new_desc_fp . write ( desc_line ) else : if bool ( go_term_dict ) is False : continue elif go_term_dict [ desc_go_term ] [ "FUNCTION" ] == "DELETE" : continue elif go_term_dict [ desc_go_term ] [ "FUNCTION" ] == "REPLACE" : new_go_line = desc_line . replace ( go_term_dict [ desc_go_term ] [ "OLD" ] , go_term_dict [ desc_go_term ] [ "NEW" ] ) new_desc_fp . write ( new_go_line ) elif go_term_dict [ desc_go_term ] [ "FUNCTION" ] == "ADD" : pass new_desc_fp . close ( )
List of GO term modifications for a specific family parse_go_term_validation_file
The function reads the
List of GO term modifications for a specific family parse_go_term_validation_file The function reads the
"""
    List of GO term modifications for a specific family parse_go_term_validation_file
    The function reads the

    go_term_list: Family GO term list as generated by
    desc_file_path:
    :return:
    """ # need to do the check for an empty list outside this function # get destination for new desc # read desc lines and delete DESC file # get go_term # if GO term is not in dictionary, write it to file as we are keeping it # check if empty and skip # if go term is marked for deletion move to next iteration # to be implemented
None
go_term_dict
desc_file_path