# Analyze


<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

## Setup

## Read summary confidences json

------------------------------------------------------------------------

<a
href="https://github.com/sky1ove/af_kit/blob/main/af_kit/analyze.py#L13"
target="_blank" style="float:right; font-size:smaller">source</a>

### read_summary_json

>  read_summary_json (json_path)

*Read json file to dictionary*

``` python
data = read_summary_json('data/seq_only_summary_confidences.json')
data
```

    {'ID': 'seq_only_summary_confidences',
     'chain_iptm_0': None,
     'chain_pair_iptm_0_0': 0.72,
     'chain_pair_pae_min_0_0': 0.76,
     'chain_ptm_0': 0.72,
     'fraction_disordered': 0.19,
     'has_clash': 0.0,
     'iptm': None,
     'ptm': 0.72,
     'ranking_score': 0.82}

------------------------------------------------------------------------

<a
href="https://github.com/sky1ove/af_kit/blob/main/af_kit/analyze.py#L33"
target="_blank" style="float:right; font-size:smaller">source</a>

### get_summary_df

>  get_summary_df (output_dir)

*Pack the summary json from the output folder to the df*

``` python
out = get_summary_df('data')
out
```

    1 summary_confidences.json files detected

<div>
<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }
&#10;    .dataframe tbody tr th {
        vertical-align: top;
    }
&#10;    .dataframe thead th {
        text-align: right;
    }
</style>

<table class="dataframe" data-quarto-postprocess="true" data-border="1">
<thead>
<tr style="text-align: right;">
<th data-quarto-table-cell-role="th"></th>
<th data-quarto-table-cell-role="th">ID</th>
<th data-quarto-table-cell-role="th">chain_iptm_0</th>
<th data-quarto-table-cell-role="th">chain_pair_iptm_0_0</th>
<th data-quarto-table-cell-role="th">chain_pair_pae_min_0_0</th>
<th data-quarto-table-cell-role="th">chain_ptm_0</th>
<th data-quarto-table-cell-role="th">fraction_disordered</th>
<th data-quarto-table-cell-role="th">has_clash</th>
<th data-quarto-table-cell-role="th">iptm</th>
<th data-quarto-table-cell-role="th">ptm</th>
<th data-quarto-table-cell-role="th">ranking_score</th>
</tr>
</thead>
<tbody>
<tr>
<td data-quarto-table-cell-role="th">0</td>
<td>seq_only_summary_confidences</td>
<td>None</td>
<td>0.72</td>
<td>0.76</td>
<td>0.72</td>
<td>0.19</td>
<td>0.0</td>
<td>None</td>
<td>0.72</td>
<td>0.82</td>
</tr>
</tbody>
</table>

</div>

## Specific for protein pairs

------------------------------------------------------------------------

<a
href="https://github.com/sky1ove/af_kit/blob/main/af_kit/analyze.py#L41"
target="_blank" style="float:right; font-size:smaller">source</a>

### process_summary_df

>  process_summary_df (df, generate_report=False)

*Post process the json-converted pandas df; remove redundant columns;
available for pairs*

``` python
# out2 = process_summary_df(out)
```

------------------------------------------------------------------------

<a
href="https://github.com/sky1ove/af_kit/blob/main/af_kit/analyze.py#L94"
target="_blank" style="float:right; font-size:smaller">source</a>

### get_top_cases

>  get_top_cases (df, n=30)

*Get top cases from the metric*

``` python
# genes = get_top_cases(out2)
```

------------------------------------------------------------------------

<a
href="https://github.com/sky1ove/af_kit/blob/main/af_kit/analyze.py#L113"
target="_blank" style="float:right; font-size:smaller">source</a>

### get_3d_report

>  get_3d_report (df, index_list, x='iptm', y='ptm',
>                     z='chain_pair_pae_min_add', save_dir='af_report')

*Generate 3d plot html file given case index and x, y, z colname*

``` python
# get_3d_report(out2,genes)
```

------------------------------------------------------------------------

<a
href="https://github.com/sky1ove/af_kit/blob/main/af_kit/analyze.py#L144"
target="_blank" style="float:right; font-size:smaller">source</a>

### get_report

>  get_report (out_dir, save_dir='af_report')

*Generate summary report based on summary_confidences file; return
summary df and top cases*

``` python
df_sum, top_genes = get_report('af_output/data','af_report/proteinA')

df_sum.sort_values('iptm_ptm_rnk_add').head(10)
```

------------------------------------------------------------------------

<a
href="https://github.com/sky1ove/af_kit/blob/main/af_kit/analyze.py#L157"
target="_blank" style="float:right; font-size:smaller">source</a>

### copy_file

>  copy_file (idx_name, source_dir, dest_dir)

*Copy all model cif generated by AF3 to the new dest folder*

``` python
from fastcore.utils import L
copy_file('proA_proB',source_dir='af_output/proA',dest_dir='af_top')
# Or 
L(top_genes).map(copy_file,source_dir='af_output/proA',dest_dir='af_top')
```

## End
