本文整理汇总了Python中UI.cleanUpLine方法的典型用法代码示例。如果您正苦于以下问题:Python UI.cleanUpLine方法的具体用法?Python UI.cleanUpLine怎么用?Python UI.cleanUpLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UI
的用法示例。
在下文中一共展示了UI.cleanUpLine方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: importExpressionValues
# 需要导入模块: import UI [as 别名]
# 或者: from UI import cleanUpLine [as 别名]
def importExpressionValues(filename):
""" Imports tab-delimited expression values"""
header = True
sample_expression_db = {}
fn = unique.filepath(filename)
for line in open(fn, "rU").xreadlines():
data = UI.cleanUpLine(line)
if header:
sample_names = string.split(data, "\t")
header = False
else:
exp_values = string.split(data, "\t")
gene = exp_values[0]
index = 1
for value in exp_values[1:]:
sample_name = sample_names[index]
if sample_name in sample_expression_db:
gene_expression_db = sample_expression_db[sample_name]
gene_expression_db[gene] = value
else:
gene_expression_db = {}
gene_expression_db[gene] = value
sample_expression_db[sample_name] = gene_expression_db
index += 1
return sample_expression_db
示例2: importAgilentExpressionValues
# 需要导入模块: import UI [as 别名]
# 或者: from UI import cleanUpLine [as 别名]
def importAgilentExpressionValues(filename,array,channel_to_extract):
""" Imports Agilent Feature Extraction files for one or more channels """
print '.',
red_expr_db={}
green_expr_db={}
parse=False
fn=unique.filepath(filename)
for line in open(fn,'rU').xreadlines():
data = UI.cleanUpLine(line)
if parse==False:
if 'ProbeName' in data:
headers = string.split(data,'\t')
pn = headers.index('ProbeName')
try: gc = headers.index('gProcessedSignal')
except Exception: pass
try: rc = headers.index('rProcessedSignal')
except Exception: pass
parse = True
else:
t = string.split(data,'\t')
probe_name = t[pn]
try: green_channel = math.log(float(t[gc])+1,2) #min is 0
except Exception: pass
try: red_channel = math.log(float(t[rc])+1,2) #min is 0
except Exception: pass
if 'red' in channel_to_extract:
red_expr_db[probe_name] = red_channel
if 'green' in channel_to_extract:
green_expr_db[probe_name] = green_channel
if 'red' in channel_to_extract:
red_channel_db[array] = red_expr_db
if 'green' in channel_to_extract:
green_channel_db[array] = green_expr_db
示例3: annotateMetaProbesetGenes
# 需要导入模块: import UI [as 别名]
# 或者: from UI import cleanUpLine [as 别名]
def annotateMetaProbesetGenes(summary_exp_file, expression_file, metaprobeset_file, species):
metaprobeset_cv_file = string.replace(metaprobeset_file,species+'_',species+'_Conversion_')
metaprobeset_cv_file = string.replace(metaprobeset_cv_file,'.mps','.txt')
fn=filepath(metaprobeset_cv_file); uid_db={}
for line in open(fn,'rU').xreadlines():
data = UI.cleanUpLine(line)
uid,ens_gene = string.split(data,'\t')
uid_db[uid] = ens_gene
export_data = export.ExportFile(expression_file)
fn=filepath(summary_exp_file); x=0
for line in open(fn,'rU').xreadlines():
if line[0] == '#': null=[]
elif x == 0: export_data.write(line); x+=1
else:
data = cleanUpLine(line)
t = string.split(data,'\t')
uid = t[0]; ens_gene = uid_db[uid]
export_data.write(string.join([ens_gene]+t[1:],'\t')+'\n')
export_data.close()
示例4: compareImportedTables
# 需要导入模块: import UI [as 别名]
# 或者: from UI import cleanUpLine [as 别名]
def compareImportedTables(file_list,outputDir,importDir=False,considerNumericDirection=False,display=True):
### added for AltAnalyze
print 'Creating Venn Diagram from input files...'
import UI
import export
file_id_db={}
file_list2=[]
for file in file_list:
x=0
if '.txt' in file:
if importDir !=False: ### When all files in a directory are analyzed
fn=UI.filepath(import_dir+'/'+file)
else:
fn = file
file = export.findFilename(fn) ### Only report the actual filename
file_list2.append(file)
for line in open(fn,'rU').xreadlines():
if x == 0:
data_type = examineFields(line)
x+=1
else:
data = UI.cleanUpLine(line)
t = string.split(data,'\t')
uid = t[0]
valid = True
if data_type != 'first':
if data_type == 'comparison':
score = float(string.split(t[6],'|')[0])
if 'yes' not in t[5]:
valid = False ### not replicated independently
if data_type == 'reciprocal':
uid = t[8]+'-'+t[10]
score = float(t[1])
if data_type == 'single':
uid = t[6]
score = float(t[1])
else:
try:
score = float(t[1]) #t[2]
except Exception: score = None
if score != None and considerNumericDirection: ### change the UID so that it only matches if the same direction
if score>0:
uid+='+' ### encode the ID with a negative sign
else:
uid+='-' ### encode the ID with a negative sign
#if score>0:
if valid:
try: file_id_db[file].append(uid)
except Exception: file_id_db[file] = [uid]
id_lists=[]
new_file_list=[]
for file in file_list2: ### Use the sorted names
if file in file_id_db:
uids = file_id_db[file]
id_lists.append(uids)
new_file_list.append(file)
#print file, len(new_file_list), len(uids)
if len(file_id_db):
if len(new_file_list)==2 or len(new_file_list)==3:
SimpleMatplotVenn(new_file_list,id_lists,outputDir=outputDir,display=False) ### display both below
venn(id_lists, new_file_list, fill="number", show_names=False, outputDir=outputDir, show_plot=display)