Created
May 9, 2013 13:41
-
-
Save jimmyz/5547493 to your computer and use it in GitHub Desktop.
Merging two pedigrees with Ahnentafel numbering scheme.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # You have a 4 generation pedigree that you would like to extend | |
| # to a 7 generation pedigree. | |
| # | |
| # 8 9 10 11 12 13 14 15 | |
| # 4 5 6 7 | |
| # 2 3 | |
| # 1 | |
| # | |
| # If you take the person on the 4th generation and pull its pedigree, | |
| # you can merge the two pedigrees to create a new larger pedigree. | |
| # | |
| # Let's say you would like to extend from person 12 and merge the new four | |
| # generation pedigree into the original so that you have one large pedigree. | |
| # The end result you are looking for would be the following pedigree: | |
| # | |
| # 96 97 98 99 100 101 102 103 | |
| # 48 49 50 51 | |
| # 24 25 | |
| # 8 9 10 11 12 13 14 15 | |
| # 4 5 6 7 | |
| # 2 3 | |
| # 1 | |
| # | |
| # Note that you can find 12's father (24), mother (25), paternal grandfather(48),etc. | |
| # The problem is that 12's pedigree will be returned by the system with numbering | |
| # beginning with 1, so you must transpose the Ahnentafel numbers to stitch them | |
| # in at 12. The algorith requires the following: | |
| # | |
| # 8+88 9+88 10+88 11+88 12+88 13+88 14+88 15+88 | |
| # 4+44 5+44 6+44 7+44 | |
| # 2+22 3+22 | |
| # 1+11 | |
| # | |
| # The transpose method will transpose any position value in the pedigree to the new | |
| # number so that it can be stitched in. | |
| # | |
| # Example Usage: | |
| # | |
| # transposing with a new base position of 12: | |
| # | |
| # transpose 1, 12 #=> 12 | |
| # transpose 2, 12 #=> 24 | |
| # transpose 3, 12 #=> 25 | |
| # transpose 4, 12 #=> 48 | |
| def transpose(ahnen_position,new_base) | |
| merge_num=new_base-1 | |
| level = Math.log2(ahnen_position).floor | |
| to_add = (2**level)*merge_num | |
| result = ahnen_position+to_add | |
| result | |
| end | |
| puts (1..15).to_a.collect{|n|transpose(12,n)} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment