Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

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.

Replies are listed 'Best First'.
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 C00668 Bacteroides thetaiotaomicron C00221 C01172 Bacteroides thetaiotaomicron C00074 C00022 Bacteroides thetaiotaomicron C00221 C00267 Parabacteroides Distasonis C02876 C00163
    Homosapiens C00267 C00668 Homosapiens C00267 C00221 Homosapiens C00221 C00267 Homosapiens C00221 C01172 Homosapiens C00221 C01172 Homosapiens C00668 C01172 Homosapiens C01172 C00668 Homosapiens C00668 C05345 Homosapiens C05345 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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://904147]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (5)
As of 2018-02-23 21:07 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (310 votes). Check out past polls.