in reply to Re: Repeats exclusion
in thread Repeats exclusion

Thank you very much!

And how this script could be changed if it is nesessry to include additional variables to the hash.

For example, chromosome number, number of certain elements and so on? Let it be variables $chr, $exons $palindromes. At the same moment those lines should be excluded that contain repetative coord value according to the distance value (the lines with the smalest distance value should remain), as your script already does.

coord dist chr exons palindromes 567 344 5 7 8 1345 567 5 8 123 2346 78 12 1 567 3456 67 10 1 5 3456 789 10 3 6 4678 45 6 2 0 5349 6 8 2 14 6700 124 13 8 56 6700 50 13 1 4 8964 560 2 18 8
So the output will be something like this:
coord dist chr exons palindromes 567 344 5 7 8 1345 567 5 8 123 2346 78 12 1 567 3456 67 10 1 5 4678 45 6 2 0 5349 6 8 2 14 6700 50 13 1 4 8964 560 2 18 8

Thank you once more!

Replies are listed 'Best First'.
Re^3: Repeats exclusion
by JavaFan (Canon) on Sep 13, 2010 at 14:12 UTC
    You know, first asking "how do I do X", and then after getting the answer coming back with "yeah, but I didn't really want X, I want Y, Z and W" doesn't win you many friends.

    Next time, ask what you want in the first place. Then you may get useful answers. Now you've just wasted someones time, and still not have a solution.

Re^3: Repeats exclusion
by suhailck (Friar) on Sep 14, 2010 at 05:52 UTC
    The code is modified for your new requirement

    use strict; my %hash;while(<DATA>){ my($cord,@others)=split; push @{$hash{$cord}},\@others;} print map {my $__=$_; map {$__," @{$hash{$__}->[$_->[0]]}","\n"} (sort {$a->[1] <=> $b->[1]} map{[$_,${$hash{$_}}->[$_]->[0]]} 0 .. $#{$hash{$__}})[0]} sort {$a <=> $b}keys %hash __DATA__ 567 344 5 7 8 1345 567 5 8 123 2346 78 12 1 567 3456 67 10 1 5 3456 789 10 3 6 4678 45 6 2 0 5349 6 8 2 14 6700 124 13 8 56 6700 50 13 1 4 8964 560 2 18 8