"""
Code adapted from https://github.com/ohlerlab/DeepRiPe with changes
Extract information and graphs from the Integrated gradients output
"""

import argparse
import os
import sys

import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns

from classifier.plotseqlogo import seqlogo_fig
from commons import files_tools

sns.set()
sns.set_style('whitegrid')


def parse_input():
    parser = argparse.ArgumentParser()
    parser.add_argument('--interpretation_file', help='path for the input file', required=True)
    parser.add_argument('--output_folder', help='Path of the output folder', required=False,
                        default=os.path.dirname(sys.argv[0]))

    args = parser.parse_args()
    return args


def plot_one_seq(seq, output, title, yl=None):
    fig = seqlogo_fig(seq[:, :], vocab="DNA", yl=yl, figsize=(20, 4), ncol=1, plot_name=title)
    fig.savefig(output)
    plt.close()


def plot_multi_seq(sequences_dict, number_of_seq, output_folder=None):
    """
    Plot the multiple sequences in one figure
    :param sequences_dict: A dictionary with pl or cl as key and the integrated values results for each
    sequence in this label
    :param number_of_seq: number of sequences in one figure
    :param output_folder: Output folder
    """
    for k in sequences_dict:
        ex_seq = sequences_dict[k][:number_of_seq]
        fig = seqlogo_fig(np.transpose(ex_seq[:, :, :], axes=(1, 2, 0)), vocab="DNA",
                          figsize=(8, 4), ncol=1, yl=0.1,
                          plot_name="seq for top %s of type %s" % (number_of_seq, k))

        if output_folder:
            fig.savefig(os.path.join(output_folder, "seq_for_top_%s_of_type_%s" % (number_of_seq, k)))
        else:
            plt.show()

    plt.close()


def plot_avg_sequence(sequences_dict, output_folder=None):
    """
    Plot the average sequence across 30 letters and all the sequence
    :param sequences_dict: A dictionary with pl or cl as key and the integrated values results for each
    sequence in this label
    :param output_folder: Output folder
    """
    for k in sequences_dict:
        ex_seq = sequences_dict[k]
        mean_seq = np.transpose(np.mean(ex_seq[:, 60:90, :], axis=0).reshape(1, 30, 4), axes=(1, 2, 0))

        name = k
        fig = seqlogo_fig(mean_seq, vocab="DNA", figsize=(20, 4), ncol=1,
                          plot_name="Average attribution score for prediction %s" % name)

        ax = fig.axes[0]
        ax.set_title("Average sequence for prediction %s" % name, fontsize=16)

        if output_folder:
            fig.savefig(os.path.join(output_folder, "Avg_seq_for_%s30.png" % k))
        else:
            plt.show()
        plt.close()

    for k in sequences_dict:
        ex_seq = sequences_dict[k]
        mean_seq = np.transpose(np.mean(ex_seq[:, :, :], axis=0).reshape(1, 150, 4), axes=(1, 2, 0))

        fig = seqlogo_fig(mean_seq, vocab="DNA", figsize=(20, 4), ncol=1,
                          plot_name="Avg seq for %s" % k)

        if output_folder:
            fig.savefig(os.path.join(output_folder, "Avg_seq_for_%s.png" % k))
        else:
            plt.show()
        plt.close()


