- 论坛徽章:
- 8
|
本帖最后由 huang6894 于 2015-02-03 23:14 编辑
回复 1# Li_0817
我直觉告诉我你的问题是有问题的~
- #!/usr/bin/perl -w
- my ($mrna, $utr) = @ARGV;
- my %hash;
- open MRNA,"< $mrna" or die "$!";
- while(<MRNA>){
- chomp;
- my @all = split;
- push @{$hash{$all[0]}},[@all];
- }
- close MRNA;
- open UTR,"< $utr" or die "$!";
- while(<UTR>){
- chomp;
- my @all = split;
- next unless exists $hash{$all[0]};
- FOR: foreach my $all_data(@{$hash{$all[0]}}){
- if((abs($all[3] - $all_data->[3]) <= 1000) and (abs($all[4] - $all_data->[4]) <= 1000) and ($all_data->[2] eq 'mRNA')){
- push @{$hash{$all[0]}},[@all];
- last FOR;
- }
- }
- }
- close UTR;
- foreach my $key(sort keys %hash){
- my @all_data = sort{$a->[3]<=>$b->[3]}@{$hash{$key}};
- print join("\t",@$_),"\n" for(@all_data);
- }
复制代码
- => perl hh.pl mrna.gff utr.gff
- C25482226 GLEAN mRNA 183 658 1 - . ID=AR_GLEAN_10000004;
- C25494756 GLEAN mRNA 440 688 0.999963 + . ID=AR_GLEAN_10000006;
- C25522030 GLEAN mRNA 160 672 1 - . ID=AR_GLEAN_10000007;
- C25652603 GLEAN mRNA 243 646 1 - . ID=AR_GLEAN_10000012;
- C25786066 GLEAN mRNA 393 1107 1 + . ID=AR_GLEAN_10000016;
- C25902867 GLEAN mRNA 160 722 1 - . ID=AR_GLEAN_10000020;
- C25958551 GLEAN mRNA 320 1185 1 - . ID=AR_GLEAN_10000023;
- C25973241 GLEAN mRNA 227 830 1 + . ID=AR_GLEAN_10000024;
- C26033497 GLEAN mRNA 1421 2025 1 - . ID=AR_GLEAN_10000029;
- C26078333 GLEAN mRNA 38 3519 0.999985 - . ID=AR_GLEAN_10000032;
- C26088879 GLEAN mRNA 511 4724 0.255876 - . ID=AR_GLEAN_10000036;
- scaffold1 GLEAN mRNA 15684 31704 0.499626 - . ID=AR_GLEAN_10004351;
- scaffold1 GLEAN mRNA 205036 251824 1 - . ID=AR_GLEAN_10004353;
- scaffold1 GLEAN mRNA 652321 654066 1 - . ID=AR_GLEAN_10004358;
- scaffold1 GLEAN mRNA 692896 714109 0.996397 - . ID=AR_GLEAN_10004359;
- scaffold1 GLEAN mRNA 729357 743691 0.869061 - . ID=AR_GLEAN_10004361;
- scaffold1 GLEAN mRNA 842800 845546 0.728297 - . ID=AR_GLEAN_10004362;
- scaffold1 GLEAN mRNA 879294 941576 0.999999 - . ID=AR_GLEAN_10004364;
- scaffold1 GLEAN mRNA 977815 983011 0.790595 - . ID=AR_GLEAN_10004365;
- scaffold1 GLEAN mRNA 1136652 1160869 0.998504 + . ID=AR_GLEAN_10004369;
- scaffold1 GLEAN mRNA 1787631 1790162 0.910098 + . ID=AR_GLEAN_10004372;
- scaffold1 GLEAN mRNA 2052740 2059479 0.998505 - . ID=AR_GLEAN_10004376;
- scaffold1 GLEAN mRNA 2079204 2087326 0.995474 - . ID=AR_GLEAN_10004378;
- scaffold1 GLEAN mRNA 2200010 2231455 0.806929 - . ID=AR_GLEAN_10004381;
- scaffold2 GLEAN mRNA 193 16824 0.902009 - . ID=AR_GLEAN_10003436;
- scaffold2 GLEAN mRNA 55145 74491 0.694455 - . ID=AR_GLEAN_10003438;
- scaffold2 GLEAN mRNA 510390 558468 0.414427 - . ID=AR_GLEAN_10003449;
- scaffold2 GLEAN mRNA 665785 740472 0.696962 + . ID=AR_GLEAN_10003453;
- scaffold2 GLEAN mRNA 837066 837386 0.999013 + . ID=AR_GLEAN_10003460;
- scaffold2 GLEAN mRNA 1348480 1350426 0.651022 - . ID=AR_GLEAN_10003470;
复制代码 |
|