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

Re: comparing data btwn 2 files

by tospo (Hermit)
on May 11, 2011 at 12:09 UTC ( #904147=note: print w/ replies, xml ) Need Help??


in reply to comparing data btwn 2 files

why do you split this on tabs? If you want to compare the whole line you can compare the lines as in "if ($line_from_hum eq line_from_bact){...}" or something. If you need to extract only a part of the line (say the first three fields) you could use a regex as in:

my ($part_of_line) = ($line=~/^((?:\S+\t){3})/);
One problem in the logic of your code might be that you are comparing lines only from "the point of view" of the human file. Lines in bact that are not in human will not be captured at the moment, which may or may not be what you wanted.


Comment on Re: comparing data btwn 2 files
Download Code
Re^2: comparing data btwn 2 files
by Anonymous Monk on May 11, 2011 at 17:39 UTC
    ^^my data in the .txt file is something like this:
    Bacteroides thetaiotaomicron C00267 5.3.1.9 C00668 Bacteroides thetaiotaomicron C00221 5.3.1.9 C01172 Bacteroides thetaiotaomicron C00074 5.3.1.9 C00022 Bacteroides thetaiotaomicron C00221 5.3.1.1 C00267 Parabacteroides Distasonis C02876 2.7.2.1 C00163
    Homosapiens C00267 2.7.1.2 C00668 Homosapiens C00267 5.1.3.3 C00221 Homosapiens C00221 5.1.3.3 C00267 Homosapiens C00221 2.7.1.2 C01172 Homosapiens C00221 2.7.1.1 C01172 Homosapiens C00668 5.3.1.9 C01172 Homosapiens C01172 5.3.1.9 C00668 Homosapiens C00668 5.3.1.9 C05345 Homosapiens C05345 5.3.1.9 C00668
    i want to compare the second, third and fourth columns in the 2 files..and find the matches.
      ok, if yuo only need the matches and don't need to know which elements are only in the bacterium or only in human then your approach will be sufficient.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2014-08-30 10:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (293 votes), past polls