-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsnobound_scanner_FINAL.pl
More file actions
executable file
·64 lines (61 loc) · 1.63 KB
/
snobound_scanner_FINAL.pl
File metadata and controls
executable file
·64 lines (61 loc) · 1.63 KB
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
#!/usr/bin/perl
# script by: Hemant/Sara
# File: scans for snoRNAs using sliding window
use strict;
use warnings;
use Getopt::Long;
use String::Approx 'amatch';
my $in;
my $out1;
my $out2;
GetOptions('input=s' => \$in,
'outputf=s' => \$out1,
'outputg=s' => \$out2
);
my %hash;
my $header;
open (IN, '<', $in) or die "provide fasta file: $!\n";
open (OUT1, '>', $out1) or die "$!\n";
open (OUT2, '>', $out2) or die "$!\n";
while (my $line = <IN>){
chomp $line;
if ($line =~ /^>(\w+)/){
$header = $1;
}
else{
$hash{$header}{sequence} .= $line;
}
# foreach my $header (keys %hash){
# foreach $longseq(keys $hash => {$header}){
# print "$hash => {$header}=>{$longseq}";
# }
# }
}
foreach my $key (keys %hash){
my $num;
my $seq = $hash{$key}{sequence};
for (my $i = 0; $i < length($seq); $i++){
my $window = substr($seq, $i, 170);
if ($window =~ /((\w{4}).[AG]TGATG[ATGC].{30,140}CTGA(\w{4}))/i) {
my $fiveprime = $2;
$fiveprime =~ tr/atgcATGC/tacgTACG/;
my $revfive = reverse($fiveprime);
my $compare = amatch($revfive, $3);
# my $compare = ($revfive cmp $3);
if ($compare == 1){
my $begin = $i + $-[0];
my $end = $i + $+[0] - 1;
$i = $end;
# push (@{$hash{$key}{snoseq}}, $1);
$num++;
print OUT1 ">",$key, "snoRNA_","$num\n",uc($1),"\n";
# print OUT1 ">$key","_snoRNA_","$num\n$1\n";
print OUT2 "$key\tsnoBound\tsnoRD\t$begin\t$end\t.\t+\t.\tID=\"snoRD_$num\"; Name=\"snoRD_$num\"\n";
}
}
else {
next; # print "no match found\n";
}
}
}
__END__