zoukankan      html  css  js  c++  java
  • *.efasta to fasta format transformation

    #/*******************************************************************************
    # * Author : HaoTan
    # * Email : tanhao2013@foxmail.com
    # * Last modified : 2013-03-05 13:01
    # * Filename : efa2fa.pl
    # * *****************************************************************************/
    #!/usr/bin/perl
    use Bio::SeqIO;
    use Data::Dumper;
    
    die("perl $0 in.efasta >out.fasta\n")unless(@ARGV == 1);
    open(FH,"<$ARGV[0]");
    
    my $e_seq = Bio::SeqIO->new( -format => 'Fasta', -fh => \*FH|| \*STDIN );
    
    while((my $seq_obj = $e_seq->next_seq())){
        my $id  = $seq_obj->id;
        my $seq = $seq_obj->seq;
    
        my @block = split(/\{|\}/,$seq,);
        my $tseq = "";
        foreach my $t (@block){
            if($t =~ /,/){
                my %hash = map{ $_ => length($_)} (split(/\,/,$t));
                $tseq .= (sort{$hash{$b} <=> $hash{$a}}(keys %hash))[0];
            }else{
                $tseq .= $t;
            }
        }
    
        my $hn  = (scalar(@block)-1)/2;
        my $len = length($tseq);
        $tseq =~ s/(.{100})/$1\n/ig;
    
        print ">$id\t$hn\t$len\n$tseq\n";
    }
    tanhao2013@foxmail.com || http://weibo.com/buttonwood
  • 相关阅读:
    spring无法接收上传文件
    springcloud feign增加熔断器Hystrix
    mybatis调用存储过程(@Select方式)
    spring在注解标注的方法上加切面
    java注解Annotation
    java包装类
    JZ-C-43
    JZ-C-42-Plus
    JZ-C-42
    JZ-C-41-Plus
  • 原文地址:https://www.cnblogs.com/buttonwood/p/2944146.html
Copyright © 2011-2022 走看看