def read_msr_line(line, tstat_switch, msr_id_switch):
    """
    Function to read msr components from a single line in adj file
    :param line: Msr line in adj file
    :param tstat_switch: True/False switch for presence of tstats
    :param msr_id_switch: True/False switch for presence of msr_ids
    :return: Dictionary of components
    """

    msr_type = line[:1]
    stn1 = line[2:22].strip()
    stn2 = line[22:42].strip()
    if stn2 == '':
        stn2 = None
    stn3 = line[42:62].strip()
    if stn3 == '':
        stn3 = None

    if msr_type == 'D':
        if msr_id_switch:
            items = line.split()
            cluster_id = items[-1].strip()
            msr_id = items[-2]
        else:
            msr_id = None
            cluster_id = None
        msr_components = {
            'msr_type': msr_type,
            'stn1': stn1,
            'stn2': stn2,
            'stn3': stn3,
            'msr_id': msr_id,
            'cluster_id': cluster_id
        }

        return msr_components
    else:
        if line[62:65].strip() == '*':
            ignore = True
        else:
            ignore = False

        cardinal = line[65:67].strip()
        msr = line[67:86].strip()
        adj = line[86:105].strip()
        cor = line[105:117].strip()
        msr_sd = line[117:130].strip()
        adj_sd = line[130:143].strip()
        cor_sd = line[143:156].strip()
        nstat = line[156:167].strip()

        if tstat_switch:
            tstat = line[167:178].strip()
            pelzer = line[178:190].strip()
            pre_adj_cor = line[190:204].strip()
            outlier = line[204:216]
            if msr_id_switch:
                msr_id = line[216:226].strip()
                cluster_id = line[226:236].strip()
            else:
                msr_id = None
                cluster_id = None
        else:
            tstat = None
            pelzer = line[167:178].strip()
            pre_adj_cor = line[180:193].strip()
            outlier = line[204:205]
            if msr_id_switch:
                msr_id = line[205:216].strip()
                cluster_id = line[216:226].strip()
            else:
                msr_id = None
                cluster_id = None

        msr_components = {
            'msr_type': msr_type,
            'stn1': stn1,
            'stn2': stn2,
            'stn3': stn3,
            'ignore': ignore,
            'cardinal': cardinal,
            'msr': msr,
            'adj': adj,
            'cor': cor,
            'msr_sd': msr_sd,
            'adj_sd': adj_sd,
            'cor_sd': cor_sd,
            'nstat': nstat,
            'tstat': tstat,
            'pelzer': pelzer,
            'pre_adj_cor': pre_adj_cor,
            'outlier': outlier,
            'msr_id': msr_id,
            'cluster_id': cluster_id
        }

        return msr_components