Mercurial > repos > portiahollyoak > temp
comparison scripts/excision.clustering.pl @ 0:28d1a6f8143f draft
planemo upload for repository https://github.com/portiahollyoak/Tools commit 132bb96bba8e7aed66a102ed93b7744f36d10d37-dirty
author | portiahollyoak |
---|---|
date | Mon, 25 Apr 2016 13:08:56 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:28d1a6f8143f |
---|---|
1 #! /usr/bin/perl | |
2 | |
3 use strict; | |
4 | |
5 my %position=(); | |
6 my %names=(); | |
7 open (input, "<$ARGV[0]") or die "Can't open $ARGV[0] since $!\n"; | |
8 while (my $line=<input>) { | |
9 chomp($line); | |
10 my @a=split(/\t/, $line); | |
11 my @b=split(/\#/, $a[8]); | |
12 | |
13 if (defined $position{$b[0]}) { | |
14 my @c=split(/\:/, $position{$b[0]}); | |
15 if (($c[0] eq $a[0])&&($a[1] < $c[1])) { | |
16 $position{$b[0]} =~ s/$c[1]/$a[1]/; | |
17 } | |
18 if (($c[0] eq $a[0])&&($a[2] > $c[2])) { | |
19 $position{$b[0]} =~ s/$c[2]/$a[2]/; | |
20 } | |
21 my $transposon=$a[3]; | |
22 if ($names{$b[0]} !~ /$transposon/) {$names{$b[0]}=$names{$b[0]}.",$transposon";} | |
23 } | |
24 else { | |
25 $position{$b[0]}="$a[0]\:$a[1]\:$a[2]"; | |
26 $names{$b[0]}=$a[3]; | |
27 } | |
28 } | |
29 close input; | |
30 | |
31 open (output, ">>temp_for_sort") or die "Can't open temp_for_sort since $!\n"; | |
32 while ((my $key, my $value) = each (%position)) { | |
33 my @z=split(/\:/, $value); | |
34 print output "$z[0]\t$z[1]\t$z[2]\t$names{$key}\n"; | |
35 } | |
36 close output; | |
37 | |
38 system("sort +0 -1 +1n -2 +2n -3 temp_for_sort > sorted"); | |
39 system("uniq -c sorted > $ARGV[1]"); | |
40 system("rm sorted temp_for_sort"); |