<jupyter_start><jupyter_text>load probes<jupyter_code># minimal imports for biopython
from Bio import SeqIO
from Bio.Seq import Seq
from Bio.Alphabet import IUPAC
from Bio.SeqRecord import SeqRecord
probe_file = os.path.join(library_folder, 'final_probes', 'filtered_probes.fasta')
with open(probe_file, "r") as handle:
    probes = []
    for record in SeqIO.parse(handle, "fasta"):
        probes.append(record);
region_dict = {}
combo_bcs = []
unique_bcs = []

for _pb in probes:
    _id = _pb.id
    _reg = int(_id.split('reg_')[1].split('_gene')[0])
    if _reg not in region_dict:
        _readouts = _id.split('barcodes_')[1].split('_color')[0]
        _combo = _readouts.split(']')[0].split('[')[-1].split(',')
        _combo = [_bc[1:-1] for _bc in _combo]
        for _b in _combo:
            if _b not in combo_bcs:
                combo_bcs.append(_b)
        _unique = _readouts.split(']')[1].split(',')[1][1:-1]
        if _unique not in unique_bcs:
            unique_bcs.append(_unique)
        _color = int(_id.split('color_')[-1])
        _info_dict = {'reg': _reg,
                      'color': _color,
                      'combo': _combo,
                      'unique': _unique}
        region_dict[_reg] = _info_dict
print(len(region_dict))
combo_bcs = sorted(combo_bcs, key=lambda v:int(v.split('_')[1]))
combo_groups = [combo_bcs[5*i:5*i+5] for i in range(int(len(combo_bcs)/5))]
# find unique_groups
unique_groups = []
for _group in combo_groups:
    _unique_group = []
    for _r, _info in region_dict.items():
        _cb = _info['combo']
        for _b in _cb:
            if _b in _group and _info['unique'] not in _unique_group:
                _unique_group.append(_info['unique'])
    _unique_group = sorted(_unique_group, key=lambda v:int(v.split('_')[1]))
    unique_groups.append(_unique_group)
for _color in range(3):
    _cgroups = combo_groups[_color*5:(_color+1)*5]
    _ugroups = unique_groups[_color*5:(_color+1)*5]
    print(_cgroups)
# print hybes
for _i in range(31):
    print(f'H{_i}R{_i}')
# print combos
for _i in range(int(len(combo_groups)/3)):
    _g0 = combo_groups[_i]
    _g1 = combo_groups[_i+int(len(combo_groups)/3)]
    _g2 = combo_groups[_i+int(len(combo_groups)/3)*2]
    for _r0, _r1, _r2 in zip(_g0, _g1, _g2):
        print(f"{_r0}\t{_r1}\t{_r2}")
    print("")
# print uniques
for _i in range(int(len(unique_groups)/3)):
    _g0 = unique_groups[_i]
    _g1 = unique_groups[_i+int(len(unique_groups)/3)]
    _g2 = unique_groups[_i+int(len(unique_groups)/3)*2]
    for _r0, _r1, _r2 in zip(_g0, _g1, _g2):
        print(f"{_r0}\t{_r1}\t{_r2}")
    print("")
design_dict = pickle.load(open(os.path.join(library_folder, 'sub_encoding.pkl'), 'rb'))
region_dict<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1554667635306938, 'fraction_numerical': 0.02179440610243371, 'mean_word_length': 3.3853503184713376, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '421788', 'license': 'MIT', 'n_tokens_mistral': 1096, 'n_tokens_neox': 1081, 'n_words': 205, 'path': 'Library_design/CTP-03/Generate_Adaptor_list.ipynb', 'repo_name': 'shiwei23/Chromatin_Analysis_Scripts', 'size': '2753'}