Introducing the Relatedness Calculator

I’m releasing a new open-source app today. It’s called the Relatedness Calculator. It’s a pretty simple app: what it does is take the name of a relative, written in plain English, and calculate the relatedness coefficient for that relative. It even accepts complex English descriptions, like “father’s half-brother’s granddaughter.” Plus, it draws a family tree, so that you can visualize the relationship. It’s pretty fun if you’re into genealogy!

Why did I write this app? Well, the inspiration actually came from a strange place: a message board. On this message board, a guy was wondering if anyone though it would be weird to date a distant relative of his. He said she was his grandma’s cousin’s daughter, and although that’s a pretty big distance in the family tree, he was worried about the social stigma if the two of them were to get married. Having a layman’s interest in genetics, I did the math for him and told him that he was only 1.5% related to her. And if he compared that to cousins (12.5%), which is kind of the borderline of acceptability for most cultures, he could see that it’s not really a big deal.

Doing the math for such a far-flung relation, though, was kind of tough. I had to go back and re-read some of Richard Dawkin’s excellent The Selfish Gene to brush up on the calculations. And then I wanted to make sure that my math was right, so I wrote some Java classes to help me out. Then I started writing unit tests. Then I started writing a parser, and… well, sometimes when you’re moderately autistic, as many programmers are, you start to get carried away. So I did, and that became a standalone Java library.

At this point I knew I wanted to make an app out of this project, because I thought it was neat enough to interest a lot of people (and not just those who want to date their relatives). I could have easily built an Android app out of it, but I’ve already written 8 Android apps, and anyway I didn’t think it was the right platform. Nobody’s going to download such a trivial app to their phone. Also, there didn’t seem to be any general-purpose relatedness calculators on the web, so I thought: why not make my own?

This is my first published webapp, so in many ways it’s kind of a “hello world” for me. I used Grails, because it seemed like a nice framework, and Groovy is close to Java. Astute Grails fans will notice that I didn’t even bother to change the default theming, but that’s typically what I do when I write apps. I don’t have a head for design, so even with my Android apps I’ve always just used the default theme. I prefer focusing on functionality over flash.

To deploy the app was a bit complicated. I hesitated between choosing Google App Engine and Amazon EC2, but in the end I decided to go with the latter, because as it turned out I needed full OS access in order to run Graphviz on the command line in a separate process, which I don’t believe is supported by GAE.

I registered for an Amazon EC2 Micro instance because it’s free for one year, so we’ll see how it holds up. Even though the app is pretty lightweight – no persistence, no heavy computation, most everything cached – I’ve already seen some significant slowdown. Since the server is free, though, I can’t really complain.

The biggest difference I find with developing webapps versus Android apps is just the barrier to entry. When it comes to costs, being an Android developer will only run you the $25 signup fee, and then after that Google takes care of the rest. For a webapp, though, I need to pay $10-15/year for the domain name, and then my micro EC2 instance (after the first free year) will cost at least $15/month, plus more if the app is popular. That’s pretty steep for hobby apps like mine, which don’t even bring in any money.

As for deployment, you also don’t need to know how to set up a LAMP stack on Android, or how to build a WAR file, or even how to use the command line. You just submit your app to Google using the web interface, and you’re done.

Plus, of course, the project structure itself is much simpler. Android apps are just Java and XML, whereas with a modern webapp, you need to make sure your Javascript plays nice with your CSS, and that your HTML plays nice with whatever’s generating it on the server side – Java, Groovy, Perl, Python, Ruby, etc. That’s a lot to take in at once.

When it comes to Android, I think an undergrad, with one or two intro Java courses under their belt, could probably build a decent app just by reading the Android tutorials. Building a webapp, on the other hand, requires a lot of additional specialized knowledge. Having come from a server-side background, and having had to figure this stuff out myself by trial and error, I can definitely say that web development is not for the faint of heart. It’s a global standard, and the W3C has tried to please everybody, so much of it feels like a Frankenstein’s monster of barely compatible compromises, rather than a holistic framework built from the ground up, like what Google did with Android.

And yet, web development is so… satisfying. I love that I can build this app, and now anybody with a browser can just point themselves to my site and make use of my code. It even works on mobile! Just play around with the CSS a bit, and you can turn your webapp into a perfectly functional, cross-platform mobile application. I suppose these observations seem pretty banal to folks who have been doing web development for forever, but for me, it’s still kind of amazing.

