Why not just define check_tgc as a function that accepts brl_db as an input? This has the advantage of not needing to define check_tgc inside of another function.

Also, you may be interested in knowing about `functools.partial`, see my Nobel prize-winning example:

``` python
import functools

def whatever(x, y, z):
    return str([x, y, z])

mostly_whatever = functools.partial(whatever, 1, 2)
abc = mostly_whatever(3)
print abc
```