in reply to Re^3: NON Common Elements between two columns
in thread NON Common Elements between two columns

Here are the two columns, The second is a sublist of the firs generated after an analys, I need to know what elements have not been reported. (The NON common elements) The columns are in the same file.
>chr9:133738100-133738472_0 chr20:62159728-62161126_840 >chr9:133738100-133738472_60 chr2:215589720-215676478_59220 >chr9:133738100-133738472_120 chr2:215589720-215676478_59160 >chr9:133738100-133738472_180 chr15:99500240-99507809_0 >chr9:133738100-133738472_240 chr2:215589720-215676478_59100 >chr9:133738100-133738472_253 chr1:162745876-162746210_215 >chr9:133747466-133747650_0 chr5:108523084-108532592_960 >chr9:133747466-133747650_60 chr20:62159728-62161126_900 >chr9:133747466-133747650_65

Replies are listed 'Best First'.
Re^5: NON Common Elements between two columns
by aitap (Curate) on Jul 17, 2012 at 10:50 UTC
    Try this code:
    #!/usr/bin/perl use warnings; use strict; # firstly, put all data in hashes because it's easier to look for data + in a hash my @input = ({},{}); # 2 hash references my @output; while (<>) { # this means: <STDIN> and/or filenames from @ARGV if (/^>([^\s]+)(\s+)?([^\s]+)?$/) { ++$input[0]->{$1}; # first match is an element of 1st +column defined $3 && ++$input[1]->{$3}; # third match might n +ot exist and belongs to 2nd column } } # secondly, loop over first hash searching for elements in second hash for (keys %{$input[0]}) { unless (exists ${$input[1]}{$_}) { push @output,$_; } } print join "\n",@output;
    Sorry if my advice was wrong.