Help with these tasks
Help with problem 1
- Use the example code as a starting point
- Look at the XML while you are developing the Python code - your Python
should mirror the structure of the XML
- First of all you want to grab the
<mutant_group> elements with
.getElementsByTagName('mutant_group')
- For each <mutant_group>, you must grab the
<native_structure> element and since there is only
one of these, use .item(0) or [0] to get
that first (and only) one
- From this, use
.getElementsByTagName('resolution') to extract the
<resolution> tags
- Again, there is only one, so get that one using
.item(0); or [0]
- Extract the first child from that using
.getFirstChild and convert it to a value using
.data
- If the value is ≤2.0, then extract the 'native' attribute from
the <mutant_group> and print its value together
with the resolution
Help with problem 2
- Use the example code as a starting point
- Start by extracting the <mutant_group>
elements
- For each <mutant_group>, extract the 'native'
attribute
- If the native attribute has the value '1eugA0' then...
- Use .getElementsByTagName('mutant') on the
<mutant_group> to extract all the mutant elements
and work through each of them
- Extract the value of the 'domid' attribute for the
<mutant> element
- Obtain the first (and only) <structure> element
from the <mutant> element using
.getElementsByTagName('structure').item(0)
or .getElementsByTagName('structure').[0]
- Obtain the first (and only) <resolution>
element from the <structure> element using
.getElementsByTagName('resolution').item(0)
or .getElementsByTagName('resolution')[0]
- Obtain the value of the resolution from this by using
.getFirstChild.data
- Get the first (and only) <mutation> element
from the <mutant> element by using
.getElementsByTagName('mutation').item(0)
or .getElementsByTagName('mutation')[0]
- From the <mutation> element, get the values for
the three attributes
- Print the values as required.