Anyway, the Relatedness Calculator is live now, so go check it out. And if you have improvements to make, fork it on GitHub!

4 responses to this post.

  1. Posted by Skip Magyar on August 2, 2012 at 4:03 PM

    Hi Nolan,

    Nice job on your Relatedness Calculator and thank you for putting it on the internet. I have been looking for a similar program that will help me determine the “closeness” of cousins when there are multiple connections through various bloodlines as compared to other cousins with multiple connections.

    Here are a few general examples of the types of relationships I have been puzzling over:
    • Would I be more closely related, i.e., have a higher degree of consanguinity with my 1st cousin thrice removed or my 2nd cousin, once removed? Now what if one or the other was younger than I rather than older?
    • Say Bill is my 3rd cousin, twice removed two different ways through one line and my 4th cousin, once removed through another line. Another ancestor, Bob, is my half 2nd cousin, twice removed and my 3rd cousin, three times removed. Given those relationships, am I more closely related to Bill or to Bob?
    • If my grandparents were descended from a common ancestor; I’ll call Ezekiel; do I have a “double dose” of Ezikiel’s genes, i.e., am I more closely related to Ezekiel than I am to my other grandparents of that same generation or are the genes from him not replicated in some manner? What if there were a different spouse for Ezekial for one of my granparents?
    It’s not rocket science but neither is it intuitively obvious. I was hoping that someone had already developed a quick and easy program that would have enough flexibility to let me do some similar and some more complicated degree of consanguinity calculations.

    Thanks again,

    Skip Magyar


    • Glad to know you’ve taken an interest in the app. The answers to your questions are below:

      1) “X removed” currently isn’t accepted by the relatedness calculator, but we can spell out your relations more precisely to get an answer. Your first cousin thrice removed could be a lot of different things, but let’s just say it’s your cousin’s great-grandchild (, which has a consanguinity of 1.5625%. Again “second cousin once removed” is ambiguous – it could be your second cousin’s child (( or your parent’s second cousin (, but we can choose either one because they have the same consanguinity of 1.5625%. So in this case the relatedness is the same. Also, it make no difference whether the cousin is older or younger.

      2) Sounds like you’re trying to give me a math problem. :) I’m going to assume that Bob is your “half second cousin” because you only share one great-grandparent, i.e. he’s your grandparent’s half-sibling’s grandchild ( Adding the multiple relations together using the relatedness calculator (and just randomly picking some more precise resolution for the ambiguous “X removed” relations, as explained above), I come up with:

      third cousin’s grandchild = 0.1953125%
      third cousin’s grandchild = 0.1953125% (second line)
      fourth cousin’s child = 0.09765625%
      total = 0.48828125%

      grandparent’s half-sibling’s grandchild = 1.5625%
      third cousin’s great-grandchild = 0.09765625%
      total = 1.66015625%

      So Bob is more closely related by a long shot, mostly due to the “half second cousin” relation.

      3) Yes, you would have a “double dose” of Ezekiel’s genes in this case. As for your relatedness to Ezekiel vs your grandparents, even with the “double dose,” there’s no way you’d be more related to him than to your grandparents. The funky thing to remember about genealogy is that the genes get split in half every generation, so your relatedness to someone decreases exponentially the further back you go. Ezekiel would have to have directly fathered all four of your grandparents (4/8 = 1/2 = 50%) in order to exceed your relatedness to one of your grandparents (1/4 = 25%).

      As for a “quick and easy” program to do these sorts of calculations, I’m afraid that AFAIK the Relatedness Calculator is the only one anyone’s built. :) Your questions have given me some interesting starting points to start improving the app, though. If you have any RFEs, you can add them to the app’s page on GitHub:


  2. Posted by Krishna on April 9, 2017 at 3:47 AM

    This is a great application. In India we have big weddings. So deciding who should be invited is really complicated. For my daughter’s wedding I intend to set of a Relatedness coefficient of 6.25% + as the cutoff. For in-laws I am arbitrarily saying it is multiplied by .5 So brother’s wife is .5 x .5 = 25% and brothers wife’s sister is .5x.5x.5 = 12.5%

    This relatedness by marriage is interesting and I may fork it for that


  3. Posted by delicado on December 8, 2017 at 4:07 PM

    A really nicely built and explained project – thanks!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.