kalininalab / DataSAIL

DataSAIL is a tool to split datasets while reducing information leakage.
https://datasail.readthedocs.io
MIT License
13 stars 1 forks source link

FASTA input for split in two dimensions and How to save the results of split in 2D #11

Open EasternCaveMan opened 5 months ago

EasternCaveMan commented 5 months ago

Hi Roman I hope you are doing well, You have given a example in DatatSAIL web site how to prepare the target for split as bellow: Preparation of Targets: you copy all pdb files into one folder. This is a requirement of FoldSeek, the internally used algorithm to cluster PDB data.

os.makedirs("pdbs", exist_ok=True)
for name, filename in df[["ids", "Target"]].values.tolist():
    shutil.copyfile(filename, f"pdbs/{name}.pdb")

I am trying to do the same when the target are protein seqences: here is my data structure:

Screenshot 2024-01-26 at 11 58 53

and use this code to save each sequnce in a fasta file with ids as ID

sequences_dir = os.path.abspath(os.path.join(CURRENT_DIR, ".." ,"data", "enzyme_substrate_data","sequences"))
os.makedirs(sequences_dir, exist_ok=True)

for name, sequence in final_df_UID_MID[["ids", "Sequence"]].values.tolist():
    filename = os.path.join(sequences_dir, f"{name}.fasta")
    with open(filename, 'w') as f:
        f.write(f">{name}\n")
        f.write(sequence + "\n")

Best, Vahid

EasternCaveMan commented 5 months ago

I have saved all sequences in one file and didnt get any error related to sequence file. Is this correct or should each sequence be saved in seperate file and if so, should >ids to first line or just add idsto file name? Input structure for fasta file

>ID0
FFEGKNIFVTGGTGLLGKVLVEKILRSTPIGKIYVLVKADDQEAAVDRITKELINSELFRCLKEKHGKYYQAYIRETLIPIVGNICEPNLGMDSDSAHAIMEDVNVIIESAAITTLNERYDVSLEANVNSPQQLMRFAKTCKN
>ID1
MDPHNKGVAEAEFFTEYGEASRYEIQEVIGKGSYGIVGSVIDTHTGERVAIKKINDVFEHVSDATRILREIKKADP
Old-Shatterhand commented 5 months ago

Hi @atabaigi , You cannot use FoldSeek for protein sequences. FoldSeek is based on 3d structures. For sequences, can use MMseqs2 or CD-HIT. But as input for MMseqs or CD-HIT, your fasta file looks good.

Old-Shatterhand commented 5 months ago

Note to my-self: Recheck input validation and raise an error in these cases.