拟南芥基因注释

Athaliana_447_Araport11.annotation_info.txt文件下载链接 https://phytozome.jgi.doe.gov/pz/portal.html#!bulk?org=Org_Athaliana_er

#!/usr/bin/perl

my $infile=shift;
my $gene_num=shift;
my $outfile=$infile.".annotation.txt";
$gene_num-=1;

my %anno_hash;

$usage="USAGE:
    perl $0 infile line_number\n";
unless($infile && $gene_num>=1){
    die "$usage";
}

my $anno_file="./Athaliana_447_Araport11.annotation_info.txt";
open ANNO,$anno_file or die "fileOpenError: unable to open $anno_file\n";
while(<ANNO>){
    chomp;
    my @line=split "\t",$_;
    if($line[12]){
        $anno_hash{$line[1]}=$line[12];
    }
}
close ANNO;


open INFILE,$infile or die "fileOpenError: unable to open $infile\n";
open OUTFILE,">".$outfile;
while(<INFILE>){
    chomp;
    my $line=$_;
    my @line=split "\t",$line;
    my $gene=$line[$gene_num];
    $gene=~s/\..*//g;
    if(exists $anno_hash{$gene}){
        print OUTFILE "$line\t$anno_hash{$gene}\n";
    }
    else{
        print OUTFILE "$line\n";
    }
}
close INFILE;
close OUTFILE;
上一篇:基于注解的声明式事务配置


下一篇:Java Predicate 断定型接口