-
Notifications
You must be signed in to change notification settings - Fork 0
/
renumber_probes3.pl
executable file
·55 lines (44 loc) · 1.26 KB
/
renumber_probes3.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
50
51
52
53
54
55
#!/usr/bin/perl
#v3.0
# renumber_probes.pl $probe_file.[0-9][0-9][0-9]
no warnings 'deprecated';
my @probe_files=@ARGV;
my %probeID =();
my $count_probe_seqs=0;
open OUT,">probes";
print OUT "SEQ_ID\tPROBE_ID\tPROBE_SEQUENCE\n";
open TABLE,">probes.table";
print TABLE "LOCUS_ID\tSTRAND\tALLELE\tPROBE_ID\tPROBE_SEQUENCE\n";
my $target="seq_id";
my $count=0;
foreach my $file (@probe_files) {
my $previous=-1;
print "$file\n";
my $table_file=$file.".table";
open IN,"$table_file";
while (my $line=<IN>) {
chomp $line;
if ($line !~ /PROBE_ID/) {
my ($locus_ID,$strand,$allele,$pID,$seq)=split/\s+/,$line;
$seq =~ s/[^atcgATCG]//g; # remove non-ATCG characters
if ( length($seq)>25 ) {
if ($locus_ID =~ /(.*)_(\d+)$/) {
$target=$1;
$num=$2;
if ($previous ne $num) {
$count++;
$previous = $num;
}
$locus_ID =$target."_".$count;
}
if (!defined $probeID{$seq}) {
$count_probe_seqs++;
$probeID{$seq}=$count_probe_seqs;
print OUT "$target\t$probeID{$seq}\t$seq\n";
}
print TABLE "$locus_ID\t$strand\t$allele\t$probeID{$seq}\t$seq\n";
} # if ( length($seq)>25 )
} # if ($line !~ /PROBE_ID/) {
} # while (my $line=<IN>) {
close IN;
} # foreach $file