in reply to Searching and Coutning using 2 files with multiple columns
my @file1 = (); open(FILE, @ARGV[0]) || die ("could not open file @ARGV[0]\n"); while (my $line = <FILE>) { chomp $line; my ($chr, $start, $stop) = split(/\t/, $line); push @file1, [$chr, $start, $stop]; } close FILE; open(FILE, @ARGV[1])||die ("could not open file @ARGV[1]\n"); while(<FILE>){ ($Gene,$Chrom,$ModStart,$ModEnd,$Strand,$ExonCount,$SizeKB)= s +plit; # foreach (line in genes.db){ # I don't know what to put here +. foreach my $line (@file1){ my ($chr, $start, $stop) = @$line; if ($chr eq $Chrom && $start gt $ModStart && $end lt $ModE +nd){ $Count++; print ;($Gene,$Chrom,$ModStart,$ModEnd,$Strand,$ExonCount, +$SizeKB,$Count) } }
Note that your original concept had some scoping issues.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Searching and Coutning using 2 files with multiple columns
by shart3 (Novice) on Sep 16, 2009 at 16:38 UTC | |
by kennethk (Abbot) on Sep 16, 2009 at 18:10 UTC |