#!/usr/bin/perl/ -w
use strict;
##useage:perl get.pl ref.vcf map out
###ref chr1 4357 DUP00000001 G <DUP> 1560 PASS IMPRECISE;SVTYPE=DUP;SVMETHOD=EMBL.DELLYv1.1.6;END=16430;
##map 1 DEL00000015 0 27720
open IN,"<$ARGV[0]";
open MA,"<$ARGV[1]";
open OU,">$ARGV[2]";
my %MA=();
my $pos;
while(<MA>){
chomp;
my @ma=split/\t/;
my $pos=$ma[3];
$MA{$ma[1]}=$ma[3];
}
while (<IN>){
chomp;
my @ref=split;
my $chr=$ref[0];
my $str=$ref[1];
my $id=$ref[2];
my @end=$ref[7]=~/(\d+)/g; ###提取所有数字
my $en=$end[3];##第四个匹配的就是end值
my $len=$en-$str+1;
if (exists $MA{$id}){
print OU "$id\t$chr\t$str\t$len\n";
}
}
close MA;
close ref;
close OU;
网友评论