def create_summary_SAbDab_entries(df_in, onlypaired=True, output_dir=None):
    """
    Takes a SAbDab summary as input.
    Removes all entries without sufficient information.
    Outputs a dataframe with an entry for every unique PDB ID with one combination of L, H and antigen chain.
    Saves the dataframe to a csv file if directory is specified.
    """
    
    # drop entries without antigen chain, type or species information
    df_in.dropna(axis=0, subset=["antigen_chain", "antigen_type", "antigen_species"], inplace=True)
    
    # drop entries without paired L and H chain 
    if onlypaired == True:
        df_in.dropna(axis=0, subset=["Hchain", "Lchain"], inplace=True)
        
    # drop entries solved by NMR
    df_in = df_in[df_in["method"].isin(["X-RAY DIFFRACTION", "ELECTRON MICROSCOPY"])]
    
    # remove duplicate PDB entries
    df_in.drop_duplicates(subset=["pdb"], inplace=True)
    
    # keep only relevant columns
    df = df_in.copy()[["pdb", "Hchain", "Lchain", "antigen_chain"]]
    
    # convert PDB IDs to upper case
    df["pdb"] = df["pdb"].apply(lambda x: x.upper())
    
    # drop PDB ID that contains nucleotide antigen
    df = df[df["pdb"] != "6CF2"]
    
    # save dataframe to csv
    if output_dir != None:
        try:
            df.to_csv(path_or_buf=output_dir, index=False)
            print("File saved.")
            return df
        except IOError: 
            print("Directory not found. File not saved.")
            return df
    else:
        return df