4 use lib
'/nas/RD_09C/resequencing/soft/lib';
5 use GalaxyXS
::ChromByte
1.02;# ':all';
8 print "perl $0 <chr.nfo> <fabychr_path> <marker_len> <marker_file> <parent_snp> <out_file>\n";
12 my ($chrnfo,$fabychr_path,$marker_len,$marker_file,$psnp_file,$out_file)=@ARGV;
13 $marker_len=int $marker_len;
14 die "[x]marker_len must > 10 !\n" if $marker_len < 10;
15 open M
,'<',$marker_file or die $!;
19 my $ChrID=(split /\t/)[0];
22 my ($ChrLen,$ChrMem,$SNPMem)=(0);
23 open ChrNFO
,'<',$chrnfo or die "[x]Error opening $chrnfo: $!\n";
26 my ($chrid,$len)=split /\t/;
27 next if $chrid ne $ChrID;
31 die "[x]Cannot find correct ChrLen for [$ChrID] !\n" if $ChrLen<1;
32 $ChrMem=initchr
($ChrLen);
33 $SNPMem=initchr
($ChrLen); # OK, leave the 8th bit and alloc a new byte !
36 open F
,'<',$fabychr_path."/$ChrID.fa" or die $!;
39 my ($id)=split / /,$_,2;
41 die "[x]Wrong RefSeq ! ($ChrID != $id)\n" if $ChrID ne $id;
74 #$rbIUB{$bIUB{$k}}=$_ for keys %bIUB;
75 @rbIUB{ values %bIUB } = keys %bIUB;
77 #@hash1{ keys %hash2 } = values %hash2;
78 @bIUB{ keys %bIUBex } = values %bIUBex;
80 for my $k (keys %bIUB) {
81 $ubIUB{$k}=16*$bIUB{$k};
84 for my $pos (1..$ChrLen) {
86 my $base=shift @seq; # to save running memory as $seq[$pos-1]
87 if (exists $bIUB{$base}) {
89 #warn $seq[$pos-1]," $v\t$pos\n";
91 warn "[!]$pos -> ",$base;
93 setbase
($ChrMem,$pos,$v) if $v;
97 open PSNP
,'<',$psnp_file or die "[x]Error opening $psnp_file: $!\n";
100 my ($chr,$pos,$ref,$ga,undef,undef,$gb)=split /\s+/;
101 my @bases=split //,$ga.$gb;
103 $v |= $bIUB{$_} for @bases;
104 #print STDERR "$ref [$ga.$gb] $v\t";
105 #$v = orbase($ChrMem,$pos,$v) if $v && ($v != 240);
107 setbase
($SNPMem,$pos,$v) if $v && ($v != 15);
112 open O
,'>',$out_file or die $!;
114 my $pos=(split /\t/)[1];
116 my ($left,$right)=($pos-$marker_len,$pos+$marker_len);
117 my $marker_seq=substr($seq,$left-1,$marker_len).'N'.substr($seq,$pos,$marker_len);
118 print O ">${ChrID}_${pos}m\n$marker_seq\n";
120 # my $v=getbase($ChrMem,$pos);
122 # my $snp=($v & 240) >> 4; # $v >> 4 is wrong !
123 my $base=getbase
($ChrMem,$pos);
124 my $snp=getbase
($SNPMem,$pos);
125 #warn "[$snp][$base]\t$pos\n";
127 setbase
($ChrMem,$pos,$snp);
128 setbase
($SNPMem,$pos,15);
133 for my $pos (@poses) {
134 my ($left,$right)=($pos-$marker_len,$pos+$marker_len);
136 for my $ipos ($left..$right) {
137 #my $v=getbase($ChrMem,$ipos);
138 my $base=getbase
($ChrMem,$ipos);
139 my $snp=getbase
($SNPMem,$ipos);
141 if ($snp==15) { # or $ipos == $pos
144 $marker_seq .= $base; #."($snp)";
146 print O
">${ChrID}_${pos}m${marker_len}\n$marker_seq\n";
151 ./exmarkerseq.pl chr.nfo ./fabychr
/ 45 ./dat
20101214/Chr01.marker ./psnp
/parent_Chr01
.snp eChr01
.marker
152 cat chrorder
| while read a
; do ./exmarkerseq.pl chr.nfo ./fabychr
/ 45 ./dat
20101214/${a}.marker ./psnp
/parent_
$a.snp ex45
${a
}.marker
;done
&
155 #$ -v PERL5LIB,PATH,PYTHONPATH,LD_LIBRARY_PATH,BLASTDB
156 #$ -cwd -r y -l vf=8g
157 #$ -o /dev/null -e /dev/null
158 #$ -S /bin/bash -t 1-12
160 a
=$(sed
-n
-e
"$SGE_TASK_ID p" $SEEDFILE)
161 eval ./exmarkerseq.pl chr.nfo ./fabychr
/ 25 ./dat
20101214/${a}.marker ./psnp
/parent_$a.snp ./out
20110106/ex25
${a
}.marker