Ejemplo n.º 1
0
def ForceCriticalError(print_out):
    print print_out
    if len(
            sys.argv[1:]
    ) < 2:  ### Don't create a Tkinter window if command-line options supplied
        try:
            UI.WarningWindow(print_out, 'Error Encountered!')
            root.destroy()
            GO_Elite.importGOEliteParameters('yes')
            sys.exit()
        except Exception:
            sys.exit()
    sys.exit()
def importDataSimple(filename,input_type,MOD=None,Species=None):
    id_db={}
    fn = filepath(filename)
    x=0
    for line in open(fn,'rU').xreadlines():         
        data = cleanUpLine(line)
        t = string.split(data,'\t')
        if data[0]=='#' and x==0: x=0
        elif x==0:
            column_headers = t[1:]
            if input_type != 'LineageProfiler':
                try: column_headers = t[2] ### exclude the ID, system code and p-value column headers
                except Exception: column_headers = 'NA'
            x=1
        else:
            if x==1 and input_type != 'LineageProfiler':
                ### get system conversions
                system_code = t[1]
                import GO_Elite
                import OBO_import
                system_codes,source_types,mod_types = GO_Elite.getSourceData()
                source_data = system_codes[system_code]
                try:
                    Mod=mod ### global established in upstream functions
                    speciescode = species_code
                except Exception:
                    Mod=MOD
                    speciescode = Species
                if source_data == Mod:
                    source_is_mod = True
                else:
                    source_is_mod = False
                    mod_source = Mod+'-'+source_data+'.txt'
                    gene_to_source_id = gene_associations.getGeneToUid(speciescode,('hide',mod_source))
                    source_to_gene = OBO_import.swapKeyValues(gene_to_source_id)
            if input_type != 'LineageProfiler':
                if source_is_mod == True:
                    try: id_db[t[0]] = float(t[2])
                    except Exception: id_db[t[0]] = 'NA'
                elif t[0] in source_to_gene:
                    mod_ids = source_to_gene[t[0]]
                    for mod_id in mod_ids:
                        try: value = t[2]
                        except Exception: value = 'NA'
                        if value == '+': value = 1
                        elif value == '-': value = -1
                        try: id_db[mod_id] = float(value) ### If multiple Ensembl IDs in dataset, only record the last associated fold change
                        except Exception: id_db[mod_id] = 'NA'
                        break
            else:
                id_db[t[0]]= map(float,t[1:]) ### Applies to LineageProfiler
            x+=1
    #print len(id_db),column_headers
    return id_db,column_headers
Ejemplo n.º 3
0
def importDataSimple(filename, input_type):
    id_db = {}
    fn = filepath(filename)
    x = 0
    for line in open(fn, 'rU').xreadlines():
        data = cleanUpLine(line)
        t = string.split(data, '\t')
        if data[0] == '#': x = 0
        elif x == 0:
            column_headers = t[1:]
            if input_type != 'LineageProfiler':
                column_headers = t[
                    2]  ### exclude the ID, system code and p-value column headers
            x = 1
        else:
            if x == 1 and input_type != 'LineageProfiler':
                ### get system conversions
                system_code = t[1]
                import GO_Elite
                import OBO_import
                system_codes, source_types, mod_types = GO_Elite.getSourceData(
                )
                source_data = system_codes[system_code]
                if source_data == mod:
                    source_is_mod = True
                else:
                    source_is_mod = False
                    mod_source = mod + '-' + source_data + '.txt'
                    gene_to_source_id = gene_associations.getGeneToUid(
                        species_code, ('hide', mod_source))
                    source_to_gene = OBO_import.swapKeyValues(
                        gene_to_source_id)
            if input_type != 'LineageProfiler':
                if source_is_mod == True:
                    id_db[t[0]] = float(t[2])
                elif t[0] in source_to_gene:
                    mod_ids = source_to_gene[t[0]]
                    for mod_id in mod_ids:
                        id_db[mod_id] = float(
                            t[2]
                        )  ### If multiple Ensembl IDs in dataset, only record the last associated fold chagne
            else:
                id_db[t[0]] = map(float, t[1:])  ### Applies to LineageProfiler
            x += 1
    return id_db, column_headers
Ejemplo n.º 4
0
def importOntologyAnnotations(species_code, ontology_type):
    try:
        system_codes, source_types, mod_types = GO_Elite.getSourceData()
        verified_nested = OBO_import.verifyNestedFileCreation(
            species_code, mod_types, ontology_type)
        if verified_nested == 'no': force_error
        ontology_annotations = OBO_import.importPreviousOntologyAnnotations(
            ontology_type)
    except Exception:
        try:
            ### Occurs when the annotation file isn't built yet - if so try to build
            OBO_import.buildNestedOntologyAssociations(species_code, mod_types,
                                                       ontology_type)
            ontology_annotations = OBO_import.importPreviousOntologyAnnotations(
                ontology_type)
        except Exception:
            ontology_annotations = None
    return ontology_annotations
def importDataSimple(filename, input_type, MOD=None, Species=None):
    id_db = {}
    fn = filepath(filename)
    x = 0
    for line in open(fn, 'rU').xreadlines():
        data = cleanUpLine(line)
        t = string.split(data, '\t')
        if data[0] == '#' and x == 0: x = 0
        elif x == 0:
            column_headers = t[1:]
            if input_type != 'LineageProfiler':
                try:
                    column_headers = t[
                        2]  ### exclude the ID, system code and p-value column headers
                except Exception:
                    column_headers = 'NA'
            x = 1
        else:
            if x == 1 and input_type != 'LineageProfiler':
                ### get system conversions
                system_code = t[1]
                import GO_Elite
                import OBO_import
                system_codes, source_types, mod_types = GO_Elite.getSourceData(
                )
                source_data = system_codes[system_code]
                try:
                    Mod = mod  ### global established in upstream functions
                    speciescode = species_code
                except Exception:
                    Mod = MOD
                    speciescode = Species
                if source_data == Mod:
                    source_is_mod = True
                else:
                    source_is_mod = False
                    mod_source = Mod + '-' + source_data + '.txt'
                    gene_to_source_id = gene_associations.getGeneToUid(
                        speciescode, ('hide', mod_source))
                    source_to_gene = OBO_import.swapKeyValues(
                        gene_to_source_id)
            if input_type != 'LineageProfiler':
                if source_is_mod == True:
                    try:
                        id_db[t[0]] = float(t[2])
                    except Exception:
                        id_db[t[0]] = 'NA'
                elif t[0] in source_to_gene:
                    mod_ids = source_to_gene[t[0]]
                    for mod_id in mod_ids:
                        try:
                            value = t[2]
                        except Exception:
                            value = 'NA'
                        if value == '+': value = 1
                        elif value == '-': value = -1
                        try:
                            id_db[mod_id] = float(
                                value
                            )  ### If multiple Ensembl IDs in dataset, only record the last associated fold change
                        except Exception:
                            id_db[mod_id] = 'NA'
                        break
            else:
                id_db[t[0]] = map(float, t[1:])  ### Applies to LineageProfiler
            x += 1
    #print len(id_db),column_headers
    return id_db, column_headers