|Don't ask to ask, just ask|
Obtaining combinations of hash keys and valuesby Anonymous Monk
|on Apr 28, 2016 at 14:00 UTC||Need Help??|
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question: ⭐
I have a short script which splits a DNA-sequence (imported by BioPerl) by a user-provided pattern and subsequently populates a hash with modified versions of the resulting fragments along with a unique ID. Each fragment produced by split appears in the hash twice - in the original form and in a reverse complement form (F and R respectively).
I now want to obtain unique combinations (of two) whilst excluding a fragment from combining with its own reverse cognate. Using the example above, it would produce:
But would not produce 1F1R or 2F2R. As shown above, both the keys of the involved fragments are combined as well as the values - and stored in a new hash.
I've tried using the CPAN modules Algorithm::Combinatorics and Math::Combinatorics but can't seem to adapt these to fit this task.
Does anybody have any code snippets, examples or suggestions that could help achieve this? If it helps: i'm very new to Perl.