Exemple #1
0
    def dot(self,
            comment=None,
            path="test.gv",
            view=False,
            tests=('auto_rec', 'auto_dom')):
        from graphviz import Digraph
        viz = Digraph(comment=comment)
        subjects = self.family.subjects
        lookup = ["HOM_REF", "HET", "UNKOWN", "HOM_ALT"]
        for i, s in enumerate(subjects):

            attrs = dict(style="filled", fontcolor="white")
            attrs["fillcolor"] = {
                True: 'black',
                False: 'white',
                None: 'gray'
            }[s.affected]
            attrs["shape"] = {
                'male': 'square',
                'female': 'circle',
                None: 'octagon'
            }[s.gender]

            if attrs["fillcolor"] == "black":
                attrs["fontcolor"] = "white"
            elif attrs["fillcolor"] == "white":
                attrs["fontcolor"] = "black"

            gt = lookup[self.gt_types[i]]
            label = s.name
            viz.node(s.name, label + "\n" + gt, **attrs)
        for s in subjects:
            if s.dad is not None:
                viz.edge(s.dad.name, s.name)
            if s.mom is not None:
                viz.edge(s.mom.name, s.name)
        for test in tests:
            res = {}
            res['default'] = getattr(self, test)()
            res['strict=False'] = getattr(self, test)(strict=False)
            res['only_affected=False'] = getattr(self,
                                                 test)(only_affected=False)
            res['both False'] = getattr(self, test)(only_affected=False,
                                                    strict=False)
            print("\n" + test)
            print("-" * len(test))
            for k in ("default", "strict=False", "only_affected=False",
                      "both False"):
                print("%-20s\t%s" % (k, res[k]))

        viz._format = "png"
        return viz.render(path, view=view)
Exemple #2
0
    def dot(self, comment=None, path="test.gv", view=False, tests=('auto_rec', 'auto_dom')):
        from graphviz import Digraph
        viz = Digraph(comment=comment)
        subjects = self.family.subjects
        lookup = ["HOM_REF", "HET", "UNKOWN", "HOM_ALT"]
        for i, s in enumerate(subjects):

            attrs = dict(style="filled", fontcolor="white")
            attrs["fillcolor"] = {True: 'black', False: 'white', None: 'gray'}[s.affected]
            attrs["shape"] = {'male': 'square', 'female': 'circle', None: 'octagon'}[s.gender]

            if attrs["fillcolor"] == "black":
                attrs["fontcolor"] = "white"
            elif attrs["fillcolor"] == "white":
                attrs["fontcolor"] = "black"

            gt = lookup[self.gt_types[i]]
            label = s.name
            viz.node(s.name, label + "\n" + gt, **attrs)
        for s in subjects:
            if s.dad is not None:
                viz.edge(s.dad.name, s.name)
            if s.mom is not None:
                viz.edge(s.mom.name, s.name)
        for test in tests:
            res = {}
            res['default'] = getattr(self, test)()
            res['strict=False'] = getattr(self, test)(strict=False)
            res['only_affected=False'] = getattr(self, test)(only_affected=False)
            res['both False'] = getattr(self, test)(only_affected=False, strict=False)
            print("\n" + test)
            print("-" * len(test))
            for k in ("default", "strict=False", "only_affected=False", "both False"):
                print("%-20s\t%s" % (k, res[k]))

        viz._format = "png"
        return viz.render(path, view=view)