fields.append('mutsprot')
            annotate_tree(patient, tree,
                          fields=fields,
                          VERBOSE=VERBOSE)


            if VERBOSE >= 2:
                print 'Ladderize tree'
            tree.ladderize()


            if use_save:
                if VERBOSE >= 2:
                    print 'Save tree (JSON)'
                fields.extend(['sequence', 'confidence'])
                fn = patient.get_consensi_tree_filename(region, format='json')
                tree_json = tree_to_json(tree.root, fields=fields)
                write_json(tree_json, fn)

            if use_plot:
                import matplotlib.pyplot as plt
                fig, ax = plt.subplots(figsize=(15, 12))
                Phylo.draw(tree, do_show=False, axes=ax)
                ax.set_title(pname+', '+region)

                x_max = max(tree.depths().itervalues())
                ax.set_xlim(0.995, 0.995 + (x_max - 0.995) * 1.4)
                ax.grid(True)
                
                plt.ion()
                plt.show()
Exemplo n.º 2
0
            if VERBOSE >= 2:
                print 'Annotate tree'
            fields = ['DSI', 'muts', 'VL', 'ntemplates', 'CD4', 'subtype']
            if region in regionsprot:
                fields.append('mutsprot')
            annotate_tree(patient, tree, fields=fields, VERBOSE=VERBOSE)

            if VERBOSE >= 2:
                print 'Ladderize tree'
            tree.ladderize()

            if use_save:
                if VERBOSE >= 2:
                    print 'Save tree (JSON)'
                fields.extend(['sequence', 'confidence'])
                fn = patient.get_consensi_tree_filename(region, format='json')
                tree_json = tree_to_json(tree.root, fields=fields)
                write_json(tree_json, fn)

            if use_plot:
                import matplotlib.pyplot as plt
                fig, ax = plt.subplots(figsize=(15, 12))
                Phylo.draw(tree, do_show=False, axes=ax)
                ax.set_title(pname + ', ' + region)

                x_max = max(tree.depths().itervalues())
                ax.set_xlim(0.995, 0.995 + (x_max - 0.995) * 1.4)
                ax.grid(True)

                plt.ion()
                plt.show()