最もクラスター数の多い順にCLUTER_IDナンバーをつけて吐き出します。
#!/usr/bin/perl -w
use strict;
use warnings;
use POSIX;
#################################################
my ($fastafile) = @ARGV;
open FASTA, "<$fastafile";
my %hash=(); # initializes a hash
while (<FASTA>)
{
if ($_ =~ /^>/)
{
my $header = $_;
$header =~ s/\s//g;
my $read_id = $_;
$hash{$header}{name}=$read_id;
my $line = <FASTA>;
$hash{$header}{sequence}= $line;
}
}
close FASTA;
#################################################
my $counter = 0;
my $name = <STDIN>;
open (FASTANAME, $name);
while (my $name_cluster = <FASTANAME>)
{
$counter = $counter + 1;
if ($counter < 10)
{print "\nCLUSTER_ID_0000$counter\n"
}elsif ($counter < 100)
{print "\nCLUSTER_ID_000$counter\n"
}elsif ($counter < 1000)
{print "\nCLUSTER_ID_00$counter\n"
}elsif ($counter < 10000)
{print "\nCLUSTER_ID_0$counter\n"
}
my @filename = split (" ", $name_cluster);
my @count = @filename;
if (@count <= 1)
{
exit;
}
my $header1 = ">$filename[0]";
$header1 =~ s/\s//g;
if (exists $hash{"$header1"})
{
print "$hash{$header1}{name}";
print "$hash{$header1}{sequence}";
}
}
close (FASTANAME);
#!/usr/bin/perl -w
use strict;
use warnings;
use POSIX;
#################################################
my ($fastafile) = @ARGV;
open FASTA, "<$fastafile";
my %hash=(); # initializes a hash
while (<FASTA>)
{
if ($_ =~ /^>/)
{
my $header = $_;
$header =~ s/\s//g;
my $read_id = $_;
$hash{$header}{name}=$read_id;
my $line = <FASTA>;
$hash{$header}{sequence}= $line;
}
}
close FASTA;
#################################################
my $counter = 0;
my $name = <STDIN>;
open (FASTANAME, $name);
while (my $name_cluster = <FASTANAME>)
{
$counter = $counter + 1;
if ($counter < 10)
{print "\nCLUSTER_ID_0000$counter\n"
}elsif ($counter < 100)
{print "\nCLUSTER_ID_000$counter\n"
}elsif ($counter < 1000)
{print "\nCLUSTER_ID_00$counter\n"
}elsif ($counter < 10000)
{print "\nCLUSTER_ID_0$counter\n"
}
my @filename = split (" ", $name_cluster);
my @count = @filename;
if (@count <= 1)
{
exit;
}
my $header1 = ">$filename[0]";
$header1 =~ s/\s//g;
if (exists $hash{"$header1"})
{
print "$hash{$header1}{name}";
print "$hash{$header1}{sequence}";
}
}
close (FASTANAME);
PR
トラックバック
トラックバックURL: