From 195d11a48d2a738f4178232ea3b5162a6aff4984 Mon Sep 17 00:00:00 2001 From: "David Eccles (gringer)" Date: Sun, 1 May 2016 22:11:39 +1200 Subject: [PATCH] added script to remove identical matches from LAST alignment --- last-rmident.pl | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 last-rmident.pl diff --git a/last-rmident.pl b/last-rmident.pl new file mode 100755 index 0000000..b91d5ef --- /dev/null +++ b/last-rmident.pl @@ -0,0 +1,31 @@ +#!/usr/bin/perl + +my @lineBuffer = (); +my @ids = (); + +while(<>){ + my $line = $_; + if(/^([a-z])\s(.*?)\s/){ + my ($flag, $id) = ($1, $2); + if($flag eq "s"){ + push(@ids, $id); + } elsif($flag eq "a"){ # new alignment + if((scalar(@ids) != 2) || ($ids[0] ne $ids[1])){ + print(join("",@lineBuffer)); + } + # if(@ids){ + # printf("a '%s' '%s' %d %d\n", $ids[0], $ids[1], + # scalar(@lineBuffer), scalar(@ids)); + # } else { + # print("a\n"); + # } + @lineBuffer = (); + @ids = (); + } + } + push(@lineBuffer, $line); +} + +if((scalar(@ids) != 2) || ($ids[0] ne $ids[1])){ + print(join("",@lineBuffer)); +}