def plot_insertions_two_panels(fname, seqs, gene, domain, tax, id2name):
<EOL>import matplotlib<EOL>import matplotlib.pyplot as plt<EOL>import numpy as np<EOL>from matplotlib.backends.backend_pdf import PdfPages<EOL>import matplotlib.cm as cm<EOL>import matplotlib.colors as col<EOL>from itertools import cycle as cycle<EOL>from matplotlib.font_manager import FontProperties<EOL>plt.rcParams['<STR_LIT>'] = <NUM_LIT> <EOL>max_insert = max_insertion(seqs, gene, domain)<EOL>height = max_insert + max_insert * <NUM_LIT><EOL>xmax = model_length(gene, domain)<EOL>f, axarr = plt.subplots(<NUM_LIT:2>, sharex = True, sharey = True)<EOL>plt.axis([<NUM_LIT:0>, xmax, <NUM_LIT:0>, height])<EOL>plt.xticks(np.arange(<NUM_LIT:0>, xmax, <NUM_LIT:100>), rotation = <NUM_LIT>)<EOL>plt.yticks(np.arange(<NUM_LIT:0>, height, <NUM_LIT:100>))<EOL>axarr[<NUM_LIT:0>].set_title('<STR_LIT>')<EOL>axarr[<NUM_LIT:1>].set_title('<STR_LIT>')<EOL>plt.suptitle('<STR_LIT>' % (domain, gene))<EOL>plt.ylabel('<STR_LIT>')<EOL>plt.xlabel('<STR_LIT>' % (domain, gene))<EOL>color2tax = {}<EOL>if tax is False:<EOL><INDENT>taxa = ['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>taxa = sorted(set([tax[id2name[i]] for i, j in list(seqs.items()) if j[<NUM_LIT:2>] != [] and id2name[i] in tax]))<EOL>if '<STR_LIT>' not in taxa:<EOL><INDENT>taxa.append('<STR_LIT>')<EOL><DEDENT><DEDENT>colors = cm.spectral(np.linspace(<NUM_LIT:0>, <NUM_LIT:1>, len(taxa)))<EOL>colors = cycle(colors)<EOL>for t in taxa:<EOL><INDENT>color2tax[t] = next(colors)<EOL><DEDENT>for name, seq in list(seqs.items()):<EOL><INDENT>g, d = seq[<NUM_LIT:0>], seq[<NUM_LIT:1>]<EOL>if g != gene or d != domain or seq[<NUM_LIT:2>] == []:<EOL><INDENT>continue<EOL><DEDENT>if tax is False or id2name[name] not in tax:<EOL><INDENT>t = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>t = tax[id2name[name]]<EOL><DEDENT>c = color2tax[t] <EOL>for ins in seq[<NUM_LIT:2>]:<EOL><INDENT>x, y = int(ins[<NUM_LIT:1>]), int(ins[<NUM_LIT:2>])<EOL>if ins[<NUM_LIT:4>] == True: <EOL><INDENT>marker, size = '<STR_LIT>', <NUM_LIT:30><EOL><DEDENT>else:<EOL><INDENT>marker, size = '<STR_LIT:o>', <NUM_LIT:30><EOL><DEDENT>if ins[<NUM_LIT:3>] == True: <EOL><INDENT>axarr[<NUM_LIT:0>].scatter(x, y, marker = marker, s = size, facecolors = '<STR_LIT:none>',clip_on = False, edgecolors = c, label = t)<EOL><DEDENT>else:<EOL><INDENT>axarr[<NUM_LIT:1>].scatter(x, y, marker = marker, s = size, facecolors = '<STR_LIT:none>',clip_on = False, edgecolors = c, label = t)<EOL><DEDENT><DEDENT><DEDENT>boxes = [matplotlib.patches.Rectangle((<NUM_LIT:0>, <NUM_LIT:0>), <NUM_LIT:1>, <NUM_LIT:1>, fc = color2tax[t]) for t in taxa]<EOL>names = [t for t in taxa]<EOL>plt.legend(boxes, names, prop = {'<STR_LIT:size>':<NUM_LIT:10>}, loc='<STR_LIT>', bbox_to_anchor=(<NUM_LIT:1>, <NUM_LIT:0.5>), scatterpoints = <NUM_LIT:1>)<EOL>figure = plt.gcf()<EOL>figure.set_size_inches(<NUM_LIT:20>, <NUM_LIT:12>)<EOL>pdf = PdfPages('<STR_LIT>' % (fname.rsplit('<STR_LIT:.>')[<NUM_LIT:0>], domain, gene))<EOL>pdf.savefig()<EOL>plt.close()<EOL>pdf.close()<EOL>
plot insertions wrt model positions
2 panels:
    1. insertions with ORF
        - triangle if has intron
        - circle if no intron
    2. insertion does not have ORF
        - triangle if has intron
        - circle if no intron
    *3. conservation of sequence in model
    *4. e. coli positions
# seqs[id] = [gene, model, [[i-gene_pos, i-model_pos, i-length, orf, intron], ...]]