1
안녕하세요, 저는 silva 데이터베이스를 사용하여 qiime에서 얻은 OTUs 파일에서 모든 문을 추출하기 위해이 스크립트를 만들었습니다. 중복 분류군을 제거하고 각 분류군 중 하나를 추출하기 위해 서브 루틴을 추가했습니다. 내 문제는 함께 난 그냥 (하나 개의 분류군)perl로 중복 목록을 제거하십시오
#!/usr/bin/perl -w
use strict;
use Getopt::Long;
my ($imput, $output, $line, $phylum, @taxon_list, @final_list);
GetOptions (
'in=s' =>\$imput,
'ou=s' =>\$output,
'k' =>\$phylum,
);
if (!$imput or !$output){
exit;
print "Error";
}
#SUBRUTINE TO ELIMINATE DUPLICATES
# --------------------------------------------------------------------------------------------
sub uniq {
my %seen;
grep !$seen{$_}++, @_;
}
# --------------------------------------------------------------------------------------------
open INPUTFILE, "<", "$imput", or die "can`t open file\n";
open OUTPUTFILE, ">", "$output" or die "can`t creat file\n";
while (<INPUTFILE>){
$line=$_;
chomp($line);
if ($line=~ m/^#/g){
next;
}
elsif($phylum){
my @kingd=($line=~m/D_1__(.*);D_2/g);
foreach (@kingd){
if ($_=~/^$/){
next;
}
elsif ($_=~ m/^[Uu]nknown/g){
next;
}
elsif ($_=~ m/^[Uu]ncultured$/g){
next;
}
elsif ($_=~ m/^[Uu]nidentified$/g){
}
else {
@taxon_list =$_;
@final_list = uniq @taxon_list;
}
}
}
}
print OUTPUTFILE "@final_list\n";
close INPUTFILE;
close OUTPUTFILE;
exit;
정말 고마워요 빈스, 정말 작동! –