def plot_avg_sequence_sw(sequences_dict, output_folder=None):
    """
    plot the avg sequence using SW, flatten the AT to W and CG to S
    :param sequences_dict: A dictionary with pl or cl as key and the integrated values results for each
    sequence in this label
    :param output_folder: Output folder
    """
    for k in sequences_dict:
        ex_seq = sequences_dict[k]
        mean_seq = np.transpose(np.mean(ex_seq[:, 60:90, :], axis=0).reshape(1, 30, 4), axes=(1, 2, 0))
        new_seq = np.zeros_like(mean_seq)
        for i in range(mean_seq.shape[0]):
            new_seq[i][0] = mean_seq[i][0] + mean_seq[i][3]
            new_seq[i][1] = mean_seq[i][1] + mean_seq[i][2]

        fig = seqlogo_fig(new_seq, vocab="DNAWS", figsize=(20, 4), ncol=1, plot_name="Avg seq for %s" % k)

        if output_folder:
            fig.savefig(os.path.join(output_folder, "Avg_seq_for_%s_sw30.png" % k))
        else:
            plt.show()

    for k in sequences_dict:
        ex_seq = sequences_dict[k]
        mean_seq = np.transpose(np.mean(ex_seq[:, :, :], axis=0).reshape(1, 150, 4), axes=(1, 2, 0))
        new_seq = np.zeros_like(mean_seq)
        for i in range(mean_seq.shape[0]):
            new_seq[i][0] = mean_seq[i][0] + mean_seq[i][3]
            new_seq[i][1] = mean_seq[i][1] + mean_seq[i][2]

        fig = seqlogo_fig(new_seq, vocab="DNAWS", figsize=(20, 4), ncol=1, plot_name="Avg seq for %s" % k)

        if output_folder:
            fig.savefig(os.path.join(output_folder, "Avg_seq_for_%s_sw.png" % k))
        else:
            plt.show()

    plt.close()


def plot_avg_sequence_sw_flatten_values(sequences_dict, output_folder=None):
    """
    plot the avg sequence using SW, flatten the AT to W and CG to S and combining both options to get one
    number per sequence place
    :param sequences_dict: A dictionary with pl or cl as key and the integrated values results for each
    sequence in this label
    :param output_folder: Output folder
    """
    for k in sequences_dict:
        ex_seq = sequences_dict[k]
        mean_seq = np.transpose(np.mean(ex_seq[:, 60:90, :], axis=0).reshape(1, 30, 4), axes=(1, 2, 0))
        new_seq = np.zeros_like(mean_seq)
        for i in range(mean_seq.shape[0]):
            w = mean_seq[i][0] + mean_seq[i][3]
            s = mean_seq[i][1] + mean_seq[i][2]
            delta = s - w
            sw_index = 1 if delta > 0 else 0
            new_seq[i][sw_index] = abs(delta)

        fig = seqlogo_fig(new_seq, vocab="DNAWS", figsize=(8, 4), ncol=1, plot_name="Avg seq for %s" % k)

        if output_folder:
            fig.savefig(os.path.join(output_folder, "Avg_seq_for_%s_sw30_flatten.png" % k))
        else:
            fig.show()

    for k in sequences_dict:
        ex_seq = sequences_dict[k]
        mean_seq = np.transpose(np.mean(ex_seq[:, :, :], axis=0).reshape(1, 150, 4), axes=(1, 2, 0))
        new_seq = np.zeros_like(mean_seq)
        for i in range(mean_seq.shape[0]):
            w = mean_seq[i][0] + mean_seq[i][3]
            s = mean_seq[i][1] + mean_seq[i][2]
            delta = s - w
            sw_index = 1 if delta > 0 else 0
            new_seq[i][sw_index] = abs(delta)

        fig = seqlogo_fig(new_seq, vocab="DNAWS", figsize=(20, 4), ncol=1, plot_name="Avg seq for %s" % k)

        if output_folder:
            fig.savefig(os.path.join(output_folder, "Avg_seq_for_%s_sw_flatten.png" % k))
        else:
            plt.show()

    plt.close()


def plot_distance_weight_two_sides(sequences_dict, output_folder=None):
    """
    Plot the integrated gradient value of each feature based on distance from center, two ways graph(-74->74)
    We wanted to see if there are indexes and some periodicity
    :param sequences_dict: A dictionary with pl or cl as key and the integrated values results for each
    sequence in this label
    :param output_folder: Output folder
    """
    for k in sequences_dict:
        class_type = k
        ex_seq = np.abs(sequences_dict[k])

        mean_seq = np.transpose(np.mean(ex_seq[:, :, :], axis=0).reshape(1, 150, 4), axes=(1, 2, 0))
        seq_weight = np.sum(mean_seq, axis=1)
        middle = int(seq_weight.shape[0] / 2) - 1
        seq_weight[middle] = None
        seq_weight[middle + 1] = None

        x = np.arange(-74, 1).astype(np.int)
        x = np.append(x, x[::-1] * -1)

        x_ticks = [i for i in range(-70, 80, 10)]
        plt.xticks(x_ticks)
        plt.plot(x, seq_weight, '.-')
        plt.legend()
        plt.grid(axis="y")
        plt.xlabel("Distance from CpG Site", fontsize=12)
        plt.ylabel("Attribute score", fontsize=12)
        plt.title("Attribute score base on distance from CpG site for %s" % class_type, fontsize=14)

        if output_folder:
            plt.savefig(
                os.path.join(output_folder,
                             "distance_importance_of_flanking_letters_type_%s_two_way.png" % k))
        else:
            plt.show()
        plt.close()


