forked from liangclab/HERA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
22-Filling-Gap.pl
executable file
·439 lines (424 loc) · 19.9 KB
/
22-Filling-Gap.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
#!/usr/bin/perl
#################################################################################################################
# Filling the gap by pathcontig with the alignment of daligner
# Author: huilong du
#
#
#################################################################################################################
use warnings;
use strict;
sub reverse_complement{
my $input_seq=shift;
my $reverse=reverse $input_seq;
$reverse=~tr/ACGT/TGCA/;
$reverse=~tr/acgt/tgca/;
return $reverse;
}
my $infile1=shift; #Scaffold2Ctg_Gap.txt
my $infile3=shift; #Prosudo_ScaffoldNonEnzyme2Contig.fasta
my $infile4=shift; #PathContigRename.fasta
my $outfile=shift; #Connected sequence
my $minidentity=0.95;
my $maxoverhang=10000;
my $minoverlap=1000;
open IN1,"<$infile1" or die $!;
open IN3,"<$infile3" or die $!;
open IN4,"<$infile4" or die $!;
open OUT,">$outfile" or die $!;
open PATH,">Selected_Path.txt" or die $!;
open POS,">Ctg_Position.txt" or die $!;
open INFO,">SuperContig_Part_Info.txt" or die $!;
#Super-Scaffold_3.1 Super-Scaffold_3.2 499 364273 364771
my %Contig_Position=();
my %Contig_Pair=();
my %Total_Contig=();
my %Contig_In_Scaffold=();
my %PathContig_Ori=();
while(<IN1>){
chomp;
my $info=$_;
my @infos=split /\s+/,$info;
$infos[0]=~/(Super-Scaffold_\d+)\.(\d+)/;
my $scaffold=$1;
my $First=$2;
my $Second=$First+1;
my $Gap_Len=$infos[2];
$Contig_In_Scaffold{$infos[0]}=0;
$Contig_In_Scaffold{$infos[1]}=0;
print PATH "#$infos[0]\t$infos[1]\n";
my $Gap_Info=$scaffold."-".$First."-".$Second;
open IN,"<$Gap_Info/$Gap_Info-Final_Reformated.txt" or die $!;
my %PairContig_Gap=();
my %PathContig_Info=();
#+ Super-Scaffold_1067.1 4077 5089 364118 Super-Scaffold_1067.2 12910 13930 314580 153
#+ Super-Scaffold_1067.1 4077 5089 364118 Super-Scaffold_1067-1-2.58017 44552 45571 55596 154
#+ Super-Scaffold_1067.2 3314 23988 314580 Super-Scaffold_1067-1-2.58017 35051 55596 55596 331
my $Loverlap=0;
my $Roverlap=0;
my $Loverhang=0;
my $Roverhang=0;
my $Max_Overlap_Score=0;
my $Max_Path_Score=0;
my $Max_Overlap_Line="";
my $Max_Path_Line_Left="";
my $Max_Path_Line_Right="";
while(<IN>){
chomp;
my $line=$_;
my @content=split /\s+/,$line;
if($content[1]=~/Super-Scaffold_\d+\.\d+/ && $content[5]=~/Super-Scaffold_\d+\.\d+/){
$Total_Contig{$content[1]}=$content[4];
$Total_Contig{$content[5]}=$content[8];
}
next if($content[0] eq "Strand");
# next if($content[0] ne "+");
next if($content[3]-$content[2]<$minoverlap);
my $identity=1-($content[9]/($content[3]-$content[2]+$content[7]-$content[6]))*2;
next if($identity<$minidentity);
if($Gap_Len<500){
if($content[1]=~/Super-Scaffold_\d+\.(\d+)/ && $content[5]=~/Super-Scaffold_\d+\.(\d+)/){
next if($content[0] eq "-");
$content[1]=~/Super-Scaffold_\d+\.(\d+)/;
my $First_Ctg=$1;
$content[5]=~/Super-Scaffold_\d+\.(\d+)/;
my $Second_Ctg=$1;
if($First_Ctg==$Second_Ctg-1){
$Loverlap=$content[3]-$content[2];
$Loverhang=$content[4]-$content[3];
$Roverlap=$content[7]-$content[6];
$Roverhang=$content[6];
if($Loverlap>=$Loverhang && $Roverlap>=$Roverhang){
my $Overlap_Score=($Loverlap+$Roverlap)*$identity-$Loverhang-$Roverhang;
if($Overlap_Score>$Max_Overlap_Score){
$Max_Overlap_Score=$Overlap_Score;
$Max_Overlap_Line=$line;
}
}
}
}
elsif($content[1]=~/Super-Scaffold_\d+\.(\d+)/ && $content[5]=~/Super-Scaffold_\d+-(\d+)-(\d+)\.(\d+)/){
$Total_Contig{$content[1]}=$content[4];
$content[1]=~/Super-Scaffold_\d+\.(\d+)/;
my $First_Ctg=$1;
$content[5]=~/Super-Scaffold_\d+-(\d+)-(\d+)\.(\d+)/;
my $Path_First=$1;
my $Path_Second=$2;
if($First_Ctg==$Path_First){
$Loverlap=$content[3]-$content[2];
$Loverhang=$content[4]-$content[3];
$Roverlap=$content[7]-$content[6];
$Roverhang=$content[6];
next if($Loverlap<$Loverhang || $Roverlap<$Roverhang);
if(!exists $PathContig_Info{$content[5]}{'left'}){
$PathContig_Info{$content[5]}{'left'}{0}=$line;
$PathContig_Info{$content[5]}{'left'}{1}=($Loverlap+$Roverlap)*$identity-$Loverhang-$Roverhang;
$PathContig_Info{$content[5]}{'left'}{2}=$content[0];
}
else{
my $Overlap_Score=($Loverlap+$Roverlap)*$identity-$Loverhang-$Roverhang;
if($Overlap_Score>$PathContig_Info{$content[5]}{'left'}{1}){
$PathContig_Info{$content[5]}{'left'}{0}=$line;
$PathContig_Info{$content[5]}{'left'}{1}=$Overlap_Score;
$PathContig_Info{$content[5]}{'left'}{2}=$content[0];#chain
}
}
}
elsif($First_Ctg==$Path_Second){
$Loverlap=$content[7]-$content[6];
$Loverhang=$content[8]-$content[7];
$Roverlap=$content[3]-$content[2];
$Roverhang=$content[2];
next if($Loverlap<$Loverhang || $Roverlap<$Roverhang);
if(!exists $PathContig_Info{$content[5]}{'right'}){
$PathContig_Info{$content[5]}{'right'}{0}=$line;
$PathContig_Info{$content[5]}{'right'}{1}=($Loverlap+$Roverlap)*$identity-$Loverhang-$Roverhang;
$PathContig_Info{$content[5]}{'right'}{2}=$content[0]; #chain
}
else{
my $Overlap_Score=($Loverlap+$Roverlap)*$identity-$Loverhang-$Roverhang;
if($Overlap_Score>$PathContig_Info{$content[5]}{'right'}{1}){
$PathContig_Info{$content[5]}{'right'}{0}=$line;
$PathContig_Info{$content[5]}{'right'}{1}=$Overlap_Score;
$PathContig_Info{$content[5]}{'right'}{2}=$content[0]; #chain
}
}
}
}
}
elsif($Gap_Len>=500){
if($content[1]=~/Super-Scaffold_\d+\.(\d+)/ && $content[5]=~/Super-Scaffold_\d+-(\d+)-(\d+)\.(\d+)/){
$Total_Contig{$content[1]}=$content[4];
$content[1]=~/Super-Scaffold_\d+\.(\d+)/;
my $First_Ctg=$1;
$content[5]=~/Super-Scaffold_\d+-(\d+)-(\d+)\.(\d+)/;
my $Path_First=$1;
my $Path_Second=$2;
if($First_Ctg==$Path_First){
$Loverlap=$content[3]-$content[2];
$Loverhang=$content[4]-$content[3];
$Roverlap=$content[7]-$content[6];
$Roverhang=$content[6];
next if($Loverlap<$Loverhang || $Roverlap<$Roverhang);
if(!exists $PathContig_Info{$content[5]}{'left'}){
$PathContig_Info{$content[5]}{'left'}{0}=$line;
$PathContig_Info{$content[5]}{'left'}{1}=($Loverlap+$Roverlap)*$identity-$Loverhang-$Roverhang;
$PathContig_Info{$content[5]}{'left'}{2}=$content[0]; #chain
}
else{
my $Overlap_Score=($Loverlap+$Roverlap)*$identity-$Loverhang-$Roverhang;
if($Overlap_Score>$PathContig_Info{$content[5]}{'left'}{1}){
$PathContig_Info{$content[5]}{'left'}{0}=$line;
$PathContig_Info{$content[5]}{'left'}{1}=$Overlap_Score;
$PathContig_Info{$content[5]}{'left'}{2}=$content[0]; #chain
}
}
}
elsif($First_Ctg==$Path_Second){
$Loverlap=$content[7]-$content[6];
$Loverhang=$content[8]-$content[7];
$Roverlap=$content[3]-$content[2];
$Roverhang=$content[2];
next if($Loverlap<$Loverhang || $Roverlap<$Roverhang);
if(!exists $PathContig_Info{$content[5]}{'right'}){
$PathContig_Info{$content[5]}{'right'}{0}=$line;
$PathContig_Info{$content[5]}{'right'}{1}=($Loverlap+$Roverlap)*$identity-$Loverhang-$Roverhang;
$PathContig_Info{$content[5]}{'right'}{2}=$content[0]; #chain
}
else{
my $Overlap_Score=($Loverlap+$Roverlap)*$identity-$Loverhang-$Roverhang;
if($Overlap_Score>$PathContig_Info{$content[5]}{'right'}{1}){
$PathContig_Info{$content[5]}{'right'}{0}=$line;
$PathContig_Info{$content[5]}{'right'}{1}=$Overlap_Score;
$PathContig_Info{$content[5]}{'right'}{2}=$content[0]; #chain
}
}
}
}
}
}
close(IN);
=pod
#+ Super-Scaffold_1067.1 4077 5089 364118 Super-Scaffold_1067.2 12910 13930 314580 153
#+ Super-Scaffold_1067.1 4077 5089 364118 Super-Scaffold_1067-1-2.58017 44552 45571 55596 154
#+ Super-Scaffold_1067.2 3314 23988 314580 Super-Scaffold_1067-1-2.58017 35051 55596 55596 331
=cut
#selecting the best match path based on the gap length
my $Best_Path_Score=0;
my $Best_Path_Left=""; #recording the left alignment of best path
my $Best_Path_Right=""; #recording the right alignment of best path
my $Best_Path_Gap=9999999999;
foreach my $path (keys %PathContig_Info){
if($Gap_Len<500){ #if with overlap, selecting the highest score path
next if(!exists $PathContig_Info{$path}{'left'} or !exists $PathContig_Info{$path}{'right'});
next if($PathContig_Info{$path}{'left'}{2} ne $PathContig_Info{$path}{'right'}{2});
if($PathContig_Info{$path}{'left'}{1}+$PathContig_Info{$path}{'right'}{1}>$Best_Path_Score){
$Best_Path_Score=$PathContig_Info{$path}{'left'}{1}+$PathContig_Info{$path}{'right'}{1};
$Best_Path_Left=$PathContig_Info{$path}{'left'}{0};
$Best_Path_Right=$PathContig_Info{$path}{'right'}{0};
}
}
elsif($Gap_Len>=500){ #if without overlap, selecting the best match path
next if(!exists $PathContig_Info{$path}{'left'} or !exists $PathContig_Info{$path}{'right'});
next if($PathContig_Info{$path}{'left'}{2} ne $PathContig_Info{$path}{'right'}{2});
my @Left_Line=split /\s+/,$PathContig_Info{$path}{'left'}{0};
my @Right_Line=split /\s+/,$PathContig_Info{$path}{'right'}{0};
my $Path_Len_Used=$Right_Line[7]-$Left_Line[6];
my $Gap_Len_Used=$Left_Line[4]-$Left_Line[2]+$Right_Line[3]+$Gap_Len;
my $Path_Gap=abs ($Path_Len_Used-$Gap_Len_Used);
if($Path_Gap<$Best_Path_Gap){
$Best_Path_Gap=$Path_Gap;
$Best_Path_Left=$PathContig_Info{$path}{'left'}{0};
$Best_Path_Right=$PathContig_Info{$path}{'right'}{0};
}
}
}
# print "$Best_Path_Left\n$Best_Path_Right\n";
#recording the part of Scaffold_Contig and Path_Contig used to construct the final super-contig
if($Gap_Len<500){ #Contig may be with overlap
if($Max_Overlap_Line ne ""){
my @content=split /\s+/,$Max_Overlap_Line;
$Contig_Position{$content[1]}{'End'}=$content[3]; #Left_Contig End
$Contig_Position{$content[1]}{'Len'}=$content[4]; #Left_Contig Length
$Contig_Position{$content[5]}{'Start'}=$content[7]; #Right_Contig Start
$Contig_Position{$content[5]}{'Len'}=$content[8]; #Right_Contig Length
$Contig_Pair{$content[1]}{$content[5]}=0;
print PATH "$Max_Overlap_Line\n";
}
elsif($Best_Path_Left ne "" && $Best_Path_Right ne ""){
my @Left_Line=split /\s+/,$Best_Path_Left;
my @Right_Line=split /\s+/,$Best_Path_Right;
$PathContig_Ori{$Left_Line[5]}{'left'}=$Left_Line[0];
$PathContig_Ori{$Right_Line[5]}{'right'}=$Right_Line[0];
print PATH "$Best_Path_Left\n$Best_Path_Right\n";
$Contig_Position{$Left_Line[1]}{'End'}=$Left_Line[3]; #left contig end
$Contig_Position{$Left_Line[1]}{'Len'}=$Left_Line[4]; #left contig length
$Contig_Position{$Left_Line[1]}{'Path'}=$Left_Line[5]; #Path
$Contig_Position{$Right_Line[1]}{'Start'}=$Right_Line[3];#right contig start
$Contig_Position{$Right_Line[1]}{'Len'}=$Right_Line[4];#right contig length
$Contig_Pair{$Left_Line[1]}{$Right_Line[1]}=0;
$Contig_Position{$Left_Line[5]}{'Start'}=$Left_Line[7];#path contig start
$Contig_Position{$Left_Line[5]}{'End'}=$Right_Line[7];#path contig end
$Contig_Position{$Left_Line[5]}{'Len'}=$Left_Line[8]; #path contig length
}
}
else{ #Contig without overlap
next if($Best_Path_Left eq "" || $Best_Path_Right eq "");
my @Left_Line=split /\s+/,$Best_Path_Left;
my @Right_Line=split /\s+/,$Best_Path_Right;
if($Best_Path_Left eq ""){
print STDERR "$Best_Path_Left\n";
}
print PATH "$Best_Path_Left\n$Best_Path_Right\n";
$Contig_Position{$Left_Line[1]}{'End'}=$Left_Line[3];
$Contig_Position{$Left_Line[1]}{'Len'}=$Left_Line[4];
$Contig_Position{$Left_Line[1]}{'Path'}=$Left_Line[5];
$Contig_Position{$Right_Line[1]}{'Start'}=$Right_Line[3];
$Contig_Position{$Right_Line[1]}{'Len'}=$Right_Line[4];
$Contig_Pair{$Left_Line[1]}{$Right_Line[1]}=0;
$Contig_Position{$Left_Line[5]}{'Start'}=$Left_Line[7];
$Contig_Position{$Left_Line[5]}{'End'}=$Right_Line[7];
$Contig_Position{$Left_Line[5]}{'Len'}=$Left_Line[8];
}
}
close(IN1);
my $sign="";
my %Path_Contig_Seq=();
while(<IN4>){
chomp;
my $line=$_;
if($line=~/^>(\S+)/){
$sign=$1;
}
else{
$Path_Contig_Seq{$sign}=$line;
$Total_Contig{$sign}=length($line);
}
}
close(IN4);
foreach my $key (keys %Total_Contig){
if(!exists $Contig_Position{$key}){
$Contig_Position{$key}{'Start'}=0;
$Contig_Position{$key}{'End'}=$Total_Contig{$key};
$Contig_Position{$key}{'Len'}=$Total_Contig{$key};
}
elsif(!exists $Contig_Position{$key}{'Start'}){
$Contig_Position{$key}{'Start'}=0;
}
elsif(!exists $Contig_Position{$key}{'End'}){
$Contig_Position{$key}{'End'}=$Total_Contig{$key};
}
}
my %Scaffold_Contig_Seq=();
$sign="";
while(<IN3>){
chomp;
my $line=$_;
if($line=~/^>(\S+)/){
$sign=$1;
}
else{
if(exists $Contig_In_Scaffold{$sign} && !exists $Contig_Position{$sign}{'Start'}){
$Contig_Position{$sign}{'Start'}=0;
}
if(exists $Contig_In_Scaffold{$sign} && !exists $Contig_Position{$sign}{'End'}){
$Contig_Position{$sign}{'End'}=length($line);
}
$Scaffold_Contig_Seq{$sign}=$line;
if(!exists $Contig_In_Scaffold{$sign}){
print OUT ">$sign\n";
print OUT "$line\n";
my $Whole_Len=length($line);
print POS "$sign\t0\t$Whole_Len\n";
}
}
}
close(IN3);
open IN1,"<$infile1" or die $!;
#Super-Scaffold_3.1 Super-Scaffold_3.2 499 364273 364771
my $Current_Seq="";
my $name="";
my $count=1;
my $Current_Start=0;
my $Current_Scaffold="";
my %Current_Total_Len=();
my $Current_Count=1;
while(<IN1>){
chomp;
my $line=$_;
my @content=split /\s+/,$line;
# print "$content[0]\t$content[1]\n";
$content[0]=~/(Super-Scaffold_\d+)\.\d+/;
my $Scaffold=$1;
print POS "$content[0]\t$Contig_Position{$content[0]}{'Start'}\t$Contig_Position{$content[0]}{'End'}\n";
print POS "$content[1]\t$Contig_Position{$content[1]}{'Start'}\t$Contig_Position{$content[1]}{'End'}\n";
if($Current_Scaffold ne $Scaffold){
$Current_Count=1;
if($name eq ""){
$Current_Scaffold=$Scaffold;
}
else{
print OUT ">$name\n";
print OUT "$Current_Seq\n";
foreach my $part (sort {$a<=>$b} keys %Current_Total_Len){
print INFO "$name\t$Current_Total_Len{$part}{'start'}\t$Current_Total_Len{$part}{'end'}\t$Current_Total_Len{$part}{'type'}\n";
}
%Current_Total_Len=();
}
my $First_Len=$Contig_Position{$content[0]}{'End'}-$Contig_Position{$content[0]}{'Start'};
my $First_Seq=substr($Scaffold_Contig_Seq{$content[0]},$Contig_Position{$content[0]}{'Start'},$First_Len);
$Current_Seq=$First_Seq;
$name=$content[0];
$Current_Scaffold=$Scaffold;
}
if(exists $Contig_Pair{$content[0]}{$content[1]}){
$name=$name."|".$content[1];
my $Path_Seq="";
if(exists $Contig_Position{$content[0]}{'Path'}){
my $Path_Len=$Contig_Position{$Contig_Position{$content[0]}{'Path'}}{'End'}-$Contig_Position{$Contig_Position{$content[0]}{'Path'}}{'Start'};
$Current_Total_Len{$Current_Count}{'start'}=length($Current_Seq)+1;
$Current_Total_Len{$Current_Count}{'end'}=length($Current_Seq)+$Path_Len+1;
$Current_Total_Len{$Current_Count}{'type'}="Path";
$Current_Count++;
print "$content[0]\t$Path_Len\t$Contig_Position{$content[0]}{'Path'}\n";
if(($PathContig_Ori{$Contig_Position{$content[0]}{'Path'}}{'left'} eq $PathContig_Ori{$Contig_Position{$content[0]}{'Path'}}{'right'}) && ($PathContig_Ori{$Contig_Position{$content[0]}{'Path'}}{'left'} eq "+")){
$Path_Seq=substr($Path_Contig_Seq{$Contig_Position{$content[0]}{'Path'}},$Contig_Position{$Contig_Position{$content[0]}{'Path'}}{'Start'},$Path_Len);
}
elsif(($PathContig_Ori{$Contig_Position{$content[0]}{'Path'}}{'left'} eq $PathContig_Ori{$Contig_Position{$content[0]}{'Path'}}{'right'}) && ($PathContig_Ori{$Contig_Position{$content[0]}{'Path'}}{'left'} eq "-")){
my $reverse_seq=reverse_complement($Path_Contig_Seq{$Contig_Position{$content[0]}{'Path'}});
$Path_Seq=substr($reverse_seq,$Contig_Position{$Contig_Position{$content[0]}{'Path'}}{'Start'},$Path_Len);
}
print POS "$Contig_Position{$content[0]}{'Path'}\t$Contig_Position{$Contig_Position{$content[0]}{'Path'}}{'Start'}\t$Contig_Position{$Contig_Position{$content[0]}{'Path'}}{'End'}\t$PathContig_Ori{$Contig_Position{$content[0]}{'Path'}}{'left'}\n";
}
else{
$Current_Total_Len{$Current_Count}{'start'}=length($Current_Seq)-$Contig_Position{$content[1]}{'Start'};
$Current_Total_Len{$Current_Count}{'end'}=length($Current_Seq)+$Contig_Position{$content[1]}{'Start'};
$Current_Total_Len{$Current_Count}{'type'}="Overlap";
$Current_Count++;
}
my $Second_Len=$Contig_Position{$content[1]}{'End'}-$Contig_Position{$content[1]}{'Start'};
my $Second_Seq=substr($Scaffold_Contig_Seq{$content[1]},$Contig_Position{$content[1]}{'Start'},$Second_Len);
$Current_Seq=$Current_Seq.$Path_Seq.$Second_Seq;
$Current_Scaffold=$Scaffold;
}
else{
print OUT ">$name\n";
print OUT "$Current_Seq\n";
foreach my $part (sort {$a<=>$b} keys %Current_Total_Len){
print INFO "$name\t$Current_Total_Len{$part}{'start'}\t$Current_Total_Len{$part}{'end'}\t$Current_Total_Len{$part}{'type'}\n";
}
%Current_Total_Len=();
$name=$content[1];
my $Second_Len=$Contig_Position{$content[1]}{'End'}-$Contig_Position{$content[1]}{'Start'};
my $Second_Seq=substr($Scaffold_Contig_Seq{$content[1]},$Contig_Position{$content[1]}{'Start'},$Second_Len);
$Current_Seq=$Second_Seq;
$Current_Scaffold=$Scaffold;
}
}
foreach my $part (sort {$a<=>$b} keys %Current_Total_Len){
print INFO "$name\t$Current_Total_Len{$part}{'start'}\t$Current_Total_Len{$part}{'end'}\t$Current_Total_Len{$part}{'type'}\n";
}
close(INFO);
print OUT ">$name\n";
print OUT "$Current_Seq\n";
close(IN1);
close(OUT);