2 use lib
'/share/raid010/resequencing/resequencing/tmp/bin/annotation/glfsqlite';
6 use Time
::HiRes qw
( gettimeofday tv_interval
);
11 our $opts='i:o:s:l:m:bv';
12 our ($opt_i, $opt_o, $opt_s, $opt_v, $opt_b, $opt_l, $opt_m);
15 \t-i PSNP list (./npsnp.lst) for chrid.individual.finalSNPs
16 \t-l scaffold.list (./scaffold.N90.id)
17 \t-m merge.list for scaffold positions (./watermelon.merge.list)
18 \t-s GLF list (./glf.list), will use \$1 of (([^/]+)/[^/]+\$) for sample names
19 \t-o Output Prefix (./plots/p_)
20 \t-v show verbose info to STDOUT
21 \t-b No pause for batch runs
26 $opt_o='./plots/p_' unless defined $opt_o;
27 $opt_i='./npsnp.lst' unless $opt_i;
28 $opt_s='./glf.list' unless $opt_s;
29 $opt_l='./scaffold.N90.id' unless $opt_l;
30 $opt_m='./watermelon.merge.list' unless $opt_m;
33 print STDERR
"From [$opt_i] to [$opt_o], with [$opt_s][$opt_l][$opt_m]\n";
34 if (! $opt_b) {print STDERR
'press [Enter] to continue...'; <>;}
36 my $start_time = [gettimeofday
];
38 system('mkdir','-p',$opt_o);
39 system('rmdir',$opt_o) if $opt_o =~ m
#/[\s.]*[^/\s.]+[^/]*$#;
42 open L
,'<',$opt_s or die "[x]Error opening $opt_s: $!\n";
43 print STDERR
"[!]Sample Order: ";
47 print STDERR
(scalar @Samples),':[',$1,"] ";
52 my ($LEN,%Scaffolds,@Scaffoldo)=(0);
53 open L
,'<',$opt_l or die "[x]Error opening $opt_l: $!\n";
54 print STDERR
"[!]Scaffolds: ";
58 #print STDERR (scalar (keys %Scaffolds)),':[',$_,"] ";
61 print STDERR
scalar (keys %Scaffolds),"\n";
63 open L
,'<',$opt_m or die "[x]Error opening $opt_m: $!\n";
64 print STDERR
"[!]Scaffolds Len: ";
68 my ($chrid,$scaffold,$start,$end)=split /\t/;
69 next unless exists $Scaffolds{$scaffold};
71 $Scaffolds{$scaffold}=[$len,0];
73 warn "$chrid,$scaffold,$start,$end\t$len\t$LEN\n" if $opt_v;
77 print STDERR
"$LEN\n";
78 @Scaffoldo = sort {${$Scaffolds{$b}}[0] <=> ${$Scaffolds{$a}}[0]} keys %Scaffolds;
81 ${$Scaffolds{$_}}[1]=$i;
82 $i += ${$Scaffolds{$_}}[0];
83 warn "$_\t${$Scaffolds{$_}}[0]\t${$Scaffolds{$_}}[1]\n" if $opt_v;
87 print STDERR
"[!]Parsing SNP ";
88 open P
,'<',$opt_i or die "[x]Error opening $opt_i: $!\n";
89 while (my $file=<P
>) {
91 open SNP
,'<',$file or (warn "\n[!]Error opening $file: $!\n" and next);
94 my ($scaffold,$pos,$ref,$tail)=split /\t/;
95 next unless exists $Scaffolds{$scaffold};
96 $POS = ${$Scaffolds{$_}}[1] + $pos;
98 for (split / /,$tail) {
99 next unless /[ACGTRYMKSWHBVDNX-]/;
100 if (/[ACGTRYMKSWHBVDNX]/) {
102 } elsif ($_ eq '-') {
111 my $stop_time = [gettimeofday
];
113 print STDERR
"\nTime Elapsed:\t",tv_interval
( $start_time, $stop_time )," second(s).\n";