- 论坛徽章:
- 0
|
回复 45# yanglc2013
你觉得这样子输出有具体意义吗?inc中任何一个region都会被输出到non_include中去,只要你的refGene足够多。对于后面三种有交集的情况,如果要输出到多个文件中,你把下面的代码替换一下就行。- my %result; # one of ref_include_inc, inc_include_ref, overlap or undef
- while (@ref_data) {
- my @rd = @{+shift @ref_data};
- # igore genes on the left side of inc region
- next if $rd[3] < $id[2];
- push @store, [@rd];
- # stop when this gene is on the right side of inc region
- last if $rd[2] > $id[3];
- # this gene must overlap with this inc region
- if ($id[2] >= $rd[2] && $id[3] <= $rd[3]) {
- $result{ref_include_inc} = 1;
- }
- elsif ($rd[2] >= $id[2] && $rd[3] <= $id[3]) {
- $result{inc_include_ref} = 1;
- }
- else {
- $result{overlap} = 1;
- }
- }
- # output result
- if (%result) {
- if ($result{ref_include_inc}) {
- print {$ref_include_inc} join("\t", @id), "\n";
- }
- if ($result{inc_include_ref}) {
- print {$inc_include_ref} join("\t", @id), "\n";
- }
- if ($result{overlap}) {
- print {$overlap} join("\t", @id), "\n";
- }
- }
- else { # if $result is undef, means no overlapped genes
- print {$non_include} join("\t", @id), "\n";
- }
-
- # put this genes back into @ref_data, use to check next inc region
- unshift @ref_data, @store;
- @store = ();
- }
复制代码 |
|