<jupyter_start><jupyter_text>Helper Functions for ESM-1b<jupyter_code>deletekeys = dict.fromkeys(string.ascii_lowercase)
deletekeys["."] = None
deletekeys["*"] = None
translation = str.maketrans(deletekeys)

def read_sequence(filename: str) -> Tuple[str, str]:
    """ Reads the first (reference) sequences from a fasta or MSA file."""
    record = next(SeqIO.parse(filename, "fasta"))
    return record.description, str(record.seq)

def remove_insertions(sequence: str) -> str:
    """ Removes any insertions into the sequence. Needed to load aligned sequences in an MSA. """
    return sequence.translate(translation)

def read_msa(filename: str, nseq: int) -> List[Tuple[str, str]]:
    """ Reads the first nseq sequences from an MSA file, automatically removes insertions."""
    return [(record.description, remove_insertions(str(record.seq)))
            for record in itertools.islice(SeqIO.parse(filename, "fasta"), nseq)]

def load_ESM_1b():
    """ Download the ESM_1b model and initalizes it."""
    esm1b, esm1b_alphabet = esm.pretrained.esm1b_t33_650M_UR50S()
    esm1b = esm1b.eval().cpu()
    esm1b_batch_converter = esm1b_alphabet.get_batch_converter()
    return esm1b,esm1b_batch_converter<jupyter_output><empty_output><jupyter_text>Data for Contact Map Analysis  The query for obtaining the list of PDB_IDs are as follows:Search Query<jupyter_code>query_res="3KHF,3LQ3,3FEG,6YA6,2WWE,2IIM,4L0N,3WAR,2X18,7A22,7A1Z,7A2H,7A1B,1WYX,6Z19,3M9J,4YPD,6ELM,7D0E,2YJC,6YZH,6GY5,5JJ2,7CCW,2HSH,6RCH,6RCG,1KGD,3TW2,3O46,3I4W,6TSE,3S4E,3G36,6EGE,2QT1,6HOG,2QFA,2C60,2XRW,5GJH,6G9Z,5O8I,1LKK,4N6X,3ZYQ,2C01,4RFZ,3L46,5EP6,1EAZ,6KC4,6KEC,6KEI,5K26,6TT2,4EIH,5NP5,6B9X,3FIA,4LMM,2R3R,2R3I,6HOL,6J5S,5ED3,6TEW,4FKL,4EK4,4EK3,4P5Q,6HMB,6HMC,6HMD,4LDJ,4OBE,3LNY,3WA4,1OBX,5P21,5XRD,4YDP,4FH0,7F0W,6ZBK,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O,4YS1,6D40,2PDG,2PDH,2PDL,1Z3N,3LQG,5KL3,4PK3,4PK2,4Q6S,2XG3,4UE1,1A7S,6HN3,7NUS,6Q9L,6Q9O"
pdb_list = query_res.split(",")<jupyter_output><empty_output><jupyter_text>Download corresponding PDB Files and store it in a directory<jupyter_code>pdblist = biopy()
PDB_IDs = pdb_list
counter = 1
for PDB_ID in PDB_IDs:
    print(f'At entry {counter} out of {len(PDB_IDs)} entries.')
    pdblist.retrieve_pdb_file(pdb_code = PDB_ID, file_format = 'pdb', pdir = './data1/test1/')
    counter += 1<jupyter_output><empty_output><jupyter_text>Download corresponding Files and store it in a directoryUse this link to download all FASTA files by providing the list of PDB IDs  Comparative Analysis of Contact maps- ESM_1b  and PDB Structure<jupyter_code>def getContactMap_fromPDB(PDB_file):
    """ Takes a PDB file and creates a PCN from the alpha carbons and computes distance matrix 
    followed by generating a contact map with 8.0 Å threshold value."""
    protein_contact_network = PCN.PCN(PDB_file)
    C_alphas = protein_contact_network.get_C_alphas()
    chain_length = protein_contact_network.get_chain_length(C_alphas)
    if protein_contact_network.get_link_lengths(C_alphas) is not None:
        distance_matrix=protein_contact_network.get_link_lengths(C_alphas)
        contact_map = distance_matrix >= 8
        return contact_map
    else:
        return None