def plot_distance_weight_one_side(sequences_dict, output_folder=None):
    """
    Plot the integrated gradient value of each feature based on distance from center, one way graph (0->74)
    We wanted to see if there are indexes and some periodicity
    :param sequences_dict: A dictionary with pl or cl as key and the integrated values results for each
    sequence in this label
    :param output_folder: Output folder
   """
    for k in sequences_dict:
        class_type = k
        ex_seq = np.abs(sequences_dict[k])

        mean_seq = np.transpose(np.mean(ex_seq[:, :, :], axis=0).reshape(1, 150, 4), axes=(1, 2, 0))
        seq_weight = np.sum(mean_seq, axis=1)
        std_seq = np.std(mean_seq, axis=1)
        middle = int(seq_weight.shape[0] / 2) - 1
        seq_to_values = np.flip(seq_weight[:middle])
        seq_from_values = seq_weight[middle + 2:]
        seq_to_std = np.flip(std_seq[:middle])
        seq_from_std = std_seq[middle + 2:]
        x = np.arange(1, seq_from_values.shape[0] + 1)

        plt.errorbar(x, seq_to_values, seq_to_std, marker='^', label="to", alpha=0.5)
        plt.errorbar(x, seq_from_values, seq_from_std, marker='^', label="from", alpha=0.5)

        plt.legend()
        x_ticks = [i for i in range(1, 5)] + [i for i in range(5, 75, 5)]
        plt.xticks(x_ticks)
        plt.xlabel("Distance from CG")
        plt.ylabel("Importance shannon values")
        plt.title("Importance of flanking letters - %s" % (class_type))

        if output_folder:
            plt.savefig(os.path.join(output_folder,
                                     "distance_importance_of_flanking_letters_type_%s_one_way.png" % k))
        else:
            plt.show()
        plt.close()


def print_each_seq(sequences_dict, output_folder):
    """
    Plot all the sequences on after the other
    :param sequences_dict: A dictionary with pl or cl as key and the integrated values results for each
    sequence in this label
    :param output_folder: Output folder
    """
    cl_list = []
    pl_list = []

    # Remove duplicates
    seq = None

    for i in range(sequences_dict["cl"].shape[0]):
        new_seq = sequences_dict["cl"][i]
        if np.all(new_seq == seq):
            continue
        else:
            cl_list.append(new_seq)
            seq = new_seq

    seq = None
    for i in range(sequences_dict["pl"].shape[0]):
        new_seq = sequences_dict["pl"][i]
        if np.all(new_seq == seq):
            continue
        else:
            pl_list.append(new_seq)
            seq = new_seq

    for i in range(1000):
        plot_one_seq(seq=cl_list[i], output=os.path.join(output_folder, "cl_seq_%s.png" % i),
                     title="CL seq num %s" % i, yl=0.1)

    for i in range(1000):
        plot_one_seq(seq=pl_list[i], output=os.path.join(output_folder, "pl_seq_%s.png" % i),
                     title="PL seq num %s" % i, yl=0.1)


def main():
    args = parse_input()

    ex_seq_d = files_tools.load_pickle(args.interpretation_file)
    new_d = {"cl": ex_seq_d["cl"], "pl": ex_seq_d["pl"]}

    plot_distance_weight_one_side(new_d, args.output_folder)
    plot_distance_weight_two_sides(new_d, args.output_folder)
    plot_multi_seq(new_d, 1000, args.output_folder)
    plot_avg_sequence(new_d, args.output_folder)
    plot_avg_sequence_sw(new_d, args.output_folder)
    plot_avg_sequence_sw_flatten_values(new_d, args.output_folder)
    print_each_seq(new_d, args.output_folder)


