Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Finding intersection of many sequences

by emos (Initiate)
on Sep 13, 2012 at 09:20 UTC ( #993432=perlquestion: print w/ replies, xml ) Need Help??
emos has asked for the wisdom of the Perl Monks concerning the following question:

Hello, I'm pretty new to programming, and I'd like to know how to find the intersection between many (sometimes 5, sometimes even 20) DNA sequences for which I have the coordinates.

I have found Bio::Range, that does most of the work for me, but I still need some help in how to automate all possible interactions (e.g. seq1 with 2,3,4,5, then seq2 with 1,3,4,5, then seq3 with 1,2,4,5 etc).

I have tried with a for loop, but I would need to manually compute all the possible iterations.

Is there a quicker way?

Thanks

Emanuele

Comment on Finding intersection of many sequences
Re: Finding intersection of many sequences
by Anonymous Monk on Sep 13, 2012 at 09:30 UTC
Re: Finding intersection of many sequences
by BrowserUk (Pope) on Sep 13, 2012 at 09:37 UTC

    Try this:

    for my $seq1 ( 1 .. 5 ) { for my $seq2 ( 1 .. $seq1 - 1, $seq1 + 1 .. 5 ) { print "$seq1 : $seq2"; } } ;; 1 : 2 1 : 3 1 : 4 1 : 5 2 : 1 2 : 3 2 : 4 2 : 5 3 : 1 3 : 2 3 : 4 3 : 5 4 : 1 4 : 2 4 : 3 4 : 5 5 : 1 5 : 2 5 : 3 5 : 4

    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.

    RIP Neil Armstrong

      thanks! that's exactly what I needed!
    Re: Finding intersection of many sequences
    by grizzley (Chaplain) on Sep 13, 2012 at 09:49 UTC

      You can try following algorithm:

      • 1. compare seq 1 with seq 2 (create intersection 12).
      • 2. compare seq 3 with intersection 12 (create intersection 13).
      • 3. compare seq 4 with intersection 13 (create intersection 14)
      • ...

    Log In?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others about the Monastery: (6)
    As of 2014-12-20 21:22 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

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





      Results (99 votes), past polls