-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbionano2Allmaps.pl
77 lines (67 loc) · 2.09 KB
/
bionano2Allmaps.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!perl
use Getopt::Std;
getopts "x:i:e:";
if ((!defined $opt_x) || (!defined $opt_i) || (!defined $opt_e)) {
die "************************************************************************
Usage: perl $0 -x xmap -i ref.fasta -e BspQI
-h : help and usage.
-x : xmap from hybrid assembly
-i : ref.fasta
-e : in silico digest enzyme, could be any dual enzyme
e.g. -e BspQI,BbvCI
************************************************************************\n";
}else{
print "************************************************************************\n";
print "Version 1.0\n";
print "Copyright to Tanger, tanger.zhang\@gmail.com\n";
print "RUNNING...\n";
print "************************************************************************\n";
}
$ref_file = $opt_i;
$enzyme = $opt_e;
$xmap = $opt_x;
$enzyme =~ s/,/ /g;
if($ref_file ne "ref.fasta"){
$cmd = "ln -s $ref_file ./ref.fasta" ;
system($cmd);
}
$cmd = "perl ~/Irys-scaffolding/KSU_bioinfo_lab/assemble_XeonPhi/third-party/fa2cmap_multi.pl -i ref.fasta -e $enzyme";
system($cmd);
$enzyme =~ s/\s+/_/g;
$key_file = "ref_".$enzyme."_key.txt";
open(IN, $key_file) or die"";
while(<IN>){
chomp;
next if(/#/);
next if(/CompntId/);
@data = split(/\s+/,$_);
$id = $data[0];
$scaf = $data[1];
$iddb{$id} = $scaf;
}
close IN;
open(IN, $xmap) or die"";
while(<IN>){
chomp;
next if(/#/);
@data = split(/\s+/,$_);
$chr_id = $data[1];
$chr_posia = $data[3];
$chr_posib = $data[4];
$lg = $data[2];
$lg_posia = $data[5];
$lg_posib = $data[6];
$infordb{$lg}->{$lg_posia} = $chr_id."_".$chr_posia;
$infordb{$lg}->{$lg_posib} = $chr_id."_".$chr_posib;
}
close IN;
open(OUT, "> bionano.map.csv") or die"";
print OUT "Scaffold ID,scaffold position,LG,genetic position\n";
foreach $lg(sort {$a<=>$b} keys %infordb){
foreach $lg_posi (sort {$a<=>$b} keys %{$infordb{$lg}}){
($chr_id,$chr_posi) = split(/_/,$infordb{$lg}->{$lg_posi});
$chrn = $iddb{$chr_id};
print OUT "$chrn,$chr_posi,$lg,$lg_posi\n";
}
}
close OUT;