-
Notifications
You must be signed in to change notification settings - Fork 12
/
get_circRNA_from_bed.pl
55 lines (54 loc) · 1.65 KB
/
get_circRNA_from_bed.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
#!/usr/bin/perl -w
use strict;
# convert bed_formatted pre_defined_circRNAs into proprietray sum format
die "Usage: $0 \"bed_input\" \(optional\)output" if (@ARGV < 1);
my $filein=$ARGV[0];
my $fileout="pre_defined_circRNA.sum";
if (scalar(@ARGV) > 1) {$fileout=$ARGV[1];}
open IN,$filein;
open OUT,">".$fileout;
my $count=0;
while(<IN>) {
chomp;
if (m/^>/){ next; }
if (m/^@/){ next; }
if (m/^#/){ next; }
if (m/^track/){ next; }
my @a=split("\t",$_);
$count++;
my $id="tpid-".$count."/1__1";
my $chr=$a[0];
if ($chr=~m/^chromosome/i) {$chr=~s/chromosome//i;}
if ($chr=~m/^chr/i) {$chr=~s/chr//i;}
my $SS=100;
my $HS=50;
my $strand="+";
if ($a[5] eq "+") {
$strand="-";
if (scalar(@a) >= 12) {
my @b=split(/\|/,$a[3]);
if (scalar(@b) eq 4) {
$SS=$b[1];
$HS=sprintf("%.2f",$SS/2);
}
print OUT join("\t",$id,60,$chr,30,30,($a[2]-30+1),$a[2],$strand,0,30,($a[1]+1),($a[1]+30),$strand,($a[1]-$a[2]+1),$SS,$HS,$HS,$a[5],0,0,0,10,0),"\n";
}
elsif (scalar(@a) >= 6 ) {
print OUT join("\t",$id,60,$chr,30,30,($a[2]-30+1),$a[2],$strand,0,30,($a[1]+1),($a[1]+30),$strand,($a[1]-$a[2]+1),$SS,$HS,$HS,$a[5],0,0,0,10,0),"\n";
}
}
else {
# $a[5] eq "-"
if (scalar(@a) >= 12) {
my @b=split(/\|/,$a[3]);
if (scalar(@b) eq 4) {
$SS=$b[1];
$HS=sprintf("%.2f",$SS/2);
}
print OUT join("\t",$id,60,$chr,0,30,($a[2]-30+1),($a[2]),$strand,30,30,($a[1]+1),($a[1]+30),$strand,($a[1]-$a[2]+1),$SS,$HS,$HS,$a[5],0,0,0,10,0),"\n";
}
elsif (scalar(@a) >= 6 ) {
print OUT join("\t",$id,60,$chr,0,30,($a[2]-30+1),($a[2]),$strand,30,30,($a[1]+1),($a[1]+30),$strand,($a[1]-$a[2]+1),$SS,$HS,$HS,$a[5],0,0,0,10,0),"\n";
}
}
}