# Path: pergola/intervals.py
# class IntData(object):
#     def __init__(self, path, map_dict, header=True, **kwargs):
#     def _check_delimiter (self, path, delimiter):
#     def _reader_data(self):
#     def _pandas_df_reader(self, df):
#     def _set_fields_b(self, fields=None):
#     def _set_fields_g (self, map_dict):
#     def _simple_read(self):
#     def get_field_items(self, data, field="data_types", default=None):
#     def read(self, fields=None, relative_coord=False, intervals=False, int_step=None, fields2rel=None, multiply_t=None,
#              **kwargs):
#     def _min_max(self, list_data, f_start="start", f_end="end"):
#     def _time2rel_time(self, i_fields):
#     def _multiply_values(self, i_fields, factor=1):
#     def _create_int(self, start_int, int_step=None):
#     def _create_int_add_integ(self, start_int, integer=1):
#     def __del__(self):
# def is_number(var):
# def num(s):
# 
# Path: pergola/mapping.py
# class MappingInfo():
#     def __init__(self, path, **kwargs):
#     def _correspondence_from_config(self, path):
#     def _tab_config(self, file_tab):
#     def _mapping_config(self, file_map):
#     def write(self, indent=0):
# def check_path(path):
# def write_chr(self, mode="w", path_w=None, min_c=None, max_c=None):
# def write_chr_sizes(self, mode="w", path_w=None, file_n=None, min_c=None, max_c=None):
# def write_cytoband(end, start=0, delta=43200, start_phase="light", mode="w", path_w=None, lab_bed=True, track_line=True):
# def write_period_seq (end, start=0, delta=43200, tag="day", mode="w", path_w=None, name_file="period_seq", lab_bed=True, track_line=True):
# 
# Path: pergola/parsers.py
# PATH = abspath(split(realpath(__file__))[0])
# def parse_num_range(string):
# def read_track_actions (tracks, track_action = "split_all"):
# def read_colors (path_color_file):


from pergola  import intervals
from pergola  import mapping
from argparse import ArgumentParser
from sys      import stderr, exit
from os.path import basename, splitext
from pergola import parsers
                      list=args.list, range=args.range, track_actions=args.track_actions,
                      data_types_actions=args.data_types_actions, data_types_list=args.data_types_list,
                      write_format=args.format, relative_coord=args.relative_coord,
                      intervals_gen=args.intervals_gen, interval_step=args.interval_step,
                      multiply_f=args.multiply_intervals, no_header=args.no_header, fields2read=args.fields_read,
                      window_size=args.window_size, no_track_line=args.no_track_line, separator=args.field_separator,
                      bed_lab_sw=args.bed_label, color_dict=args.color_file, window_mean=args.window_mean,
                      value_mean=args.value_mean, min_t=args.min_time, max_t=args.max_time, phases=args.phases,
                      genome=args.genome, output_file_name=output_file_n, starting_phase=args.starting_phase,
                      shift=args.shift)

def pergola_rules(path, map_file_path, sel_tracks=None, list=None, range=None, track_actions=None, 
                  data_types_actions=None, data_types_list=None, write_format=None, relative_coord=False,
                  intervals_gen=False, multiply_f=None, no_header=False, fields2read=None, window_size=None,
                  no_track_line=False, separator=None, bed_lab_sw=False, color_dict=None, window_mean=False,
                  value_mean=False, min_t=None, max_t=None, interval_step=None, phases=False, genome=False,
                  output_file_name=None, starting_phase=False, shift=None):
    
    print("@@@Pergola_rules.py: Input file: %s" % path, file=stderr) 
    print("@@@Pergola_rules.py: Configuration file: %s" % map_file_path, file=stderr)
    
    # Tracks selected by user
    print("@@@Pergola_rules.py: Selected tracks are: ", sel_tracks, file=stderr)
    
    # Configuration file
    map_file_dict = mapping.MappingInfo(map_file_path)
    
    # Reading color dictionary to set data_types
    if color_dict:
        print("@@@Pergola_rules.py: Color for data_types in file............ %s" % color_dict, file=stderr)

