我尝试在python中解析以下XML:
<abstract>
<title>Abstract</title>
<p>Amphinomids, more commonly known as fireworms, are a basal lineage of marine annelids characterized by the presence of defensive dorsal calcareous chaetae, which break off upon contact. It has long been hypothesized that amphinomids are venomous and use the chaetae to inject a toxic substance. However, studies investigating fireworm venom from a morphological or molecular perspective are scarce and no venom gland has been identified to date, nor any toxin characterized at the molecular level. To investigate this question, we analyzed the transcriptomes of three species of fireworms—
<italic>Eurythoe complanata</italic>
,
<italic>Hermodice carunculata</italic>
, and
<italic>Paramphinome jeffreysii</italic>
—following a venomics approach to identify putative venom compounds. Our venomics pipeline involved de novo transcriptome assembly, open reading frame, and signal sequence prediction, followed by three different homology search strategies: BLAST, HMMER sequence, and HMMER domain. Following this pipeline, we identified 34 clusters of orthologous genes, representing 13 known toxin classes that have been repeatedly recruited into animal venoms. Specifically, the three species share a similar toxin profile with C-type lectins, peptidases, metalloproteinases, spider toxins, and CAP proteins found among the most highly expressed toxin homologs. Despite their great diversity, the putative toxins identified are predominantly involved in three major biological processes: hemostasis, inflammatory response, and allergic reactions, all of which are commonly disrupted after fireworm stings. Although the putative fireworm toxins identified here need to be further validated, our results strongly suggest that fireworms are venomous animals that use a complex mixture of toxins for defense against predators.
</p>
</abstract>我试图检索<abstract>节点之间的所有文本,包括子节点。我可以迭代到节点并得到文本,但是迭代在‘最深节点’处停止:
import xml.etree.ElementTree as ET
resXML = ET.fromstring(response)
abstract = resXML.find(".//abstract").iter()
for section in abstract:
print section.text
> Abstract
> Amphinomids, more commonly known as fireworms, are a basal
> lineage of marine annelids characterized by the presence of defensive
> dorsal calcareous chaetae, which break off upon contact. It has long
> been hypothesized that amphinomids are venomous and use the chaetae to
> inject a toxic substance. However, studies investigating fireworm
> venom from a morphological or molecular perspective are scarce and no
> venom gland has been identified to date, nor any toxin characterized
> at the molecular level. To investigate this question, we analyzed the
> transcriptomes of three species of fireworms—
> Eurythoe complanata
> Hermodice carunculata
> Paramphinome jeffreysii显然我的方法不太好。我没有得到斜体物种之间的逗号或段落的其余部分:'-following a venomics...'
如何迭代所选节点下的所有节点?
发布于 2018-02-01 10:52:24
在ElementTree模型中,元素后面的文本节点存储为该元素的尾,而不是父元素的text。因此,除了section.text之外,还需要查看section.tail:
>>> section in abstract:
... print section.text.strip()
... if section.tail:
... print section.tail.strip()
...
Abstract
Amphinomids, more commonly known as fireworms, are a basal lineage of marine annelids characterized by the presence of defensive dorsal calcareous chaetae, which break off upon contact. It has long been hypothesized that amphinomids are venomous and use the chaetae to inject a toxic substance. However, studies investigating fireworm venom from a morphological or molecular perspective are scarce and no venom gland has been identified to date, nor any toxin characterized at the molecular level. To investigate this question, we analyzed the transcriptomes of three species of fireworms—
Eurythoe complanata
,
Hermodice carunculata
, and
Paramphinome jeffreysii
—following a venomics approach to identify putative venom compounds. Our venomics pipeline involved de novo transcriptome assembly, open reading frame, and signal sequence prediction, followed by three different homology search strategies: BLAST, HMMER sequence, and HMMER domain. Following this pipeline, we identified 34 clusters of orthologous genes, representing 13 known toxin classes that have been repeatedly recruited into animal venoms. Specifically, the three species share a similar toxin profile with C-type lectins, peptidases, metalloproteinases, spider toxins, and CAP proteins found among the most highly expressed toxin homologs. Despite their great diversity, the putative toxins identified are predominantly involved in three major biological processes: hemostasis, inflammatory response, and allergic reactions, all of which are commonly disrupted after fireworm stings. Although the putative fireworm toxins identified here need to be further validated, our results strongly suggest that fireworms are venomous animals that use a complex mixture of toxins for defense against predators.https://stackoverflow.com/questions/48560703
复制相似问题