def getContactMap_fromESM(esm1b,esm1b_batch_converter,fasta_file):
    """ Loads the ESM_1b model, computes contact map from the inputted FASTA file. """
    esm1b_data = [read_sequence(fasta_file),]
    esm1b_batch_labels, esm1b_batch_strs, esm1b_batch_tokens = esm1b_batch_converter(esm1b_data)
    esm1b_batch_tokens = esm1b_batch_tokens.cpu()
    esm1b_contacts = esm1b.predict_contacts(esm1b_batch_tokens).cpu()
    seqlen = len(esm1b_batch_strs[0])
    #contact_map=esm1b_contacts[0][:seqlen, :seqlen]>=0.1
    contact_map=esm1b_contacts[0][:seqlen, :seqlen]>=0.1
    contact_map=contact_map.numpy()
    return contact_map
def compareContactMaps(contact_pdb,contact_esm,pdb_name,results_path):
    """ Compare contact maps generated by ESM_1b vs PDB and compute accuracy."""
    print(contact_pdb.shape[0],contact_esm.shape[0])
    if contact_pdb.shape[0]==contact_esm.shape[0]:
        contact_pdb_upperTraingle=contact_pdb[np.triu_indices(contact_pdb.shape[0],k=1)]
        contact_pdb_upperTraingle=np.multiply(contact_pdb_upperTraingle,1)
        contact_esm_upperTraingle=contact_esm[np.triu_indices(contact_esm.shape[0],k=1)]
        contact_esm_upperTraingle=np.multiply(contact_esm_upperTraingle,1)
        print(len(contact_pdb_upperTraingle),len(contact_esm_upperTraingle))
        acc,f1=accuracy_score(contact_pdb_upperTraingle,contact_esm_upperTraingle),f1_score(contact_pdb_upperTraingle,contact_esm_upperTraingle)
        title_text='Analysis of Contact Maps- %s'%(pdb_name)
        fig, ax = plt.subplots(nrows=1, ncols=2, figsize=(10, 5))
        fig.suptitle(title_text, fontsize=14,fontweight='bold')
        ax[0].title.set_text('PDB -> Contact Map')
        ax[0].imshow(contact_pdb,cmap="Blues")
        ax[1].title.set_text('ESM-1b -> Contact Map')
        ax[1].imshow(contact_esm,cmap="Blues")
        resultstr = 'Metrics\nAccuracy:%.2f'%(acc)
        ax[1].text(contact_esm.shape[0]+15, contact_esm.shape[0]/2+15, resultstr, fontsize=12)
        fig.tight_layout()
        final_result_path=results_path+pdb_name+".pdf"
        fig.savefig(final_result_path, bbox_inches='tight')
    else:
        print('FASTA and PDB are differnet for' +str(pdb_name))
def main():
    PDB_IDs = pdb_list
    #Load ESM_1b Model
    esm1b,esm1b_batch_converter=load_ESM_1b()
    #Set the path to results
    results_path="/Users/rohan/Desktop/DTI_setup/contact_results/" 
    for i,j in enumerate(PDB_IDs):
        print(PDB_IDs[i])
        PDB_IDs_lower = str(PDB_IDs[i]).lower()
        #Set path to PDB files
        PDB_file = f'//Users/rohan/Desktop/DTI_setup/data_main/pdb_files/pdb{PDB_IDs_lower}.ent' 
        #Set path to FASTA files
        fasta_file=f'//Users/rohan/Desktop/DTI_setup/data_main/fasta_files/{PDB_IDs[i]}_1.fasta'
        if os.path.isfile(PDB_file) and os.path.isfile(fasta_file):
            contact_pdb=getContactMap_fromPDB(PDB_file)
            contact_esm=getContactMap_fromESM(esm1b,esm1b_batch_converter,fasta_file)
            if contact_pdb is not None:
                compareContactMaps(contact_pdb,contact_esm,PDB_IDs[i],results_path)
            else: 
                continue
main()<jupyter_output>3KHF
106 99
FASTA and PDB are differnet for3KHF
3LQ3
{'fraction_non_alphanumeric': 0.16407007563514125, 'fraction_numerical': 0.20654211649104662, 'mean_word_length': 13.789674952198853, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '252378', 'license': 'MIT', 'n_tokens_mistral': 10943, 'n_tokens_neox': 10405, 'n_words': 381, 'path': 'contact_map_analysis/ContactMapAnalysis.ipynb', 'repo_name': 'meyresearch/DL_Binding_Affinity', 'size': '15469'}