Created
May 14, 2024 00:40
-
-
Save carleen/3364a42472618f42ae025872b2a869ae to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import xml.etree.ElementTree as ET | |
import numpy as np | |
''' | |
XML file has tag called "reactivity". Take value from "reactivity" | |
and put it into a variable (list) | |
Set NaN values to 0 | |
''' | |
filename = 'HCV_IRES_IVT_RNA_0mg_DMS1.xml' | |
tree = ET.parse(filename) | |
root = tree.getroot() | |
for reactivity_tag in root.iter('reactivity'): | |
# Get the text string from the xml file | |
reactivity_string = reactivity_tag.text | |
# Separate the string by commas | |
reactive_list = [i.strip()for i in reactivity_string.split(',')] | |
# Convert to numpy array | |
reactive_list = np.array(reactive_list) | |
reactive_list = reactive_list.astype(float) | |
reactive_list[np.isnan(reactive_list)] = 0 | |
print(reactive_list) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment