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);
21 my ($borderL,$borderR) = (206000000,220000000);
23 die "Usage: $0 <hap scaffold list> <tped sets prefix> <out>\n" if @ARGV<3;
29 open L
,'<',$lstfs or die "Error opening $lstfs : $!\n";
33 push @Scaffs,$_ unless exists $Scaff{$_};
37 print "Total ",scalar keys %Scaff," Scaffolds: [",join('],[',sort keys %Scaff),"]\n";
39 open LOG
,'>',"$outfs.log" or die "Error opening $outfs.log : $!\n";
40 print LOG
"Total ",scalar keys %Scaff," Scaffolds: [",join('],[',sort keys %Scaff),"]\n";
50 open D
,'<',$infs.'.dict' or die "Error opening $infs.dict : $!\n";
54 my ($scaffid,$pos,$rid) = split /\t/;
55 #if (exists $Scaff{$scaffid}) {
56 if (exists $Scaff{$scaffid} and $pos>=$borderL and $pos<=$borderR) {
57 $Rid{$rid} = $scaffid;
61 print "Total ",scalar keys %Rid," Markers.\n";
63 for my $type (qw
[case control all
]) {
68 $inprefix = "${infs}.$type";
70 for my $scaffid (keys %Scaff) {
71 open C
,'<',"$inprefix.tped" or die "Error opening $inprefix.tped : $!\n";
72 open O
,'>',"$outfs.$type.$scaffid.tped" or die "Error opening $outfs.$type.$scaffid.tped : $!\n";
73 #symlink "$inprefix.tfam","$outfs.$type.$scaffid.tfam";
75 my @items = split /\t/;
76 if (exists $Rid{$items[1]} and $Rid{$items[1]} eq $scaffid) {
77 $items[0] = $Scaff{$Rid{$items[1]}};
78 print O
join("\t",@items);
83 my $cmd = "p-link --tped \'$outfs.$type.$scaffid.tped\' --tfam $inprefix.tfam --out \'${outfs}$type.$scaffid\' --recode";
84 print "Running [$cmd].\n";
93 ./ped2hap
.pl tighap
.lst radseq17 dohap17
95 p
-link --tfile dohap17
.case
--out dohap17case
--recode