统计fasta格式数据数量

作者使用Perl编写了一个简单的脚本来统计FASTA格式文件中的序列数量,并对比了一种更简洁的方法:使用grep命令行工具。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

今天很2b地用perl自己写了个统计fasta格式数据量的script

#!/usr/bin/perl -w
# Program name: detectDataNum.pl
# Author      : SunChen
# Contact     : bbsunchen@gmail.com
# Date        : 04/21/2011
# Last Update : 04/21/2011
# Reference   : Please cite our following papers when you are using this script.
#				None
#
# Description : connect 2 meta-pair files to 1 file for the PE assembler.

#===========================================================================
use warnings;
use strict;
use Getopt::Long;

my %opts;
GetOptions(\%opts,"f:s");
my $usage= <<"USAGE";
	Program	: $0
	INPUT:
	-f	blabla...
USAGE
die $usage unless $opts{f};

open DATA, "< $opts{f}" or die "Can't open file ".$!;
my $lines = 0;
while(<DATA>)
{
	my $data = $_;

	chomp($data);#deal with \n
	$data=~s/\r//g;#deal with \r
	next unless($data=~/\S+/); #deal with blank line here.
	if($data =~ m/^>/)
	{
		$lines++;	
	}
}
close DATA;

print "data num is $lines /n";

 实际上只要用一句话就行...

grep -c "^>" s1.fa
 grep -c "^>" s1.fa s2.fa 命令得到,比如分别为100和200
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值