if __name__ == '__main__':
    main()

[((17, 0, 17, 9), 'seaborn.set', 'sns.set', ({}, {}), '()', True, 'import seaborn as sns\n'), ((18, 0, 18, 26), 'seaborn.set_style', 'sns.set_style', ({(18, 14, 18, 25): '"""whitegrid"""'}, {}), "('whitegrid')", True, 'import seaborn as sns\n'), ((22, 13, 22, 38), 'argparse.ArgumentParser', 'argparse.ArgumentParser', ({}, {}), '()', False, 'import argparse\n'), ((32, 10, 32, 94), 'classifier.plotseqlogo.seqlogo_fig', 'seqlogo_fig', (), '', False, 'from classifier.plotseqlogo import seqlogo_fig\n'), ((34, 4, 34, 15), 'matplotlib.pyplot.close', 'plt.close', ({}, {}), '()', True, 'import matplotlib.pyplot as plt\n'), ((56, 4, 56, 15), 'matplotlib.pyplot.close', 'plt.close', ({}, {}), '()', True, 'import matplotlib.pyplot as plt\n'), ((134, 4, 134, 15), 'matplotlib.pyplot.close', 'plt.close', ({}, {}), '()', True, 'import matplotlib.pyplot as plt\n'), ((181, 4, 181, 15), 'matplotlib.pyplot.close', 'plt.close', ({}, {}), '()', True, 'import matplotlib.pyplot as plt\n'), ((305, 15, 305, 64), 'commons.files_tools.load_pickle', 'files_tools.load_pickle', ({(305, 39, 305, 63): 'args.interpretation_file'}, {}), '(args.interpretation_file)', False, 'from commons import files_tools\n'), ((71, 14, 72, 89), 'classifier.plotseqlogo.seqlogo_fig', 'seqlogo_fig', (), '', False, 'from classifier.plotseqlogo import seqlogo_fig\n'), ((81, 8, 81, 19), 'matplotlib.pyplot.close', 'plt.close', ({}, {}), '()', True, 'import matplotlib.pyplot as plt\n'), ((87, 14, 88, 57), 'classifier.plotseqlogo.seqlogo_fig', 'seqlogo_fig', (), '', False, 'from classifier.plotseqlogo import seqlogo_fig\n'), ((94, 8, 94, 19), 'matplotlib.pyplot.close', 'plt.close', ({}, {}), '()', True, 'import matplotlib.pyplot as plt\n'), ((107, 18, 107, 41), 'numpy.zeros_like', 'np.zeros_like', ({(107, 32, 107, 40): 'mean_seq'}, {}), '(mean_seq)', True, 'import numpy as np\n'), ((112, 14, 112, 106), 'classifier.plotseqlogo.seqlogo_fig', 'seqlogo_fig', (), '', False, 'from classifier.plotseqlogo import seqlogo_fig\n'), ((122, 18, 122, 41), 'numpy.zeros_like', 'np.zeros_like', ({(122, 32, 122, 40): 'mean_seq'}, {}), '(mean_seq)', True, 'import numpy as np\n'), ((127, 14, 127, 106), 'classifier.plotseqlogo.seqlogo_fig', 'seqlogo_fig', (), '', False, 'from classifier.plotseqlogo import seqlogo_fig\n'), ((148, 18, 148, 41), 'numpy.zeros_like', 'np.zeros_like', ({(148, 32, 148, 40): 'mean_seq'}, {}), '(mean_seq)', True, 'import numpy as np\n'), ((156, 14, 156, 105), 'classifier.plotseqlogo.seqlogo_fig', 'seqlogo_fig', (), '', False, 'from classifier.plotseqlogo import seqlogo_fig\n'), ((166, 18, 166, 41), 'numpy.zeros_like', 'np.zeros_like', ({(166, 32, 166, 40): 'mean_seq'}, {}), '(mean_seq)', True, 'import numpy as np\n'), ((174, 14, 174, 106), 'classifier.plotseqlogo.seqlogo_fig', 'seqlogo_fig', (), '', False, 'from classifier.plotseqlogo import seqlogo_fig\n'), ((194, 17, 194, 42), 'numpy.abs', 'np.abs', ({(194, 24, 194, 41): 'sequences_dict[k]'}, {}), '(sequences_dict[k])', True, 'import numpy as np\n'), ((197, 21, 197, 45), 'numpy.sum', 'np.sum', (), '', True, 'import numpy as np\n'), ((203, 12, 203, 38), 'numpy.append', 'np.append', ({(203, 22, 203, 23): 'x', (203, 25, 203, 37): 'x[::-1] * -1'}, {}), '(x, x[::-1] * -1)', True, 'import numpy as np\n'), ((206, 8, 206, 27), 'matplotlib.pyplot.xticks', 'plt.xticks', ({(206, 19, 206, 26): 'x_ticks'}, {}), '(x_ticks)', True, 'import matplotlib.pyplot as plt\n'), ((207, 8, 207, 37), 'matplotlib.pyplot.plot', 'plt.plot', ({(207, 17, 207, 18): 'x', (207, 20, 207, 30): 'seq_weight', (207, 32, 207, 36): '""".-"""'}, {}), "(x, seq_weight, '.-')", True, 'import matplotlib.pyplot as plt\n'), ((208, 8, 208, 20), 'matplotlib.pyplot.legend', 'plt.legend', ({}, {}), '()', True, 'import matplotlib.pyplot as plt\n'), ((209, 8, 209, 26), 'matplotlib.pyplot.grid', 'plt.grid', (), '', True, 'import matplotlib.pyplot as plt\n'), ((210, 8, 210, 57), 'matplotlib.pyplot.xlabel', 'plt.xlabel', (), '', True, 'import matplotlib.pyplot as plt\n'), ((211, 8, 211, 50), 'matplotlib.pyplot.ylabel', 'plt.ylabel', (), '', True, 'import matplotlib.pyplot as plt\n'), ((212, 8, 212, 100), 'matplotlib.pyplot.title', 'plt.title', (), '', True, 'import matplotlib.pyplot as plt\n'), ((220, 8, 220, 19), 'matplotlib.pyplot.close', 'plt.close', ({}, {}), '()', True, 'import matplotlib.pyplot as plt\n'), ((233, 17, 233, 42), 'numpy.abs', 'np.abs', ({(233, 24, 233, 41): 'sequences_dict[k]'}, {}), '(sequences_dict[k])', True, 'import numpy as np\n'), ((236, 21, 236, 45), 'numpy.sum', 'np.sum', (), '', True, 'import numpy as np\n'), ((237, 18, 237, 42), 'numpy.std', 'np.std', (), '', True, 'import numpy as np\n'), ((239, 24, 239, 52), 'numpy.flip', 'np.flip', ({(239, 32, 239, 51): 'seq_weight[:middle]'}, {}), '(seq_weight[:middle])', True, 'import numpy as np\n'), ((241, 21, 241, 46), 'numpy.flip', 'np.flip', ({(241, 29, 241, 45): 'std_seq[:middle]'}, {}), '(std_seq[:middle])', True, 'import numpy as np\n'), ((243, 12, 243, 54), 'numpy.arange', 'np.arange', ({(243, 22, 243, 23): '1', (243, 25, 243, 53): 'seq_from_values.shape[0] + 1'}, {}), '(1, seq_from_values.shape[0] + 1)', True, 'import numpy as np\n'), ((245, 8, 245, 85), 'matplotlib.pyplot.errorbar', 'plt.errorbar', (), '', True, 'import matplotlib.pyplot as plt\n'), ((246, 8, 246, 91), 'matplotlib.pyplot.errorbar', 'plt.errorbar', (), '', True, 'import matplotlib.pyplot as plt\n'), ((248, 8, 248, 20), 'matplotlib.pyplot.legend', 'plt.legend', ({}, {}), '()', True, 'import matplotlib.pyplot as plt\n'), ((250, 8, 250, 27), 'matplotlib.pyplot.xticks', 'plt.xticks', ({(250, 19, 250, 26): 'x_ticks'}, {}), '(x_ticks)', True, 'import matplotlib.pyplot as plt\n'), ((251, 8, 251, 38), 'matplotlib.pyplot.xlabel', 'plt.xlabel', ({(251, 19, 251, 37): '"""Distance from CG"""'}, {}), "('Distance from CG')", True, 'import matplotlib.pyplot as plt\n'), ((252, 8, 252, 47), 'matplotlib.pyplot.ylabel', 'plt.ylabel', ({(252, 19, 252, 46): '"""Importance shannon values"""'}, {}), "('Importance shannon values')", True, 'import matplotlib.pyplot as plt\n'), ((253, 8, 253, 71), 'matplotlib.pyplot.title', 'plt.title', ({(253, 18, 253, 70): "('Importance of flanking letters - %s' % class_type)"}, {}), "('Importance of flanking letters - %s' % class_type)", True, 'import matplotlib.pyplot as plt\n'), ((260, 8, 260, 19), 'matplotlib.pyplot.close', 'plt.close', ({}, {}), '()', True, 'import matplotlib.pyplot as plt\n'), ((278, 11, 278, 33), 'numpy.all', 'np.all', ({(278, 18, 278, 32): '(new_seq == seq)'}, {}), '(new_seq == seq)', True, 'import numpy as np\n'), ((287, 11, 287, 33), 'numpy.all', 'np.all', ({(287, 18, 287, 32): '(new_seq == seq)'}, {}), '(new_seq == seq)', True, 'import numpy as np\n'), ((25, 32, 25, 60), 'os.path.dirname', 'os.path.dirname', ({(25, 48, 25, 59): 'sys.argv[0]'}, {}), '(sys.argv[0])', False, 'import os\n'), ((47, 26, 47, 71), 'numpy.transpose', 'np.transpose', (), '', True, 'import numpy as np\n'), ((54, 12, 54, 22), 'matplotlib.pyplot.show', 'plt.show', ({}, {}), '()', True, 'import matplotlib.pyplot as plt\n'), ((80, 12, 80, 22), 'matplotlib.pyplot.show', 'plt.show', ({}, {}), '()', True, 'import matplotlib.pyplot as plt\n'), ((93, 12, 93, 22), 'matplotlib.pyplot.show', 'plt.show', ({}, {}), '()', True, 'import matplotlib.pyplot as plt\n'), ((117, 12, 117, 22), 'matplotlib.pyplot.show', 'plt.show', ({}, {}), '()', True, 'import matplotlib.pyplot as plt\n'), ((132, 12, 132, 22), 'matplotlib.pyplot.show', 'plt.show', ({}, {}), '()', True, 'import matplotlib.pyplot as plt\n'), ((179, 12, 179, 22), 'matplotlib.pyplot.show', 'plt.show', ({}, {}), '()', True, 'import matplotlib.pyplot as plt\n'), ((219, 12, 219, 22), 'matplotlib.pyplot.show', 'plt.show', ({}, {}), '()', True, 'import matplotlib.pyplot as plt\n'), ((259, 12, 259, 22), 'matplotlib.pyplot.show', 'plt.show', ({}, {}), '()', True, 'import matplotlib.pyplot as plt\n'), ((52, 24, 52, 101), 'os.path.join', 'os.path.join', ({(52, 37, 52, 50): 'output_folder', (52, 52, 52, 100): "('seq_for_top_%s_of_type_%s' % (number_of_seq, k))"}, {}), "(output_folder, 'seq_for_top_%s_of_type_%s' % (number_of_seq, k))", False, 'import os\n'), ((78, 24, 78, 79), 'os.path.join', 'os.path.join', ({(78, 37, 78, 50): 'output_folder', (78, 52, 78, 78): "('Avg_seq_for_%s30.png' % k)"}, {}), "(output_folder, 'Avg_seq_for_%s30.png' % k)", False, 'import os\n'), ((91, 24, 91, 77), 'os.path.join', 'os.path.join', ({(91, 37, 91, 50): 'output_folder', (91, 52, 91, 76): "('Avg_seq_for_%s.png' % k)"}, {}), "(output_folder, 'Avg_seq_for_%s.png' % k)", False, 'import os\n'), ((115, 24, 115, 82), 'os.path.join', 'os.path.join', ({(115, 37, 115, 50): 'output_folder', (115, 52, 115, 81): "('Avg_seq_for_%s_sw30.png' % k)"}, {}), "(output_folder, 'Avg_seq_for_%s_sw30.png' % k)", False, 'import os\n'), ((130, 24, 130, 80), 'os.path.join', 'os.path.join', ({(130, 37, 130, 50): 'output_folder', (130, 52, 130, 79): "('Avg_seq_for_%s_sw.png' % k)"}, {}), "(output_folder, 'Avg_seq_for_%s_sw.png' % k)", False, 'import os\n'), ((159, 24, 159, 90), 'os.path.join', 'os.path.join', ({(159, 37, 159, 50): 'output_folder', (159, 52, 159, 89): "('Avg_seq_for_%s_sw30_flatten.png' % k)"}, {}), "(output_folder, 'Avg_seq_for_%s_sw30_flatten.png' % k)", False, 'import os\n'), ((177, 24, 177, 88), 'os.path.join', 'os.path.join', ({(177, 37, 177, 50): 'output_folder', (177, 52, 177, 87): "('Avg_seq_for_%s_sw_flatten.png' % k)"}, {}), "(output_folder, 'Avg_seq_for_%s_sw_flatten.png' % k)", False, 'import os\n'), ((202, 12, 202, 29), 'numpy.arange', 'np.arange', ({(202, 22, 202, 25): '-74', (202, 27, 202, 28): '1'}, {}), '(-74, 1)', True, 'import numpy as np\n'), ((216, 16, 217, 95), 'os.path.join', 'os.path.join', ({(216, 29, 216, 42): 'output_folder', (217, 29, 217, 94): "('distance_importance_of_flanking_letters_type_%s_two_way.png' % k)"}, {}), "(output_folder, \n    'distance_importance_of_flanking_letters_type_%s_two_way.png' % k)", False, 'import os\n'), ((256, 24, 257, 103), 'os.path.join', 'os.path.join', ({(256, 37, 256, 50): 'output_folder', (257, 37, 257, 102): "('distance_importance_of_flanking_letters_type_%s_one_way.png' % k)"}, {}), "(output_folder, \n    'distance_importance_of_flanking_letters_type_%s_one_way.png' % k)", False, 'import os\n'), ((294, 44, 294, 92), 'os.path.join', 'os.path.join', ({(294, 57, 294, 70): 'output_folder', (294, 72, 294, 91): "('cl_seq_%s.png' % i)"}, {}), "(output_folder, 'cl_seq_%s.png' % i)", False, 'import os\n'), ((298, 44, 298, 92), 'os.path.join', 'os.path.join', ({(298, 57, 298, 70): 'output_folder', (298, 72, 298, 91): "('pl_seq_%s.png' % i)"}, {}), "(output_folder, 'pl_seq_%s.png' % i)", False, 'import os\n'), ((68, 32, 68, 68), 'numpy.mean', 'np.mean', (), '', True, 'import numpy as np\n'), ((85, 32, 85, 64), 'numpy.mean', 'np.mean', (), '', True, 'import numpy as np\n'), ((106, 32, 106, 68), 'numpy.mean', 'np.mean', (), '', True, 'import numpy as np\n'), ((121, 32, 121, 64), 'numpy.mean', 'np.mean', (), '', True, 'import numpy as np\n'), ((147, 32, 147, 68), 'numpy.mean', 'np.mean', (), '', True, 'import numpy as np\n'), ((165, 32, 165, 64), 'numpy.mean', 'np.mean', (), '', True, 'import numpy as np\n'), ((196, 32, 196, 64), 'numpy.mean', 'np.mean', (), '', True, 'import numpy as np\n'), ((235, 32, 235, 64), 'numpy.mean', 'np.mean', (), '', True, 'import numpy as np\n')]