annotate jbrowse2/maf2bed.pl @ 3:0d953fc4ca97 draft

Uploaded
author fubar
date Wed, 03 Jan 2024 08:07:45 +0000
parents cd5d63cd0eb5
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
cd5d63cd0eb5 Uploaded
fubar
parents:
diff changeset
1 #!/usr/bin/env perl
cd5d63cd0eb5 Uploaded
fubar
parents:
diff changeset
2 use warnings;
cd5d63cd0eb5 Uploaded
fubar
parents:
diff changeset
3 use strict;
cd5d63cd0eb5 Uploaded
fubar
parents:
diff changeset
4
cd5d63cd0eb5 Uploaded
fubar
parents:
diff changeset
5 $, = ' ';
cd5d63cd0eb5 Uploaded
fubar
parents:
diff changeset
6 $\ = "\n";
cd5d63cd0eb5 Uploaded
fubar
parents:
diff changeset
7 $, = "\t";
cd5d63cd0eb5 Uploaded
fubar
parents:
diff changeset
8
cd5d63cd0eb5 Uploaded
fubar
parents:
diff changeset
9 my $id = 0;
cd5d63cd0eb5 Uploaded
fubar
parents:
diff changeset
10 my $buffer = '';
cd5d63cd0eb5 Uploaded
fubar
parents:
diff changeset
11 my $start = 0;
cd5d63cd0eb5 Uploaded
fubar
parents:
diff changeset
12 my $end = 0;
cd5d63cd0eb5 Uploaded
fubar
parents:
diff changeset
13 my $score = 0;
cd5d63cd0eb5 Uploaded
fubar
parents:
diff changeset
14 my $chrom = '';
cd5d63cd0eb5 Uploaded
fubar
parents:
diff changeset
15
cd5d63cd0eb5 Uploaded
fubar
parents:
diff changeset
16 while (<STDIN>) {
cd5d63cd0eb5 Uploaded
fubar
parents:
diff changeset
17 chomp;
cd5d63cd0eb5 Uploaded
fubar
parents:
diff changeset
18 next if /^$/;
cd5d63cd0eb5 Uploaded
fubar
parents:
diff changeset
19 my @line = split('\s+');
cd5d63cd0eb5 Uploaded
fubar
parents:
diff changeset
20 if (/^s\s+$ARGV[0]/) {
cd5d63cd0eb5 Uploaded
fubar
parents:
diff changeset
21 $chrom = $line[1];
cd5d63cd0eb5 Uploaded
fubar
parents:
diff changeset
22 $chrom =~ s/$ARGV[0]\.//;
cd5d63cd0eb5 Uploaded
fubar
parents:
diff changeset
23 $start = $line[2];
cd5d63cd0eb5 Uploaded
fubar
parents:
diff changeset
24 $end = $line[2] + $line[3];
cd5d63cd0eb5 Uploaded
fubar
parents:
diff changeset
25 s/^s //;
cd5d63cd0eb5 Uploaded
fubar
parents:
diff changeset
26 s/ +/:/g;
cd5d63cd0eb5 Uploaded
fubar
parents:
diff changeset
27 my $temp = $_;
cd5d63cd0eb5 Uploaded
fubar
parents:
diff changeset
28 $buffer = $buffer eq '' ? $temp : "$buffer,$temp";
cd5d63cd0eb5 Uploaded
fubar
parents:
diff changeset
29 }
cd5d63cd0eb5 Uploaded
fubar
parents:
diff changeset
30 elsif (/^a/) {
cd5d63cd0eb5 Uploaded
fubar
parents:
diff changeset
31 $score = +(s/^a score=//);
cd5d63cd0eb5 Uploaded
fubar
parents:
diff changeset
32 if($id > 0) {
cd5d63cd0eb5 Uploaded
fubar
parents:
diff changeset
33 print $chrom, $start, $end, "$ARGV[0]_$id", $score, $buffer;
cd5d63cd0eb5 Uploaded
fubar
parents:
diff changeset
34 }
cd5d63cd0eb5 Uploaded
fubar
parents:
diff changeset
35 $id += 1;
cd5d63cd0eb5 Uploaded
fubar
parents:
diff changeset
36 $buffer = '';
cd5d63cd0eb5 Uploaded
fubar
parents:
diff changeset
37 }
cd5d63cd0eb5 Uploaded
fubar
parents:
diff changeset
38
cd5d63cd0eb5 Uploaded
fubar
parents:
diff changeset
39 elsif (/^s/) {
cd5d63cd0eb5 Uploaded
fubar
parents:
diff changeset
40 s/^s //;
cd5d63cd0eb5 Uploaded
fubar
parents:
diff changeset
41 s/ +/:/g;
cd5d63cd0eb5 Uploaded
fubar
parents:
diff changeset
42 my $temp = $_;
cd5d63cd0eb5 Uploaded
fubar
parents:
diff changeset
43 $buffer = $buffer eq '' ? $temp : "$buffer,$temp";
cd5d63cd0eb5 Uploaded
fubar
parents:
diff changeset
44 }
cd5d63cd0eb5 Uploaded
fubar
parents:
diff changeset
45 }
cd5d63cd0eb5 Uploaded
fubar
parents:
diff changeset
46 print $chrom, $start, $end, "$ARGV[0]_$id", $score, $buffer;