broadinstitute/gamgee — pull request #275 by MauricioCarneiro (2014-09-25 04:03:35+00:00)
Title: Genotype: add convenience functions: snp, indel...

This is a tricky request from Louis which I anticipate to be a big hit
with the compbios. Everyone wants to query directly at the genotype what
kind of event it is. The problem is that doing so is expensive. One
should always strive to batch this kind of computation across all
samples using functionality like select_if or simple for_each loops.

However sometimes you want to just query one or two of these conditions
and it is nice to have such convenience functions. I strived here to
achieve as much performance as possible without increasing the state of
the Genotype object. To avoid string comparisons, all member functions
rely on an AlleleMask that pre-computes the string differences in the
alt/ref fields only once. All functions operate on key comparisons only.

Still, if you are going to use this for multiple comparisons such as:

```c++
if (genotype.insertion() || genotype.snp() && genotype.simple())
do_something(genotype);
```

You will most likely be better off writing your own for loop instead of
paying for 3 passes on the data. But for quick queries in data with few
alleles (like diploids) this should be fine.

closes #204