-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathprepforvit2fixedallelecount.pl
46 lines (45 loc) · 1.1 KB
/
prepforvit2fixedallelecount.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
#!/bin/perl
use strict;
use warnings;
my $cut_off = 0.98; #minimum difference in allele frequency between parents
my %name;
while(<STDIN>){
chomp;
my @a = split(/\t/,$_);
if ($. == 1){
foreach my $i (5..$#a){
$name{$i} = $a[$i];
}
print "name\tchr\tbp\tcm\tpet_alleles";
}else{
my $chr = $a[0];
my $bp = $a[1];
my $cm = $a[2];
my $p1 = $a[3];
my $p2 = $a[4];
my $dif = abs($p1 - $p2);
if ($dif < $cut_off){
next;
}
my $state = "P2";
if ($p1 > $p2){
$state = "P1";
}
foreach my $i (5..$#a){
if ($a[$i] eq "N"){
next;
}
if (($a[$i] eq "0") and ($state eq "P1")){
print "\n$name{$i}\t$chr\t$bp\t$cm\t2";
}elsif (($a[$i] eq "0") and ($state eq "P2")){
print "\n$name{$i}\t$chr\t$bp\t$cm\t0";
}elsif (($a[$i] eq "2") and ($state eq "P1")){
print "\n$name{$i}\t$chr\t$bp\t$cm\t0";
}elsif (($a[$i] eq "2") and ($state eq "P2")){
print "\n$name{$i}\t$chr\t$bp\t$cm\t2";
}elsif ($a[$i] eq "1"){
print "\n$name{$i}\t$chr\t$bp\t$cm\t1";
}
}
}
}