5 open I0
, "<", "../a.information/Haplotype_Region.txt";
11 $hap_reg{$c[0]} = $c[1];
15 open I1
, "<", "../a.information/Sample_MT_X_Y.txt";
16 my %sample_gt; # Sample, MT, X, Y, ATP8, Autosome.
17 my %sample_re; # Sample, MT, X, Y, ATP8, Autosome.
22 $sample_gt{$d} = [@c];
23 $sample_re{$d} = [$hap_reg{$c[0]}, $hap_reg{$c[1]}, $hap_reg{$c[2]}];
27 open I2
, "<", "/share/users/miaolin/5.Leopard_cat/3.PBE_paper_2015/g.ATP8_haplotype_tree/b.modified_alignment/f.modified_alignment/ATP8_haplotype_location_sampleID.txt";
32 my @d = split / /, $c[2];
34 push @
{$sample_gt{$_}}, $c[0];
35 push @
{$sample_re{$_}}, $hap_reg{$c[0]};
39 foreach (keys %sample_gt) {
40 if (@
{$sample_gt{$_}} == 3) {
41 push @
{$sample_gt{$_}}, 0;
42 } elsif (@
{$sample_gt{$_}} == 4) {
45 warn @
{$sample_gt{$_}};
49 foreach (keys %sample_re) {
50 if (@
{$sample_re{$_}} == 3) {
51 push @
{$sample_re{$_}}, 0;
52 } elsif (@
{$sample_re{$_}} == 4) {
55 warn @
{$sample_re{$_}};
59 open I3
, "<", "../a.information/Sample_AutoRegion.txt";
63 push @
{$sample_gt{$c[0]}}, $c[1];
64 push @
{$sample_re{$c[0]}}, $c[2];
67 foreach (keys %sample_gt) {
68 if (@
{$sample_gt{$_}} == 4) {
69 push @
{$sample_gt{$_}}, 0;
70 } elsif (@
{$sample_gt{$_}} == 5) {
73 warn @
{$sample_gt{$_}};
77 foreach (keys %sample_re) {
78 if (@
{$sample_re{$_}} == 4) {
79 push @
{$sample_re{$_}}, 0;
80 } elsif (@
{$sample_re{$_}} == 5) {
83 warn @
{$sample_re{$_}};
87 foreach (sort keys %sample_gt) {
88 foreach (@
{$sample_gt{$_}}) {
92 foreach (@
{$sample_re{$_}}) {
96 delete $region{"n/a"};
97 if ((keys %region) == 1) {
98 push @
{$sample_re{$_}}, (keys %region);
99 } elsif ((keys %region) == 2) {
100 if ($region{Northern
}) {
101 if ($region{Iriomote
}) {
102 push @
{$sample_re{$_}}, "Iriomote";
103 } elsif ($region{"China/Indochina"}) {
104 push @
{$sample_re{$_}}, "China/Indochina";
105 } elsif ($region{Taiwan
}) {
106 push @
{$sample_re{$_}}, "Taiwan";
107 } elsif ($region{Amur
}) {
108 push @
{$sample_re{$_}}, "Amur";
109 } elsif ($region{Sunda
}) {
110 push @
{$sample_re{$_}}, "Hybrid";
111 } elsif ($region{Philippines
}) {
112 push @
{$sample_re{$_}}, "Hybrid";
113 } elsif ($region{Southern
}) {
114 push @
{$sample_re{$_}}, "Hybrid";
116 push @
{$sample_re{$_}}, "CHECK!";
118 } elsif ($region{Southern
}) {
119 if ($region{Iriomote
}) {
120 push @
{$sample_re{$_}}, "Hybrid";
121 } elsif ($region{"China/Indochina"}) {
122 push @
{$sample_re{$_}}, "Hybrid";
123 } elsif ($region{Taiwan
}) {
124 push @
{$sample_re{$_}}, "Hybrid";
125 } elsif ($region{Amur
}) {
126 push @
{$sample_re{$_}}, "Hybrid";
127 } elsif ($region{Sunda
}) {
128 push @
{$sample_re{$_}}, "Sunda";
129 } elsif ($region{Philippines
}) {
130 push @
{$sample_re{$_}}, "Philippines";
132 push @
{$sample_re{$_}}, "CHECK!";
136 if ($region{Northern
} and $region{Southern
}) {
137 push @
{$sample_re{$_}}, "Hybrid";
139 push @
{$sample_re{$_}}, "CHECK!";
144 open O
, ">", "sample_genotype_region.txt";
145 print O
"#SampleID\tgtMT\tgtX\tgtY\tgtATP8\tqAutosome(K=2)\tregionMT\tregionX\tregionY\tregionATP8\tregionAutosome\tGeneticRegion\n";
146 foreach (sort keys %sample_gt) {
148 print O
join("\t", @
{$sample_gt{$_}}), "\t";
149 print O
join("\t", @
{$sample_re{$_}}), "\n";