AlphaFold

repository·main·Indexed 11 days ago

https://github.com/google-deepmind/alphafold

An implementation of the inference pipeline of AlphaFold v2.0, a model for high-accuracy protein structure predictions. Includes documentation for the AlphaFold Protein Structure Database, including file formats (model_v4.cif, confidence_v4.json, predicted_aligned_error_v4.json), bulk data retrieval via Google Cloud Storage, and metadata querying using BigQuery. Also provides specifications for AlphaFold Server JSON job files for modeling protein chains, DNA, RNA, ligands, and ions.

Tokens
6.6K
Snippets
15
Records
24
Agent score
95%

What's inside AlphaFold

  1. Query AlphaFold metadata using BigQuery

    main

    The AlphaFold DB metadata is available in BigQuery, allowing for complex SQL queries over 214M proteins. This is useful for creating custom subsets of the data based on criteria like species, confidence (pLDDT), or sequence information.

    Metadata Table: bigquery-public-data.deepmind_alphafold.metadata

    Warning: While Google Cloud offers a free tier (BigQuery Sandbox), repeated or large queries may incur costs if you have an upgraded billing account. Monitor your usage in the Google Cloud console.

  2. Structure of AlphaFold Server JSON job files

    main

    AlphaFold Server job requests are defined in JSON files. A single JSON file can contain a list of multiple job descriptions (dictionaries). Each job dictionary must include a name, modelSeeds, sequences, dialect, and version.

    To automate repetitive tasks, you can generate these files by running a job via the AlphaFold Server GUI and downloading the resulting zip file. The file <job_name>_job_request.json inside the zip serves as a perfect template.

    Note: JSON comments are not supported.

    {
      "name": "Test Fold Job Number One",
      "modelSeeds": [],
      "sequences": [...],
      "dialect": "alphafoldserver",
      "version": 1
    }
  3. Set up a Google Cloud account for dataset access

    main

    To download data directly from the Google Cloud Public Datasets, you must have a Google Cloud account. While access to the AlphaFold Public Datasets storage bucket is at no cost under the free tier, you must set up a project and install the CLI to perform downloads.

    Important Note on Costs: After the 90-day trial period, you must upgrade to a billing account to continue access. While the storage bucket itself is free to access, usage beyond the free tier limits for other services will incur costs. Familiarize yourself with Google Cloud pricing to avoid unexpected charges.

    Setup Steps:

    1. Create Account: Visit https://cloud.google.com/datasets, click "get started for free", and follow the setup instructions (a payment method is required for identity verification but won't be charged unless you enable billing).
    2. Create a Project: In the Google Cloud Console, navigate to Cloud overview -> Dashboard, use the project menu to create a New Project.
    3. Install CLI: Install the Google Cloud CLI to enable data transfers via the command line.
  4. Download proteome subsets by NCBI Taxonomy ID

    main

    To download all proteins for a specific species, you can download sharded tar files from Google Cloud Storage. Each shard contains at most 10,000 proteins.

    1. Find the NCBI taxonomy ID ([TAX_ID]) for your target species.
    2. Use gcloud storage cp to download the shards.
    3. Un-tar the downloaded files and un-gzip the individual files within.
    gcloud storage cp gs://public-datasets-deepmind-alphafold-v4/proteomes/proteome-tax_id-[TAX_ID]-*_v4.tar .
  5. Download specific files using a manifest

    main

    If you have a list of specific files (a manifest), you can download them using gcloud storage cp with the --read-paths-from-stdin flag. Note that this method is slower than downloading sharded tar files due to per-file overhead.

    cat [manifest file] | gcloud storage cp --read-paths-from-stdin .
  6. Bulk download the AlphaFold dataset via GCS

    main

    The full dataset is approximately 23 TiB. For large-scale processing (e.g., in an HPC environment), the recommended method is to download the sharded proteome tar files rather than individual files. This minimizes per-file latency.

    Use the gcloud storage cp command to recursively download the proteomes directory from the public bucket:

    gcloud storage cp --recursive gs://public-datasets-deepmind-alphafold-v4/proteomes/ .

    Post-Download Processing

    1. Un-tar: You will need to un-tar the proteome files.
    2. Un-gzip: Un-gzip the individual files within the tarballs.

    Warning: After un-taring, the dataset expands to approximately 644 million files. Ensure your filesystem is configured to handle this high number of inodes/files.

  7. Control model relaxation with `--models_to_relax`

    main

    The final relaxation step (Amber relaxation) can be time-consuming. Use the --models_to_relax flag to control which models are processed:

    • all: All predicted models are relaxed.
    • best: Only the most confident model (based on ranking confidence) is relaxed.
    • none: No relaxation is performed. This may result in predictions with stereochemical violations but is useful for troubleshooting or saving time.
  8. Run the AlphaFold inference pipeline via CLI

    main

    Use the run_alphafold.py script to perform protein structure prediction. The script processes FASTA files to generate protein models, optionally performing template searches and Amber relaxation.

    Note on Multimers: If a FASTA file contains multiple sequences, it will be folded as a multimer. Ensure that model_preset is set to multimer when working with multi-sequence files.

    # Example usage (conceptual)
    python run_alphafold.py \
      --fasta_paths=target.fasta \
      --output_dir=./results \
      --data_dir=/path/to/params \
      --uniref90_database_path=/path/to/uniref90 \
      --mgnify_database_path=/path/to/mgnify \
      --template_mmcif_dir=/path/to/templates \
      --max_template_date=2023-01-01 \
      --obsolete_pdbs_path=/path/to/obsolete_pdbs.txt \
      --use_gpu_relax=True
  9. Generate summary statistics for prediction confidence

    main

    Use this SQL query to calculate the mean of prediction confidence fractions (pLDDT) per species:

    SELECT
     organismScientificName AS name,
     SUM(fractionPlddtVeryLow) / COUNT(fractionPlddtVeryLow) AS mean_plddt_very_low,
     SUM(fractionPlddtLow) / COUNT(fractionPlddtLow) AS mean_plddt_low,
     SUM(fractionPlddtConfident) / COUNT(fractionPlddtConfident) AS mean_plddt_confident,
     SUM(fractionPlddtVeryHigh) / COUNT(fractionPlddtVeryHigh) AS mean_plddt_very_high,
     COUNT(organismScientificName) AS num_predictions
    FROM bigquery-public-data.deepmind_alphafold.metadata
    GROUP by name
    ORDER BY num_predictions DESC;
  10. Generate a list of specific file paths for bulk download

    main

    To download a custom subset of proteins (e.g., high-confidence Homo sapiens proteins) without downloading the entire dataset, use BigQuery to generate a list of Cloud Storage URIs. You can then pipe this list into gcloud storage cp.

    with file_rows AS (
      with file_cols AS (
        SELECT
          CONCAT(entryID, '-model_v4.cif') as m,
          CONCAT(entryID, '-predicted_aligned_error_v4.json') as p
        FROM bigquery-public-data.deepmind_alphafold.metadata
        WHERE organismScientificName = "Homo sapiens"
          AND (fractionPlddtVeryHigh + fractionPlddtConfident) > 0.5
      )
      SELECT * FROM file_cols UNPIVOT (files for filetype in (m, p))
    )
    SELECT CONCAT('gs://public-datasets-deepmind-alphafold-v4/', files) as files
    from file_rows
  11. Define DNA sequences in AlphaFold Server jobs

    main

    Use the dnaSequence entity type. Note that this refers to single stranded DNA. To model double stranded DNA, include a second dnaSequence entry containing the reverse complement strand.

    Key Fields:

    • sequence (string): DNA sequence (only A, T, G, C allowed).
    • count (integer): Number of copies.
    • modifications (optional list): DNA chemical modifications. Requires modificationType (CCD code) and basePosition (integer).
      • Allowed modificationType codes: CCD_5CM, CCD_C34, CCD_5HC, CCD_6OG, CCD_6MA, CCD_1CC, CCD_8OG, CCD_5FC, CCD_3DR.
    {
      "dnaSequence": {
        "sequence": "GATTACA",
        "modifications": [
          {
            "modificationType": "CCD_6OG",
            "basePosition": 1
          }
        ],
        "count": 1
      }
    }