# Path: pergola/intervals.py
# class IntData(object):
#     def __init__(self, path, map_dict, header=True, **kwargs):
#     def _check_delimiter (self, path, delimiter):
#     def _reader_data(self):
#     def _pandas_df_reader(self, df):
#     def _set_fields_b(self, fields=None):
#     def _set_fields_g (self, map_dict):
#     def _simple_read(self):
#     def get_field_items(self, data, field="data_types", default=None):
#     def read(self, fields=None, relative_coord=False, intervals=False, int_step=None, fields2rel=None, multiply_t=None,
#              **kwargs):
#     def _min_max(self, list_data, f_start="start", f_end="end"):
#     def _time2rel_time(self, i_fields):
#     def _multiply_values(self, i_fields, factor=1):
#     def _create_int(self, start_int, int_step=None):
#     def _create_int_add_integ(self, start_int, integer=1):
#     def __del__(self):
# def is_number(var):
# def num(s):
# 
# Path: pergola/mapping.py
# class MappingInfo():
#     def __init__(self, path, **kwargs):
#     def _correspondence_from_config(self, path):
#     def _tab_config(self, file_tab):
#     def _mapping_config(self, file_map):
#     def write(self, indent=0):
# def check_path(path):
# def write_chr(self, mode="w", path_w=None, min_c=None, max_c=None):
# def write_chr_sizes(self, mode="w", path_w=None, file_n=None, min_c=None, max_c=None):
# def write_cytoband(end, start=0, delta=43200, start_phase="light", mode="w", path_w=None, lab_bed=True, track_line=True):
# def write_period_seq (end, start=0, delta=43200, tag="day", mode="w", path_w=None, name_file="period_seq", lab_bed=True, track_line=True):
# 
# Path: pergola/parsers.py
# PATH = abspath(split(realpath(__file__))[0])
# def parse_num_range(string):
# def read_track_actions (tracks, track_action = "split_all"):
# def read_colors (path_color_file):


# Path: pergola/scripts/pergola_rules.py
from pergola  import intervals
from pergola  import mapping
from argparse import ArgumentParser
from sys      import stderr, exit
from os.path import basename, splitext
from pergola import parsers

                      list=args.list, range=args.range, track_actions=args.track_actions,
                      data_types_actions=args.data_types_actions, data_types_list=args.data_types_list,
                      write_format=args.format, relative_coord=args.relative_coord,
                      intervals_gen=args.intervals_gen, interval_step=args.interval_step,
                      multiply_f=args.multiply_intervals, no_header=args.no_header, fields2read=args.fields_read,
                      window_size=args.window_size, no_track_line=args.no_track_line, separator=args.field_separator,
                      bed_lab_sw=args.bed_label, color_dict=args.color_file, window_mean=args.window_mean,
                      value_mean=args.value_mean, min_t=args.min_time, max_t=args.max_time, phases=args.phases,
                      genome=args.genome, output_file_name=output_file_n, starting_phase=args.starting_phase,
                      shift=args.shift)

def pergola_rules(path, map_file_path, sel_tracks=None, list=None, range=None, track_actions=None, 
                  data_types_actions=None, data_types_list=None, write_format=None, relative_coord=False,
                  intervals_gen=False, multiply_f=None, no_header=False, fields2read=None, window_size=None,
                  no_track_line=False, separator=None, bed_lab_sw=False, color_dict=None, window_mean=False,
                  value_mean=False, min_t=None, max_t=None, interval_step=None, phases=False, genome=False,
                  output_file_name=None, starting_phase=False, shift=None):
    
    print("@@@Pergola_rules.py: Input file: %s" % path, file=stderr) 
    print("@@@Pergola_rules.py: Configuration file: %s" % map_file_path, file=stderr)
    
    # Tracks selected by user
    print("@@@Pergola_rules.py: Selected tracks are: ", sel_tracks, file=stderr)
    
    # Configuration file
    map_file_dict = mapping.MappingInfo(map_file_path)
    
    # Reading color dictionary to set data_types
    if color_dict:
        print("@@@Pergola_rules.py: Color for data_types in file............ %s" % color_dict, file=stderr)

        d_colors_data_types = parsers.read_colors (color_dict)