- 论坛徽章:
- 7
|
- #!/usr/bin/perl
- use strict;
- use Bio::SeqIO;
- #限制程序参数
- unless (@ARGV==2){
- print "Usage:\t$0\tScore_file\tFasta_file\n";
- sleep 3;
- }
- my $score_f=shift@ARGV;
- my $fasta_f=shift@ARGV;
- #读取Score数据
- my $Scores={};
- open (my $sc,"<$score_f") or die "Open score file failed!\n";
- my $n=0;
- while (<$sc>){
- chomp;
- if($_){
- $n++;
- $Scores->{$n}=$_;
- }
- }
- close $sc;
- #读取Seq信息
- my $Data={};
- my $Fas=Bio::SeqIO->new(-file=>"$fasta_f",-format=>'fasta');
- while(my $seq=$Fas->next_seq()){
- $Data->{$seq->id}=$seq;
- }
- $Fas->close();
- #提取Score值大于5的位置对应的碱基
- my $Seqs={};
- foreach my $point(sort {$a<=>$b}keys %{$Scores}){
- if($Scores->{$point} > 5){
- foreach my $seq_id(keys %{$Data}){
- $Seqs->{$seq_id}.=$Data->{$seq_id}->subseq($point,$point) if $point <= $Data->{$seq_id}->length();
- }
- }
- }
- #输出数据
- my $Out=Bio::SeqIO->new(-file=>">out.fasta",-format=>'fasta');
- foreach my $seq_id(keys %{$Data}){
- print "Now is:\t$seq_id\n";
- $Data->{$seq_id}->seq($Seqs->{$seq_id});
- $Out->write_seq($Data->{$seq_id});
- }
- $Out->close();
- print "Finished!\n";
复制代码
Data.rar
(694 Bytes, 下载次数: 13)
|
评分
-
查看全部评分
|