Skip to content

Commit

Permalink
Merge pull request #558 from brentp/genewise_sample_info
Browse files Browse the repository at this point in the history
populate eval dict with sample_info. Thanks @udp3f for reporting.
  • Loading branch information
brentp committed Sep 22, 2015
2 parents 5a056b4 + 3103c4a commit fb560e5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
9 changes: 7 additions & 2 deletions gemini/genewise.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,16 @@ def add_cols(cols, gt_filter):
return [x for x in all_cols if x in gt_filter and not x in cols]


def gen_results(rows, gt_filters, min_filters, min_variants, columns):
def gen_results(rows, gt_filters, min_filters, min_variants, columns,
user_dict=None):
# we track the index of the passed filter in passed_filters.
gene_passed_filters = {}
if user_dict is None:
user_dict = {}
subset = []
for row in rows:
cols = {c: row[c] for c in columns}
cols.update(user_dict)
# have to test all filters since 1 row can meet multiple fitlers.
row_passed_filters = []
for i, gt_filter in enumerate(gt_filters, start=1):
Expand Down Expand Up @@ -87,11 +91,12 @@ def genewise(db, gt_filters, filter=None, columns=None, min_filters=None,
if isinstance(grouper, basestring):
grouper = operator.itemgetter(grouper)

user_dict = dict(sample_info=gq.sample_info)
header_printed = False
for groupkey, grp in it.groupby(gq, grouper):
grp = list(grp)
for x in gen_results(list(grp), cleaned_filters, min_filters or 0,
min_variants, columns):
min_variants, columns, user_dict=user_dict):
for c in added_cols:
if c != 'gene':
del x.print_fields[c]
Expand Down
12 changes: 12 additions & 0 deletions test/test-genewise.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,15 @@ gemini gene_wise \
test.auto_dom.db > obs
check obs exp

echo "genewise.t4"
echo "gene chrom start end ref alt impact impact_severity variant_filters n_gene_variants gene_filters
ASAH2C chr10 48003991 48003992 C T non_syn_coding MED 1 2 1
ASAH2C chr10 48004991 48004992 C T non_syn_coding MED 1 2 1
WDR37 chr10 1142207 1142208 T C stop_loss HIGH 1 2 1
WDR37 chr10 1142208 1142209 T C stop_loss HIGH 1 2 1" > exp
gemini gene_wise \
--columns "gene, chrom, start, end, ref, alt, impact, impact_severity" \
--gt-filter "((gt_types).(phenotype==1).(==HOM_ALT).(none))" \
--min-filters 1 \
test.auto_dom.db > obs
check obs exp

0 comments on commit fb560e5

Please sign in to comment.