Protein X-ray Structure Determination Tutorial: Step.3 Determining Initial Phases

**This article is written in English. Japanese Version is [here](https://qiita.com/noguhiro2002/items/5efd602895c3f13d46ee).**

# Introduction
Welcome to the third installment of our tutorial series on structural analysis in the age of AlphaFold2 ([First time](https://qiita.com/noguhiro2002/items/31e3a915afce44166ba0), [Second time](https://qiita.com/noguhiro2002/items/542a93026e4c553b2889)). This time, we will derive the initial phase from the structure factor F(hkl). As the title indicates "In the Era of AlphaFold2," we will use the high-precision model structures output by AlphaFold2 to derive the initial phase.

![image.png](https://github.com/noguhiro2002/xray_tutorial/blob/main/qiita_img/step_3/000.png?raw=true)

# Table of Contents
- [Step.0 The flow of structure determination](https://qiita.com/noguhiro2002/items/31e3a915afce44166ba0)
- [Step.1 Installing analytical software](https://qiita.com/noguhiro2002/items/31e3a915afce44166ba0)
- [Step.2 Checking diffraction images and calculating structure factors](https://qiita.com/noguhiro2002/items/542a93026e4c553b2889)
- Step.3 Finding initial phases(This article)
- [Step.4 Structure refinement and validation](https://qiita.com/noguhiro2002/items/2eff5aec58dc4c76eaa9)

# Target Audience and Purpose of This Article
This article aims to enable researchers, graduate students, and undergraduates who are not specialized in protein X-ray crystallography to understand the entire process of protein X-ray crystal structure analysis, from diffraction images to structure determination. We assume that readers have some familiarity with Bash commands in a Linux environment.

In this article, we will present a tutorial on protein structure analysis in a four-part series. This is the third part.

:::note info
Also, **this article is completely open.** Whether at schools, research institutions, or companies, we would be delighted if you could spread this article and use it for educational purposes. However, we have not abandoned copyright.
:::



# Computing Environment Needed for Protein X-ray Crystallographic Analysis
From my experience, the following computing environment is suitable for protein X-ray crystallographic analysis. It requires computer power, so it's important not to attempt it on a Raspberry Pi or similar device.

- OS
    - Linux, such as Ubuntu, CentOS (strongly recommended)
    - MacOSX
    - Windows 10/11 (use either the native environment or a Linux environment on WSL2)
- CPU: > 4 cores (recommended: > 16 cores)
- Main Memory: > 16 GB (recommended: > 32 GB)
- Storage: > 50 GB (about 12 GB for software installation, data sets 20 - 30 GB/crystal)
- GPU: Not essential (recommended: equipped with a GPU)

:::note info
In this step, we will perform the analysis on a virtual machine on Google Cloud Platform, which we set up in[Step.1](https://qiita.com/noguhiro2002/items/5efd602895c3f13d46ee#step1-3-google-cloud-platformgcp%E4%B8%8A%E3%81%AB%E8%A8%88%E7%AE%97%E6%A9%9F%E7%92%B0%E5%A2%83%E3%82%92%E6%A7%8B%E7%AF%89%E3%81%99%E3%82%8B-skip%E5%8F%AF%E8%83%BD).
:::

# Github Repository
We have uploaded representative files related to this tutorial to Github. We hope it will serve as a useful reference.

https://github.com/noguhiro2002/xray_tutorial

# Step.3 Deriving the Initial Phase
## Step.3-0 Preparation: What are the Initial Phase and the MR Method?

As explained in [Step 0, the phase problem is a stumbling block in protein X-ray crystallography](https://qiita.com/noguhiro2002/items/31e3a915afce44166ba0#step-0-workflow-for-structural-determination). This is due to the inability of current 2D detectors (such as the EIGER detector from DECTRIS) to directly observe the phase α(hkl). You may wonder how then is it computed? It may sound peculiar, but **we backtrack the phase α(hkl) from the constructed model of the protein structure (which is what we want to achieve), thereby obtaining the electron density ρ(xyz). However, to construct the protein model structure, the electron density ρ(xyz) is required in the first place[^1].** Thus, the protein model structure and phase α(hkl) are mutually dependent, analogous to the "which came first, the chicken or the egg?" conundrum, making the process of obtaining the protein model structure challenging.

Without overcoming this obstacle, obtaining the target protein model structure would be impossible. Therefore, **we first obtain a rough initial phase α(hkl) to gain an approximate electron density ρ(xyz), which allows for some model construction.** Afterward, the protein model structure is constructed using the derived initial phase, from which a new phase α(hkl) and new electron density ρ(xyz) are calculated. The model structure is then improved based on the enhanced electron density ρ(xyz). This cycle is repeated, gradually refining the protein model structure. This process is referred to as **Refinement**.

While the phase problem can be solved in the field of low-molecular X-ray crystal structure analysis (inorganic, organic compounds) by harnessing computer power through the [Direct Method](https://en.wikipedia.org/wiki/Direct_methods_(crystallography)), this approach is not feasible for protein X-ray crystallography when the molecule is large (= the unit cell is large). Therefore, numerous methods have been developed by our predecessors to obtain the initial phase. These methods are mainly divided into ①experimental techniques (MIR, MAD, SAD methods, etc.) and ②computational methods (MR method). The experimental methods ①, unless sulfur atoms (S) from [Cysteine](https://en.wikipedia.org/wiki/Cysteine) or [Methionine](https://en.wikipedia.org/wiki/Methionine) are present in the protein2, require additional experiments such as introducing heavy atoms into the protein crystal, which are time, money, and labor-intensive. On the other hand, in the computational method ②, the **Molecular Replacement method (MR) is used, which leverages similar protein structures, does not require additional experiments, and can be entirely executed on a computer, making it very convenient.**

From my experience, for example, where an experimental method (SAD method using heavy atoms like Pt) takes 1-2 months, the determination of the initial phase can be completed within about 5 minutes using the MR method. Due to its convenience, the MR method is often selected as the first choice to determine the initial phase. However, when a similar structure cannot be found, there was no choice but to rely on the experimental methods for determining the initial phase3.

This situation was transformed with the introduction of [AlphaFold2](https://github.com/deepmind/alphafold) developed by DeepMind. Until now, similar structures used in the MR method were obtained from [the Protein Data Bank (PDB)](https://www.rcsb.org/) using sequence information. However, protein structures are highly diverse based on their amino acid sequences, and even if the sequences are similar (it has been said that a 30% sequence similarity suggests a potential similar structure), critical amino acid mutations that can alter the overall structure can result in substantial differences between the target structure and the similar structure, making structural determination difficult at times. Here is where the highly accurate protein structure prediction model, AlphaFold2, comes into play. Instead of finding similar structures from the PDB, it is expected that very accurate initial phases can be obtained if the protein model structure output by AlphaFold2 is used as a similar structure for the MR method. In fact, many structural biologists on Twitter are expressing their surprise ([example](https://twitter.com/sugargroove/status/1416959217257250818?s=20&t=9rC5ppxBIUXF9GiYRQ0GVA))(JP). Therefore, it is expected that the use of AlphaFold2 + MR method will become the mainstream method for determining the initial phase, and this tutorial will follow this approach for deriving the initial phase.


[^1]: For the sake of clarity, the explanation is oriented differently from most textbooks and introductory articles. 
[^2]: In some synchrotrons, it is possible to determine the initial phase using the slight anomalous scattering of sulfur atoms through the S-SAD method. In this case, additional experiments are not necessary, and the initial phase can be obtained conveniently.
[^3]: In the elucidation of the structure of novel proteins important for drug discovery/biological phenomena, similar structures often did not exist in the first place, forcing reliance on experimental methods for determining the initial phase. 

## Step 3-1: Preparing Model Structures Using AlphaFold2

This section will guide you on how to use AlphaFold2 to output model structures for input into the molecular replacement method. However, the original AlphaFold2 released by DeepMind requires a huge database (around 2.6TB) and expensive GPU (which uses a large amount of VRAM in proportion to the length of the protein sequence), making it a high hurdle for casual use. Therefore, we will be using one implementation of AlphaFold2, [ColabFold](https://github.com/sokrypton/ColabFold), which operates on [Google Colaboratory](https://colab.research.google.com/), a Python analysis execution platform provided for free by Google. For a detailed understanding of AlphaFold2 and ColabFold, please refer to articles by Professor Mori at the University of Tokyo, one of the developers, on [Qiita](https://qiita.com/Ag_smith/items/fca48002fbdcb15145c0)(JP) and [the overview published on JSBi Bioinformatics Review](https://www.jstage.jst.go.jp/article/jsbibr/3/2/3_jsbibr.2022.3/_article/-char/ja/)(JP).


1. Access [ColabFold's GitHub repository](https://github.com/sokrypton/ColabFold) and launch Google Colaboratory's Notebooks from the "AlphaFold2_mmseq2" link. Please note that a Google account is required to use Google Colaboratory.
![image.png](https://github.com/noguhiro2002/xray_tutorial/blob/main/qiita_img/step_3/001.png?raw=true)

2\. The basic usage is as written in the opened Notebook. Input the sequence of Lysozyme in ```query_sequence```. Be careful not to insert any spaces in the sequence. Additionally, while it's optional, input a recognizable name in ```jobname```. Then, select ```Run all``` from ```Runtime``` to start the inference of the model structure. After processing, a zip file will be automatically downloaded. If a warning appears, select ```Run anyway```.
![image.png](https://github.com/noguhiro2002/xray_tutorial/blob/main/qiita_img/step_3/002.png?raw=true)

```text:Lysozyme_crystal.fasta
KVFGRCELAAAMKRHGLDNYRGYSLGNWVCAAKFESNFNTQATNRNTDGSTDYGILQINSRWWCNDGRTPGSRNLCNIPCSALLSSDITASVNCAKKIVSDGNGMNAWVAWRNRCKGTDVQAWIRGCRL
```

:::note info
The author has uploaded the Lysozyme model structure inferred using ColabFold [here](https://github.com/noguhiro2002/xray_tutorial/tree/main/tutorial_data/step_3/alphafold). Feel free to use it as needed.
:::


## Step 3-2: Determining Initial Phases via Molecular Replacement (MR)
Using the predicted model structure obtained from AlphaFold2, we will perform molecular replacement (MR).

### Step 3-2-1: MR with Structure Factors F(hkl) (Space Group: P41212)
1. Launch CCP4i, then select ```Data Reduction and Analysis``` --> ```Molecular Replacement``` from the menu on the left, and start the Molecular Replacement software, ```Molrep```.
```bash
$ ccp4i
```

![image.png](https://github.com/noguhiro2002/xray_tutorial/blob/main/qiita_img/step_3/003.png?raw=true)

2\. Refer to the image below and input the necessary fields in the opened Molrep window. For "Data", specify the structure factor F(hkl) finally obtained in Step 2 after scaling. For "Model", specify the protein model structure predicted in Step 3-1. "Solution" is automatically filled in, but you may specify an appropriate filename depending on the situation. Once the inputs are completed, select ```Run``` --> ```Run Now``` to start MR.
![image.png](https://github.com/noguhiro2002/xray_tutorial/blob/main/qiita_img/step_3/004.png?raw=true)

:::note info
Though the default settings of ColabFold output five predicted model structures, an appropriate one is used for MR.
:::

3\. Once the process is complete, the status changes to "FINISHED". Double-click on this item to view the log in the GUI. From there, click on the Log File tab to see the original log output from MOLREP. At this point, the focus should be on the TF/sg and Score columns in the "--- Summary (V2) ---" table (highlighted in red). **Generally, if the correct initial phase is obtained, both the TF/sg and Score will be significantly higher than the other solutions.**

![image.png](https://github.com/noguhiro2002/xray_tutorial/blob/main/qiita_img/step_3/005.png?raw=true)

:::note warn
The values in the TF/sg and Score columns of the MOLREP log are **not significantly higher** than the other values. Therefore, it is highly likely that an appropriate initial phase has not been obtained.
:::

4\. Even if the TF/sg and Score values from the MOLREP log suggest that it's unlikely that a suitable solution has been obtained, we will check the electron density map ρ(xyz) with our own eyes. To do so, we use the refinement software Refmac to perform one refinement and generate an electron density map ρ(xyz). From the CCP4i menu, select ```Refinement``` --> ```Run Refmac5``` to display the parameter input window for Refmac.
![image.png](https://github.com/noguhiro2002/xray_tutorial/blob/main/qiita_img/step_3/006.png?raw=true)

5\. Refer to the red arrow in the figure to input the necessary parameters. Then select ```Run``` --> ```Run Now``` to start Refmac.
![image.png](https://github.com/noguhiro2002/xray_tutorial/blob/main/qiita_img/step_3/007.png?raw=true)

6\. When Refmac's process has finished (FINISHED), double-click on that item and click the ```Coot``` button at the bottom of the displayed window to launch Coot, a protein structure and map viewer frequently used in this field.
![image.png](https://github.com/noguhiro2002/xray_tutorial/blob/main/qiita_img/step_3/008.png?raw=true)

After starting Coot, refer to the following video to check the electron density map ρ(xyz).
<iframe width="560" height="315" src="https://www.youtube.com/embed/mcmUpXP770k" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>

What you should pay attention to is the difference in electron density map ρ(xyz) between the solvent space between the sides of the lysozyme and the lysozyme itself when displaying the protein model as a whole (video: 2:00 ~). In the video, even when changing the visualization threshold of the electron density map ρ(xyz), it is difficult to distinguish between the two, giving the impression that the electron density map ρ(xyz) exists randomly. In this case, it is judged that a good initial phase has not been obtained.

<iframe width="560" height="315" src="https://www.youtube.com/embed/mcmUpXP770k?start=120" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>

:::note warn
Though it is empirical, generally, if the **density ratio of the electron density map between the protein model body and the surrounding solvent space is clear, it can be judged that a good initial phase has been obtained.**
:::

:::note info
The author has uploaded the results of Molrep and Refmac processing in the space group P41212 to [GitHub](https://github.com/noguhiro2002/xray_tutorial/tree/main/tutorial_data/step_3/). Feel free to refer to it as needed.
:::

### Step 3.2.2 Why the MR Method Did Not Work Well with the Structure Factor F(hkl) (Space Group: P41212)

In this tutorial, as in the case of successful Scaling ([refer to Step 2.5.2](https://qiita.com/noguhiro2002/items/542a93026e4c553b2889#step2-5-2-determining-resolution-and-format-conversion-using-ccp4-aimless)), it is likely that another space group belonging to the same Bravais lattice is the true space group. The structure factor $F(hkl)$ processed above was processed in the space group P41212, but this is reprocessed in the space group P43212 and the MR method is retried with Molrep.

:::note info
The Bravais lattice of the lysozyme crystal in this study is Primitive Tetragonal, and the space group P41212 was predicted by AIMLESS to belong to it. However, P41212 and P43212 both have extinction rules on the same helical axis, and it is extremely difficult to distinguish between them with only AIMLESS. In such cases, it is not uncommon for the space group to be undetermined until the initial phase (or even the final model structure) is determined, and a deep understanding of crystallography is required for determination. On the other hand, in today's era of improved computational power, a strategy of identifying the space group as "the space group that gives the best score in Molrep" can be considered effective.
:::

:::note info
For a more detailed explanation of the space groups of proteins, the article "Table of Possible Space Groups for Protein Crystals" by the Fukui Laboratory in the Department of Applied Biological Chemistry at the Graduate School of Agricultural and Life Sciences, The University of Tokyo, is very easy to understand, so please refer to it [here](http://enzyme13.bt.a.u-tokyo.ac.jp/sgroup.html) (JP).
:::

### Step 3.2.3 Obtaining the Structure Factor F(hkl) of Space Group P43212

1. Redo the Scaling in space group P43212 (refer to [Step 2.5.2](https://qiita.com/noguhiro2002/items/542a93026e4c553b2889#step2-5-2-determining-resolution-and-format-conversion-using-ccp4-aimless)). To shorten the input time of parameters, select AIMLESS (Scaled in P41212) in CCP4i's Status, select "Return aimless job" from the right-click menu to open the previous parameter input screen. Then, redo the Scaling at a resolution of 1.2Å and with the Space group name P43212, following the red arrow in the image below.

![image.png](https://github.com/noguhiro2002/xray_tutorial/blob/main/qiita_img/step_3/009.png?raw=true)

2\. As a result, the Completeness of the OuterShell was 56.6% at a resolution of 1.2Å in the space group P43212. Therefore, when I redid AIMLESS at a resolution of 1.3Å in space group P43212, the Completeness of the OuterShell was 89.4%, so the resolution was specified as 1.3Å, as was the case when processing in space group P41212.

![image.png](https://github.com/noguhiro2002/xray_tutorial/blob/main/qiita_img/step_3/010.png?raw=true)

### Step 3.2.4 MR Method Using Structure Factor F(hkl) (Space Group: P43212)

The MR method is carried out using the structure factor $F(hkl)$ in space group P43212, similar to [Step 3.2.1 MR Method Using Structure Factor F(hkl) in Space Group P41212](https://qiita.com/noguhiro2002/items/451b8207246ff932e279#step-3-2-1-mr-with-structure-factors-fhkl-space-group-p41212).


1. Open Molrep's parameter input window, as in [Step 3.2.1](https://qiita.com/noguhiro2002/items/451b8207246ff932e279#step-3-2-1-mr-with-structure-factors-fhkl-space-group-p41212), and run it using the structure factor $F(hkl)$ from the previous Scaling in space group P43212/resolution 1.3Å.
![image.png](https://github.com/noguhiro2002/xray_tutorial/blob/main/qiita_img/step_3/011.png?raw=true)

2\. Once Molrep's processing is finished, check its log. The results show that the TF/sq and Score in the second line of "Summary (V2)" are significantly higher than those in the third line, suggesting that Molrep could have found an appropriate initial phase.


![image.png](https://github.com/noguhiro2002/xray_tutorial/blob/main/qiita_img/step_3/012.png?raw=true)

3\. For verification, create an electron density map $\rho (xyz)$ using Refmac and take a look at it in Coot, similar to [Step 3.2.1](https://qiita.com/noguhiro2002/items/451b8207246ff932e279#step-3-2-1-mr-with-structure-factors-fhkl-space-group-p41212). Set the parameters in Refmac according to the image below and run the process.
![image.png](https://github.com/noguhiro2002/xray_tutorial/blob/main/qiita_img/step_3/013.png?raw=true)

In this run, the R-factor and R-free values (the lower, the better the match between the model structure and the structure factor $F(hkl)$) after refinement were about 40-41%. While these are lower than the 50% that indicates complete randomness, they are still somewhat uncertain for determining whether the initial phase is correct.
![image.png](https://github.com/noguhiro2002/xray_tutorial/blob/main/qiita_img/step_3/014.png?raw=true)

Like in [Step 3.2.1](https://qiita.com/noguhiro2002/items/451b8207246ff932e279#step-3-2-1-mr-with-structure-factors-fhkl-space-group-p41212), launch Coot from Refmac's Log Viewer and check the electron density map $\rho (xyz)$.

<iframe width="560" height="315" src="https://www.youtube.com/embed/rJJsH1DIW-w?start=0" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>

When displaying the whole protein model, look at the difference in electron density between the solvent space between adjacent Lysozymes and the Lysozyme itself (video: 1:02 ~). Even when changing the visualization threshold of the electron density map $\rho (xyz)$ in the video, it can be seen that the electron density maps of the two are distinguished more clearly than when in space group P41212. Therefore, it can be concluded that a high-quality initial phase has been obtained.

<iframe width="560" height="315" src="https://www.youtube.com/embed/rJJsH1DIW-w?start=62" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>

:::note info
Even if you can't make a distinction by visually examining the electron density map ρ(xyz), you can proceed to the structure refinement step and judge based on the values of the R-factor/R-free.
:::

:::note info
The author has uploaded the results of the Molrep and Refmac processes for the space group P43212 on [GitHub](https://github.com/noguhiro2002/xray_tutorial/tree/main/tutorial_data/step_3/). Please feel free to refer to these results.
:::



# Reference
- [CCP4 Data Collextion and Structure Solution Workshop 2022: Course Materials](https://www.ccp4.ac.uk/schools/DLS-2022/course_material.php)

# Conclusion
In this third tutorial of Protein X-ray Crystallography, we derived initial phases using AlphaFold2 and the Molecular Replacement method (MR method) from the structure factor F(hkl). In the final Step.4, we will conduct structure refinement and construct the model structure of Lysozyme.


# Table of Contents
- [Step.0 The flow of structure determination](https://qiita.com/noguhiro2002/items/31e3a915afce44166ba0)
- [Step.1 Installing analytical software](https://qiita.com/noguhiro2002/items/31e3a915afce44166ba0)
- [Step.2 Checking diffraction images and calculating structure factors](https://qiita.com/noguhiro2002/items/542a93026e4c553b2889)
- Step.3 Finding initial phases(This article)
- [Step.4 Structure refinement and validation](https://qiita.com/noguhiro2002/items/2eff5aec58dc4c76eaa9)