import json


def data_for_realignment(path_to_data):
    """Return data, needed to test the correct realignment
    - input data, expected output (alignment and score), matrix and monomers table"""

    aligned_path = path_to_data + "align_output.json"
    new_seqs = path_to_data + "new_sequences.txt"
    realign_path = path_to_data + "realign_output.json"

    matrix = path_to_data + "ROCS"
    monomers = path_to_data + "monomers_map.txt"

    with open(aligned_path)as align, open(realign_path) as realign, open(new_seqs) as new_file:
        aligned_seqs = json.load(align)
        aligned_data = ""
        for key in aligned_seqs:
            aligned_data += aligned_seqs[key]

        new_sequences = new_file.readlines()
        new_data = ""
        for line in new_sequences:
            new_data += line

        # Expected output is generated with the help of ginsi method
        expected_alignment = json.load(realign)
        expected_score = {"PEPTIDE1": 216.61280193236715,
                          "PEPTIDE2": 276.5110946745562}

        return aligned_data.strip("\n"), new_data, expected_alignment, expected_score, matrix, monomers