-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplotfsc.py
More file actions
41 lines (34 loc) · 1.1 KB
/
plotfsc.py
File metadata and controls
41 lines (34 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python3
"""
Plot FSC
Author: Ryan Feathers jrf296
Date: 01/09/2023
Generate an FSC plot in EPS format from a relion postprocess XML file
"""
import argparse
import matplotlib.pyplot as plt
import xml.etree.ElementTree as ET
# Set up the argument parser
parser = argparse.ArgumentParser()
parser.add_argument('--i', help='XML file containing the data')
parser.add_argument('--o', help='Output file for the plot')
args = parser.parse_args()
# Parse the XML file and extract the values
root = ET.parse(args.i).getroot()
resolution = []
correlation = []
for coordinate in root.findall('coordinate'):
resolution.append(float(coordinate.find('x').text))
correlation.append(float(coordinate.find('y').text))
# Generate the FSC plot
fig, ax = plt.subplots()
ax.plot(resolution, correlation)
# Add the horizontal dashed lines
ax.axhline(y=0.143, linestyle='--', color='green')
ax.axhline(y=0.5, linestyle='--', color='red')
# Set the axis labels
ax.set_xlabel('Resolution (1/Å)')
ax.set_ylabel('Correlation Coefficient')
ax.set_ylim(-0.1, 1.1)
# Save the plot in EPS format
fig.savefig(args.o, format='eps')