免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12
最近访问板块 发新帖
楼主: 小丽子酱
打印 上一主题 下一主题

关于Perl两个文件的问题 [复制链接]

论坛徽章:
0
11 [报告]
发表于 2015-05-19 19:43 |只看该作者
非常感谢大家的回复,终于鼓捣出来了,传上来大家看看,主要是为了要使以后有和我一样的货,遇到一样的问题的话,可以借鉴一下

#!/usr/bin/perl-w

use strict;
use warnings;

my $fasta_file = "xx.fasta";
my $gff_file = "xx.gff";
my $outputfile = "xx.txt";

open (FASTA,"<", $fasta_file) or die "$!";
open (GFF,"<", $gff_file) or die "$!";
open (OUT,">", $outputfile) or die "$!";

my $name;
my %hash_fasta;
while(<FASTA>{
        chomp;
        if (/>(chr[0-9]{1,2})/){
        $name = $1;
        $hash_fasta{$name} = '';
        }else{
                $hash_fasta{$name} .=  $_;
        }
}

my @array2 ;
my %hash_gff;
while ( <GFF>{
        chomp;
        @array2 = split;
        $array2[8] =~ s/^Parent=/>/g;
        my $strand = $array2[6];
        my $temp = substr($hash_fasta{$array2[0]}, $array2[3]-1, $array2[4]-$array2[3]);
        if($strand eq "-"{
                $temp =~ tr/AGCTagct/TCGAtcga/;
                $temp = reverse$temp;
                $_ = $temp;
        }elsif($strand eq "+"{
                $_ = $temp;
        }
        if(exists $hash_gff{$array2[8]}){
                $hash_gff{$array2[8]} .= $temp;
                }else{
                        $hash_gff{$array2[8]} = $temp;
                }
}
               
foreach my $key(sort keys %hash_gff){
     print OUT "$key\n$hash_gff{$key}\n";
}
       

exit;
close FASTA;
close GFF;
close OUT;

论坛徽章:
0
12 [报告]
发表于 2015-05-19 19:44 |只看该作者
顺便提一下我用的是水稻基因
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP