foldkit.af3_ensemble.AF3Ensemble#
- class foldkit.af3_ensemble.AF3Ensemble[source]#
Bases:
objectMethods
__init__()get_all_contact_probs([chain1, chain2, ...])Return the contact probs score for each structure in the ensemble.
get_all_ipae([chain1, chain2, tokens1, ...])Return the interface pae (predicted alignment error) score.
get_all_ipsae(chain1, chain2[, pae_cutoff, d0])Return the ipase score for all members of the ensemble.
get_all_iptm([chain1, chain2])Return the interchain ptm (iptm) score for all members of the ensemble.
get_all_pae([chain, tokens, agg])Return the pae (predicted alignment error) score.
get_all_plddt([chain, atoms, agg])Return the plddt score for all structures in the ensemble.
get_all_ptm([chain])Return the ptm score.
get_ensemble_contact_probs([chain1, chain2, ...])Return the contact probs score aggregated over the ensemble.
get_ensemble_ipae([chain1, chain2, tokens1, ...])Return the ensemble aggregated interface pae (predicted alignment error) score.
get_ensemble_ipsae(chain1, chain2[, ...])Return the ensemble aggregated ipsae score.
get_ensemble_iptm([chain1, chain2, ensemble_agg])Return the ensemble aggregated interchain ptm (iptm) score.
get_ensemble_pae([chain, tokens, agg, ...])Return the ensemble-aggregated pae (predicted alignment error) score.
get_ensemble_plddt([chain, atoms, agg, ...])Return the ensemble-aggregated plddt score.
get_ensemble_ptm([chain, ensemble_agg])Return the ensemble aggregated ptm score.
get_result_by_seed_and_sample(seed, sample)load_af3_result(result_dir[, id])Generate an AF3Ensemble for each of the samples from a run on the AF3 webserver.
load_compressed_result(result_dir[, id])Generate an AF3Ensemble for each of the samples stored via export.
load_webserver_result(result_dir[, seed, ...])Generate an AF3Ensemble for each of the samples from a run on the AF3 webserver.
- get_all_contact_probs(chain1=None, chain2=None, tokens1=None, tokens2=None, agg=<function mean>)[source]#
Return the contact probs score for each structure in the ensemble.
- Parameters:
chain1 (str, optional) – If provided, computes the contact probs for this specific pair of chains. Only optional if tokens1 and tokens2 are provided
chain2 (str, optional) – If provided, computes the contact probs for this specific pair of chains. Only optional if tokens1 and tokens2 are provided
tokens1 (list[int], optional) – If provided, computes the contact probs for this specific pair of token lists. Only optional if chain1 and chain2 are provided
tokens2 (list[int], optional) – If provided, computes the contact probs for this specific pair of token lists. Only optional if chain1 and chain2 are provided
agg (callable, default=np.mean) – Aggregation function to apply to the selected values.
- Return type:
- Returns:
dict[str, float] – Contact probs score for each member of the ensemble.
- Raises:
ValueError – If neither chain and tokens are provided, both are provided, or if either argument is invalid based on the data
- get_all_ipae(chain1=None, chain2=None, tokens1=None, tokens2=None, agg=<function mean>)[source]#
Return the interface pae (predicted alignment error) score.
- Parameters:
chain1 (str, optional) – If provided, computes the ipae for this specific pair of chains. Only optional if tokens1 and tokens2 are provided
chain2 (str, optional) – If provided, computes the ipae for this specific pair of chains. Only optional if tokens1 and tokens2 are provided
tokens1 (list[int], optional) – If provided, computes the ipae for this specific pair of token lists. Only optional if chain1 and chain2 are provided
tokens2 (list[int], optional) – If provided, computes the ipae for this specific pair of token lists. Only optional if chain1 and chain2 are provided
agg (callable, default=np.mean) – Aggregation function to apply to the selected values.
- Return type:
- Returns:
dict[str, float] – Aggregated ipae score for each structure in the ensemble.
- Raises:
ValueError – If neither chain and tokens are provided, both are provided, or if either argument is invalid based on the data
- get_all_ipsae(chain1, chain2, pae_cutoff=10, d0='d0res')[source]#
Return the ipase score for all members of the ensemble.
- Parameters:
chain1 (str) – Computes the ipsae for this specific pair of chains.
chain2 (str) – Computes the ipsae for this specific pair of chains.
pae_cutoff (float, default=10) – PAE cutoff (in Angstroms) passed through to the ipSAE calculation.
d0 (str, default=d0res) – d0 used for calculation. Options are: d0res: d0 determined by number of residues in 2nd chain with PAE<cutoff d0chn: sum of chain lengths d0dom: d0 = total number of residues in both chains with any interchain PAE<cutoff
- Return type:
- Returns:
dict[str, float] – ipsae scores for each AF3 Result.
- Raises:
ValueError – If chain1 or chain2 is invalid based on the data
- get_all_iptm(chain1=None, chain2=None)[source]#
Return the interchain ptm (iptm) score for all members of the ensemble.
- Parameters:
chain1 (str, optional) – If provided, computes the iptm for this specific pair of chains. Otherwise, returns the global iptm score for all pairs of chains
chain2 (str, optional) – If provided, computes the iptm for this specific pair of chains. Otherwise, returns the global iptm score for all pairs of chains
- Return type:
- Returns:
dict[str, float] – iptm scores for each AF3 Result.
- Raises:
ValueError – If chain1 or chain2 is invalid based on the data
- get_all_pae(chain=None, tokens=None, agg=<function mean>)[source]#
Return the pae (predicted alignment error) score.
- Parameters:
chain (str, optional) – If provided, computes the pae for this specific chain. If None, returns the score across all tokens (residues) in the structure.
tokens (list[int], optional) – If provided, computes the pae for specific tokens. If None, returns the score across all tokens (residues) in the structure. Cannot be used in combination with “chain”
agg (callable, default=np.mean) – Aggregation function to apply to the selected values.
- Return type:
- Returns:
dict[str, float] – Full ensemble of pae scores, aggregated across PAE matrix.
- Raises:
ValueError – If both chain and tokens are provided, or if either argument is invalid based on the data
- get_all_plddt(chain=None, atoms=None, agg=<function mean>)[source]#
Return the plddt score for all structures in the ensemble.
- Parameters:
chain (str, optional) – If provided, computes the plddt for this specific chain. If None, returns the score across all atoms in the structure.
atoms (list[int], optional) – If provided, computes the plddt for specific atoms. If None, returns the score across all atoms in the structure. Cannot be used in combination with “chain”
agg (callable, default=np.mean) – Aggregation function to apply to the selected values.
- Return type:
- Returns:
dict[str, float] – per structure plddt score.
- Raises:
ValueError – If both chain and atoms are provided, or if either argument is invalid based on the data
- get_all_ptm(chain=None)[source]#
Return the ptm score.
- Parameters:
chain (str, optional) – If provided, computes the ptm for this specific chain. If None, returns the global score across all chains in the structure.
- Return type:
- Returns:
dict[str, float] – ptm scores for each AF3 Result.
- Raises:
ValueError – If chain is invalid based on the data
- get_ensemble_contact_probs(chain1=None, chain2=None, tokens1=None, tokens2=None, agg=<function mean>, ensemble_agg=<function mean>)[source]#
Return the contact probs score aggregated over the ensemble.
- Parameters:
chain1 (str, optional) – If provided, computes the contact probs for this specific pair of chains. Only optional if tokens1 and tokens2 are provided
chain2 (str, optional) – If provided, computes the contact probs for this specific pair of chains. Only optional if tokens1 and tokens2 are provided
tokens1 (list[int], optional) – If provided, computes the contact probs for this specific pair of token lists. Only optional if chain1 and chain2 are provided
tokens2 (list[int], optional) – If provided, computes the contact probs for this specific pair of token lists. Only optional if chain1 and chain2 are provided
agg (callable, default=np.mean) – Aggregation function to apply to the selected values.
ensemble_agg (callable, default=np.mean) – Aggregation function to apply to the ensemble of values.
- Return type:
- Returns:
float – Contact probs score aggregated across the ensemble.
- Raises:
ValueError – If neither chain and tokens are provided, both are provided, or if either argument is invalid based on the data
- get_ensemble_ipae(chain1=None, chain2=None, tokens1=None, tokens2=None, agg=<function mean>, ensemble_agg=<function mean>)[source]#
Return the ensemble aggregated interface pae (predicted alignment error) score.
- Parameters:
chain1 (str, optional) – If provided, computes the ipae for this specific pair of chains. Only optional if tokens1 and tokens2 are provided
chain2 (str, optional) – If provided, computes the ipae for this specific pair of chains. Only optional if tokens1 and tokens2 are provided
tokens1 (list[int], optional) – If provided, computes the ipae for this specific pair of token lists. Only optional if chain1 and chain2 are provided
tokens2 (list[int], optional) – If provided, computes the ipae for this specific pair of token lists. Only optional if chain1 and chain2 are provided
agg (callable, default=np.mean) – Aggregation function to apply to the selected values.
ensemble_agg (callable, default=np.mean) – Aggregation function to apply to the ensemble of values.
- Return type:
- Returns:
float – Ensemble aggregated ipae score.
- Raises:
ValueError – If neither chain and tokens are provided, both are provided, or if either argument is invalid based on the data
- get_ensemble_ipsae(chain1, chain2, pae_cutoff=10, d0='d0res', ensemble_agg=<function mean>)[source]#
Return the ensemble aggregated ipsae score.
- Parameters:
chain1 (str) – Computes the ipsae for this specific pair of chains.
chain2 (str) – Computes the ipsae for this specific pair of chains.
pae_cutoff (float, default=10) – PAE cutoff (in Angstroms) passed through to the ipSAE calculation.
d0 (str, default=d0res) – d0 used for calculation. Options are: d0res: d0 determined by number of residues in 2nd chain with PAE<cutoff d0chn: sum of chain lengths d0dom: d0 = total number of residues in both chains with any interchain PAE<cutoff
ensemble_agg (callable, default=np.mean) – Aggregation function to apply to the ensemble of values.
- Return type:
- Returns:
float – ensemble aggregated ipsae score.
- Raises:
ValueError – If chain is invalid based on the data
- get_ensemble_iptm(chain1=None, chain2=None, ensemble_agg=<function mean>)[source]#
Return the ensemble aggregated interchain ptm (iptm) score.
- Parameters:
chain1 (str, optional) – If provided, computes the iptm for this specific pair of chains. Otherwise, returns the global iptm score for all pairs of chains
chain2 (str, optional) – If provided, computes the iptm for this specific pair of chains. Otherwise, returns the global iptm score for all pairs of chains
ensemble_agg (callable, default=np.mean) – Aggregation function to apply to the ensemble of values.
- Return type:
- Returns:
float – ensemble aggregated iptm score.
- Raises:
ValueError – If chain is invalid based on the data
- get_ensemble_pae(chain=None, tokens=None, agg=<function mean>, ensemble_agg=<function mean>)[source]#
Return the ensemble-aggregated pae (predicted alignment error) score.
- Parameters:
chain (str, optional) – If provided, computes the pae for this specific chain. If None, returns the score across all tokens (residues) in the structure.
tokens (list[int], optional) – If provided, computes the pae for specific tokens. If None, returns the score across all tokens (residues) in the structure. Cannot be used in combination with “chain”
agg (callable, default=np.mean) – Aggregation function to apply to the selected values.
ensemble_agg (callable, default=np.mean) – Aggregation function to apply to the ensemble of values.
- Return type:
- Returns:
float – Ensemble aggregated pae score, aggregated across PAE matrix per structure and then aggregated across ensemble.
- Raises:
ValueError – If both chain and tokens are provided, or if either argument is invalid based on the data
- get_ensemble_plddt(chain=None, atoms=None, agg=<function mean>, ensemble_agg=<function mean>)[source]#
Return the ensemble-aggregated plddt score.
- Parameters:
chain (str, optional) – If provided, computes the plddt for this specific chain. If None, returns the score across all tokens (residues) in the structure.
atoms (list[int], optional) – If provided, computes the plddt for specific atoms. If None, returns the score across all atoms in the structure. Cannot be used in combination with “chain”
agg (callable, default=np.mean) – Aggregation function to apply to the selected values.
ensemble_agg (callable, default=np.mean) – Aggregation function to apply to the ensemble of values.
- Return type:
- Returns:
float – Aggregated plddt score.
- Raises:
ValueError – If both chain and atoms are provided, or if either argument is invalid based on the data
- get_ensemble_ptm(chain=None, ensemble_agg=<function mean>)[source]#
Return the ensemble aggregated ptm score.
- Parameters:
chain (str, optional) – If provided, computes the ptm for this specific chain. If None, returns the global score across all chains in the structure.
ensemble_agg (callable, default=np.mean) – Aggregation function to apply to the ensemble of values.
- Return type:
- Returns:
float – ensemble aggregated ptm score.
- Raises:
ValueError – If chain is invalid based on the data
- static load_af3_result(result_dir, id=None)[source]#
Generate an AF3Ensemble for each of the samples from a run on the AF3 webserver. :type result_dir:
str:param result_dir: :type result_dir: path to directory storing results. :type id:Optional[str] :param id: :type id: optional ID. If unset, will set to directory name- Return type:
- Returns:
AF3Ensemble – loaded AF3Ensemble
- Parameters:
- static load_compressed_result(result_dir, id=None)[source]#
Generate an AF3Ensemble for each of the samples stored via export. :type result_dir:
str:param result_dir: :type result_dir: path to directory storing results. :type id:Optional[str] :param id: :type id: optional ID. If unset, will set to directory name- Return type:
- Returns:
AF3Ensemble – loaded AF3Ensemble
- Parameters:
- static load_webserver_result(result_dir, seed=None, id_stem=None)[source]#
Generate an AF3Ensemble for each of the samples from a run on the AF3 webserver.
- Parameters:
result_dir (path to directory storing results.)
seed (Model seed. If unset, will try to infer these from a request file in result_dir.)
id_stem (Job name. If unset, will try to infer these from a request file in result_dir.)
- Return type:
- Returns:
AF3Ensemble – loaded AF3Ensemble