输入文件(包含测序材料号的文件,测序材料后缀需要是_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