Last active
February 16, 2016 16:31
-
-
Save brentp/1f06b43a39c3af67b085 to your computer and use it in GitHub Desktop.
This file contains 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
from gemini.gim import AutoDom, AutoRec, DeNovo, MendelViolations, CompoundHet | |
# turn a dictionary into something that can be accessed by attribute. | |
class Args(object): | |
""" | |
>>> args = Args(db='some.db') | |
>>> args.db | |
'some.db' | |
""" | |
_opts = ("columns", "db", "filter", "min_kindreds", "families", | |
"pattern_only", "max_priority", # only for compound_het | |
"allow_unaffected", "min_gq", "lenient", "min_sample_depth") | |
def __init__(self, **kwargs): | |
if not "min_gq" in kwargs: kwargs['min_gq'] = 0 | |
if not "lenient" in kwargs: kwargs['lenient'] = False | |
for k in ("families", "filter"): | |
if not k in kwargs: kwargs[k] = None | |
if not "gt_phred_ll" in kwargs: kwargs['gt_phred_ll'] = None | |
if not "min_sample_depth" in kwargs: kwargs['min_sample_depth'] = 0 | |
for k in ("min_kindreds", "max_priority"): | |
if not k in kwargs: kwargs[k] = 1 | |
for k in ("pattern_only", "allow_unaffected"): | |
if not k in kwargs: kwargs[k] = False | |
self.__dict__.update(**kwargs) | |
model = AutoDom(Args(db="../test/test.auto_dom.db", | |
columns="chrom,start,end,impact_severity,impact,gene,transcript,max_aaf_all", | |
filter="max_aaf_all < 0.1")) | |
for i, row in enumerate(model.report_candidates()): | |
# row is an OrderedDict | |
if i == 0: | |
print "\t".join(row.keys()) | |
print "\t".join(map(str, row.values())) | |
model = CompoundHet(Args(db="../test/test.comp_het.db", | |
columns="chrom,start,end,impact_severity,impact,gene,transcript,max_aaf_all", | |
gt_phred_ll=100, | |
max_priority=3, | |
allow_unaffected=True)) | |
for i, row in enumerate(model.report_candidates()): | |
# row is an OrderedDict | |
if i == 0: | |
print "\t".join(row.keys()) | |
print "\t".join(map(str, row.values())) | |
if __name__ == "__main__": | |
import doctest | |
import sys | |
doctest.testmod() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment