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

Re^3: Comparing a large set of DNA sequences

by BrowserUk (Pope)
on Nov 10, 2011 at 16:26 UTC ( #937410=note: print w/replies, xml ) Need Help??

in reply to Re^2: Comparing a large set of DNA sequences
in thread Comparing a large set of DNA sequences

I concur. This is extremely clever.

It has the downside that it doesn't scale so well if you need to allow more than one char difference. But for the OPs stated problem, quite brilliant.

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
  • Comment on Re^3: Comparing a large set of DNA sequences

Replies are listed 'Best First'.
Re^4: Comparing a large set of DNA sequences
by roboticus (Chancellor) on Nov 10, 2011 at 18:39 UTC



    Yes, this method breaks down pretty quickly when the criteria are relaxed much. But I found a nifty variation that's a little bit more flexible (and still very limited): Rather than replace the character with an asterisk, we can remove the character entirely. That way, not only will it match a single wildcard position, but would allow it to find some two-character differences (such as a character deleted or inserted in two different locations). I need to find a simple way to group the replicated matches before I'm happy with it.

    I'm still playing around with it, but I'm at work and need to get stuff done. So I'm posting what I have so far, just in case I never get back around to it:

    $ cat #!/usr/bin/perl use strict; use warnings; my %H; open my $FH, '<', 'DNA_strings.dat' or die $!; while (<$FH>) { next if /^\s*(#.*)?$/; s/\s+$//; for my $i (0 .. length($_)-1) { my $k = $_; substr($k,$i,1) = ''; $H{$k}{$_}++; } } for my $k (sort keys %H) { if (keys %{$H{$k}} > 1) { print "$k\t", join("\n\t\t", keys %{$H{$k}}), "\n"; } } $ cat DNA_strings.dat # Add a random character to GTTAACCGGA in various positions GTxTAACCGGA GTTAAyCCGGA GTTAACCGzGA # Delete a random character from GAGGGTGATC in various positions GAGGGTGAT GAGGGTGTC GAGGTGATC AGGGTGATC GCAATTTGTC GCAAATTGTC GCAATTGGTC GTTTATAAGT TGGACAAGCT TCAGCGGATC CTACATAACT TTACTTCAGG CGGACCTTGG TGCGTGTGAC $ perl AGGGTGAT GAGGGTGAT AGGGTGATC AGGGTGTC GAGGGTGTC AGGGTGATC AGGTGATC AGGGTGATC GAGGTGATC GAGGGTGT GAGGGTGAT GAGGGTGTC GAGGTGAT GAGGGTGAT GAGGTGATC GAGGTGTC GAGGGTGTC GAGGTGATC GCAATTGTC GCAATTTGTC GCAATTGGTC GCAAATTGTC GGGTGATC AGGGTGATC GAGGTGATC GTTAACCGGA GTTAAyCCGGA GTxTAACCGGA GTTAACCGzGA

    I'd like to eliminate the duplicate groups, probably by building another hash from the original results. But I haven't figured out a nice way to do so yet.


    When your only tool is a hammer, all problems look like your thumb.

    Update: Minor formatting & text update.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://937410]
[choroba]: Yeah, my wife sent me some pictures of the children yesterday, and there was snow all around. 10 days in Saigon and I totally forgot what weather they have back there.
[stevieb]: We've had so much snow here this year that the whole area is pretty much under constant avalanche warnings (and avalanches pretty much daily all over the place)

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (11)
As of 2017-02-23 17:21 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (350 votes). Check out past polls.