Package: proteinflow
ProteinFlow - A data processing pipeline for all your protein design needsDocsProteinFlow is an open-source Python library that streamlines the pre-processing of protein structure data for deep learning applications. ProteinFlow enables users to efficiently filter, cluster, and generate new datasets from resources like the Protein Data Bank (PDB) and SAbDab (The Structural Antibody Database).Here are some of the key features we currently support:⛓️ Processing of both single-chain and multi-chain protein structures (Biounit PDB definition)🏷️ Various featurization options can be computed, including secondary structure features, torsion angles, etc.💾 A variety of data loading options and conversions to cater to different downstream training frameworks🧬 Access to up-to-date, pre-computed protein structure datasetsInstallationconda:# This should take a few minutes, be patientcondainstall-cconda-forge-cbioconda-cadaptyvbioproteinflowpip:pipinstallproteinflowdocker:dockerpulladaptyvbio/proteinflowBy default installingproteinflowwith conda or pip will only load the dependencies that are required for the main functions of the package: downloading, generating and splitting datasets. If you are interested in using other functions like visualization, metrics and other data processing methods, please install the package withpip install proteinflow[processing]or use the docker image.Some metric functions also have separate requirements, see the documentation for details. All of them are installed in the docker image.TroubleshootingIf you are using python 3.10 and encountering installation problems, try runningpython -m pip install prody==2.4.0before installingproteinflow.If you are planning to generate new datasets and installedproteinflowwithpip(or withcondaon Mac OS with an M1 processor), you will need to additionally installmmseqs.Generating new datasets also depends on thercsbsearchpackage and the latest releasev0.2.3is currently not working correctly. The recommended fix is installing the version fromthis pull request.python-mpipinstall"rcsbsearch @ git+https://github.com/sbliven/rcsbsearch@dbdfe3880cc88b0ce57163987db613d579400c8e"The docker image can be accessed in interactive mode with this command.dockerrun-it-v/path/to/data:/mediaadaptyvbio/proteinflowbashUsageDownloading pre-computed datasets (stable)Already precomputed datasets with consensus set of parameters and can be accessed and downloaded using theproteinflow. package. Check the output ofproteinflow check_tagsfor a list of available tags.proteinflowdownload--tag20230102_stableRunning the pipeline (PDB)You can also runproteinflowwith your own parameters. Check the output ofproteinflow check_snapshotsfor a list of available PDB snapshots (naming rule:yyyymmdd).For instance, let's generate a dataset with the following description:resolution threshold: 5 angstrom,PDB snapshot: 20190101,structure methods accepted: all (x-ray christolography, NRM, Cryo-EM),sequence identity threshold for clustering: 40% sequence similarity,maximum length per sequence: 1000 residues,minimum length per sequence: 5 residues,maximum fraction of missing values at the ends: 10%,size of validation subset: 10%.proteinflowgenerate--tagnew--resolution_thr5--pdb_snapshot20190101--not_filter_methods--min_seq_id0.4--max_length1000--min_length5--missing_ends_thr0.1--valid_split0.1See thedocs(orproteinflow generate --help) for the full list of parameters and more information.A registry of all the files that are removed during the filtering as well as description with the reason for their removal is created automatically for eachgeneratecommand. The log files are save (atdata/logsby default) and a summary can be accessed runningproteinflow get_summary {log_path}.Running the pipeline (SAbDab)You can also use the--sabdaboption inproteinflow generateto load files from SAbDab and cluster them based on CDRs. By default the--sabdabtag will download the latest up-to-date version of the SabDab dataset and cluster the antibodies based on their CDR sequence.
Alternatively, it can be used together with the tag--sabdab_data_pathto process a custom SAbDab-like zip file or folder. This allows you to use search and query tools from theSabDab web interfaceto create a custom dataset by downloading the archived zip file of the structures selected. (Under Downloads section of your SabDab query).SAbDab sequences clustering is done across all 6 Complementary Determining Regions (CDRs) - H1, H2, H3, L1, L2, L3, based on theChothia numberingimplemented by SabDab. CDRs from nanobodies and other synthetic constructs are clustered together with other heavy chain CDRs. The resulting CDR clusters are split into training, test and validation in a way that ensures that every PDB file only appears in one subset.Individual output pickle files represent heavy chain - light chain - antigen complexes (created from SAbDab annotation, sometimes more than one per PDB entry). Each of the elements (heavy chain, light chain, antigen) can be missing in specific entries and there can be multiple antigen chains. In order to filter for at least one antigen chain, use the--require_antigenoption.For instance, let's generate a dataset with the following description:SabDab version: latest (up-to-date),resolution threshold: 5 angstrom,structure methods accepted: all (x-ray christolography, NRM, Cryo-EM),sequence identity threshold for clustering (CDRs): 40%,size of validation subset: 10%.proteinflowgenerate--sabdab--tagnew--resolution_thr5--not_filter_methods--min_seq_id0.4--valid_split0.1SplittingBy default, bothproteinflow generateandproteinflow downloadwill also split your data into training, test and validation according to MMseqs2 clustering and homomer/heteromer/single chain proportions. However, you can skip this step with a--skip_splittingflag and then perform it separately with theproteinflow splitcommand.The following command will perform the splitting with a 10% validation set, a 5% test set and a 50% threshold for sequence identity clusters.proteinflowsplit--tagnew--valid_split0.1--test_split0.5--min_seq_id0.5Use the--exclude_chainsand--exclude_thresholdparameters to move all biounits that contain chains similar to what you specify to a separate folder.Using the dataThe output files are pickled nested dictionaries where first-level keys are chain Ids and second-level keys are the following:'crd_bb': anumpyarray of shape(L, 4, 3)with backbone atom coordinates (N, C, CA, O),'crd_sc': anumpyarray of shape(L, 10, 3)with sidechain atom coordinates (checkproteinflow.sidechain_order()for the order of atoms),'msk': anumpyarray of shape(L,)where ones correspond to residues with known coordinates and
zeros to missing values,'seq': a string of lengthLwith residue types.In a SAbDab datasets, an additional key is added to the dictionary:'cdr': anumpyarray of shape(L,)where CDR residues are marked with the corresponding type ('H1','L1', ...)
and non-CDR residues are marked with'-'.Note that the sequence information in the PDB files is aligned to the FASTA sequences to identify the missing residues.Once your data is ready, you can open the files withpickledirectly.importpickleimportostrain_folder="./data/proteinflow_new/training"forfilenameinos.listdir(train_folder):withopen(os.path.join(train_folder,filename),"rb")asf:data=pickle.load(f)crd_bb=data["crd_bb"]seq=data["seq"]...Alternatively, you can use ourProteinDatasetorProteinLoaderclasses
for convenient processing. Among other things, they allow for feature extraction, single chain / homomer / heteromer filtering and randomized sampling from sequence identity clusters.For example, here is how we can create a data loader that:samples a different cluster representative at every epoch,extracts dihedral angles, sidechain orientation and secondary structure features,only loads pairs of interacting proteins (larger biounits are broken up into pairs),has batch size 8.fromproteinflowimportProteinLoadertrain_loader=ProteinLoader.from_args("./data/proteinflow_new/training",clustering_dict_path="./data/proteinflow_new/splits_dict/train.pickle",node_features_type="dihedral+sidechain_orientation+secondary_structure",entry_type="pair",batch_size=8,)forbatchintrain_loader:crd_bb=batch["X"]#(B, L, 4, 3)seq=batch["S"]#(B, L)sse=batch["secondary_structure"]#(B, L, 3)to_predict=batch["masked_res"]#(B, L), 1 where the residues should be masked, 0 otherwise...See more details on available parameters and the data format in thedocs+this repositoryfor a use case.ProteinFlow Stable ReleasesYou can download them withproteinflow download --tag {tag}in the command line or browse in theinterface.TagDateSnapshotSizeMin resMin lenMax lenMax chainsMMseqs thrSplit (train/val/test)Missing thr (ends/middle)SourceRemove redundanciesNotepaper10.11.222022010324G3.53010'000-0.390/5/50.3/0.1PDByesfirst release, no mmCIF files20230102_stable27.02.232023010228G3.53010'000-0.390/5/50.3/0.1PDByesv1.1.120230623_sabdab26.06.23live 26.06.231.4G3.53010'000-0.396/3/10.5/0.2SAbDabnov1.4.1 (requires >= v1.4.0)20230102_v20019.07.232023010233G3.53010'000100.390/5/50.3/0.1PDBnov2.0.020231221_sabdab21.12.23live 21.12.231.8G3.53010'000-0.396/3/10.5/0.2SAbDabnov2.6.1 (requires >= v1.4.0)LicenseTheproteinflowpackage and data are released and distributed under the BSD 3-Clause LicenseContributionsThis is an open source project supported byAdaptyv Bio. Contributions, suggestions and bug-fixes are welcomed.