-
Notifications
You must be signed in to change notification settings - Fork 0
/
gRNA.pl
56 lines (51 loc) · 1.33 KB
/
gRNA.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
#!/usr/bin/perl -w
###################################
# Author: Xiaoyu Zhou
# Email: [email protected]
###################################
#use strict;
#$inpeak = @ARGV;
open(FNA, "Homo_data/GRCh38.p13.genome.fa")or die "can't open the fasta:$!\n";
print "The file fasta has been opened.\n";
my ($id, %seq);
my $origin=$/;
$/=">";
while(my $line=<FNA>){
if($line=~/^chr(.*?)\s.*?\n(.*?)$/xs){
$id = $1;
$seq{$id} = $2;
$seq{$id} =~ s/[\n\r]*//g;
#print "$line\n";
#print "$id:$seq{$id}\n";
}else{
next;
}
}
close FNA;
$/=$origin;
open(IN, "/dellfsqd2/ST_LBI/USER/zhouxiaoyu/DNBseq/peak/501/bed.cut")or die "can't open the file:$!\n";
print "bed.cut opened!\n";
my ($chr, $before, %query, %gRNA);
while (<IN>){
chomp;
my @t=split /\s+/;
$chr = $t[0];
$before = $t[1];
my $q1 = $before - 6;
my $q2 = $before + 5;
#print "$chr:$seq{$chr}\n";
$query{$chr} = substr($seq{$chr}, $q1, $q2);
if ($query{$chr} =~ /[(GG)|(CC)]/i){
my $g1 = $before - 20;
my $g2 = $before + 19;
$gRNA{$before} = substr($seq{$chr}, $g1, $g2);
$len = length($gRNA{$before});
print ">chr$chr:$g1-$g2|chr$chr:$before|\n";
#print OUT "$gRNA{$before}\n";
print "$len\n";
}else{
next;
}
#print "@t\t\n";
}
close IN;