-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathb2r.pl
executable file
·49 lines (44 loc) · 1.15 KB
/
b2r.pl
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
#!/usr/bin/env perl
# ___UNDOCUMENTED___
use strict;
use warnings;
unless (@ARGV == 1) {
print STDERR ("Usage: b2r.pl <fastafile.fas>\n") ;
exit(-1);
}
my $fastafile = "$ARGV[0]";
my @fastaseq=();
open(FAS,"<$fastafile") or die "Can't read input file";
while(my $line = <FAS>) {
if($line !~ m/^>/) {
my @chars = split(//, $line);
if(!int(rand(9)==0)) {
push @fastaseq, $line;
next;
}
if(int(rand(1)==0)) {
$chars[int(rand(length(@chars)))-1]=chr(int(rand(3)) + 65);
$line = join("", @chars);
push @fastaseq, $line;
next;
}
if(int(rand(2)==0)) {
$chars[int(rand(length(@chars)))-1]=chr(int(rand(3)) + 65);
$chars[int(rand(length(@chars)))-1]=chr(int(rand(3)) + 65);
$line = join("", @chars);
push @fastaseq, $line;
next;
}
if(int(rand(3)==0)) {
$chars[int(rand(length(@chars)))-1]=chr(int(rand(3)) + 65);
$chars[int(rand(length(@chars)))-1]=chr(int(rand(3)) + 65);
$chars[int(rand(length(@chars)))-1]=chr(int(rand(3)) + 65);
$line = join("", @chars);
push @fastaseq, $line;
next;
}
}
}
print STDERR chr(int(rand(3)) + 65);
close(FAS);
print @fastaseq;