Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Pattern matching across two files, Need something better than grep -f!

by snape (Pilgrim)
on Apr 11, 2012 at 08:20 UTC ( #964472=note: print w/ replies, xml ) Need Help??


in reply to Pattern matching across two files, Need something better than grep -f!

Try Hash table for comparing the two files.

#!usr/bin/perl use strict; use warnings; my %data1; ## Hash for Pattern File open IN1, 'patterns.txt' or die $!; while (<IN1>){ chomp $_; my @line = split('\t',$_); $data1{$line[0]} = $line[1]; } close (IN1); open IN2, 'data.txt' or die $!; while( <IN2> ) { my @line = split('\t',$_); if (exists $data1{$line[0]}){ print$line[0],"\t", $line[1],"\t",$line[2],"\t",$line[3], "\n"; } } close IN2;


Comment on Re: Pattern matching across two files, Need something better than grep -f!
Download Code
Re^2: Pattern matching across two files, Need something better than grep -f!
by Anonymous Monk on Feb 18, 2013 at 13:13 UTC
    how can i make a code for file that look like this...
    pattern.txt AT1G48210 AT1G48240 AT1G48260 AT1G48330 AT1G48370 AT1G48440 AT1G48450 AT1G01073
    data.txt
    AT1G01010 Bra033296 . . AT1G01020 Bra033295 . . AT1G01030 Bra033294 . . AT1G01040 Bra033293 . . AT1G01046 . . . AT1G01050 Bra033292 Bra032616 . AT1G01060 Bra033291 . . AT1G01070 Bra033290 Bra032617 . AT1G01073 . . . AT1G01080 Bra033287 . . AT1G01090 Bra033286 Bra032619 . AT1G01100 Bra033285 Bra032620 . AT1G01110 Bra033284 . . AT1G01115 . . . AT1G01120 Bra033283 Bra032621 . AT1G01130 Bra033282 Bra032622 . AT1G01140 Bra033282 Bra032622 . AT1G01150 . . . AT1G01160 Bra033281 Bra032623 . AT1G01170 Bra033280 . . AT1G01180 Bra033279 . . AT1G01183 . . . AT1G01190 Bra033278 Bra032624 .
    and i need to find the lines with "dots" only and pull out the sequences above and below that have atleast one "Bra...." rather than "dot" which is most closer to the line with only "dots". In the file there can be more than one lines closer which have only "dots". plss help... Im so stuck!!

      how can i make a code ...

      SMOP

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://964472]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (5)
As of 2014-12-25 16:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (160 votes), past polls