#!/usr/bin/perl #use warnings; #use strict; #use Data::Dumper; my $file1 = $ARGV[0]; open($infile1,$file1); my $file2 = $ARGV[1]; open($infile2,$file2); my %file2_hash; while (my $line = <$infile2>) { next if $line =~ /^\s*$/; #skip blank lines (a common infile goof +) my ($key, $value1, $value2) = split /\s+/, $line; # use better "nam +es" I have # no idea of what a chr col + means $file2_hash{"$key:$value1:$value2"} = 1; } close $infile2; while (my $line = <$infile1>) { chomp $line; #so that output with E or M can be on same line next if $line =~ /^\s*$/; #skip blank lines (a common infile goof +) my ($chr, $value1) = split /\s+/,$line; if (exists $file2_hash{"$chr:$value1"} or exists $file2_hash{"$chr: +$value2"} ) { print "$line\tE\n"; # match exists with file 1 } else { print "$line\tM\n"; # match does NOT exist with file 1 } }
In reply to Re^2: compare two files on the basis of Two IDs
by genome
in thread compare two files on the basis of Two IDs
by genome
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |