美文网首页
批量计算测序文件reads长度

批量计算测序文件reads长度

作者: pumpkinC | 来源:发表于2022-12-24 22:38 被阅读0次

输入文件(包含测序材料号的文件,测序材料后缀需要是_1.fq.ft.gz,_2.fq.ft.gz )

SRR13661968
SRR13661969
SRR13661970
SRR13661971
SRR13661972
SRR13661973
SRR13661974

使用的perl脚本如下:

#!/usrr/bin/perl -w
use strict;

my $in0 = $ARGV[0]; ##- samples 

my $out = "read_length.lst";

open OUT, ">$out";
open IN0, $in0;
while(<IN0>){
  chomp;
  my $samid = $_;

  my $left  = $samid."_1.fq.ft.gz";
  my $right = $samid."_2.fq.ft.gz";
 
  my $leftLen = &countLen($left);
  my $rightLen = &countLen($right);
     print OUT join("\t", $samid, $leftLen, $rightLen), "\n";
}
close IN0;
close OUT;


sub countLen {
 
    my ($fileIn) = @_;
 
    my $count = 0;
    my $length = 0;
 
    open IN1, "gzip -dc $fileIn | ";
    while(<IN1>){
      chomp;
      $count += 1;
      if($count == 2){
         $length = length($_);    
         last;
      }
    }
    close IN1;
    return($length);

}

输出结果(材料对应的左端和右端reads长度):

SRR13661968     100     100
SRR13661969     100     100
SRR13661970     100     100
SRR13661971     100     100
SRR13661972     100     100
SRR13661973     100     100

相关文章

网友评论

      本文标题:批量计算测序文件reads长度

      本文链接:https://www.haomeiwen.com/subject/qbppqdtx.html