Mercurial > repos > portiahollyoak > temp
view scripts/excision.clustering.pl @ 8:f60f60cf4a34 draft
planemo upload for repository https://github.com/portiahollyoak/Tools commit 2bc118a40da59fc3a2b8ee9ed04152c8effff94f
author | portiahollyoak |
---|---|
date | Tue, 26 Apr 2016 06:27:41 -0400 |
parents | 28d1a6f8143f |
children |
line wrap: on
line source
#! /usr/bin/perl use strict; my %position=(); my %names=(); open (input, "<$ARGV[0]") or die "Can't open $ARGV[0] since $!\n"; while (my $line=<input>) { chomp($line); my @a=split(/\t/, $line); my @b=split(/\#/, $a[8]); if (defined $position{$b[0]}) { my @c=split(/\:/, $position{$b[0]}); if (($c[0] eq $a[0])&&($a[1] < $c[1])) { $position{$b[0]} =~ s/$c[1]/$a[1]/; } if (($c[0] eq $a[0])&&($a[2] > $c[2])) { $position{$b[0]} =~ s/$c[2]/$a[2]/; } my $transposon=$a[3]; if ($names{$b[0]} !~ /$transposon/) {$names{$b[0]}=$names{$b[0]}.",$transposon";} } else { $position{$b[0]}="$a[0]\:$a[1]\:$a[2]"; $names{$b[0]}=$a[3]; } } close input; open (output, ">>temp_for_sort") or die "Can't open temp_for_sort since $!\n"; while ((my $key, my $value) = each (%position)) { my @z=split(/\:/, $value); print output "$z[0]\t$z[1]\t$z[2]\t$names{$key}\n"; } close output; system("sort +0 -1 +1n -2 +2n -3 temp_for_sort > sorted"); system("uniq -c sorted > $ARGV[1]"); system("rm sorted temp_for_sort");