问题描述:比如数据(如下),我现在想提取表头里第二列数字小于99的序列,以下perl代码可以完成这个工作。
>example 100 other tail 1
AGCTAGTAGATGACCAGTGATCAGGATGTTGATTAGGAGGAGGGGATTAACCCCCAAGTAGATGATG
>example 99 other tail 2
AATGATCAGTAGGATCCCAGTTATGATCGGACGATCCAGCAGTAGTCGTCGATGACGATGACGATCA
#! /usr/bin/perl -w ######example.pl#######
use strict;
use diagnostics;
print "please input your file,then press Enter! \n";
my $file = ;
open FILE,"$file";
open OUT,">output_result";
my $key;
my %hash;
while (){
chomp;
if (/>/){ $key=$_ ;} else{ $hash{$key}.=$_ ;}
}
foreach $line (keys %hash){
chomp $line;
my @match= split (/\s+/,$line);
if ($match[1] < 99) {
print OUT " $key\n$hash{$key}\n";
}
}
close OUT;
close FILE;
#####脚本运行:perl example.pl#########
阅读(1099) | 评论(0) | 转发(0) |