#!python
import argparse

import spatialprofilingtoolbox as spt

if __name__=='__main__':
    parser = argparse.ArgumentParser(
        description = ''.join([
            'This program does calculations with multiplexed IF images. ',
            'It is formulated as a script so that it can be run as part of large HPC batches. '
            'It generally needs to be run as part of spt-pipeline, to ensure proper initialization.',
        ])
    )
    parser.add_argument('--input-file-identifier',
        dest='input_file_identifier',
        type=str,
        required=True,
        help='Input file identifier, as it appears in the file manifest.',
    )
    parser.add_argument('--fov',
        dest='input_fov',
        type=int,
        required=True,
        help='Ordinality of field of view to consider (i.e. one-based integer index).',
    )
    parser.add_argument('--regional-compartment',
        dest='regional_compartment',
        type=str,
        required=True,
        help='?',
    )
    parser.add_argument('--job-index',
        dest='job_index',
        type=str,
        required=True,
        help='Integer index into job activity table.',
    )
    args = parser.parse_args()
    kwargs = {}
    kwargs['input_file_identifier'] = args.input_file_identifier
    kwargs['fov_index'] = args.input_fov
    kwargs['regional_compartment'] = args.regional_compartment
    kwargs['job_index'] = args.job_index
    parameters = spt.get_config_parameters_from_file()
    parameters = {**kwargs, **parameters}
    a = spt.get_analyzer(**parameters)
    a.calculate()
