view maf2bed.pl @ 26:e578621acb13 draft

planemo upload for repository https://github.com/usegalaxy-eu/temporary-tools/tree/master/jbrowse2 commit 50ecae3ea703a1b04501cc44f0d1fa6d714a6cc9-dirty
author fubar
date Sat, 03 Feb 2024 22:22:07 +0000
parents 2de9f585505b
children e7a6f7a7148d
line wrap: on
line source

#!/usr/bin/env perl
# https://unpkg.com/browse/jbrowse-plugin-mafviewer@1.0.6/dist/
# license is Apache2_license.txt included here
use warnings;
use strict;

$, = ' ';
$\ = "\n";
$, = "\t";

my $id = 0;
my $buffer = '';
my $start = 0;
my $end = 0;
my $score = 0;
my $chrom = '';

while (<STDIN>) {
    chomp;
    next if /^$/;
    my @line = split('\s+');
    if (/^s\s+$ARGV[0]/) {
        $chrom = $line[1];
        $chrom =~ s/$ARGV[0]\.//;
        $start = $line[2];
        $end = $line[2] + $line[3];
        s/^s //;
        s/ +/:/g;
        my $temp = $_;
        $buffer = $buffer eq '' ? $temp : "$buffer,$temp";
    }
    elsif (/^a/) {
        $score = +(s/^a score=//);
        if($id > 0) {
            print $chrom, $start, $end, "$ARGV[0]_$id", $score, $buffer;
        }
        $id += 1;
        $buffer = '';
    }

    elsif (/^s/) {
        s/^s //;
        s/ +/:/g;
        my $temp = $_;
        $buffer = $buffer eq '' ? $temp : "$buffer,$temp";
    }
}
print $chrom, $start, $end, "$ARGV[0]_$id", $score, $buffer;