RULE基本语法

rule类似于if语句,有条件判断(condition),再有执行语句。每一个判断都是针对一个数据点,而不是一串数据点。

1 Condition

1.1 默认设置:

  • 基于perl语言规则,代码将会被自动计算而不需要eval()函数。
  • 你可以使用kb,mb,gb去表示长度单位。

1.2 基本函数:

1.2.1 后缀的含义:

数值后缀(e.g. var(start1) vs var(start2)) 其中 1 表示其实点, 2表示终止点。不加的时候表示整体。

有一些关键字在运行时被解析,并被替换为基于正在测试的链接的值。 例如,可以通过var(FIELD)函数访问各个数据点属性,其中FIELD是其中之一 CHRn chromosome of span n in the link (e.g. var(chr1)) STARTn start position of span n in the link (e.g. var(start2)) ENDn end position of span n in the link (e.g. var(end2)) POSn middle position of span n in the link (e.g. var(position1)) SIZEn size of span n in the link (e.g. var(size1)) REVn returns 1 if the link end is reversed (e.g. start > end) INV returns 1 if the link is inverted (i.e. one of its ends is reversed). If both ends are reversed, the link is not inverted INTERCHR returns 1 if the link ends are on different chromosomes, otherwise returns 0 (e.g. var(interchr))不同染色体 INTRACHR returns 1 if the link ends are on the same chromosome, otherwise returns 0 (e.g. var(intrachr))同一染色体

1.3 帮助函数 helper functions

  • on(CHR) returns 1 if link的两端至少一端在染色体CHR上
    • on(CHR,START,END) returns 1 if data point is on chromosome CHR and intersects coordinate START-END, for links tests both ends
  • from(CHR) returns 1 if link的起点在CHR上
  • to(CHR) returns 1 if link的重点在CHR上
  • between(CHR1,CHR2) returns 1 if link链接了CHR1 和 CHR2 不管方向
  • fromto(CHR1,CHR2) returns 1 if link is from CHR1 to CHR2, used for links only
  • tofrom(CHR1,CHR2) returns 1 if link is from CHR2 to CHR1, used for links only
  • within(CHR,START,END) returns 1 if data point is on chromosome CHR and falls entirely within START-END, for links tests both ends
condition = var(chr1) eq "hs1"  # 连线的其实是否在染色体1上
condition = var(size1) < 1mb    # 连线起始的区间跨度是否小于1mb
condition = 1                   # always true for any link

example

<link>

file       = data/5/segdup.txt

<rules>

<rule>
# multiple conditions are combined with AND 
# i.e. all conditions must be satisfied
condition  = var(interchr) 
condition  = within(hs2,40Mb,80Mb)
z          = 60
color      = red
thickness  = 5
</rule>

<rule>
condition  = max(var(size1),var(size2)) > 40kb
z          = 50
color      = green
thickness  = 5
</rule>

<rule>
condition  = max(var(size1),var(size2)) > 10kb    
z          = 45
color      = dgrey    #浅灰色
thickness  = 4
</rule>

<rule>
condition  = max(var(size1),var(size2)) > 5kb
z          = 40
color      = grey     #灰色
thickness  = 3
</rule>

<rule>
condition  = max(var(size1),var(size2)) > 1000
z          = 35
color      = lgrey    #深灰色
thickness  = 2
</rule>

</rules>

</link>

</links>

1.4 Rule模块优先级:

rule 模块是级联执行且有优先级顺序,这意味着前面的rule一旦执行成功将会终止之后的判断。但是通过flow参数可以巧妙回避这一点。

<rule>
...
flow = continue # if this rule passes, continue testing
</rule>

flow参数有非常灵活的用法,可以要根据condition的条件来设置, 具体参见flow

# continue testing
flow = continue { if true|false }
# continue testing, but start at top of rule chain
flow = restart  { if true|false }
# stop testing
flow = stop     { if true|false }
# goto rule associated with tag=TAG
flow = goto TAG { if true|false }

1.5 多个condition判断:

condition = var(interchr) && var(size1) > 40kb #是否是统一染色体内的link,起始是否区间长度大于40kb

results matching ""

    No results matching ""