3 Author: Hu Xuesong @ BIOPIC <galaxy001@gmail.com>
4 Version: 1.0.0 @ 20120720
5 Purpose: Read bcf, get tped for p-link
6 Notes: rad2marker is deprecated.
10 use Data
::Dump
qw(ddx);
15 die "Usage: $0 <tped prefix> [out].chrID.inp\n" if @ARGV<1;
18 unless (defined $outfs) {
19 warn "Using prefix[$prefix] for both input and output.\n";
22 warn "From [$prefix] to [$outfs]\n";
24 my $Target = 'scaffold97,scaffold1457';
26 my @tTarget = map { s/\s//g;$Targets{$_}=1;$_ } split /\,/,$Target;
27 #ddx \%Targets,\@tTarget;
31 open ID
,'<',$prefix.'.dict' or die "Error opening $prefix.dict : $!\n";
32 open IP
,'<',$prefix.'.tped' or die "Error opening $prefix.tped : $!\n";
33 open IF
,'<',$prefix.'.tfam' or die "Error opening $prefix.tfam : $!\n";
38 my ($chr,$pos,$id) = split /\t/;
39 if (exists $Targets{$chr}) {
40 $mid2pos{$id} = [$chr,$pos];
46 my ($NumberOfIndividuals,@Individuals);
49 push @Individuals,$tmp[1];
51 $NumberOfIndividuals = @Individuals;
56 my ($chrNO,$id,undef,$pos,@dat) = split /\t/;
57 if (exists $mid2pos{$id}) {
58 #print join(',',@{$mid2pos{$id}},$chrNO,$id,$pos,@dat),"\n";
59 my ($chrid,$chrpos) = @
{$mid2pos{$id}};
60 #$NumberOfIndividuals = @dat;
64 #$_ = '??' if $_ eq '00';
66 $GTdata{$chrid}{$chrpos} = \
@dat;
73 for my $chrid (keys %GTdata) {
74 my @Locus = sort { $a <=> $b } keys %{$GTdata{$chrid}};
75 my $NumberOfLoci = @Locus;
76 open O
,'>',"$outfs.$chrid.inp" or die "Error opening $outfs.$chrid.inp : $!\n";
77 print O
"$NumberOfIndividuals\n$NumberOfLoci\nP ";
78 print O
join(' ',@Locus),"\n",'S' x
$NumberOfLoci,"\n";
79 for my $i (0 .. $#Individuals) {
80 print O
"#$Individuals[$i]\n";
83 @t = split //,$GTdata{$chrid}{$_}->[$i];
93 perl ped2phase
.pl sw000
-18
94 ./hp/phase
.2.1.1.source
/PHASE sw000
-18.scaffold1457
.inp p18s1457
>p18s1457
.log 2>p18s1457
.err
&
95 ./hp/phase
.2.1.1.source
/PHASE sw000
-18.scaffold97
.inp p18s97
>p18s97
.log 2>p18s97
.err
&