尝试正确使用expand和zip扩展两个列表以定义输出规则会导致出现我认为不会定义的新通配符
BASES = ['wt_base', 'wt', 'wt_base_ars', 'F210i_base', 'no_4su']
CONTRASTS = ['f210i_base', 'f210i', 'wt_during_ars', 'F210i_during_ars', '24hr_4su']
rule top:
input:
expand(config['majiq_top_level'] + "delta_psi/" + "{base}_{contrast}" + ".tsv",zip, base = BASES,contrast = CONTRASTS)
失败
Building DAG of jobs...
InputFunctionException in line 81 of /SAN/vyplab/alb_projects/pipelines/splicing/rules/majiq.smk:
UnboundLocalError: local variable 'grps' referenced before assignment
Wildcards:
base=wt_base_f210i
contrast=base
我已经尝试从规则和具有相同错误的名称中删除“ _”
BASES=['wtbase', 'wt', 'wtbasears', 'F210ibase', 'no4su']
CONTRASTS=['f210ibase', 'f210i', 'wtduringars', 'F210iduringars', '24hr4su']
rule top:
input:
expand(config['majiq_top_level'] + "delta_psi/" + "{base}{contrast}" + ".tsv",zip, base = BASES,contrast = CONTRASTS)
InputFunctionException in line 82 of /SAN/vyplab/alb_projects/pipelines/splicing/rules/majiq.smk:
UnboundLocalError: local variable 'grps' referenced before assignment
Wildcards:
base=wtbasef210ibas
contrast=e
该错误是由稍后的功能引起的,但是如果输入的通配符位于提供的BASES或CONTRASTS列表中,则该功能不会失败。
相反,我们将每个列表中的两个值组合在一起作为“基础”通配符,我什至不知道对比度=基础来自哪里
我想在列表名称中使用“ _”可能会引起混淆,但我不确定吗?
答案 0 :(得分:0)
这对我为什么并不完全有意义,但是解决方案似乎除了除去列表值中的歧义连字符以外,还修复了输入函数:
以前,我使用的是一种懒惰的方法,如果该组出现在我的原始列表中,则总是在此循环中定义变量grp
#go through the values of the dictionary and break when we find the right groups in that contrast
for v in compare_dict.values():
for k in v.keys():
if k == grp:
grps = v[k]
break
#take the sample names corresponding to those groups
grp_samples = list(samples2[samples2['group'].isin(grps)].sample_name)
简单地添加else条件并将grps定义为空列表似乎可以解决问题。
#go through the values of the dictionary and break when we find the right groups in that contrast
for v in compare_dict.values():
for k in v.keys():
if k == grp:
grps = v[k]
break
else:
grps = list('')
#take the sample names corresponding to those groups
grp_samples = list(samples2[samples2['group'].isin(grps)].sample_name)
似乎已解决该错误。我不知道为什么会这样,但是还可以。