Wednesday, September 28, 2011

Modeling Family Relationships in Rails3

Background

We research the causes of genetic diseases in our group and the specific kinds of diseases that we focus on are family based diseases.  Therefore genealogy and how people are related are very important to us.  We do whole genome sequencing of families and analyze the data.  As we get more and more of these families, we need to design ways to manage that data.

Therefore, I'm putting together a piece of software that contains information on genealogy and family relationships.  Specifically, it's a ruby on rails 3 site that has a MySQL data store.  Most of our analysis code is written in Perl, so there will be a Perl client that uses the Rails API to return JSON data from the database and then use the information in the Perl script. 

Relationship Modeling

I have most of the database implemented, but I'm down to the portion of relationship modeling.  This seems to be fairly tricky because people have lots of different kinds of relationships:

1) Parents
2) Children
3) Spouses/Partners/etc
4) Non-biological family structure (adopted, etc)
5) Divorces/re-marriages

I'm sure there are more than that, but these are just some of the ones that I'm attempting to model here.  I'd like to be able to use the rails gems that work on trees, such as ancestry, or sets, such as acts_as_nested_set in order to be able to process the family trees and draw them down the road.  There's one big problem with that...  marriages are not a tree structure.  Rather than one node having multiple child nodes, it's multiple parent nodes having one or many child nodes. 

Our Sample Family

Bob and Betty Smith have two children, Bryan and Barbie.  Bryan Smith is married to Daphne Smith and they have one child, Dan.  Barbie Smith is married to Max Payne and they have no children.  This is a pretty simple 3 generation family.


No comments:

Post a Comment