-
Notifications
You must be signed in to change notification settings - Fork 5
/
SNPtable2newhybrids.pl
executable file
·98 lines (88 loc) · 1.77 KB
/
SNPtable2newhybrids.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/perl
use warnings;
use strict;
use lib '/home/owens/bin';
my %t;
$t{"N"} = "NN";
$t{"A"} = "AA";
$t{"T"} = "TT";
$t{"G"} = "GG";
$t{"C"} = "CC";
$t{"W"} = "TA";
$t{"R"} = "AG";
$t{"M"} = "AC";
$t{"S"} = "CG";
$t{"K"} = "TG";
$t{"Y"} = "CT";
my %NT;
$NT{"A"} = "1";
$NT{"T"} = "2";
$NT{"C"} = "3";
$NT{"G"} = "4";
my $in = $ARGV[0];
my $pures = $ARGV[1];
require "countbadcolumns.pl";
my ($iupac_coding, $badcolumns) = count_bad_columns($in);
$. = 0;
my $samplenumber;
my $NumLoci = 0;
my %data;
my $maxA;
my $NumIndivs;
my @samplename;
my %locusname;
my %type;
open PURE, $pures;
while (<PURE>){
chomp;
my @a = split (/\t/, $_);
$type{$a[0]} = $a[1];
}
open IN, $in;
while (<IN>){
chomp;
my @a = split (/\t/, $_);
$maxA = $#a;
$NumIndivs = ($#a - $badcolumns + 1);
if ($. == 1){
foreach my $i ($badcolumns..$#a){
$samplename[$i] = $a[$i];
}
}else{
$NumLoci++;
$locusname{$NumLoci} = "$a[0]_$a[1]";
foreach my $i ($badcolumns..$#a){
if ($iupac_coding eq "TRUE"){
$a[$i] = $t{$a[$i]};
}
unless (($a[$i] eq "NN")or($a[$i] eq "XX")){
my @bases = split(//, $a[$i]);
$data{$i}{$NumLoci} = "$NT{$bases[0]}"."$NT{$bases[1]}";
}else{
$data{$i}{$NumLoci} = "0";
}
}
}
}
close IN;
print "NumIndivs\t$NumIndivs\n";
print "NumLoci\t$NumLoci\n";
print "Digits\t1\n";
print "Format Lumped\n";
print "LocusNames";
foreach my $i (1..$NumLoci){
print "\t$locusname{$NumLoci}";
}
print "\n";
foreach my $i ($badcolumns..$maxA){
my $samplenumber = ($i - $badcolumns + 1);
print "$samplenumber";
if ($type{$samplename[$i]}){
my $z = ($type{$samplename[$i]} - 1);
print "\tz$z";
}
foreach my $j (1..$NumLoci){
print "\t$data{$i}{$j}";
}
print "\n";
}