1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| #!/usr/bin/perl
use strict;
use warnings;
use Carp qw(confess);
use Getopt::Long;
use Bio::SeqIO;
my %seq;
my $title;
my ($fasta_file,$output_file);
GetOptions("fasta=s" => \$fasta_file,"out=s" => \$output_file );
my $in = Bio::SeqIO->new( -file => $fasta_file, '-format' => 'Fasta' );
open(my $out,'>',$output_file) or die "$output_file : $!\n\n";
while ( my $seqs = $in->next_seq()){
my $title = $seqs->id() ;
my $sequence = $seqs->seq ;
$seq{$sequence}=$title;
}
my @seq = keys (%seq);
my @uniqueseq;
my $find=0;
foreach (@seq){
$find=0;
my $seq=uc($_);
foreach (@uniqueseq){
if ($seq=~/$_/){
$_=$seq;
$find=1;
}
if ($_=~/$seq/){
$find=1;
}
}
if ($find==0){
push @uniqueseq,$seq;
}
}
foreach (@uniqueseq){
print {$out} ">$seq{$_}\n$_\n";
} |
Partager