<jupyter_start><jupyter_text>find pdb reference:<jupyter_code>refs = pdb_refs[pdb_refs.index.str.contains(fam.name)]
refs.head()
n_refs = refs.shape[0]
print(n_refs)
for i in range(n_refs):
    ref = refs.iloc[i]
    #print(ref)

    # pdb sequence
    #seq = msa[:,ref.seq]
    seq = msa[:,ref.seq+1]  # change j-1 --> j
    #print(seq)
    
    gap_pos = seq == '-'
    seq_non_gap = seq[~gap_pos] 

    #print(seq_non_gap.shape)
    #print(seq_non_gap)
    
    pdb_file = pdb_list.retrieve_pdb_file(ref.pdb_id, pdir=fam_dir, file_format='pdb')
    chain = pdb_parser.get_structure(ref.pdb_id, pdb_file)[0][ref.chain]
    coords = np.array([a.get_coord() for a in chain.get_atoms()])
    #print(coords.shape)
    #print(coords)
    coords_cut = coords[ref.pdb_start-1:ref.pdb_end]
    #print(coords_cut.shape)
    
    print(seq_non_gap.shape[0]-coords_cut.shape[0])<jupyter_output>Structure exists: '../protein_pfam/Pfam-A.full/PF00186/pdb1zdr.ent' 
0
Structure exists: '../protein_pfam/Pfam-A.full/PF00186/pdb1zdr.ent' 
0
Structure exists: '../protein_pfam/Pfam-A.full/PF00186/pdb3jwk.ent' 
0
Structure exists: '../protein_pfam/Pfam-A.full/PF00186/pdb3s9u.ent' 
0
Structure exists: '../protein_pfam/Pfam-A.full/PF00186/pdb3fl9.ent' 
0
Structure exists: '../protein_pfam/Pfam-A.full/PF00186/pdb3fl8.ent' 
0
Structure exists: '../protein_pfam/Pfam-A.full/PF00186/pdb4elf.ent' 
0
Structure exists: '../protein_pfam/Pfam-A.full/PF00186/pdb4elf.ent' 
0
Structure exists: '../protein_pfam/Pfam-A.full/PF00186/pdb4elh.ent' 
0
Structure exists: '../protein_pfam/Pfam-A.full/PF00186/pdb4elf.ent' 
0
Structure exists: '../protein_pfam/Pfam-A.full/PF00186/pdb4elg.ent' 
0
Structure exists: '../protein_pfam/Pfam-A.full/PF00186/pdb3fl8.ent' 
0
Structure exists: '../protein_pfam/Pfam-A.full/PF00186/pdb3s9u.ent' 
0
Structure exists: '../protein_pfam/Pfam-A.full/PF00186/pdb3jw3.ent' 
0
Struct[...]