<p>The <code>/label=5'ITR</code> is called a <strong>qualifier</strong>. You can look for those qualifiers:</p>

<pre><code>for feature in reference.features:
    for k, v in feature.qualifiers.items():
        if k == "label" and v == ["5' ITR"]:  # or "5' ITR" in v
            print(feature.location)
</code></pre>

CC BY-SA 4.0
2019-09-20T12:33:30.573Z
2019-09-21T12:23:30.507Z
2019-09-21T12:23:30.507Z
xbello
<p>I'm trying to parse a Genbank file to find a specific feature. I can pull it out if I know the feature type (e.g. repeat_region). E.g. if I'm looking for this feature:</p>

<pre><code> repeat_region   5623..5756
                 /label=5' ITR
                 /note="5' ITR"
</code></pre>

<p>I know that I can find it using:</p>

<pre><code>for feature in reference.features:
    if feature.type == "repeat_region":
        print(feature.location)
</code></pre>

<p>But I don't trust that it will always be a repeat_region. Instead, I'd like to look for it by label (5' ITR). I can seem to find a way to parse that from the feature object. Any suggestions?</p>

<python><genbank>
Parsing specific features from Genbank by label?
# Parsing specific features from Genbank by label?

(Asked by: username_0 on 2019-09-17)

I'm trying to parse a Genbank file to find a specific feature. I can pull it out if I know the feature type (e.g. repeat_region). E.g. if I'm looking for this feature:
 repeat_region   5623..5756
                 /label=5' ITR
                 /note="5' ITR"

I know that I can find it using:
for feature in reference.features:
    if feature.type == "repeat_region":
        print(feature.location)

But I don't trust that it will always be a repeat_region. Instead, I'd like to look for it by label (5' ITR). I can seem to find a way to parse that from the feature object. Any suggestions?

**Tags:** python, genbank

---

## 1 answers

### Answer by username_1 on 2019-09-20. Score: 1

The /label=5'ITR is called a qualifier. You can look for those qualifiers:
for feature in reference.features:
    for k, v in feature.qualifiers.items():
        if k == "label" and v == ["5' ITR"]:  # or "5' ITR" in v
            print(feature.location)


---

