annotate 2.4/script/Annotate_SoftSearch.pl @ 16:8eb7d93f7e58 draft

Uploaded
author plus91-technologies-pvt-ltd
date Sat, 31 May 2014 11:23:36 -0400
parents e3609c8714fb
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
1 #!/usr/bin/perl
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
2 open(VCF,"$ARGV[0]")||die "Usage: <VCF> <Annotation.bed>\n\n\t\t The annotation BED should be of exons\n";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
3
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
4 $bedtools=`which intersectBed`;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
5 if(!$bedtools){die "Requires Bedtools in path\n\n"}
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
6 if(!$ARGV[1]){die "Usage: <VCF> <Annotation.bed>\n\n";}
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
7
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
8 while (<VCF>){
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
9 if($_=~/^#/){print;next}
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
10 chomp;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
11 @data=split(/\t/,$_);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
12 #Get left pair information
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
13 $chr1=$data[0];
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
14 $pos1a=$data[1]-1;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
15 $pos1b=$data[1];
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
16 #Get right pair information
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
17 $data[4]=~s/[ACTGactghr\[\]]//g;#$data[4]=~s/hr/chr/;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
18 @pos2=split(/:/,$data[4]);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
19 $chr2="chr";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
20 $chr2.=$pos2[0];
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
21 $pos2a=$pos2[1]-1;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
22 $pos2b=$pos2[1];
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
23 #Now get left side annotations
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
24 #
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
25 #print "LEFT=get_anno($chr1,$pos1a,$pos1b)\n";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
26 $left_gene=get_anno($chr1,$pos1a,$pos1b);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
27 #print "RIGHT=get_anno($chr2,$pos2a,$pos2b)\n";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
28 $right_gene=get_anno($chr2,$pos2a,$pos2b);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
29 print "$_\t$left_gene\t$right_gene\n";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
30 }
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
31
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
32 close VCF;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
33
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
34 sub get_anno(){
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
35 my ($chr,$pos1,$pos2)=@_;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
36 $result=`perl -e 'if(($chr)&&($pos1)&&($pos2)){print join(\"\\t\",$chr,$pos1,$pos2,\"\\n\")}else {print STDERR "Not all variables defined: chr,pos1,pos2=$chr,$pos1,$pos2\n$_\n"}'|intersectBed -a $ARGV[1] -b stdin|cut -f4|head -1`;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
37 $result=~chomp;$result=~s/\n//;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
38 if(!$result){$result="NA"};
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
39 return $result;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
40 }