scripts/support/update_go_terms.py
def parse_go_term_file(go_term_file):
    """
    Parses a tabular file of valid GO terms and returns a dictionary with all
    available GO terms per family. An example of the file can be found in this
    url(https://goo.gl/5PN5LT)

    go_term_file: The path to a go term file. This should be a tab delimited
    file where multiple terms followed by their description, are

    return: void
    """

    # need to add a column for the function DELETE, ADD, REPLACE

    go_terms_dict = {}
    go_terms_fp = open(go_term_file, 'r')

    for go_line in go_terms_fp:
        go_line = go_line.strip().split('\t')

        go_terms = go_line[1:]

        rfam_acc = go_line[0].strip()

        if rfam_acc not in go_terms_dict:
            go_terms_dict[rfam_acc] = []

        # check if the go term pairs are correct. Each GO term id must be followed
        # by a description
        if len(go_terms) % 2 != 0:
            print "Erroneous go term for %s" % rfam_acc
            continue

        idx = 0
        # work on go term pairs for a specific family
        while idx < len(go_terms):
            # organize go term pairs in tuples
            go_terms_dict[rfam_acc].append((go_terms[idx].strip(),
                                            go_terms[idx+1].strip()))
            idx += 2

    return go_terms_dict

    Parses a tabular file of valid GO terms and returns a dictionary with all
    available GO terms per family. An example of the file can be found in this
    url(https://goo.gl/5PN5LT)

    go_term_file: The path to a go term file. This should be a tab delimited
    file where multiple terms followed by their description, are

    return: void
    
Parses a tabular file of valid GO terms and returns a dictionary with all
available GO terms per family. An example of the file can be found in this
url

The path to a go term file. This should be a tab delimited
file where multiple terms followed by their description, are

void
Parses a tabular file of valid GO terms and returns a dictionary with all available GO terms per family . An example of the file can be found in this url The path to a go term file . This should be a tab delimited file where multiple terms followed by their description are void
def parse_go_term_file(go_term_file):
    go_terms_dict = {}
    go_terms_fp = open(go_term_file, 'r')
    for go_line in go_terms_fp:
        go_line = go_line.strip().split('\t')
        go_terms = go_line[1:]
        rfam_acc = go_line[0].strip()
        if rfam_acc not in go_terms_dict:
            go_terms_dict[rfam_acc] = []
        if len(go_terms) % 2 != 0:
            print "Erroneous go term for %s" % rfam_acc
            continue
        idx = 0
        while idx < len(go_terms):
            go_terms_dict[rfam_acc].append((go_terms[idx].strip(),
                                            go_terms[idx+1].strip()))
            idx += 2
    return go_terms_dict
def parse_go_term_file ( go_term_file ) : go_terms_dict = { } go_terms_fp = open ( go_term_file , 'r' ) for go_line in go_terms_fp : go_line = go_line . strip ( ) . split ( '\t' ) go_terms = go_line [ 1 : ] rfam_acc = go_line [ 0 ] . strip ( ) if rfam_acc not in go_terms_dict : go_terms_dict [ rfam_acc ] = [ ] if len ( go_terms ) % 2 != 0 : print "Erroneous go term for %s" % rfam_acc continue idx = 0 while idx < len ( go_terms ) : go_terms_dict [ rfam_acc ] . append ( ( go_terms [ idx ] . strip ( ) , go_terms [ idx + 1 ] . strip ( ) ) ) idx += 2 return go_terms_dict
Parses a tabular file of valid GO terms and returns a dictionary with all
available GO terms per family.
Parses a tabular file of valid GO terms and returns a dictionary with all available GO terms per family .
"""
    Parses a tabular file of valid GO terms and returns a dictionary with all
    available GO terms per family. An example of the file can be found in this
    url(https://goo.gl/5PN5LT)

    go_term_file: The path to a go term file. This should be a tab delimited
    file where multiple terms followed by their description, are

    return: void
    """ # need to add a column for the function DELETE, ADD, REPLACE # check if the go term pairs are correct. Each GO term id must be followed # by a description # work on go term pairs for a specific family # organize go term pairs in tuples
go_term_file