//  [python]
def main(options):
    if options.labels is None:
        profile_csvs = dict((file.name, file) for file in options.profiles)
    else:
        profile_csvs = dict(zip(options.labels, options.profiles))
    profiles_df = read_indel_error_profiles_and_summaries(profile_csvs, merge_libraries=True)
    error_model = make_octopus_indel_error_model(profiles_df)
    write_error_model(error_model, options.output)
    if options.plot:
        if plotting_available:
            fig, ax = plt.subplots()
            sns.lineplot(x='tract_length', y='error_rate',
                         style='period',
                         data=profiles_df['period'].query('0 < period <= 5 and tract_length <= 150'),
                         ax=ax)
            ax.set(xlabel="tract length", ylabel="error rate", title="Indel error rates by repeat context")
            plt.savefig(options.output.parent / "error_rates_by_period.pdf", format='pdf', transparent=True, bbox_inches='tight')
            
            fig, ax = plt.subplots()
            sns.lineplot(x='periods', y='error_rate',
                         hue='motif',
                         data=profiles_df['homopolymer-class'],
                         ax=ax)
            ax.set(xlabel="periods", ylabel="error rate", title="Homopolymer error rates by repeat context")
            plt.savefig(options.output.parent / "homopolymer_error_rates.pdf", format='pdf', transparent=True, bbox_inches='tight')
            
            fig, ax = plt.subplots()
            sns.lineplot(x='periods', y='error_rate',
                         hue='motif',
                         data=profiles_df['dinucleotide-motif'].query('periods < 100'),
                         ax=ax)
            ax.set(xlabel="periods", ylabel="error rate", title="Dinucleotide repeat error rates by repeat context")
            plt.savefig(options.output.parent / "dinucleotide_repeat_error_rates.pdf", format='pdf', transparent=True, bbox_inches='tight')
            
            if len(profile_csvs) > 1:
                library_profiles = read_indel_error_profiles_and_summaries(profile_csvs, merge_libraries=False)
                fig, ax = plt.subplots()
                sns.lineplot(x='tract_length', y='error_rate',
                                 hue='period', style='library',
                                 data=library_profiles['period'].query('0 < period <= 5 and tract_length <= 150'),
                                 ax=ax)
                ax.set(xlabel="tract length", ylabel="error rate", title="Indel error rates by repeat context")
                plt.savefig(options.output.parent / "library_error_rates_by_period.pdf", format='pdf', transparent=True, bbox_inches='tight')
                
                fig, ax = plt.subplots()
                sns.lineplot(x='periods', y='error_rate',
                             hue='motif', style='library',
                             data=library_profiles['homopolymer-class'],
                             ax=ax)
                ax.set(xlabel="periods", ylabel="error rate", title="Homopolymer error rates by repeat context")
                plt.savefig(options.output.parent / "library_homopolymer_error_rates.pdf", format='pdf', transparent=True, bbox_inches='tight')
                
                fig, ax = plt.subplots()
                sns.lineplot(x='periods', y='error_rate',
                             hue='motif', style='library',
                             data=library_profiles['dinucleotide-motif'].query('periods < 100'),
                             ax=ax)
                ax.set(xlabel="periods", ylabel="error rate", title="Dinucleotide repeat error rates by repeat context")
                plt.savefig(options.output.parent / "library_dinucleotide_repeat_error_rates.pdf", format='pdf', transparent=True, bbox_inches='tight')
        else:
            print("Plotting unavailable: " + str(plot_import_exception))