Wednesday, 15 July 2015

ruby - Create an array of strings of all possible combination of the elements of a series of arrays -



ruby - Create an array of strings of all possible combination of the elements of a series of arrays -

i reverse deoxyribonucleic acid translation using bioruby offers nice codon table bacterias.

here code snippet describing series of arrays have (they lot more!).

# arrays sample = table.revtrans("a") # ["gct", "gcc"] b = table.revtrans("m") # ["atg"] c = table.revtrans("l") # ["tta", "ttg", "ctt", "ctc", "cta", "ctg"] d = ...

i create array or hash possible combinations of above strings.

["gctatgtta", "gccatgtta", "gtcatgttg", "gctatgctt", etc]

any thought how can accomplish using ruby? tried using combination method, failed produce sensible result. also, i'd able predetermine number of computations if possible! please offer mathematical explanation if can!

some explanation

these 3-letter strings dna codons. each triplet can translated amino acid pre-determined table. i'm doing creating (huge) series of potential deoxyribonucleic acid sequences protein produced theoretically.

thanks!

[*a, *b, *c].combination(3).map &:join #=> ["gctgccatg", "gctgcctta", #...

ruby arrays algorithm bioinformatics

No comments:

Post a Comment