/usr/share/ampliconnoise/Scripts/Split.pl is in ampliconnoise 1.29-7.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | #!/usr/bin/perl
use POSIX;
my $fastaFile = shift;
my $split = shift;
my $offset = shift;
my @Seq = ();
my $total = 0;
my @id = ();
open(FILE, $fastaFile) or die "Can't open $fastaFile\n";
my $seq = "";
while($line = <FILE>){
chomp($line);
if($line =~ />(.*)/){
$id[$count] = $1;
if($seq ne ""){
$Seq[$count - 1] = $seq;
$seq = "";
}
$count++;
}
else{
$seq .= $line;
}
}
$Seq[$count - 1] = $seq;
$total = $count;
$size = floor(($total - $offset)/$split);
$sizeZero = $size + (($total - $offset) % $split);
for($i = 0; $i < $split; $i++){
my $sizeJ = 0;
$dirName = "Split$i";
print "$dirName\n";
mkdir $dirName;
if($i == 0){
$sizeJ = $sizeZero;
}
else{
$sizeJ = $size;
}
my $file = ">${dirName}\/${dirName}.fa";
open(FILE, $file) or die "Can't open $file\n";
for($j = 0; $j < $sizeJ; $j++){
print FILE ">$id[$offset + $j]\n$Seq[$offset+$j]\n";
}
close(FILE);
$offset += $sizeJ;
}
|