Ejemplo n.º 1
0
 def other(self, elem, namespace, localtag):
     return PX.Other(localtag,
                     namespace,
                     elem.attrib,
                     value=elem.text and elem.text.strip() or None,
                     children=[
                         self.other(child, *_split_namespace(child.tag))
                         for child in elem
                     ])
Ejemplo n.º 2
0
 def other(self, elem, namespace, localtag):
     """Create an Other object, a non-phyloXML element."""
     return PX.Other(localtag,
                     namespace,
                     elem.attrib,
                     value=elem.text and elem.text.strip() or None,
                     children=[
                         self.other(child, *_split_namespace(child.tag))
                         for child in elem
                     ])
Ejemplo n.º 3
0
def main():
    ##################### get parser ###############################
    parser = get_parser()

    ######## Print parser help if arguments missed #################
    if len(sys.argv) == 1:
        parser.print_help()
        sys.exit(1)

    ########### Manage workflow accorded to Args  ##################
    Arguments = parser.parse_args()

    # parser = etree.XMLParser(remove_blank_text=True)
    # xmlfile = Arguments.xml
    # tree = etree.ElementTree()
    # tree =etree.parse(xmlfile,parser)
    # print tree
    # root = tree.getroot()
    # print root
    # test = root.xpath("phylogeny")
    # print test
    # for var in test :
    # 	toto = var.findall("clade")[0]
    # 	print toto.text
    # 	print var

    tree = Phylo.read("jpp2.xml", 'phyloxml')

    for clade in tree.find_clades(name=True):
        clade.other = [
            PhyloXML.Other(tag="annotation",
                           namespace="",
                           children=[
                               PhyloXML.Other('desc', value='youpi'),
                               PhyloXML.Other('uri', value='http://lol.com')
                           ])
        ]
        clade.annotation = PhyloXML.Annotation(desc="youpi",
                                               uri="http://lol.com")

    Phylo.write(tree, "jpp.xml", 'phyloxml')