1#!/usr/local/bin/python3.8
2# -*- coding: utf-8 -*-
3# #START_LICENSE###########################################################
4#
5#
6# This file is part of the Environment for Tree Exploration program
7# (ETE).  http://etetoolkit.org
8#
9# ETE is free software: you can redistribute it and/or modify it
10# under the terms of the GNU General Public License as published by
11# the Free Software Foundation, either version 3 of the License, or
12# (at your option) any later version.
13#
14# ETE is distributed in the hope that it will be useful, but WITHOUT
15# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
17# License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with ETE.  If not, see <http://www.gnu.org/licenses/>.
21#
22#
23#                     ABOUT THE ETE PACKAGE
24#                     =====================
25#
26# ETE is distributed under the GPL copyleft license (2008-2015).
27#
28# If you make use of ETE in published work, please cite:
29#
30# Jaime Huerta-Cepas, Joaquin Dopazo and Toni Gabaldon.
31# ETE: a python Environment for Tree Exploration. Jaime BMC
32# Bioinformatics 2010,:24doi:10.1186/1471-2105-11-24
33#
34# Note that extra references to the specific methods implemented in
35# the toolkit may be available in the documentation.
36#
37# More info at http://etetoolkit.org. Contact: huerta@embl.de
38#
39#
40# #END_LICENSE#############################################################
41from __future__ import absolute_import
42from __future__ import print_function
43
44#
45# Generated Mon Jun 27 10:13:44 2011 by generateDS.py version 2.5b.
46#
47
48import sys
49import getopt
50import re as re_
51import six
52from six.moves import range
53
54etree_ = None
55Verbose_import_ = False
56(   XMLParser_import_none, XMLParser_import_lxml,
57    XMLParser_import_elementtree
58    ) = list(range(3))
59XMLParser_import_library = None
60try:
61    # lxml
62    from lxml import etree as etree_
63    XMLParser_import_library = XMLParser_import_lxml
64    if Verbose_import_:
65        print("running with lxml.etree")
66except ImportError:
67    try:
68        # cElementTree from Python 2.5+
69        import xml.etree.cElementTree as etree_
70        XMLParser_import_library = XMLParser_import_elementtree
71        if Verbose_import_:
72            print("running with cElementTree on Python 2.5+")
73    except ImportError:
74        try:
75            # ElementTree from Python 2.5+
76            import xml.etree.ElementTree as etree_
77            XMLParser_import_library = XMLParser_import_elementtree
78            if Verbose_import_:
79                print("running with ElementTree on Python 2.5+")
80        except ImportError:
81            try:
82                # normal cElementTree install
83                import cElementTree as etree_
84                XMLParser_import_library = XMLParser_import_elementtree
85                if Verbose_import_:
86                    print("running with cElementTree")
87            except ImportError:
88                try:
89                    # normal ElementTree install
90                    import elementtree.ElementTree as etree_
91                    XMLParser_import_library = XMLParser_import_elementtree
92                    if Verbose_import_:
93                        print("running with ElementTree")
94                except ImportError:
95                    raise ImportError("Failed to import ElementTree from any known place")
96
97def parsexml_(*args, **kwargs):
98    if (XMLParser_import_library == XMLParser_import_lxml and
99        'parser' not in kwargs):
100        # Use the lxml ElementTree compatible parser so that, e.g.,
101        #   we ignore comments.
102        kwargs['parser'] = etree_.ETCompatXMLParser()
103    doc = etree_.parse(*args, **kwargs)
104    return doc
105
106#
107# User methods
108#
109# Calls to the methods in these classes are generated by generateDS.py.
110# You can replace these methods by re-implementing the following class
111#   in a module named generatedssuper.py.
112
113try:
114    from generatedssuper import GeneratedsSuper
115except ImportError as exp:
116
117    class GeneratedsSuper(object):
118        def gds_format_string(self, input_data, input_name=''):
119            return input_data
120        def gds_validate_string(self, input_data, node, input_name=''):
121            return input_data
122        def gds_format_integer(self, input_data, input_name=''):
123            return '%d' % input_data
124        def gds_validate_integer(self, input_data, node, input_name=''):
125            return input_data
126        def gds_format_integer_list(self, input_data, input_name=''):
127            return '%s' % input_data
128        def gds_validate_integer_list(self, input_data, node, input_name=''):
129            values = input_data.split()
130            for value in values:
131                try:
132                    fvalue = float(value)
133                except (TypeError, ValueError) as exp:
134                    raise_parse_error(node, 'Requires sequence of integers')
135            return input_data
136        def gds_format_float(self, input_data, input_name=''):
137            return '%f' % input_data
138        def gds_validate_float(self, input_data, node, input_name=''):
139            return input_data
140        def gds_format_float_list(self, input_data, input_name=''):
141            return '%s' % input_data
142        def gds_validate_float_list(self, input_data, node, input_name=''):
143            values = input_data.split()
144            for value in values:
145                try:
146                    fvalue = float(value)
147                except (TypeError, ValueError) as exp:
148                    raise_parse_error(node, 'Requires sequence of floats')
149            return input_data
150        def gds_format_double(self, input_data, input_name=''):
151            return '%e' % input_data
152        def gds_validate_double(self, input_data, node, input_name=''):
153            return input_data
154        def gds_format_double_list(self, input_data, input_name=''):
155            return '%s' % input_data
156        def gds_validate_double_list(self, input_data, node, input_name=''):
157            values = input_data.split()
158            for value in values:
159                try:
160                    fvalue = float(value)
161                except (TypeError, ValueError) as exp:
162                    raise_parse_error(node, 'Requires sequence of doubles')
163            return input_data
164        def gds_format_boolean(self, input_data, input_name=''):
165            return '%s' % input_data
166        def gds_validate_boolean(self, input_data, node, input_name=''):
167            return input_data
168        def gds_format_boolean_list(self, input_data, input_name=''):
169            return '%s' % input_data
170        def gds_validate_boolean_list(self, input_data, node, input_name=''):
171            values = input_data.split()
172            for value in values:
173                if value not in ('true', '1', 'false', '0', ):
174                    raise_parse_error(node, 'Requires sequence of booleans ("true", "1", "false", "0")')
175            return input_data
176        def gds_str_lower(self, instring):
177            return instring.lower()
178        def get_path_(self, node):
179            path_list = []
180            self.get_path_list_(node, path_list)
181            path_list.reverse()
182            path = '/'.join(path_list)
183            return path
184        Tag_strip_pattern_ = re_.compile(r'\{.*\}')
185        def get_path_list_(self, node, path_list):
186            if node is None:
187                return
188            tag = GeneratedsSuper.Tag_strip_pattern_.sub('', node.tag)
189            if tag:
190                path_list.append(tag)
191            self.get_path_list_(node.getparent(), path_list)
192
193
194#
195# If you have installed IPython you can uncomment and use the following.
196# IPython is available from http://ipython.scipy.org/.
197#
198
199## from IPython.Shell import IPShellEmbed
200## args = ''
201## ipshell = IPShellEmbed(args,
202##     banner = 'Dropping into IPython',
203##     exit_msg = 'Leaving Interpreter, back to program.')
204
205# Then use the following line where and when you want to drop into the
206# IPython shell:
207#    ipshell('<some message> -- Entering ipshell.\nHit Ctrl-D to exit')
208
209#
210# Globals
211#
212
213ExternalEncoding = 'utf-8'
214Tag_pattern_ = re_.compile(r'({.*})?(.*)')
215STRING_CLEANUP_PAT = re_.compile(r"[\n\r\s]+")
216
217#
218# Support/utility functions.
219#
220
221def showIndent(outfile, level):
222    for idx in range(level):
223        outfile.write('    ')
224
225def quote_xml(inStr):
226    if not inStr:
227        return ''
228    s1 = (isinstance(inStr, six.string_types) and inStr or
229          '%s' % inStr)
230    s1 = s1.replace('&', '&amp;')
231    s1 = s1.replace('<', '&lt;')
232    s1 = s1.replace('>', '&gt;')
233    return s1
234
235def quote_attrib(inStr):
236    s1 = (isinstance(inStr, six.string_types) and inStr or
237          '%s' % inStr)
238    s1 = s1.replace('&', '&amp;')
239    s1 = s1.replace('<', '&lt;')
240    s1 = s1.replace('>', '&gt;')
241    if '"' in s1:
242        if "'" in s1:
243            s1 = '"%s"' % s1.replace('"', "&quot;")
244        else:
245            s1 = "'%s'" % s1
246    else:
247        s1 = '"%s"' % s1
248    return s1
249
250def quote_python(inStr):
251    s1 = inStr
252    if s1.find("'") == -1:
253        if s1.find('\n') == -1:
254            return "'%s'" % s1
255        else:
256            return "'''%s'''" % s1
257    else:
258        if s1.find('"') != -1:
259            s1 = s1.replace('"', '\\"')
260        if s1.find('\n') == -1:
261            return '"%s"' % s1
262        else:
263            return '"""%s"""' % s1
264
265def get_all_text_(node):
266    if node.text is not None:
267        text = node.text
268    else:
269        text = ''
270    for child in node:
271        if child.tail is not None:
272            text += child.tail
273    return text
274
275def find_attr_value_(attr_name, node):
276    attrs = node.attrib
277    # First try with no namespace.
278    value = attrs.get(attr_name)
279    if value is None:
280        # Now try the other possible namespaces.
281        namespaces = six.itervalues(node.nsmap)
282        for namespace in namespaces:
283            value = attrs.get('{%s}%s' % (namespace, attr_name, ))
284            if value is not None:
285                break
286    return value
287
288
289class GDSParseError(Exception):
290    pass
291
292def raise_parse_error(node, msg):
293    if XMLParser_import_library == XMLParser_import_lxml:
294        msg = '%s (element %s/line %d)' % (msg, node.tag, node.sourceline, )
295    else:
296        msg = '%s (element %s)' % (msg, node.tag, )
297    raise GDSParseError(msg)
298
299
300class MixedContainer:
301    # Constants for category:
302    CategoryNone = 0
303    CategoryText = 1
304    CategorySimple = 2
305    CategoryComplex = 3
306    # Constants for content_type:
307    TypeNone = 0
308    TypeText = 1
309    TypeString = 2
310    TypeInteger = 3
311    TypeFloat = 4
312    TypeDecimal = 5
313    TypeDouble = 6
314    TypeBoolean = 7
315    def __init__(self, category, content_type, name, value):
316        self.category = category
317        self.content_type = content_type
318        self.name = name
319        self.value = value
320    def getCategory(self):
321        return self.category
322    def getContenttype(self, content_type):
323        return self.content_type
324    def getValue(self):
325        return self.value
326    def getName(self):
327        return self.name
328    def export(self, outfile, level, name, namespace):
329        if self.category == MixedContainer.CategoryText:
330            # Prevent exporting empty content as empty lines.
331            if self.value.strip():
332                outfile.write(self.value)
333        elif self.category == MixedContainer.CategorySimple:
334            self.exportSimple(outfile, level, name)
335        else:    # category == MixedContainer.CategoryComplex
336            self.value.export(outfile, level, namespace,name)
337    def exportSimple(self, outfile, level, name):
338        if self.content_type == MixedContainer.TypeString:
339            outfile.write('<%s>%s</%s>' % (self.name, self.value, self.name))
340        elif self.content_type == MixedContainer.TypeInteger or \
341                self.content_type == MixedContainer.TypeBoolean:
342            outfile.write('<%s>%d</%s>' % (self.name, self.value, self.name))
343        elif self.content_type == MixedContainer.TypeFloat or \
344                self.content_type == MixedContainer.TypeDecimal:
345            outfile.write('<%s>%f</%s>' % (self.name, self.value, self.name))
346        elif self.content_type == MixedContainer.TypeDouble:
347            outfile.write('<%s>%g</%s>' % (self.name, self.value, self.name))
348    def exportLiteral(self, outfile, level, name):
349        if self.category == MixedContainer.CategoryText:
350            showIndent(outfile, level)
351            outfile.write('model_.MixedContainer(%d, %d, "%s", "%s"),\n' % \
352                (self.category, self.content_type, self.name, self.value))
353        elif self.category == MixedContainer.CategorySimple:
354            showIndent(outfile, level)
355            outfile.write('model_.MixedContainer(%d, %d, "%s", "%s"),\n' % \
356                (self.category, self.content_type, self.name, self.value))
357        else:    # category == MixedContainer.CategoryComplex
358            showIndent(outfile, level)
359            outfile.write('model_.MixedContainer(%d, %d, "%s",\n' % \
360                (self.category, self.content_type, self.name,))
361            self.value.exportLiteral(outfile, level + 1)
362            showIndent(outfile, level)
363            outfile.write(')\n')
364
365
366class MemberSpec_(object):
367    def __init__(self, name='', data_type='', container=0):
368        self.name = name
369        self.data_type = data_type
370        self.container = container
371    def set_name(self, name): self.name = name
372    def get_name(self): return self.name
373    def set_data_type(self, data_type): self.data_type = data_type
374    def get_data_type_chain(self): return self.data_type
375    def get_data_type(self):
376        if isinstance(self.data_type, list):
377            if len(self.data_type) > 0:
378                return self.data_type[-1]
379            else:
380                return 'xs:string'
381        else:
382            return self.data_type
383    def set_container(self, container): self.container = container
384    def get_container(self): return self.container
385
386def _cast(typ, value):
387    if typ is None or value is None:
388        return value
389    return typ(value)
390
391#
392# Data representation classes.
393#
394
395class Phyloxml(GeneratedsSuper):
396    """'phyloxml' is the name of the root element. Phyloxml contains an
397    arbitrary number of 'phylogeny' elements (each representing one
398    phylogeny) possibly followed by elements from other namespaces."""
399    subclass = None
400    superclass = None
401    def __init__(self, phylogeny=None, valueOf_=None):
402        if phylogeny is None:
403            self.phylogeny = []
404        else:
405            self.phylogeny = phylogeny
406    def factory(*args_, **kwargs_):
407        if Phyloxml.subclass:
408            return Phyloxml.subclass(*args_, **kwargs_)
409        else:
410            return Phyloxml(*args_, **kwargs_)
411    factory = staticmethod(factory)
412    def get_phylogeny(self): return self.phylogeny
413    def set_phylogeny(self, phylogeny): self.phylogeny = phylogeny
414    def add_phylogeny(self, value): self.phylogeny.append(value)
415    def insert_phylogeny(self, index, value): self.phylogeny[index] = value
416    def export(self, outfile, level, namespace_='phy:', name_='Phyloxml', namespacedef_=''):
417        showIndent(outfile, level)
418        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
419        already_processed = []
420        self.exportAttributes(outfile, level, already_processed, namespace_, name_='Phyloxml')
421        if self.hasContent_():
422            outfile.write('>\n')
423            self.exportChildren(outfile, level + 1, namespace_, name_)
424            showIndent(outfile, level)
425            outfile.write('</%s%s>\n' % (namespace_, name_))
426        else:
427            outfile.write('/>\n')
428    def exportAttributes(self, outfile, level, already_processed, namespace_='phy:', name_='Phyloxml'):
429        pass
430    def exportChildren(self, outfile, level, namespace_='phy:', name_='Phyloxml', fromsubclass_=False):
431        for phylogeny_ in self.phylogeny:
432            phylogeny_.export(outfile, level, namespace_, name_='phylogeny')
433    def hasContent_(self):
434        if (
435            self.phylogeny
436            ):
437            return True
438        else:
439            return False
440    def exportLiteral(self, outfile, level, name_='Phyloxml'):
441        level += 1
442        self.exportLiteralAttributes(outfile, level, [], name_)
443        if self.hasContent_():
444            self.exportLiteralChildren(outfile, level, name_)
445    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
446        pass
447    def exportLiteralChildren(self, outfile, level, name_):
448        showIndent(outfile, level)
449        outfile.write('phylogeny=[\n')
450        level += 1
451        for phylogeny_ in self.phylogeny:
452            showIndent(outfile, level)
453            outfile.write('model_.Phylogeny(\n')
454            phylogeny_.exportLiteral(outfile, level, name_='Phylogeny')
455            showIndent(outfile, level)
456            outfile.write('),\n')
457        level -= 1
458        showIndent(outfile, level)
459        outfile.write('],\n')
460    def build(self, node):
461        self.buildAttributes(node, node.attrib, [])
462        for child in node:
463            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
464            self.buildChildren(child, node, nodeName_)
465    def buildAttributes(self, node, attrs, already_processed):
466        pass
467    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
468        if nodeName_ == 'phylogeny':
469            obj_ = Phylogeny.factory()
470            obj_.build(child_)
471            self.phylogeny.append(obj_)
472# end class Phyloxml
473
474
475class Phylogeny(GeneratedsSuper):
476    """Element Phylogeny is used to represent a phylogeny. The required
477    attribute 'rooted' is used to indicate whether the phylogeny is
478    rooted or not. The attribute 'rerootable' can be used to
479    indicate that the phylogeny is not allowed to be rooted
480    differently (i.e. because it is associated with root dependent
481    data, such as gene duplications). The attribute 'type' can be
482    used to indicate the type of phylogeny (i.e. 'gene tree'). It is
483    recommended to use the attribute 'branch_length_unit' if the
484    phylogeny has branch lengths. Element clade is used in a
485    recursive manner to describe the topology of a phylogenetic
486    tree."""
487    subclass = None
488    superclass = None
489    def __init__(self, rerootable=None, branch_length_unit=None, type_=None, rooted=None, name=None, id=None, description=None, date=None, confidence=None, clade=None, clade_relation=None, sequence_relation=None, property=None, valueOf_=None):
490        self.rerootable = _cast(bool, rerootable)
491        self.branch_length_unit = _cast(None, branch_length_unit)
492        self.type_ = _cast(None, type_)
493        self.rooted = _cast(bool, rooted)
494        self.name = name
495        self.id = id
496        self.description = description
497        self.date = date
498        if confidence is None:
499            self.confidence = []
500        else:
501            self.confidence = confidence
502        self.clade = clade
503        if clade_relation is None:
504            self.clade_relation = []
505        else:
506            self.clade_relation = clade_relation
507        if sequence_relation is None:
508            self.sequence_relation = []
509        else:
510            self.sequence_relation = sequence_relation
511        if property is None:
512            self.property = []
513        else:
514            self.property = property
515    def factory(*args_, **kwargs_):
516        if Phylogeny.subclass:
517            return Phylogeny.subclass(*args_, **kwargs_)
518        else:
519            return Phylogeny(*args_, **kwargs_)
520    factory = staticmethod(factory)
521    def get_name(self): return self.name
522    def set_name(self, name): self.name = name
523    def get_id(self): return self.id
524    def set_id(self, id): self.id = id
525    def get_description(self): return self.description
526    def set_description(self, description): self.description = description
527    def get_date(self): return self.date
528    def set_date(self, date): self.date = date
529    def get_confidence(self): return self.confidence
530    def set_confidence(self, confidence): self.confidence = confidence
531    def add_confidence(self, value): self.confidence.append(value)
532    def insert_confidence(self, index, value): self.confidence[index] = value
533    def get_clade(self): return self.clade
534    def set_clade(self, clade): self.clade = clade
535    def get_clade_relation(self): return self.clade_relation
536    def set_clade_relation(self, clade_relation): self.clade_relation = clade_relation
537    def add_clade_relation(self, value): self.clade_relation.append(value)
538    def insert_clade_relation(self, index, value): self.clade_relation[index] = value
539    def get_sequence_relation(self): return self.sequence_relation
540    def set_sequence_relation(self, sequence_relation): self.sequence_relation = sequence_relation
541    def add_sequence_relation(self, value): self.sequence_relation.append(value)
542    def insert_sequence_relation(self, index, value): self.sequence_relation[index] = value
543    def get_property(self): return self.property
544    def set_property(self, property): self.property = property
545    def add_property(self, value): self.property.append(value)
546    def insert_property(self, index, value): self.property[index] = value
547    def get_rerootable(self): return self.rerootable
548    def set_rerootable(self, rerootable): self.rerootable = rerootable
549    def get_branch_length_unit(self): return self.branch_length_unit
550    def set_branch_length_unit(self, branch_length_unit): self.branch_length_unit = branch_length_unit
551    def get_type(self): return self.type_
552    def set_type(self, type_): self.type_ = type_
553    def get_rooted(self): return self.rooted
554    def set_rooted(self, rooted): self.rooted = rooted
555    def export(self, outfile, level, namespace_='phy:', name_='Phylogeny', namespacedef_=''):
556        showIndent(outfile, level)
557        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
558        already_processed = []
559        self.exportAttributes(outfile, level, already_processed, namespace_, name_='Phylogeny')
560        if self.hasContent_():
561            outfile.write('>\n')
562            self.exportChildren(outfile, level + 1, namespace_, name_)
563            showIndent(outfile, level)
564            outfile.write('</%s%s>\n' % (namespace_, name_))
565        else:
566            outfile.write('/>\n')
567    def exportAttributes(self, outfile, level, already_processed, namespace_='phy:', name_='Phylogeny'):
568        if self.rerootable is not None and 'rerootable' not in already_processed:
569            already_processed.append('rerootable')
570            outfile.write(' rerootable="%s"' % self.gds_format_boolean(self.gds_str_lower(str(self.rerootable)), input_name='rerootable'))
571        if self.branch_length_unit is not None and 'branch_length_unit' not in already_processed:
572            already_processed.append('branch_length_unit')
573            outfile.write(' branch_length_unit=%s' % (self.gds_format_string(quote_attrib(self.branch_length_unit).encode(ExternalEncoding), input_name='branch_length_unit'), ))
574        if self.type_ is not None and 'type_' not in already_processed:
575            already_processed.append('type_')
576            outfile.write(' type=%s' % (self.gds_format_string(quote_attrib(self.type_).encode(ExternalEncoding), input_name='type'), ))
577        if self.rooted is not None and 'rooted' not in already_processed:
578            already_processed.append('rooted')
579            outfile.write(' rooted="%s"' % self.gds_format_boolean(self.gds_str_lower(str(self.rooted)), input_name='rooted'))
580    def exportChildren(self, outfile, level, namespace_='phy:', name_='Phylogeny', fromsubclass_=False):
581        if self.name is not None:
582            showIndent(outfile, level)
583            outfile.write('<%sname>%s</%sname>\n' % (namespace_, self.gds_format_string(quote_xml(self.name).encode(ExternalEncoding), input_name='name'), namespace_))
584        if self.id:
585            self.id.export(outfile, level, namespace_, name_='id')
586        if self.description is not None:
587            showIndent(outfile, level)
588            outfile.write('<%sdescription>%s</%sdescription>\n' % (namespace_, self.gds_format_string(quote_xml(self.description).encode(ExternalEncoding), input_name='description'), namespace_))
589        if self.date is not None:
590            showIndent(outfile, level)
591            outfile.write('<%sdate>%s</%sdate>\n' % (namespace_, self.gds_format_string(quote_xml(self.date).encode(ExternalEncoding), input_name='date'), namespace_))
592        for confidence_ in self.confidence:
593            confidence_.export(outfile, level, namespace_, name_='confidence')
594        if self.clade:
595            self.clade.export(outfile, level, namespace_, name_='clade')
596        for clade_relation_ in self.clade_relation:
597            clade_relation_.export(outfile, level, namespace_, name_='clade_relation')
598        for sequence_relation_ in self.sequence_relation:
599            sequence_relation_.export(outfile, level, namespace_, name_='sequence_relation')
600        for property_ in self.property:
601            property_.export(outfile, level, namespace_, name_='property')
602    def hasContent_(self):
603        if (
604            self.name is not None or
605            self.id is not None or
606            self.description is not None or
607            self.date is not None or
608            self.confidence or
609            self.clade is not None or
610            self.clade_relation or
611            self.sequence_relation or
612            self.property
613            ):
614            return True
615        else:
616            return False
617    def exportLiteral(self, outfile, level, name_='Phylogeny'):
618        level += 1
619        self.exportLiteralAttributes(outfile, level, [], name_)
620        if self.hasContent_():
621            self.exportLiteralChildren(outfile, level, name_)
622    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
623        if self.rerootable is not None and 'rerootable' not in already_processed:
624            already_processed.append('rerootable')
625            showIndent(outfile, level)
626            outfile.write('rerootable = %s,\n' % (self.rerootable,))
627        if self.branch_length_unit is not None and 'branch_length_unit' not in already_processed:
628            already_processed.append('branch_length_unit')
629            showIndent(outfile, level)
630            outfile.write('branch_length_unit = "%s",\n' % (self.branch_length_unit,))
631        if self.type_ is not None and 'type_' not in already_processed:
632            already_processed.append('type_')
633            showIndent(outfile, level)
634            outfile.write('type_ = "%s",\n' % (self.type_,))
635        if self.rooted is not None and 'rooted' not in already_processed:
636            already_processed.append('rooted')
637            showIndent(outfile, level)
638            outfile.write('rooted = %s,\n' % (self.rooted,))
639    def exportLiteralChildren(self, outfile, level, name_):
640        if self.name is not None:
641            showIndent(outfile, level)
642            outfile.write('name=%s,\n' % quote_python(self.name).encode(ExternalEncoding))
643        if self.id is not None:
644            showIndent(outfile, level)
645            outfile.write('id=model_.Id(\n')
646            self.id.exportLiteral(outfile, level, name_='id')
647            showIndent(outfile, level)
648            outfile.write('),\n')
649        if self.description is not None:
650            showIndent(outfile, level)
651            outfile.write('description=%s,\n' % quote_python(self.description).encode(ExternalEncoding))
652        if self.date is not None:
653            showIndent(outfile, level)
654            outfile.write('date=%s,\n' % quote_python(self.date).encode(ExternalEncoding))
655        showIndent(outfile, level)
656        outfile.write('confidence=[\n')
657        level += 1
658        for confidence_ in self.confidence:
659            showIndent(outfile, level)
660            outfile.write('model_.Confidence(\n')
661            confidence_.exportLiteral(outfile, level, name_='Confidence')
662            showIndent(outfile, level)
663            outfile.write('),\n')
664        level -= 1
665        showIndent(outfile, level)
666        outfile.write('],\n')
667        if self.clade is not None:
668            showIndent(outfile, level)
669            outfile.write('clade=model_.Clade(\n')
670            self.clade.exportLiteral(outfile, level, name_='clade')
671            showIndent(outfile, level)
672            outfile.write('),\n')
673        showIndent(outfile, level)
674        outfile.write('clade_relation=[\n')
675        level += 1
676        for clade_relation_ in self.clade_relation:
677            showIndent(outfile, level)
678            outfile.write('model_.CladeRelation(\n')
679            clade_relation_.exportLiteral(outfile, level, name_='CladeRelation')
680            showIndent(outfile, level)
681            outfile.write('),\n')
682        level -= 1
683        showIndent(outfile, level)
684        outfile.write('],\n')
685        showIndent(outfile, level)
686        outfile.write('sequence_relation=[\n')
687        level += 1
688        for sequence_relation_ in self.sequence_relation:
689            showIndent(outfile, level)
690            outfile.write('model_.SequenceRelation(\n')
691            sequence_relation_.exportLiteral(outfile, level, name_='SequenceRelation')
692            showIndent(outfile, level)
693            outfile.write('),\n')
694        level -= 1
695        showIndent(outfile, level)
696        outfile.write('],\n')
697        showIndent(outfile, level)
698        outfile.write('property=[\n')
699        level += 1
700        for property_ in self.property:
701            showIndent(outfile, level)
702            outfile.write('model_.Property(\n')
703            property_.exportLiteral(outfile, level, name_='Property')
704            showIndent(outfile, level)
705            outfile.write('),\n')
706        level -= 1
707        showIndent(outfile, level)
708        outfile.write('],\n')
709    def build(self, node):
710        self.buildAttributes(node, node.attrib, [])
711        for child in node:
712            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
713            self.buildChildren(child, node, nodeName_)
714    def buildAttributes(self, node, attrs, already_processed):
715        value = find_attr_value_('rerootable', node)
716        if value is not None and 'rerootable' not in already_processed:
717            already_processed.append('rerootable')
718            if value in ('true', '1'):
719                self.rerootable = True
720            elif value in ('false', '0'):
721                self.rerootable = False
722            else:
723                raise_parse_error(node, 'Bad boolean attribute')
724        value = find_attr_value_('branch_length_unit', node)
725        if value is not None and 'branch_length_unit' not in already_processed:
726            already_processed.append('branch_length_unit')
727            self.branch_length_unit = value
728            self.branch_length_unit = ' '.join(self.branch_length_unit.split())
729        value = find_attr_value_('type', node)
730        if value is not None and 'type' not in already_processed:
731            already_processed.append('type')
732            self.type_ = value
733            self.type_ = ' '.join(self.type_.split())
734        value = find_attr_value_('rooted', node)
735        if value is not None and 'rooted' not in already_processed:
736            already_processed.append('rooted')
737            if value in ('true', '1'):
738                self.rooted = True
739            elif value in ('false', '0'):
740                self.rooted = False
741            else:
742                raise_parse_error(node, 'Bad boolean attribute')
743    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
744        if nodeName_ == 'name':
745            name_ = child_.text
746            name_ = re_.sub(STRING_CLEANUP_PAT, " ", name_).strip()
747            name_ = self.gds_validate_string(name_, node, 'name')
748            self.name = name_
749        elif nodeName_ == 'id':
750            obj_ = Id.factory()
751            obj_.build(child_)
752            self.set_id(obj_)
753        elif nodeName_ == 'description':
754            description_ = child_.text
755            description_ = re_.sub(STRING_CLEANUP_PAT, " ", description_).strip()
756            description_ = self.gds_validate_string(description_, node, 'description')
757            self.description = description_
758        elif nodeName_ == 'date':
759            date_ = child_.text
760            date_ = self.gds_validate_string(date_, node, 'date')
761            self.date = date_
762        elif nodeName_ == 'confidence':
763            obj_ = Confidence.factory()
764            obj_.build(child_)
765            self.confidence.append(obj_)
766        elif nodeName_ == 'clade':
767            obj_ = Clade.factory()
768            obj_.build(child_)
769            self.set_clade(obj_)
770        elif nodeName_ == 'clade_relation':
771            obj_ = CladeRelation.factory()
772            obj_.build(child_)
773            self.clade_relation.append(obj_)
774        elif nodeName_ == 'sequence_relation':
775            obj_ = SequenceRelation.factory()
776            obj_.build(child_)
777            self.sequence_relation.append(obj_)
778        elif nodeName_ == 'property':
779            obj_ = Property.factory()
780            obj_.build(child_)
781            self.property.append(obj_)
782# end class Phylogeny
783
784
785class Clade(GeneratedsSuper):
786    """Element Clade is used in a recursive manner to describe the topology
787    of a phylogenetic tree. The parent branch length of a clade can
788    be described either with the 'branch_length' element or the
789    'branch_length' attribute (it is not recommended to use both at
790    the same time, though). Usage of the 'branch_length' attribute
791    allows for a less verbose description. Element 'confidence' is
792    used to indicate the support for a clade/parent branch. Element
793    'events' is used to describe such events as gene-duplications at
794    the root node/parent branch of a clade. Element 'width' is the
795    branch width for this clade (including parent branch). Both
796    'color' and 'width' elements apply for the whole clade unless
797    overwritten in-sub clades. Attribute 'id_source' is used to link
798    other elements to a clade (on the xml-level)."""
799    subclass = None
800    superclass = None
801    def __init__(self, id_source=None, branch_length_attr=None, name=None, branch_length=None, confidence=None, width=None, color=None, node_id=None, taxonomy=None, sequence=None, events=None, binary_characters=None, distribution=None, date=None, reference=None, property=None, clade=None, valueOf_=None):
802        self.id_source = _cast(None, id_source)
803        self.branch_length_attr = _cast(None, branch_length_attr)
804        self.name = name
805        self.branch_length = branch_length
806        if confidence is None:
807            self.confidence = []
808        else:
809            self.confidence = confidence
810        self.width = width
811        self.color = color
812        self.node_id = node_id
813        if taxonomy is None:
814            self.taxonomy = []
815        else:
816            self.taxonomy = taxonomy
817        if sequence is None:
818            self.sequence = []
819        else:
820            self.sequence = sequence
821        self.events = events
822        self.binary_characters = binary_characters
823        if distribution is None:
824            self.distribution = []
825        else:
826            self.distribution = distribution
827        self.date = date
828        if reference is None:
829            self.reference = []
830        else:
831            self.reference = reference
832        if property is None:
833            self.property = []
834        else:
835            self.property = property
836        if clade is None:
837            self.clade = []
838        else:
839            self.clade = clade
840    def factory(*args_, **kwargs_):
841        if Clade.subclass:
842            return Clade.subclass(*args_, **kwargs_)
843        else:
844            return Clade(*args_, **kwargs_)
845    factory = staticmethod(factory)
846    def get_name(self): return self.name
847    def set_name(self, name): self.name = name
848    def get_branch_length(self): return self.branch_length
849    def set_branch_length(self, branch_length): self.branch_length = branch_length
850    def get_confidence(self): return self.confidence
851    def set_confidence(self, confidence): self.confidence = confidence
852    def add_confidence(self, value): self.confidence.append(value)
853    def insert_confidence(self, index, value): self.confidence[index] = value
854    def get_width(self): return self.width
855    def set_width(self, width): self.width = width
856    def get_color(self): return self.color
857    def set_color(self, color): self.color = color
858    def get_node_id(self): return self.node_id
859    def set_node_id(self, node_id): self.node_id = node_id
860    def get_taxonomy(self): return self.taxonomy
861    def set_taxonomy(self, taxonomy): self.taxonomy = taxonomy
862    def add_taxonomy(self, value): self.taxonomy.append(value)
863    def insert_taxonomy(self, index, value): self.taxonomy[index] = value
864    def get_sequence(self): return self.sequence
865    def set_sequence(self, sequence): self.sequence = sequence
866    def add_sequence(self, value): self.sequence.append(value)
867    def insert_sequence(self, index, value): self.sequence[index] = value
868    def get_events(self): return self.events
869    def set_events(self, events): self.events = events
870    def get_binary_characters(self): return self.binary_characters
871    def set_binary_characters(self, binary_characters): self.binary_characters = binary_characters
872    def get_distribution(self): return self.distribution
873    def set_distribution(self, distribution): self.distribution = distribution
874    def add_distribution(self, value): self.distribution.append(value)
875    def insert_distribution(self, index, value): self.distribution[index] = value
876    def get_date(self): return self.date
877    def set_date(self, date): self.date = date
878    def get_reference(self): return self.reference
879    def set_reference(self, reference): self.reference = reference
880    def add_reference(self, value): self.reference.append(value)
881    def insert_reference(self, index, value): self.reference[index] = value
882    def get_property(self): return self.property
883    def set_property(self, property): self.property = property
884    def add_property(self, value): self.property.append(value)
885    def insert_property(self, index, value): self.property[index] = value
886    def get_clade(self): return self.clade
887    def set_clade(self, clade): self.clade = clade
888    def add_clade(self, value): self.clade.append(value)
889    def insert_clade(self, index, value): self.clade[index] = value
890    def get_id_source(self): return self.id_source
891    def set_id_source(self, id_source): self.id_source = id_source
892    def get_branch_length_attr(self): return self.branch_length_attr
893    def set_branch_length_attr(self, branch_length_attr): self.branch_length_attr = branch_length_attr
894    def export(self, outfile, level, namespace_='phy:', name_='Clade', namespacedef_=''):
895        showIndent(outfile, level)
896        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
897        already_processed = []
898        self.exportAttributes(outfile, level, already_processed, namespace_, name_='Clade')
899        if self.hasContent_():
900            outfile.write('>\n')
901            self.exportChildren(outfile, level + 1, namespace_, name_)
902            showIndent(outfile, level)
903            outfile.write('</%s%s>\n' % (namespace_, name_))
904        else:
905            outfile.write('/>\n')
906    def exportAttributes(self, outfile, level, already_processed, namespace_='phy:', name_='Clade'):
907        if self.id_source is not None and 'id_source' not in already_processed:
908            already_processed.append('id_source')
909            outfile.write(' id_source=%s' % (quote_attrib(self.id_source), ))
910        if self.branch_length_attr is not None and 'branch_length_attr' not in already_processed:
911            already_processed.append('branch_length_attr')
912            outfile.write(' branch_length_attr=%s' % (self.gds_format_string(quote_attrib(self.branch_length_attr).encode(ExternalEncoding), input_name='branch_length_attr'), ))
913    def exportChildren(self, outfile, level, namespace_='phy:', name_='Clade', fromsubclass_=False):
914        if self.name is not None:
915            showIndent(outfile, level)
916            outfile.write('<%sname>%s</%sname>\n' % (namespace_, self.gds_format_string(quote_xml(self.name).encode(ExternalEncoding), input_name='name'), namespace_))
917        if self.branch_length is not None:
918            showIndent(outfile, level)
919            outfile.write('<%sbranch_length>%s</%sbranch_length>\n' % (namespace_, self.gds_format_double(self.branch_length, input_name='branch_length'), namespace_))
920        for confidence_ in self.confidence:
921            confidence_.export(outfile, level, namespace_, name_='confidence')
922        if self.width is not None:
923            showIndent(outfile, level)
924            outfile.write('<%swidth>%s</%swidth>\n' % (namespace_, self.gds_format_double(self.width, input_name='width'), namespace_))
925        if self.color:
926            self.color.export(outfile, level, namespace_, name_='color')
927        if self.node_id:
928            self.node_id.export(outfile, level, namespace_, name_='node_id')
929        for taxonomy_ in self.taxonomy:
930            taxonomy_.export(outfile, level, namespace_, name_='taxonomy')
931        for sequence_ in self.sequence:
932            sequence_.export(outfile, level, namespace_, name_='sequence')
933        if self.events:
934            self.events.export(outfile, level, namespace_, name_='events')
935        if self.binary_characters:
936            self.binary_characters.export(outfile, level, namespace_, name_='binary_characters')
937        for distribution_ in self.distribution:
938            distribution_.export(outfile, level, namespace_, name_='distribution')
939        if self.date:
940            self.date.export(outfile, level, namespace_, name_='date')
941        for reference_ in self.reference:
942            reference_.export(outfile, level, namespace_, name_='reference')
943        for property_ in self.property:
944            property_.export(outfile, level, namespace_, name_='property')
945        for clade_ in self.clade:
946            clade_.export(outfile, level, namespace_, name_='clade')
947    def hasContent_(self):
948        if (
949            self.name is not None or
950            self.branch_length is not None or
951            self.confidence or
952            self.width is not None or
953            self.color is not None or
954            self.node_id is not None or
955            self.taxonomy or
956            self.sequence or
957            self.events is not None or
958            self.binary_characters is not None or
959            self.distribution or
960            self.date is not None or
961            self.reference or
962            self.property or
963            self.clade
964            ):
965            return True
966        else:
967            return False
968    def exportLiteral(self, outfile, level, name_='Clade'):
969        level += 1
970        self.exportLiteralAttributes(outfile, level, [], name_)
971        if self.hasContent_():
972            self.exportLiteralChildren(outfile, level, name_)
973    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
974        if self.id_source is not None and 'id_source' not in already_processed:
975            already_processed.append('id_source')
976            showIndent(outfile, level)
977            outfile.write('id_source = %s,\n' % (self.id_source,))
978        if self.branch_length_attr is not None and 'branch_length_attr' not in already_processed:
979            already_processed.append('branch_length_attr')
980            showIndent(outfile, level)
981            outfile.write('branch_length_attr = "%s",\n' % (self.branch_length_attr,))
982    def exportLiteralChildren(self, outfile, level, name_):
983        if self.name is not None:
984            showIndent(outfile, level)
985            outfile.write('name=%s,\n' % quote_python(self.name).encode(ExternalEncoding))
986        if self.branch_length is not None:
987            showIndent(outfile, level)
988            outfile.write('branch_length=%e,\n' % self.branch_length)
989        showIndent(outfile, level)
990        outfile.write('confidence=[\n')
991        level += 1
992        for confidence_ in self.confidence:
993            showIndent(outfile, level)
994            outfile.write('model_.Confidence(\n')
995            confidence_.exportLiteral(outfile, level, name_='Confidence')
996            showIndent(outfile, level)
997            outfile.write('),\n')
998        level -= 1
999        showIndent(outfile, level)
1000        outfile.write('],\n')
1001        if self.width is not None:
1002            showIndent(outfile, level)
1003            outfile.write('width=%e,\n' % self.width)
1004        if self.color is not None:
1005            showIndent(outfile, level)
1006            outfile.write('color=model_.BranchColor(\n')
1007            self.color.exportLiteral(outfile, level, name_='color')
1008            showIndent(outfile, level)
1009            outfile.write('),\n')
1010        if self.node_id is not None:
1011            showIndent(outfile, level)
1012            outfile.write('node_id=model_.Id(\n')
1013            self.node_id.exportLiteral(outfile, level, name_='node_id')
1014            showIndent(outfile, level)
1015            outfile.write('),\n')
1016        showIndent(outfile, level)
1017        outfile.write('taxonomy=[\n')
1018        level += 1
1019        for taxonomy_ in self.taxonomy:
1020            showIndent(outfile, level)
1021            outfile.write('model_.Taxonomy(\n')
1022            taxonomy_.exportLiteral(outfile, level, name_='Taxonomy')
1023            showIndent(outfile, level)
1024            outfile.write('),\n')
1025        level -= 1
1026        showIndent(outfile, level)
1027        outfile.write('],\n')
1028        showIndent(outfile, level)
1029        outfile.write('sequence=[\n')
1030        level += 1
1031        for sequence_ in self.sequence:
1032            showIndent(outfile, level)
1033            outfile.write('model_.Sequence(\n')
1034            sequence_.exportLiteral(outfile, level, name_='Sequence')
1035            showIndent(outfile, level)
1036            outfile.write('),\n')
1037        level -= 1
1038        showIndent(outfile, level)
1039        outfile.write('],\n')
1040        if self.events is not None:
1041            showIndent(outfile, level)
1042            outfile.write('events=model_.Events(\n')
1043            self.events.exportLiteral(outfile, level, name_='events')
1044            showIndent(outfile, level)
1045            outfile.write('),\n')
1046        if self.binary_characters is not None:
1047            showIndent(outfile, level)
1048            outfile.write('binary_characters=model_.BinaryCharacters(\n')
1049            self.binary_characters.exportLiteral(outfile, level, name_='binary_characters')
1050            showIndent(outfile, level)
1051            outfile.write('),\n')
1052        showIndent(outfile, level)
1053        outfile.write('distribution=[\n')
1054        level += 1
1055        for distribution_ in self.distribution:
1056            showIndent(outfile, level)
1057            outfile.write('model_.Distribution(\n')
1058            distribution_.exportLiteral(outfile, level, name_='Distribution')
1059            showIndent(outfile, level)
1060            outfile.write('),\n')
1061        level -= 1
1062        showIndent(outfile, level)
1063        outfile.write('],\n')
1064        if self.date is not None:
1065            showIndent(outfile, level)
1066            outfile.write('date=model_.Date(\n')
1067            self.date.exportLiteral(outfile, level, name_='date')
1068            showIndent(outfile, level)
1069            outfile.write('),\n')
1070        showIndent(outfile, level)
1071        outfile.write('reference=[\n')
1072        level += 1
1073        for reference_ in self.reference:
1074            showIndent(outfile, level)
1075            outfile.write('model_.Reference(\n')
1076            reference_.exportLiteral(outfile, level, name_='Reference')
1077            showIndent(outfile, level)
1078            outfile.write('),\n')
1079        level -= 1
1080        showIndent(outfile, level)
1081        outfile.write('],\n')
1082        showIndent(outfile, level)
1083        outfile.write('property=[\n')
1084        level += 1
1085        for property_ in self.property:
1086            showIndent(outfile, level)
1087            outfile.write('model_.Property(\n')
1088            property_.exportLiteral(outfile, level, name_='Property')
1089            showIndent(outfile, level)
1090            outfile.write('),\n')
1091        level -= 1
1092        showIndent(outfile, level)
1093        outfile.write('],\n')
1094        showIndent(outfile, level)
1095        outfile.write('clade=[\n')
1096        level += 1
1097        for clade_ in self.clade:
1098            showIndent(outfile, level)
1099            outfile.write('model_.Clade(\n')
1100            clade_.exportLiteral(outfile, level, name_='Clade')
1101            showIndent(outfile, level)
1102            outfile.write('),\n')
1103        level -= 1
1104        showIndent(outfile, level)
1105        outfile.write('],\n')
1106    def build(self, node):
1107        self.buildAttributes(node, node.attrib, [])
1108        for child in node:
1109            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
1110            self.buildChildren(child, node, nodeName_)
1111    def buildAttributes(self, node, attrs, already_processed):
1112        value = find_attr_value_('id_source', node)
1113        if value is not None and 'id_source' not in already_processed:
1114            already_processed.append('id_source')
1115            self.id_source = value
1116        value = find_attr_value_('branch_length_attr', node)
1117        if value is not None and 'branch_length_attr' not in already_processed:
1118            already_processed.append('branch_length_attr')
1119            self.branch_length_attr = value
1120    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
1121        if nodeName_ == 'name':
1122            name_ = child_.text
1123            name_ = re_.sub(STRING_CLEANUP_PAT, " ", name_).strip()
1124            name_ = self.gds_validate_string(name_, node, 'name')
1125            self.name = name_
1126        elif nodeName_ == 'branch_length':
1127            sval_ = child_.text
1128            try:
1129                fval_ = float(sval_)
1130            except (TypeError, ValueError) as exp:
1131                raise_parse_error(child_, 'requires float or double: %s' % exp)
1132            fval_ = self.gds_validate_float(fval_, node, 'branch_length')
1133            self.branch_length = fval_
1134        elif nodeName_ == 'confidence':
1135            obj_ = Confidence.factory()
1136            obj_.build(child_)
1137            self.confidence.append(obj_)
1138        elif nodeName_ == 'width':
1139            sval_ = child_.text
1140            try:
1141                fval_ = float(sval_)
1142            except (TypeError, ValueError) as exp:
1143                raise_parse_error(child_, 'requires float or double: %s' % exp)
1144            fval_ = self.gds_validate_float(fval_, node, 'width')
1145            self.width = fval_
1146        elif nodeName_ == 'color':
1147            obj_ = BranchColor.factory()
1148            obj_.build(child_)
1149            self.set_color(obj_)
1150        elif nodeName_ == 'node_id':
1151            obj_ = Id.factory()
1152            obj_.build(child_)
1153            self.set_node_id(obj_)
1154        elif nodeName_ == 'taxonomy':
1155            obj_ = Taxonomy.factory()
1156            obj_.build(child_)
1157            self.taxonomy.append(obj_)
1158        elif nodeName_ == 'sequence':
1159            obj_ = Sequence.factory()
1160            obj_.build(child_)
1161            self.sequence.append(obj_)
1162        elif nodeName_ == 'events':
1163            obj_ = Events.factory()
1164            obj_.build(child_)
1165            self.set_events(obj_)
1166        elif nodeName_ == 'binary_characters':
1167            obj_ = BinaryCharacters.factory()
1168            obj_.build(child_)
1169            self.set_binary_characters(obj_)
1170        elif nodeName_ == 'distribution':
1171            obj_ = Distribution.factory()
1172            obj_.build(child_)
1173            self.distribution.append(obj_)
1174        elif nodeName_ == 'date':
1175            obj_ = Date.factory()
1176            obj_.build(child_)
1177            self.set_date(obj_)
1178        elif nodeName_ == 'reference':
1179            obj_ = Reference.factory()
1180            obj_.build(child_)
1181            self.reference.append(obj_)
1182        elif nodeName_ == 'property':
1183            obj_ = Property.factory()
1184            obj_.build(child_)
1185            self.property.append(obj_)
1186        elif nodeName_ == 'clade':
1187            obj_ = Clade.factory()
1188            obj_.build(child_)
1189            self.clade.append(obj_)
1190# end class Clade
1191
1192
1193class Taxonomy(GeneratedsSuper):
1194    """Element Taxonomy is used to describe taxonomic information for a
1195    clade. Element 'code' is intended to store UniProt/Swiss-Prot
1196    style organism codes (e.g. 'APLCA' for the California sea hare
1197    'Aplysia californica') or other styles of mnemonics (e.g.
1198    'Aca'). Element 'authority' is used to keep the authority, such
1199    as 'J. G. Cooper, 1863', associated with the 'scientific_name'.
1200    Element 'id' is used for a unique identifier of a taxon (for
1201    example '6500' with 'ncbi_taxonomy' as 'provider' for the
1202    California sea hare). Attribute 'id_source' is used to link
1203    other elements to a taxonomy (on the xml-level)."""
1204    subclass = None
1205    superclass = None
1206    def __init__(self, id_source=None, id=None, code=None, scientific_name=None, authority=None, common_name=None, synonym=None, rank=None, uri=None, valueOf_=None):
1207        self.id_source = _cast(None, id_source)
1208        self.id = id
1209        self.code = code
1210        self.scientific_name = scientific_name
1211        self.authority = authority
1212        if common_name is None:
1213            self.common_name = []
1214        else:
1215            self.common_name = common_name
1216        if synonym is None:
1217            self.synonym = []
1218        else:
1219            self.synonym = synonym
1220        self.rank = rank
1221        self.uri = uri
1222    def factory(*args_, **kwargs_):
1223        if Taxonomy.subclass:
1224            return Taxonomy.subclass(*args_, **kwargs_)
1225        else:
1226            return Taxonomy(*args_, **kwargs_)
1227    factory = staticmethod(factory)
1228    def get_id(self): return self.id
1229    def set_id(self, id): self.id = id
1230    def get_code(self): return self.code
1231    def set_code(self, code): self.code = code
1232    def validate_TaxonomyCode(self, value):
1233        # Validate type TaxonomyCode, a restriction on xs:token.
1234        pass
1235    def get_scientific_name(self): return self.scientific_name
1236    def set_scientific_name(self, scientific_name): self.scientific_name = scientific_name
1237    def get_authority(self): return self.authority
1238    def set_authority(self, authority): self.authority = authority
1239    def get_common_name(self): return self.common_name
1240    def set_common_name(self, common_name): self.common_name = common_name
1241    def add_common_name(self, value): self.common_name.append(value)
1242    def insert_common_name(self, index, value): self.common_name[index] = value
1243    def get_synonym(self): return self.synonym
1244    def set_synonym(self, synonym): self.synonym = synonym
1245    def add_synonym(self, value): self.synonym.append(value)
1246    def insert_synonym(self, index, value): self.synonym[index] = value
1247    def get_rank(self): return self.rank
1248    def set_rank(self, rank): self.rank = rank
1249    def validate_Rank(self, value):
1250        # Validate type Rank, a restriction on xs:token.
1251        pass
1252    def get_uri(self): return self.uri
1253    def set_uri(self, uri): self.uri = uri
1254    def get_id_source(self): return self.id_source
1255    def set_id_source(self, id_source): self.id_source = id_source
1256    def export(self, outfile, level, namespace_='phy:', name_='Taxonomy', namespacedef_=''):
1257        showIndent(outfile, level)
1258        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
1259        already_processed = []
1260        self.exportAttributes(outfile, level, already_processed, namespace_, name_='Taxonomy')
1261        if self.hasContent_():
1262            outfile.write('>\n')
1263            self.exportChildren(outfile, level + 1, namespace_, name_)
1264            showIndent(outfile, level)
1265            outfile.write('</%s%s>\n' % (namespace_, name_))
1266        else:
1267            outfile.write('/>\n')
1268    def exportAttributes(self, outfile, level, already_processed, namespace_='phy:', name_='Taxonomy'):
1269        if self.id_source is not None and 'id_source' not in already_processed:
1270            already_processed.append('id_source')
1271            outfile.write(' id_source=%s' % (quote_attrib(self.id_source), ))
1272    def exportChildren(self, outfile, level, namespace_='phy:', name_='Taxonomy', fromsubclass_=False):
1273        if self.id:
1274            self.id.export(outfile, level, namespace_, name_='id')
1275        if self.code is not None:
1276            showIndent(outfile, level)
1277            outfile.write('<%scode>%s</%scode>\n' % (namespace_, self.gds_format_string(quote_xml(self.code).encode(ExternalEncoding), input_name='code'), namespace_))
1278        if self.scientific_name is not None:
1279            showIndent(outfile, level)
1280            outfile.write('<%sscientific_name>%s</%sscientific_name>\n' % (namespace_, self.gds_format_string(quote_xml(self.scientific_name).encode(ExternalEncoding), input_name='scientific_name'), namespace_))
1281        if self.authority is not None:
1282            showIndent(outfile, level)
1283            outfile.write('<%sauthority>%s</%sauthority>\n' % (namespace_, self.gds_format_string(quote_xml(self.authority).encode(ExternalEncoding), input_name='authority'), namespace_))
1284        for common_name_ in self.common_name:
1285            showIndent(outfile, level)
1286            outfile.write('<%scommon_name>%s</%scommon_name>\n' % (namespace_, self.gds_format_string(quote_xml(common_name_).encode(ExternalEncoding), input_name='common_name'), namespace_))
1287        for synonym_ in self.synonym:
1288            showIndent(outfile, level)
1289            outfile.write('<%ssynonym>%s</%ssynonym>\n' % (namespace_, self.gds_format_string(quote_xml(synonym_).encode(ExternalEncoding), input_name='synonym'), namespace_))
1290        if self.rank is not None:
1291            showIndent(outfile, level)
1292            outfile.write('<%srank>%s</%srank>\n' % (namespace_, self.gds_format_string(quote_xml(self.rank).encode(ExternalEncoding), input_name='rank'), namespace_))
1293        if self.uri:
1294            self.uri.export(outfile, level, namespace_, name_='uri')
1295    def hasContent_(self):
1296        if (
1297            self.id is not None or
1298            self.code is not None or
1299            self.scientific_name is not None or
1300            self.authority is not None or
1301            self.common_name or
1302            self.synonym or
1303            self.rank is not None or
1304            self.uri is not None
1305            ):
1306            return True
1307        else:
1308            return False
1309    def exportLiteral(self, outfile, level, name_='Taxonomy'):
1310        level += 1
1311        self.exportLiteralAttributes(outfile, level, [], name_)
1312        if self.hasContent_():
1313            self.exportLiteralChildren(outfile, level, name_)
1314    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
1315        if self.id_source is not None and 'id_source' not in already_processed:
1316            already_processed.append('id_source')
1317            showIndent(outfile, level)
1318            outfile.write('id_source = %s,\n' % (self.id_source,))
1319    def exportLiteralChildren(self, outfile, level, name_):
1320        if self.id is not None:
1321            showIndent(outfile, level)
1322            outfile.write('id=model_.Id(\n')
1323            self.id.exportLiteral(outfile, level, name_='id')
1324            showIndent(outfile, level)
1325            outfile.write('),\n')
1326        if self.code is not None:
1327            showIndent(outfile, level)
1328            outfile.write('code=%s,\n' % quote_python(self.code).encode(ExternalEncoding))
1329        if self.scientific_name is not None:
1330            showIndent(outfile, level)
1331            outfile.write('scientific_name=%s,\n' % quote_python(self.scientific_name).encode(ExternalEncoding))
1332        if self.authority is not None:
1333            showIndent(outfile, level)
1334            outfile.write('authority=%s,\n' % quote_python(self.authority).encode(ExternalEncoding))
1335        showIndent(outfile, level)
1336        outfile.write('common_name=[\n')
1337        level += 1
1338        for common_name_ in self.common_name:
1339            showIndent(outfile, level)
1340            outfile.write('%s,\n' % quote_python(common_name_).encode(ExternalEncoding))
1341        level -= 1
1342        showIndent(outfile, level)
1343        outfile.write('],\n')
1344        showIndent(outfile, level)
1345        outfile.write('synonym=[\n')
1346        level += 1
1347        for synonym_ in self.synonym:
1348            showIndent(outfile, level)
1349            outfile.write('%s,\n' % quote_python(synonym_).encode(ExternalEncoding))
1350        level -= 1
1351        showIndent(outfile, level)
1352        outfile.write('],\n')
1353        if self.rank is not None:
1354            showIndent(outfile, level)
1355            outfile.write('rank=%s,\n' % quote_python(self.rank).encode(ExternalEncoding))
1356        if self.uri is not None:
1357            showIndent(outfile, level)
1358            outfile.write('uri=model_.Uri(\n')
1359            self.uri.exportLiteral(outfile, level, name_='uri')
1360            showIndent(outfile, level)
1361            outfile.write('),\n')
1362    def build(self, node):
1363        self.buildAttributes(node, node.attrib, [])
1364        for child in node:
1365            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
1366            self.buildChildren(child, node, nodeName_)
1367    def buildAttributes(self, node, attrs, already_processed):
1368        value = find_attr_value_('id_source', node)
1369        if value is not None and 'id_source' not in already_processed:
1370            already_processed.append('id_source')
1371            self.id_source = value
1372    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
1373        if nodeName_ == 'id':
1374            obj_ = Id.factory()
1375            obj_.build(child_)
1376            self.set_id(obj_)
1377        elif nodeName_ == 'code':
1378            code_ = child_.text
1379            code_ = re_.sub(STRING_CLEANUP_PAT, " ", code_).strip()
1380            code_ = self.gds_validate_string(code_, node, 'code')
1381            self.code = code_
1382            self.validate_TaxonomyCode(self.code)    # validate type TaxonomyCode
1383        elif nodeName_ == 'scientific_name':
1384            scientific_name_ = child_.text
1385            scientific_name_ = re_.sub(STRING_CLEANUP_PAT, " ", scientific_name_).strip()
1386            scientific_name_ = self.gds_validate_string(scientific_name_, node, 'scientific_name')
1387            self.scientific_name = scientific_name_
1388        elif nodeName_ == 'authority':
1389            authority_ = child_.text
1390            authority_ = re_.sub(STRING_CLEANUP_PAT, " ", authority_).strip()
1391            authority_ = self.gds_validate_string(authority_, node, 'authority')
1392            self.authority = authority_
1393        elif nodeName_ == 'common_name':
1394            common_name_ = child_.text
1395            if common_name_:
1396                common_name_ = re_.sub(STRING_CLEANUP_PAT, " ", common_name_).strip()
1397                common_name_ = self.gds_validate_string(common_name_, node, 'common_name')
1398            self.common_name.append(common_name_)
1399        elif nodeName_ == 'synonym':
1400            synonym_ = child_.text
1401            synonym_ = re_.sub(STRING_CLEANUP_PAT, " ", synonym_).strip()
1402            synonym_ = self.gds_validate_string(synonym_, node, 'synonym')
1403            self.synonym.append(synonym_)
1404        elif nodeName_ == 'rank':
1405            rank_ = child_.text
1406            rank_ = re_.sub(STRING_CLEANUP_PAT, " ", rank_).strip()
1407            rank_ = self.gds_validate_string(rank_, node, 'rank')
1408            self.rank = rank_
1409            self.validate_Rank(self.rank)    # validate type Rank
1410        elif nodeName_ == 'uri':
1411            obj_ = Uri.factory()
1412            obj_.build(child_)
1413            self.set_uri(obj_)
1414# end class Taxonomy
1415
1416
1417class Sequence(GeneratedsSuper):
1418    """Element Sequence is used to represent a molecular sequence (Protein,
1419    DNA, RNA) associated with a node. 'symbol' is a short (maximal
1420    ten characters) symbol of the sequence (e.g. 'ACTM') whereas
1421    'name' is used for the full name (e.g. 'muscle Actin').
1422    'location' is used for the location of a sequence on a
1423    genome/chromosome. The actual sequence can be stored with the
1424    'mol_seq' element. Attribute 'type' is used to indicate the type
1425    of sequence ('dna', 'rna', or 'protein'). One intended use for
1426    'id_ref' is to link a sequence to a taxonomy (via the taxonomy's
1427    'id_source') in case of multiple sequences and taxonomies per
1428    node."""
1429    subclass = None
1430    superclass = None
1431    def __init__(self, id_source=None, id_ref=None, type_=None, symbol=None, accession=None, name=None, location=None, mol_seq=None, uri=None, annotation=None, domain_architecture=None, valueOf_=None):
1432        self.id_source = _cast(None, id_source)
1433        self.id_ref = _cast(None, id_ref)
1434        self.type_ = _cast(None, type_)
1435        self.symbol = symbol
1436        self.accession = accession
1437        self.name = name
1438        self.location = location
1439        self.mol_seq = mol_seq
1440        self.uri = uri
1441        if annotation is None:
1442            self.annotation = []
1443        else:
1444            self.annotation = annotation
1445        self.domain_architecture = domain_architecture
1446    def factory(*args_, **kwargs_):
1447        if Sequence.subclass:
1448            return Sequence.subclass(*args_, **kwargs_)
1449        else:
1450            return Sequence(*args_, **kwargs_)
1451    factory = staticmethod(factory)
1452    def get_symbol(self): return self.symbol
1453    def set_symbol(self, symbol): self.symbol = symbol
1454    def validate_SequenceSymbol(self, value):
1455        # Validate type SequenceSymbol, a restriction on xs:token.
1456        pass
1457    def get_accession(self): return self.accession
1458    def set_accession(self, accession): self.accession = accession
1459    def get_name(self): return self.name
1460    def set_name(self, name): self.name = name
1461    def get_location(self): return self.location
1462    def set_location(self, location): self.location = location
1463    def get_mol_seq(self): return self.mol_seq
1464    def set_mol_seq(self, mol_seq): self.mol_seq = mol_seq
1465    def get_uri(self): return self.uri
1466    def set_uri(self, uri): self.uri = uri
1467    def get_annotation(self): return self.annotation
1468    def set_annotation(self, annotation): self.annotation = annotation
1469    def add_annotation(self, value): self.annotation.append(value)
1470    def insert_annotation(self, index, value): self.annotation[index] = value
1471    def get_domain_architecture(self): return self.domain_architecture
1472    def set_domain_architecture(self, domain_architecture): self.domain_architecture = domain_architecture
1473    def get_id_source(self): return self.id_source
1474    def set_id_source(self, id_source): self.id_source = id_source
1475    def get_id_ref(self): return self.id_ref
1476    def set_id_ref(self, id_ref): self.id_ref = id_ref
1477    def get_type(self): return self.type_
1478    def set_type(self, type_): self.type_ = type_
1479    def export(self, outfile, level, namespace_='phy:', name_='Sequence', namespacedef_=''):
1480        showIndent(outfile, level)
1481        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
1482        already_processed = []
1483        self.exportAttributes(outfile, level, already_processed, namespace_, name_='Sequence')
1484        if self.hasContent_():
1485            outfile.write('>\n')
1486            self.exportChildren(outfile, level + 1, namespace_, name_)
1487            showIndent(outfile, level)
1488            outfile.write('</%s%s>\n' % (namespace_, name_))
1489        else:
1490            outfile.write('/>\n')
1491    def exportAttributes(self, outfile, level, already_processed, namespace_='phy:', name_='Sequence'):
1492        if self.id_source is not None and 'id_source' not in already_processed:
1493            already_processed.append('id_source')
1494            outfile.write(' id_source=%s' % (quote_attrib(self.id_source), ))
1495        if self.id_ref is not None and 'id_ref' not in already_processed:
1496            already_processed.append('id_ref')
1497            outfile.write(' id_ref=%s' % (quote_attrib(self.id_ref), ))
1498        if self.type_ is not None and 'type_' not in already_processed:
1499            already_processed.append('type_')
1500            outfile.write(' type=%s' % (quote_attrib(self.type_), ))
1501    def exportChildren(self, outfile, level, namespace_='phy:', name_='Sequence', fromsubclass_=False):
1502        if self.symbol is not None:
1503            showIndent(outfile, level)
1504            outfile.write('<%ssymbol>%s</%ssymbol>\n' % (namespace_, self.gds_format_string(quote_xml(self.symbol).encode(ExternalEncoding), input_name='symbol'), namespace_))
1505        if self.accession:
1506            self.accession.export(outfile, level, namespace_, name_='accession')
1507        if self.name is not None:
1508            showIndent(outfile, level)
1509            outfile.write('<%sname>%s</%sname>\n' % (namespace_, self.gds_format_string(quote_xml(self.name).encode(ExternalEncoding), input_name='name'), namespace_))
1510        if self.location is not None:
1511            showIndent(outfile, level)
1512            outfile.write('<%slocation>%s</%slocation>\n' % (namespace_, self.gds_format_string(quote_xml(self.location).encode(ExternalEncoding), input_name='location'), namespace_))
1513        if self.mol_seq:
1514            self.mol_seq.export(outfile, level, namespace_, name_='mol_seq')
1515        if self.uri:
1516            self.uri.export(outfile, level, namespace_, name_='uri')
1517        for annotation_ in self.annotation:
1518            annotation_.export(outfile, level, namespace_, name_='annotation')
1519        if self.domain_architecture:
1520            self.domain_architecture.export(outfile, level, namespace_, name_='domain_architecture')
1521    def hasContent_(self):
1522        if (
1523            self.symbol is not None or
1524            self.accession is not None or
1525            self.name is not None or
1526            self.location is not None or
1527            self.mol_seq is not None or
1528            self.uri is not None or
1529            self.annotation or
1530            self.domain_architecture is not None
1531            ):
1532            return True
1533        else:
1534            return False
1535    def exportLiteral(self, outfile, level, name_='Sequence'):
1536        level += 1
1537        self.exportLiteralAttributes(outfile, level, [], name_)
1538        if self.hasContent_():
1539            self.exportLiteralChildren(outfile, level, name_)
1540    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
1541        if self.id_source is not None and 'id_source' not in already_processed:
1542            already_processed.append('id_source')
1543            showIndent(outfile, level)
1544            outfile.write('id_source = %s,\n' % (self.id_source,))
1545        if self.id_ref is not None and 'id_ref' not in already_processed:
1546            already_processed.append('id_ref')
1547            showIndent(outfile, level)
1548            outfile.write('id_ref = %s,\n' % (self.id_ref,))
1549        if self.type_ is not None and 'type_' not in already_processed:
1550            already_processed.append('type_')
1551            showIndent(outfile, level)
1552            outfile.write('type_ = %s,\n' % (self.type_,))
1553    def exportLiteralChildren(self, outfile, level, name_):
1554        if self.symbol is not None:
1555            showIndent(outfile, level)
1556            outfile.write('symbol=%s,\n' % quote_python(self.symbol).encode(ExternalEncoding))
1557        if self.accession is not None:
1558            showIndent(outfile, level)
1559            outfile.write('accession=model_.Accession(\n')
1560            self.accession.exportLiteral(outfile, level, name_='accession')
1561            showIndent(outfile, level)
1562            outfile.write('),\n')
1563        if self.name is not None:
1564            showIndent(outfile, level)
1565            outfile.write('name=%s,\n' % quote_python(self.name).encode(ExternalEncoding))
1566        if self.location is not None:
1567            showIndent(outfile, level)
1568            outfile.write('location=%s,\n' % quote_python(self.location).encode(ExternalEncoding))
1569        if self.mol_seq is not None:
1570            showIndent(outfile, level)
1571            outfile.write('mol_seq=model_.MolSeq(\n')
1572            self.mol_seq.exportLiteral(outfile, level, name_='mol_seq')
1573            showIndent(outfile, level)
1574            outfile.write('),\n')
1575        if self.uri is not None:
1576            showIndent(outfile, level)
1577            outfile.write('uri=model_.Uri(\n')
1578            self.uri.exportLiteral(outfile, level, name_='uri')
1579            showIndent(outfile, level)
1580            outfile.write('),\n')
1581        showIndent(outfile, level)
1582        outfile.write('annotation=[\n')
1583        level += 1
1584        for annotation_ in self.annotation:
1585            showIndent(outfile, level)
1586            outfile.write('model_.Annotation(\n')
1587            annotation_.exportLiteral(outfile, level, name_='Annotation')
1588            showIndent(outfile, level)
1589            outfile.write('),\n')
1590        level -= 1
1591        showIndent(outfile, level)
1592        outfile.write('],\n')
1593        if self.domain_architecture is not None:
1594            showIndent(outfile, level)
1595            outfile.write('domain_architecture=model_.DomainArchitecture(\n')
1596            self.domain_architecture.exportLiteral(outfile, level, name_='domain_architecture')
1597            showIndent(outfile, level)
1598            outfile.write('),\n')
1599    def build(self, node):
1600        self.buildAttributes(node, node.attrib, [])
1601        for child in node:
1602            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
1603            self.buildChildren(child, node, nodeName_)
1604    def buildAttributes(self, node, attrs, already_processed):
1605        value = find_attr_value_('id_source', node)
1606        if value is not None and 'id_source' not in already_processed:
1607            already_processed.append('id_source')
1608            self.id_source = value
1609        value = find_attr_value_('id_ref', node)
1610        if value is not None and 'id_ref' not in already_processed:
1611            already_processed.append('id_ref')
1612            self.id_ref = value
1613        value = find_attr_value_('type', node)
1614        if value is not None and 'type' not in already_processed:
1615            already_processed.append('type')
1616            self.type_ = value
1617    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
1618        if nodeName_ == 'symbol':
1619            symbol_ = child_.text
1620            symbol_ = re_.sub(STRING_CLEANUP_PAT, " ", symbol_).strip()
1621            symbol_ = self.gds_validate_string(symbol_, node, 'symbol')
1622            self.symbol = symbol_
1623            self.validate_SequenceSymbol(self.symbol)    # validate type SequenceSymbol
1624        elif nodeName_ == 'accession':
1625            obj_ = Accession.factory()
1626            obj_.build(child_)
1627            self.set_accession(obj_)
1628        elif nodeName_ == 'name':
1629            name_ = child_.text
1630            name_ = re_.sub(STRING_CLEANUP_PAT, " ", name_).strip()
1631            name_ = self.gds_validate_string(name_, node, 'name')
1632            self.name = name_
1633        elif nodeName_ == 'location':
1634            location_ = child_.text
1635            location_ = re_.sub(STRING_CLEANUP_PAT, " ", location_).strip()
1636            location_ = self.gds_validate_string(location_, node, 'location')
1637            self.location = location_
1638        elif nodeName_ == 'mol_seq':
1639            obj_ = MolSeq.factory()
1640            obj_.build(child_)
1641            self.set_mol_seq(obj_)
1642        elif nodeName_ == 'uri':
1643            obj_ = Uri.factory()
1644            obj_.build(child_)
1645            self.set_uri(obj_)
1646        elif nodeName_ == 'annotation':
1647            obj_ = Annotation.factory()
1648            obj_.build(child_)
1649            self.annotation.append(obj_)
1650        elif nodeName_ == 'domain_architecture':
1651            obj_ = DomainArchitecture.factory()
1652            obj_.build(child_)
1653            self.set_domain_architecture(obj_)
1654# end class Sequence
1655
1656
1657class MolSeq(GeneratedsSuper):
1658    """Element 'mol_seq' is used to store molecular sequences. The
1659    'is_aligned' attribute is used to indicated that this molecular
1660    sequence is aligned with all other sequences in the same
1661    phylogeny for which 'is aligned' is true as well (which, in most
1662    cases, means that gaps were introduced, and that all sequences
1663    for which 'is aligned' is true must have the same length)."""
1664    subclass = None
1665    superclass = None
1666    def __init__(self, is_aligned=None, valueOf_=None):
1667        self.is_aligned = _cast(bool, is_aligned)
1668        self.valueOf_ = valueOf_
1669    def factory(*args_, **kwargs_):
1670        if MolSeq.subclass:
1671            return MolSeq.subclass(*args_, **kwargs_)
1672        else:
1673            return MolSeq(*args_, **kwargs_)
1674    factory = staticmethod(factory)
1675    def get_is_aligned(self): return self.is_aligned
1676    def set_is_aligned(self, is_aligned): self.is_aligned = is_aligned
1677    def get_valueOf_(self): return self.valueOf_
1678    def set_valueOf_(self, valueOf_): self.valueOf_ = valueOf_
1679    def export(self, outfile, level, namespace_='phy:', name_='MolSeq', namespacedef_=''):
1680        showIndent(outfile, level)
1681        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
1682        already_processed = []
1683        self.exportAttributes(outfile, level, already_processed, namespace_, name_='MolSeq')
1684        if self.hasContent_():
1685            outfile.write('>')
1686            outfile.write(str(self.valueOf_).encode(ExternalEncoding))
1687            self.exportChildren(outfile, level + 1, namespace_, name_)
1688            outfile.write('</%s%s>\n' % (namespace_, name_))
1689        else:
1690            outfile.write('/>\n')
1691    def exportAttributes(self, outfile, level, already_processed, namespace_='phy:', name_='MolSeq'):
1692        if self.is_aligned is not None and 'is_aligned' not in already_processed:
1693            already_processed.append('is_aligned')
1694            outfile.write(' is_aligned="%s"' % self.gds_format_boolean(self.gds_str_lower(str(self.is_aligned)), input_name='is_aligned'))
1695    def exportChildren(self, outfile, level, namespace_='phy:', name_='MolSeq', fromsubclass_=False):
1696        pass
1697    def hasContent_(self):
1698        if (
1699            self.valueOf_
1700            ):
1701            return True
1702        else:
1703            return False
1704    def exportLiteral(self, outfile, level, name_='MolSeq'):
1705        level += 1
1706        self.exportLiteralAttributes(outfile, level, [], name_)
1707        if self.hasContent_():
1708            self.exportLiteralChildren(outfile, level, name_)
1709        showIndent(outfile, level)
1710        outfile.write('valueOf_ = """%s""",\n' % (self.valueOf_,))
1711    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
1712        if self.is_aligned is not None and 'is_aligned' not in already_processed:
1713            already_processed.append('is_aligned')
1714            showIndent(outfile, level)
1715            outfile.write('is_aligned = %s,\n' % (self.is_aligned,))
1716    def exportLiteralChildren(self, outfile, level, name_):
1717        pass
1718    def build(self, node):
1719        self.buildAttributes(node, node.attrib, [])
1720        self.valueOf_ = get_all_text_(node)
1721        for child in node:
1722            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
1723            self.buildChildren(child, node, nodeName_)
1724    def buildAttributes(self, node, attrs, already_processed):
1725        value = find_attr_value_('is_aligned', node)
1726        if value is not None and 'is_aligned' not in already_processed:
1727            already_processed.append('is_aligned')
1728            if value in ('true', '1'):
1729                self.is_aligned = True
1730            elif value in ('false', '0'):
1731                self.is_aligned = False
1732            else:
1733                raise_parse_error(node, 'Bad boolean attribute')
1734    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
1735        pass
1736# end class MolSeq
1737
1738
1739class Accession(GeneratedsSuper):
1740    """Element Accession is used to capture the local part in a sequence
1741    identifier (e.g. 'P17304' in 'UniProtKB:P17304', in which case
1742    the 'source' attribute would be 'UniProtKB')."""
1743    subclass = None
1744    superclass = None
1745    def __init__(self, source=None, valueOf_=None):
1746        self.source = _cast(None, source)
1747        self.valueOf_ = valueOf_
1748    def factory(*args_, **kwargs_):
1749        if Accession.subclass:
1750            return Accession.subclass(*args_, **kwargs_)
1751        else:
1752            return Accession(*args_, **kwargs_)
1753    factory = staticmethod(factory)
1754    def get_source(self): return self.source
1755    def set_source(self, source): self.source = source
1756    def get_valueOf_(self): return self.valueOf_
1757    def set_valueOf_(self, valueOf_): self.valueOf_ = valueOf_
1758    def export(self, outfile, level, namespace_='phy:', name_='Accession', namespacedef_=''):
1759        showIndent(outfile, level)
1760        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
1761        already_processed = []
1762        self.exportAttributes(outfile, level, already_processed, namespace_, name_='Accession')
1763        if self.hasContent_():
1764            outfile.write('>')
1765            outfile.write(str(self.valueOf_).encode(ExternalEncoding))
1766            self.exportChildren(outfile, level + 1, namespace_, name_)
1767            outfile.write('</%s%s>\n' % (namespace_, name_))
1768        else:
1769            outfile.write('/>\n')
1770    def exportAttributes(self, outfile, level, already_processed, namespace_='phy:', name_='Accession'):
1771        if self.source is not None and 'source' not in already_processed:
1772            already_processed.append('source')
1773            outfile.write(' source=%s' % (self.gds_format_string(quote_attrib(self.source).encode(ExternalEncoding), input_name='source'), ))
1774    def exportChildren(self, outfile, level, namespace_='phy:', name_='Accession', fromsubclass_=False):
1775        pass
1776    def hasContent_(self):
1777        if (
1778            self.valueOf_
1779            ):
1780            return True
1781        else:
1782            return False
1783    def exportLiteral(self, outfile, level, name_='Accession'):
1784        level += 1
1785        self.exportLiteralAttributes(outfile, level, [], name_)
1786        if self.hasContent_():
1787            self.exportLiteralChildren(outfile, level, name_)
1788        showIndent(outfile, level)
1789        outfile.write('valueOf_ = """%s""",\n' % (self.valueOf_,))
1790    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
1791        if self.source is not None and 'source' not in already_processed:
1792            already_processed.append('source')
1793            showIndent(outfile, level)
1794            outfile.write('source = "%s",\n' % (self.source,))
1795    def exportLiteralChildren(self, outfile, level, name_):
1796        pass
1797    def build(self, node):
1798        self.buildAttributes(node, node.attrib, [])
1799        self.valueOf_ = get_all_text_(node)
1800        for child in node:
1801            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
1802            self.buildChildren(child, node, nodeName_)
1803    def buildAttributes(self, node, attrs, already_processed):
1804        value = find_attr_value_('source', node)
1805        if value is not None and 'source' not in already_processed:
1806            already_processed.append('source')
1807            self.source = value
1808            self.source = ' '.join(self.source.split())
1809    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
1810        pass
1811# end class Accession
1812
1813
1814class DomainArchitecture(GeneratedsSuper):
1815    """This is used describe the domain architecture of a protein.
1816    Attribute 'length' is the total length of the protein"""
1817    subclass = None
1818    superclass = None
1819    def __init__(self, length=None, domain=None, valueOf_=None):
1820        self.length = _cast(int, length)
1821        if domain is None:
1822            self.domain = []
1823        else:
1824            self.domain = domain
1825    def factory(*args_, **kwargs_):
1826        if DomainArchitecture.subclass:
1827            return DomainArchitecture.subclass(*args_, **kwargs_)
1828        else:
1829            return DomainArchitecture(*args_, **kwargs_)
1830    factory = staticmethod(factory)
1831    def get_domain(self): return self.domain
1832    def set_domain(self, domain): self.domain = domain
1833    def add_domain(self, value): self.domain.append(value)
1834    def insert_domain(self, index, value): self.domain[index] = value
1835    def get_length(self): return self.length
1836    def set_length(self, length): self.length = length
1837    def export(self, outfile, level, namespace_='phy:', name_='DomainArchitecture', namespacedef_=''):
1838        showIndent(outfile, level)
1839        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
1840        already_processed = []
1841        self.exportAttributes(outfile, level, already_processed, namespace_, name_='DomainArchitecture')
1842        if self.hasContent_():
1843            outfile.write('>\n')
1844            self.exportChildren(outfile, level + 1, namespace_, name_)
1845            showIndent(outfile, level)
1846            outfile.write('</%s%s>\n' % (namespace_, name_))
1847        else:
1848            outfile.write('/>\n')
1849    def exportAttributes(self, outfile, level, already_processed, namespace_='phy:', name_='DomainArchitecture'):
1850        if self.length is not None and 'length' not in already_processed:
1851            already_processed.append('length')
1852            outfile.write(' length="%s"' % self.gds_format_integer(self.length, input_name='length'))
1853    def exportChildren(self, outfile, level, namespace_='phy:', name_='DomainArchitecture', fromsubclass_=False):
1854        for domain_ in self.domain:
1855            domain_.export(outfile, level, namespace_, name_='domain')
1856    def hasContent_(self):
1857        if (
1858            self.domain
1859            ):
1860            return True
1861        else:
1862            return False
1863    def exportLiteral(self, outfile, level, name_='DomainArchitecture'):
1864        level += 1
1865        self.exportLiteralAttributes(outfile, level, [], name_)
1866        if self.hasContent_():
1867            self.exportLiteralChildren(outfile, level, name_)
1868    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
1869        if self.length is not None and 'length' not in already_processed:
1870            already_processed.append('length')
1871            showIndent(outfile, level)
1872            outfile.write('length = %d,\n' % (self.length,))
1873    def exportLiteralChildren(self, outfile, level, name_):
1874        showIndent(outfile, level)
1875        outfile.write('domain=[\n')
1876        level += 1
1877        for domain_ in self.domain:
1878            showIndent(outfile, level)
1879            outfile.write('model_.ProteinDomain(\n')
1880            domain_.exportLiteral(outfile, level, name_='ProteinDomain')
1881            showIndent(outfile, level)
1882            outfile.write('),\n')
1883        level -= 1
1884        showIndent(outfile, level)
1885        outfile.write('],\n')
1886    def build(self, node):
1887        self.buildAttributes(node, node.attrib, [])
1888        for child in node:
1889            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
1890            self.buildChildren(child, node, nodeName_)
1891    def buildAttributes(self, node, attrs, already_processed):
1892        value = find_attr_value_('length', node)
1893        if value is not None and 'length' not in already_processed:
1894            already_processed.append('length')
1895            try:
1896                self.length = int(value)
1897            except ValueError as exp:
1898                raise_parse_error(node, 'Bad integer attribute: %s' % exp)
1899            if self.length < 0:
1900                raise_parse_error(node, 'Invalid NonNegativeInteger')
1901    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
1902        if nodeName_ == 'domain':
1903            obj_ = ProteinDomain.factory()
1904            obj_.build(child_)
1905            self.domain.append(obj_)
1906# end class DomainArchitecture
1907
1908
1909class ProteinDomain(GeneratedsSuper):
1910    """To represent an individual domain in a domain architecture. The
1911    name/unique identifier is described via the 'id' attribute.
1912    'confidence' can be used to store (i.e.) E-values."""
1913    subclass = None
1914    superclass = None
1915    def __init__(self, to=None, confidence=None, fromxx=None, id=None, valueOf_=None):
1916        self.to = _cast(int, to)
1917        self.confidence = _cast(float, confidence)
1918        self.fromxx = _cast(int, fromxx)
1919        self.id = _cast(None, id)
1920        self.valueOf_ = valueOf_
1921    def factory(*args_, **kwargs_):
1922        if ProteinDomain.subclass:
1923            return ProteinDomain.subclass(*args_, **kwargs_)
1924        else:
1925            return ProteinDomain(*args_, **kwargs_)
1926    factory = staticmethod(factory)
1927    def get_to(self): return self.to
1928    def set_to(self, to): self.to = to
1929    def get_confidence(self): return self.confidence
1930    def set_confidence(self, confidence): self.confidence = confidence
1931    def get_from(self): return self.fromxx
1932    def set_from(self, fromxx): self.fromxx = fromxx
1933    def get_id(self): return self.id
1934    def set_id(self, id): self.id = id
1935    def get_valueOf_(self): return self.valueOf_
1936    def set_valueOf_(self, valueOf_): self.valueOf_ = valueOf_
1937    def export(self, outfile, level, namespace_='phy:', name_='ProteinDomain', namespacedef_=''):
1938        showIndent(outfile, level)
1939        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
1940        already_processed = []
1941        self.exportAttributes(outfile, level, already_processed, namespace_, name_='ProteinDomain')
1942        if self.hasContent_():
1943            outfile.write('>')
1944            outfile.write(str(self.valueOf_).encode(ExternalEncoding))
1945            self.exportChildren(outfile, level + 1, namespace_, name_)
1946            outfile.write('</%s%s>\n' % (namespace_, name_))
1947        else:
1948            outfile.write('/>\n')
1949    def exportAttributes(self, outfile, level, already_processed, namespace_='phy:', name_='ProteinDomain'):
1950        if self.to is not None and 'to' not in already_processed:
1951            already_processed.append('to')
1952            outfile.write(' to="%s"' % self.gds_format_integer(self.to, input_name='to'))
1953        if self.confidence is not None and 'confidence' not in already_processed:
1954            already_processed.append('confidence')
1955            outfile.write(' confidence="%s"' % self.gds_format_double(self.confidence, input_name='confidence'))
1956        if self.fromxx is not None and 'fromxx' not in already_processed:
1957            already_processed.append('fromxx')
1958            outfile.write(' from="%s"' % self.gds_format_integer(self.fromxx, input_name='from'))
1959        if self.id is not None and 'id' not in already_processed:
1960            already_processed.append('id')
1961            outfile.write(' id=%s' % (self.gds_format_string(quote_attrib(self.id).encode(ExternalEncoding), input_name='id'), ))
1962    def exportChildren(self, outfile, level, namespace_='phy:', name_='ProteinDomain', fromsubclass_=False):
1963        pass
1964    def hasContent_(self):
1965        if (
1966            self.valueOf_
1967            ):
1968            return True
1969        else:
1970            return False
1971    def exportLiteral(self, outfile, level, name_='ProteinDomain'):
1972        level += 1
1973        self.exportLiteralAttributes(outfile, level, [], name_)
1974        if self.hasContent_():
1975            self.exportLiteralChildren(outfile, level, name_)
1976        showIndent(outfile, level)
1977        outfile.write('valueOf_ = """%s""",\n' % (self.valueOf_,))
1978    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
1979        if self.to is not None and 'to' not in already_processed:
1980            already_processed.append('to')
1981            showIndent(outfile, level)
1982            outfile.write('to = %d,\n' % (self.to,))
1983        if self.confidence is not None and 'confidence' not in already_processed:
1984            already_processed.append('confidence')
1985            showIndent(outfile, level)
1986            outfile.write('confidence = %e,\n' % (self.confidence,))
1987        if self.fromxx is not None and 'fromxx' not in already_processed:
1988            already_processed.append('fromxx')
1989            showIndent(outfile, level)
1990            outfile.write('fromxx = %d,\n' % (self.fromxx,))
1991        if self.id is not None and 'id' not in already_processed:
1992            already_processed.append('id')
1993            showIndent(outfile, level)
1994            outfile.write('id = "%s",\n' % (self.id,))
1995    def exportLiteralChildren(self, outfile, level, name_):
1996        pass
1997    def build(self, node):
1998        self.buildAttributes(node, node.attrib, [])
1999        self.valueOf_ = get_all_text_(node)
2000        for child in node:
2001            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
2002            self.buildChildren(child, node, nodeName_)
2003    def buildAttributes(self, node, attrs, already_processed):
2004        value = find_attr_value_('to', node)
2005        if value is not None and 'to' not in already_processed:
2006            already_processed.append('to')
2007            try:
2008                self.to = int(value)
2009            except ValueError as exp:
2010                raise_parse_error(node, 'Bad integer attribute: %s' % exp)
2011            if self.to < 0:
2012                raise_parse_error(node, 'Invalid NonNegativeInteger')
2013        value = find_attr_value_('confidence', node)
2014        if value is not None and 'confidence' not in already_processed:
2015            already_processed.append('confidence')
2016            try:
2017                self.confidence = float(value)
2018            except ValueError as exp:
2019                raise ValueError('Bad float/double attribute (confidence): %s' % exp)
2020        value = find_attr_value_('from', node)
2021        if value is not None and 'from' not in already_processed:
2022            already_processed.append('from')
2023            try:
2024                self.fromxx = int(value)
2025            except ValueError as exp:
2026                raise_parse_error(node, 'Bad integer attribute: %s' % exp)
2027            if self.fromxx < 0:
2028                raise_parse_error(node, 'Invalid NonNegativeInteger')
2029        value = find_attr_value_('id', node)
2030        if value is not None and 'id' not in already_processed:
2031            already_processed.append('id')
2032            self.id = value
2033            self.id = ' '.join(self.id.split())
2034    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
2035        pass
2036# end class ProteinDomain
2037
2038
2039class Events(GeneratedsSuper):
2040    """Events at the root node of a clade (e.g. one gene duplication)."""
2041    subclass = None
2042    superclass = None
2043    def __init__(self, type_=None, duplications=None, speciations=None, losses=None, confidence=None, valueOf_=None):
2044        self.type_ = type_
2045        self.duplications = duplications
2046        self.speciations = speciations
2047        self.losses = losses
2048        self.confidence = confidence
2049    def factory(*args_, **kwargs_):
2050        if Events.subclass:
2051            return Events.subclass(*args_, **kwargs_)
2052        else:
2053            return Events(*args_, **kwargs_)
2054    factory = staticmethod(factory)
2055    def get_type(self): return self.type_
2056    def set_type(self, type_): self.type_ = type_
2057    def validate_EventType(self, value):
2058        # Validate type EventType, a restriction on xs:token.
2059        pass
2060    def get_duplications(self): return self.duplications
2061    def set_duplications(self, duplications): self.duplications = duplications
2062    def get_speciations(self): return self.speciations
2063    def set_speciations(self, speciations): self.speciations = speciations
2064    def get_losses(self): return self.losses
2065    def set_losses(self, losses): self.losses = losses
2066    def get_confidence(self): return self.confidence
2067    def set_confidence(self, confidence): self.confidence = confidence
2068    def export(self, outfile, level, namespace_='phy:', name_='Events', namespacedef_=''):
2069        showIndent(outfile, level)
2070        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
2071        already_processed = []
2072        self.exportAttributes(outfile, level, already_processed, namespace_, name_='Events')
2073        if self.hasContent_():
2074            outfile.write('>\n')
2075            self.exportChildren(outfile, level + 1, namespace_, name_)
2076            showIndent(outfile, level)
2077            outfile.write('</%s%s>\n' % (namespace_, name_))
2078        else:
2079            outfile.write('/>\n')
2080    def exportAttributes(self, outfile, level, already_processed, namespace_='phy:', name_='Events'):
2081        pass
2082    def exportChildren(self, outfile, level, namespace_='phy:', name_='Events', fromsubclass_=False):
2083        if self.type_ is not None:
2084            showIndent(outfile, level)
2085            outfile.write('<%stype>%s</%stype>\n' % (namespace_, self.gds_format_string(quote_xml(self.type_).encode(ExternalEncoding), input_name='type'), namespace_))
2086        if self.duplications is not None:
2087            showIndent(outfile, level)
2088            outfile.write('<%sduplications>%s</%sduplications>\n' % (namespace_, self.gds_format_integer(self.duplications, input_name='duplications'), namespace_))
2089        if self.speciations is not None:
2090            showIndent(outfile, level)
2091            outfile.write('<%sspeciations>%s</%sspeciations>\n' % (namespace_, self.gds_format_integer(self.speciations, input_name='speciations'), namespace_))
2092        if self.losses is not None:
2093            showIndent(outfile, level)
2094            outfile.write('<%slosses>%s</%slosses>\n' % (namespace_, self.gds_format_integer(self.losses, input_name='losses'), namespace_))
2095        if self.confidence:
2096            self.confidence.export(outfile, level, namespace_, name_='confidence')
2097    def hasContent_(self):
2098        if (
2099            self.type_ is not None or
2100            self.duplications is not None or
2101            self.speciations is not None or
2102            self.losses is not None or
2103            self.confidence is not None
2104            ):
2105            return True
2106        else:
2107            return False
2108    def exportLiteral(self, outfile, level, name_='Events'):
2109        level += 1
2110        self.exportLiteralAttributes(outfile, level, [], name_)
2111        if self.hasContent_():
2112            self.exportLiteralChildren(outfile, level, name_)
2113    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
2114        pass
2115    def exportLiteralChildren(self, outfile, level, name_):
2116        if self.type_ is not None:
2117            showIndent(outfile, level)
2118            outfile.write('type_=%s,\n' % quote_python(self.type_).encode(ExternalEncoding))
2119        if self.duplications is not None:
2120            showIndent(outfile, level)
2121            outfile.write('duplications=%d,\n' % self.duplications)
2122        if self.speciations is not None:
2123            showIndent(outfile, level)
2124            outfile.write('speciations=%d,\n' % self.speciations)
2125        if self.losses is not None:
2126            showIndent(outfile, level)
2127            outfile.write('losses=%d,\n' % self.losses)
2128        if self.confidence is not None:
2129            showIndent(outfile, level)
2130            outfile.write('confidence=model_.Confidence(\n')
2131            self.confidence.exportLiteral(outfile, level, name_='confidence')
2132            showIndent(outfile, level)
2133            outfile.write('),\n')
2134    def build(self, node):
2135        self.buildAttributes(node, node.attrib, [])
2136        for child in node:
2137            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
2138            self.buildChildren(child, node, nodeName_)
2139    def buildAttributes(self, node, attrs, already_processed):
2140        pass
2141    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
2142        if nodeName_ == 'type':
2143            type_ = child_.text
2144            type_ = re_.sub(STRING_CLEANUP_PAT, " ", type_).strip()
2145            type_ = self.gds_validate_string(type_, node, 'type')
2146            self.type_ = type_
2147            self.validate_EventType(self.type_)    # validate type EventType
2148        elif nodeName_ == 'duplications':
2149            sval_ = child_.text
2150            try:
2151                ival_ = int(sval_)
2152            except (TypeError, ValueError) as exp:
2153                raise_parse_error(child_, 'requires integer: %s' % exp)
2154            if ival_ < 0:
2155                raise_parse_error(child_, 'requires nonNegativeInteger')
2156            ival_ = self.gds_validate_integer(ival_, node, 'duplications')
2157            self.duplications = ival_
2158        elif nodeName_ == 'speciations':
2159            sval_ = child_.text
2160            try:
2161                ival_ = int(sval_)
2162            except (TypeError, ValueError) as exp:
2163                raise_parse_error(child_, 'requires integer: %s' % exp)
2164            if ival_ < 0:
2165                raise_parse_error(child_, 'requires nonNegativeInteger')
2166            ival_ = self.gds_validate_integer(ival_, node, 'speciations')
2167            self.speciations = ival_
2168        elif nodeName_ == 'losses':
2169            sval_ = child_.text
2170            try:
2171                ival_ = int(sval_)
2172            except (TypeError, ValueError) as exp:
2173                raise_parse_error(child_, 'requires integer: %s' % exp)
2174            if ival_ < 0:
2175                raise_parse_error(child_, 'requires nonNegativeInteger')
2176            ival_ = self.gds_validate_integer(ival_, node, 'losses')
2177            self.losses = ival_
2178        elif nodeName_ == 'confidence':
2179            obj_ = Confidence.factory()
2180            obj_.build(child_)
2181            self.set_confidence(obj_)
2182# end class Events
2183
2184
2185class BinaryCharacters(GeneratedsSuper):
2186    """The names and/or counts of binary characters present, gained, and
2187    lost at the root of a clade."""
2188    subclass = None
2189    superclass = None
2190    def __init__(self, lost_count=None, absent_count=None, present_count=None, type_=None, gained_count=None, gained=None, lost=None, present=None, absent=None, valueOf_=None):
2191        self.lost_count = _cast(int, lost_count)
2192        self.absent_count = _cast(int, absent_count)
2193        self.present_count = _cast(int, present_count)
2194        self.type_ = _cast(None, type_)
2195        self.gained_count = _cast(int, gained_count)
2196        self.gained = gained
2197        self.lost = lost
2198        self.present = present
2199        self.absent = absent
2200    def factory(*args_, **kwargs_):
2201        if BinaryCharacters.subclass:
2202            return BinaryCharacters.subclass(*args_, **kwargs_)
2203        else:
2204            return BinaryCharacters(*args_, **kwargs_)
2205    factory = staticmethod(factory)
2206    def get_gained(self): return self.gained
2207    def set_gained(self, gained): self.gained = gained
2208    def get_lost(self): return self.lost
2209    def set_lost(self, lost): self.lost = lost
2210    def get_present(self): return self.present
2211    def set_present(self, present): self.present = present
2212    def get_absent(self): return self.absent
2213    def set_absent(self, absent): self.absent = absent
2214    def get_lost_count(self): return self.lost_count
2215    def set_lost_count(self, lost_count): self.lost_count = lost_count
2216    def get_absent_count(self): return self.absent_count
2217    def set_absent_count(self, absent_count): self.absent_count = absent_count
2218    def get_present_count(self): return self.present_count
2219    def set_present_count(self, present_count): self.present_count = present_count
2220    def get_type(self): return self.type_
2221    def set_type(self, type_): self.type_ = type_
2222    def get_gained_count(self): return self.gained_count
2223    def set_gained_count(self, gained_count): self.gained_count = gained_count
2224    def export(self, outfile, level, namespace_='phy:', name_='BinaryCharacters', namespacedef_=''):
2225        showIndent(outfile, level)
2226        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
2227        already_processed = []
2228        self.exportAttributes(outfile, level, already_processed, namespace_, name_='BinaryCharacters')
2229        if self.hasContent_():
2230            outfile.write('>\n')
2231            self.exportChildren(outfile, level + 1, namespace_, name_)
2232            showIndent(outfile, level)
2233            outfile.write('</%s%s>\n' % (namespace_, name_))
2234        else:
2235            outfile.write('/>\n')
2236    def exportAttributes(self, outfile, level, already_processed, namespace_='phy:', name_='BinaryCharacters'):
2237        if self.lost_count is not None and 'lost_count' not in already_processed:
2238            already_processed.append('lost_count')
2239            outfile.write(' lost_count="%s"' % self.gds_format_integer(self.lost_count, input_name='lost_count'))
2240        if self.absent_count is not None and 'absent_count' not in already_processed:
2241            already_processed.append('absent_count')
2242            outfile.write(' absent_count="%s"' % self.gds_format_integer(self.absent_count, input_name='absent_count'))
2243        if self.present_count is not None and 'present_count' not in already_processed:
2244            already_processed.append('present_count')
2245            outfile.write(' present_count="%s"' % self.gds_format_integer(self.present_count, input_name='present_count'))
2246        if self.type_ is not None and 'type_' not in already_processed:
2247            already_processed.append('type_')
2248            outfile.write(' type=%s' % (self.gds_format_string(quote_attrib(self.type_).encode(ExternalEncoding), input_name='type'), ))
2249        if self.gained_count is not None and 'gained_count' not in already_processed:
2250            already_processed.append('gained_count')
2251            outfile.write(' gained_count="%s"' % self.gds_format_integer(self.gained_count, input_name='gained_count'))
2252    def exportChildren(self, outfile, level, namespace_='phy:', name_='BinaryCharacters', fromsubclass_=False):
2253        if self.gained:
2254            self.gained.export(outfile, level, namespace_, name_='gained')
2255        if self.lost:
2256            self.lost.export(outfile, level, namespace_, name_='lost')
2257        if self.present:
2258            self.present.export(outfile, level, namespace_, name_='present')
2259        if self.absent:
2260            self.absent.export(outfile, level, namespace_, name_='absent')
2261    def hasContent_(self):
2262        if (
2263            self.gained is not None or
2264            self.lost is not None or
2265            self.present is not None or
2266            self.absent is not None
2267            ):
2268            return True
2269        else:
2270            return False
2271    def exportLiteral(self, outfile, level, name_='BinaryCharacters'):
2272        level += 1
2273        self.exportLiteralAttributes(outfile, level, [], name_)
2274        if self.hasContent_():
2275            self.exportLiteralChildren(outfile, level, name_)
2276    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
2277        if self.lost_count is not None and 'lost_count' not in already_processed:
2278            already_processed.append('lost_count')
2279            showIndent(outfile, level)
2280            outfile.write('lost_count = %d,\n' % (self.lost_count,))
2281        if self.absent_count is not None and 'absent_count' not in already_processed:
2282            already_processed.append('absent_count')
2283            showIndent(outfile, level)
2284            outfile.write('absent_count = %d,\n' % (self.absent_count,))
2285        if self.present_count is not None and 'present_count' not in already_processed:
2286            already_processed.append('present_count')
2287            showIndent(outfile, level)
2288            outfile.write('present_count = %d,\n' % (self.present_count,))
2289        if self.type_ is not None and 'type_' not in already_processed:
2290            already_processed.append('type_')
2291            showIndent(outfile, level)
2292            outfile.write('type_ = "%s",\n' % (self.type_,))
2293        if self.gained_count is not None and 'gained_count' not in already_processed:
2294            already_processed.append('gained_count')
2295            showIndent(outfile, level)
2296            outfile.write('gained_count = %d,\n' % (self.gained_count,))
2297    def exportLiteralChildren(self, outfile, level, name_):
2298        if self.gained is not None:
2299            showIndent(outfile, level)
2300            outfile.write('gained=model_.BinaryCharacterList(\n')
2301            self.gained.exportLiteral(outfile, level, name_='gained')
2302            showIndent(outfile, level)
2303            outfile.write('),\n')
2304        if self.lost is not None:
2305            showIndent(outfile, level)
2306            outfile.write('lost=model_.BinaryCharacterList(\n')
2307            self.lost.exportLiteral(outfile, level, name_='lost')
2308            showIndent(outfile, level)
2309            outfile.write('),\n')
2310        if self.present is not None:
2311            showIndent(outfile, level)
2312            outfile.write('present=model_.BinaryCharacterList(\n')
2313            self.present.exportLiteral(outfile, level, name_='present')
2314            showIndent(outfile, level)
2315            outfile.write('),\n')
2316        if self.absent is not None:
2317            showIndent(outfile, level)
2318            outfile.write('absent=model_.BinaryCharacterList(\n')
2319            self.absent.exportLiteral(outfile, level, name_='absent')
2320            showIndent(outfile, level)
2321            outfile.write('),\n')
2322    def build(self, node):
2323        self.buildAttributes(node, node.attrib, [])
2324        for child in node:
2325            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
2326            self.buildChildren(child, node, nodeName_)
2327    def buildAttributes(self, node, attrs, already_processed):
2328        value = find_attr_value_('lost_count', node)
2329        if value is not None and 'lost_count' not in already_processed:
2330            already_processed.append('lost_count')
2331            try:
2332                self.lost_count = int(value)
2333            except ValueError as exp:
2334                raise_parse_error(node, 'Bad integer attribute: %s' % exp)
2335            if self.lost_count < 0:
2336                raise_parse_error(node, 'Invalid NonNegativeInteger')
2337        value = find_attr_value_('absent_count', node)
2338        if value is not None and 'absent_count' not in already_processed:
2339            already_processed.append('absent_count')
2340            try:
2341                self.absent_count = int(value)
2342            except ValueError as exp:
2343                raise_parse_error(node, 'Bad integer attribute: %s' % exp)
2344            if self.absent_count < 0:
2345                raise_parse_error(node, 'Invalid NonNegativeInteger')
2346        value = find_attr_value_('present_count', node)
2347        if value is not None and 'present_count' not in already_processed:
2348            already_processed.append('present_count')
2349            try:
2350                self.present_count = int(value)
2351            except ValueError as exp:
2352                raise_parse_error(node, 'Bad integer attribute: %s' % exp)
2353            if self.present_count < 0:
2354                raise_parse_error(node, 'Invalid NonNegativeInteger')
2355        value = find_attr_value_('type', node)
2356        if value is not None and 'type' not in already_processed:
2357            already_processed.append('type')
2358            self.type_ = value
2359            self.type_ = ' '.join(self.type_.split())
2360        value = find_attr_value_('gained_count', node)
2361        if value is not None and 'gained_count' not in already_processed:
2362            already_processed.append('gained_count')
2363            try:
2364                self.gained_count = int(value)
2365            except ValueError as exp:
2366                raise_parse_error(node, 'Bad integer attribute: %s' % exp)
2367            if self.gained_count < 0:
2368                raise_parse_error(node, 'Invalid NonNegativeInteger')
2369    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
2370        if nodeName_ == 'gained':
2371            obj_ = BinaryCharacterList.factory()
2372            obj_.build(child_)
2373            self.set_gained(obj_)
2374        elif nodeName_ == 'lost':
2375            obj_ = BinaryCharacterList.factory()
2376            obj_.build(child_)
2377            self.set_lost(obj_)
2378        elif nodeName_ == 'present':
2379            obj_ = BinaryCharacterList.factory()
2380            obj_.build(child_)
2381            self.set_present(obj_)
2382        elif nodeName_ == 'absent':
2383            obj_ = BinaryCharacterList.factory()
2384            obj_.build(child_)
2385            self.set_absent(obj_)
2386# end class BinaryCharacters
2387
2388
2389class BinaryCharacterList(GeneratedsSuper):
2390    subclass = None
2391    superclass = None
2392    def __init__(self, bc=None, valueOf_=None):
2393        if bc is None:
2394            self.bc = []
2395        else:
2396            self.bc = bc
2397    def factory(*args_, **kwargs_):
2398        if BinaryCharacterList.subclass:
2399            return BinaryCharacterList.subclass(*args_, **kwargs_)
2400        else:
2401            return BinaryCharacterList(*args_, **kwargs_)
2402    factory = staticmethod(factory)
2403    def get_bc(self): return self.bc
2404    def set_bc(self, bc): self.bc = bc
2405    def add_bc(self, value): self.bc.append(value)
2406    def insert_bc(self, index, value): self.bc[index] = value
2407    def export(self, outfile, level, namespace_='phy:', name_='BinaryCharacterList', namespacedef_=''):
2408        showIndent(outfile, level)
2409        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
2410        already_processed = []
2411        self.exportAttributes(outfile, level, already_processed, namespace_, name_='BinaryCharacterList')
2412        if self.hasContent_():
2413            outfile.write('>\n')
2414            self.exportChildren(outfile, level + 1, namespace_, name_)
2415            showIndent(outfile, level)
2416            outfile.write('</%s%s>\n' % (namespace_, name_))
2417        else:
2418            outfile.write('/>\n')
2419    def exportAttributes(self, outfile, level, already_processed, namespace_='phy:', name_='BinaryCharacterList'):
2420        pass
2421    def exportChildren(self, outfile, level, namespace_='phy:', name_='BinaryCharacterList', fromsubclass_=False):
2422        for bc_ in self.bc:
2423            showIndent(outfile, level)
2424            outfile.write('<%sbc>%s</%sbc>\n' % (namespace_, self.gds_format_string(quote_xml(bc_).encode(ExternalEncoding), input_name='bc'), namespace_))
2425    def hasContent_(self):
2426        if (
2427            self.bc
2428            ):
2429            return True
2430        else:
2431            return False
2432    def exportLiteral(self, outfile, level, name_='BinaryCharacterList'):
2433        level += 1
2434        self.exportLiteralAttributes(outfile, level, [], name_)
2435        if self.hasContent_():
2436            self.exportLiteralChildren(outfile, level, name_)
2437    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
2438        pass
2439    def exportLiteralChildren(self, outfile, level, name_):
2440        showIndent(outfile, level)
2441        outfile.write('bc=[\n')
2442        level += 1
2443        for bc_ in self.bc:
2444            showIndent(outfile, level)
2445            outfile.write('%s,\n' % quote_python(bc_).encode(ExternalEncoding))
2446        level -= 1
2447        showIndent(outfile, level)
2448        outfile.write('],\n')
2449    def build(self, node):
2450        self.buildAttributes(node, node.attrib, [])
2451        for child in node:
2452            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
2453            self.buildChildren(child, node, nodeName_)
2454    def buildAttributes(self, node, attrs, already_processed):
2455        pass
2456    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
2457        if nodeName_ == 'bc':
2458            bc_ = child_.text
2459            bc_ = re_.sub(STRING_CLEANUP_PAT, " ", bc_).strip()
2460            bc_ = self.gds_validate_string(bc_, node, 'bc')
2461            self.bc.append(bc_)
2462# end class BinaryCharacterList
2463
2464
2465class Reference(GeneratedsSuper):
2466    """A literature reference for a clade. It is recommended to use the
2467    'doi' attribute instead of the free text 'desc' element whenever
2468    possible."""
2469    subclass = None
2470    superclass = None
2471    def __init__(self, doi=None, desc=None, valueOf_=None):
2472        self.doi = _cast(None, doi)
2473        self.desc = desc
2474    def factory(*args_, **kwargs_):
2475        if Reference.subclass:
2476            return Reference.subclass(*args_, **kwargs_)
2477        else:
2478            return Reference(*args_, **kwargs_)
2479    factory = staticmethod(factory)
2480    def get_desc(self): return self.desc
2481    def set_desc(self, desc): self.desc = desc
2482    def get_doi(self): return self.doi
2483    def set_doi(self, doi): self.doi = doi
2484    def export(self, outfile, level, namespace_='phy:', name_='Reference', namespacedef_=''):
2485        showIndent(outfile, level)
2486        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
2487        already_processed = []
2488        self.exportAttributes(outfile, level, already_processed, namespace_, name_='Reference')
2489        if self.hasContent_():
2490            outfile.write('>\n')
2491            self.exportChildren(outfile, level + 1, namespace_, name_)
2492            showIndent(outfile, level)
2493            outfile.write('</%s%s>\n' % (namespace_, name_))
2494        else:
2495            outfile.write('/>\n')
2496    def exportAttributes(self, outfile, level, already_processed, namespace_='phy:', name_='Reference'):
2497        if self.doi is not None and 'doi' not in already_processed:
2498            already_processed.append('doi')
2499            outfile.write(' doi=%s' % (quote_attrib(self.doi), ))
2500    def exportChildren(self, outfile, level, namespace_='phy:', name_='Reference', fromsubclass_=False):
2501        if self.desc is not None:
2502            showIndent(outfile, level)
2503            outfile.write('<%sdesc>%s</%sdesc>\n' % (namespace_, self.gds_format_string(quote_xml(self.desc).encode(ExternalEncoding), input_name='desc'), namespace_))
2504    def hasContent_(self):
2505        if (
2506            self.desc is not None
2507            ):
2508            return True
2509        else:
2510            return False
2511    def exportLiteral(self, outfile, level, name_='Reference'):
2512        level += 1
2513        self.exportLiteralAttributes(outfile, level, [], name_)
2514        if self.hasContent_():
2515            self.exportLiteralChildren(outfile, level, name_)
2516    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
2517        if self.doi is not None and 'doi' not in already_processed:
2518            already_processed.append('doi')
2519            showIndent(outfile, level)
2520            outfile.write('doi = %s,\n' % (self.doi,))
2521    def exportLiteralChildren(self, outfile, level, name_):
2522        if self.desc is not None:
2523            showIndent(outfile, level)
2524            outfile.write('desc=%s,\n' % quote_python(self.desc).encode(ExternalEncoding))
2525    def build(self, node):
2526        self.buildAttributes(node, node.attrib, [])
2527        for child in node:
2528            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
2529            self.buildChildren(child, node, nodeName_)
2530    def buildAttributes(self, node, attrs, already_processed):
2531        value = find_attr_value_('doi', node)
2532        if value is not None and 'doi' not in already_processed:
2533            already_processed.append('doi')
2534            self.doi = value
2535    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
2536        if nodeName_ == 'desc':
2537            desc_ = child_.text
2538            desc_ = re_.sub(STRING_CLEANUP_PAT, " ", desc_).strip()
2539            desc_ = self.gds_validate_string(desc_, node, 'desc')
2540            self.desc = desc_
2541# end class Reference
2542
2543
2544class Annotation(GeneratedsSuper):
2545    """The annotation of a molecular sequence. It is recommended to
2546    annotate by using the optional 'ref' attribute (some examples of
2547    acceptable values for the ref attribute: 'GO:0008270',
2548    'KEGG:Tetrachloroethene degradation', 'EC:1.1.1.1'). Optional
2549    element 'desc' allows for a free text description. Optional
2550    element 'confidence' is used to state the type and value of
2551    support for a annotation. Similarly, optional attribute
2552    'evidence' is used to describe the evidence for a annotation as
2553    free text (e.g. 'experimental'). Optional element 'property'
2554    allows for further, typed and referenced annotations from
2555    external resources."""
2556    subclass = None
2557    superclass = None
2558    def __init__(self, source=None, type_=None, ref=None, evidence=None, desc=None, confidence=None, property=None, uri=None, valueOf_=None):
2559        self.source = _cast(None, source)
2560        self.type_ = _cast(None, type_)
2561        self.ref = _cast(None, ref)
2562        self.evidence = _cast(None, evidence)
2563        self.desc = desc
2564        self.confidence = confidence
2565        if property is None:
2566            self.property = []
2567        else:
2568            self.property = property
2569        self.uri = uri
2570    def factory(*args_, **kwargs_):
2571        if Annotation.subclass:
2572            return Annotation.subclass(*args_, **kwargs_)
2573        else:
2574            return Annotation(*args_, **kwargs_)
2575    factory = staticmethod(factory)
2576    def get_desc(self): return self.desc
2577    def set_desc(self, desc): self.desc = desc
2578    def get_confidence(self): return self.confidence
2579    def set_confidence(self, confidence): self.confidence = confidence
2580    def get_property(self): return self.property
2581    def set_property(self, property): self.property = property
2582    def add_property(self, value): self.property.append(value)
2583    def insert_property(self, index, value): self.property[index] = value
2584    def get_uri(self): return self.uri
2585    def set_uri(self, uri): self.uri = uri
2586    def get_source(self): return self.source
2587    def set_source(self, source): self.source = source
2588    def get_type(self): return self.type_
2589    def set_type(self, type_): self.type_ = type_
2590    def get_ref(self): return self.ref
2591    def set_ref(self, ref): self.ref = ref
2592    def get_evidence(self): return self.evidence
2593    def set_evidence(self, evidence): self.evidence = evidence
2594    def export(self, outfile, level, namespace_='phy:', name_='Annotation', namespacedef_=''):
2595        showIndent(outfile, level)
2596        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
2597        already_processed = []
2598        self.exportAttributes(outfile, level, already_processed, namespace_, name_='Annotation')
2599        if self.hasContent_():
2600            outfile.write('>\n')
2601            self.exportChildren(outfile, level + 1, namespace_, name_)
2602            showIndent(outfile, level)
2603            outfile.write('</%s%s>\n' % (namespace_, name_))
2604        else:
2605            outfile.write('/>\n')
2606    def exportAttributes(self, outfile, level, already_processed, namespace_='phy:', name_='Annotation'):
2607        if self.source is not None and 'source' not in already_processed:
2608            already_processed.append('source')
2609            outfile.write(' source=%s' % (self.gds_format_string(quote_attrib(self.source).encode(ExternalEncoding), input_name='source'), ))
2610        if self.type_ is not None and 'type_' not in already_processed:
2611            already_processed.append('type_')
2612            outfile.write(' type=%s' % (self.gds_format_string(quote_attrib(self.type_).encode(ExternalEncoding), input_name='type'), ))
2613        if self.ref is not None and 'ref' not in already_processed:
2614            already_processed.append('ref')
2615            outfile.write(' ref=%s' % (quote_attrib(self.ref), ))
2616        if self.evidence is not None and 'evidence' not in already_processed:
2617            already_processed.append('evidence')
2618            outfile.write(' evidence=%s' % (self.gds_format_string(quote_attrib(self.evidence).encode(ExternalEncoding), input_name='evidence'), ))
2619    def exportChildren(self, outfile, level, namespace_='phy:', name_='Annotation', fromsubclass_=False):
2620        if self.desc is not None:
2621            showIndent(outfile, level)
2622            outfile.write('<%sdesc>%s</%sdesc>\n' % (namespace_, self.gds_format_string(quote_xml(self.desc).encode(ExternalEncoding), input_name='desc'), namespace_))
2623        if self.confidence:
2624            self.confidence.export(outfile, level, namespace_, name_='confidence')
2625        for property_ in self.property:
2626            property_.export(outfile, level, namespace_, name_='property')
2627        if self.uri:
2628            self.uri.export(outfile, level, namespace_, name_='uri')
2629    def hasContent_(self):
2630        if (
2631            self.desc is not None or
2632            self.confidence is not None or
2633            self.property or
2634            self.uri is not None
2635            ):
2636            return True
2637        else:
2638            return False
2639    def exportLiteral(self, outfile, level, name_='Annotation'):
2640        level += 1
2641        self.exportLiteralAttributes(outfile, level, [], name_)
2642        if self.hasContent_():
2643            self.exportLiteralChildren(outfile, level, name_)
2644    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
2645        if self.source is not None and 'source' not in already_processed:
2646            already_processed.append('source')
2647            showIndent(outfile, level)
2648            outfile.write('source = "%s",\n' % (self.source,))
2649        if self.type_ is not None and 'type_' not in already_processed:
2650            already_processed.append('type_')
2651            showIndent(outfile, level)
2652            outfile.write('type_ = "%s",\n' % (self.type_,))
2653        if self.ref is not None and 'ref' not in already_processed:
2654            already_processed.append('ref')
2655            showIndent(outfile, level)
2656            outfile.write('ref = %s,\n' % (self.ref,))
2657        if self.evidence is not None and 'evidence' not in already_processed:
2658            already_processed.append('evidence')
2659            showIndent(outfile, level)
2660            outfile.write('evidence = "%s",\n' % (self.evidence,))
2661    def exportLiteralChildren(self, outfile, level, name_):
2662        if self.desc is not None:
2663            showIndent(outfile, level)
2664            outfile.write('desc=%s,\n' % quote_python(self.desc).encode(ExternalEncoding))
2665        if self.confidence is not None:
2666            showIndent(outfile, level)
2667            outfile.write('confidence=model_.Confidence(\n')
2668            self.confidence.exportLiteral(outfile, level, name_='confidence')
2669            showIndent(outfile, level)
2670            outfile.write('),\n')
2671        showIndent(outfile, level)
2672        outfile.write('property=[\n')
2673        level += 1
2674        for property_ in self.property:
2675            showIndent(outfile, level)
2676            outfile.write('model_.Property(\n')
2677            property_.exportLiteral(outfile, level, name_='Property')
2678            showIndent(outfile, level)
2679            outfile.write('),\n')
2680        level -= 1
2681        showIndent(outfile, level)
2682        outfile.write('],\n')
2683        if self.uri is not None:
2684            showIndent(outfile, level)
2685            outfile.write('uri=model_.Uri(\n')
2686            self.uri.exportLiteral(outfile, level, name_='uri')
2687            showIndent(outfile, level)
2688            outfile.write('),\n')
2689    def build(self, node):
2690        self.buildAttributes(node, node.attrib, [])
2691        for child in node:
2692            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
2693            self.buildChildren(child, node, nodeName_)
2694    def buildAttributes(self, node, attrs, already_processed):
2695        value = find_attr_value_('source', node)
2696        if value is not None and 'source' not in already_processed:
2697            already_processed.append('source')
2698            self.source = value
2699            self.source = ' '.join(self.source.split())
2700        value = find_attr_value_('type', node)
2701        if value is not None and 'type' not in already_processed:
2702            already_processed.append('type')
2703            self.type_ = value
2704            self.type_ = ' '.join(self.type_.split())
2705        value = find_attr_value_('ref', node)
2706        if value is not None and 'ref' not in already_processed:
2707            already_processed.append('ref')
2708            self.ref = value
2709        value = find_attr_value_('evidence', node)
2710        if value is not None and 'evidence' not in already_processed:
2711            already_processed.append('evidence')
2712            self.evidence = value
2713            self.evidence = ' '.join(self.evidence.split())
2714    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
2715        if nodeName_ == 'desc':
2716            desc_ = child_.text
2717            desc_ = re_.sub(STRING_CLEANUP_PAT, " ", desc_).strip()
2718            desc_ = self.gds_validate_string(desc_, node, 'desc')
2719            self.desc = desc_
2720        elif nodeName_ == 'confidence':
2721            obj_ = Confidence.factory()
2722            obj_.build(child_)
2723            self.set_confidence(obj_)
2724        elif nodeName_ == 'property':
2725            obj_ = Property.factory()
2726            obj_.build(child_)
2727            self.property.append(obj_)
2728        elif nodeName_ == 'uri':
2729            obj_ = Uri.factory()
2730            obj_.build(child_)
2731            self.set_uri(obj_)
2732# end class Annotation
2733
2734
2735class Property(GeneratedsSuper):
2736    """Property allows for typed and referenced properties from external
2737    resources to be attached to 'Phylogeny', 'Clade', and
2738    'Annotation'. The value of a property is its mixed (free text)
2739    content. Attribute 'datatype' indicates the type of a property
2740    and is limited to xsd-datatypes (e.g. 'xsd:string',
2741    'xsd:boolean', 'xsd:integer', 'xsd:decimal', 'xsd:float',
2742    'xsd:double', 'xsd:date', 'xsd:anyURI'). Attribute 'applies_to'
2743    indicates the item to which a property applies to (e.g. 'node'
2744    for the parent node of a clade, 'parent_branch' for the parent
2745    branch of a clade). Attribute 'id_ref' allows to attached a
2746    property specifically to one element (on the xml-level).
2747    Optional attribute 'unit' is used to indicate the unit of the
2748    property. An example: <property datatype="xsd:integer"
2749    ref="NOAA:depth" applies_to="clade" unit="METRIC:m"> 200
2750    </property>"""
2751    subclass = None
2752    superclass = None
2753    def __init__(self, datatype=None, id_ref=None, ref=None, applies_to=None, unit=None, valueOf_=None, mixedclass_=None, content_=None):
2754        self.datatype = _cast(None, datatype)
2755        self.id_ref = _cast(None, id_ref)
2756        self.ref = _cast(None, ref)
2757        self.applies_to = _cast(None, applies_to)
2758        self.unit = _cast(None, unit)
2759        self.valueOf_ = valueOf_
2760        if mixedclass_ is None:
2761            self.mixedclass_ = MixedContainer
2762        else:
2763            self.mixedclass_ = mixedclass_
2764        if content_ is None:
2765            self.content_ = []
2766        else:
2767            self.content_ = content_
2768        self.valueOf_ = valueOf_
2769    def factory(*args_, **kwargs_):
2770        if Property.subclass:
2771            return Property.subclass(*args_, **kwargs_)
2772        else:
2773            return Property(*args_, **kwargs_)
2774    factory = staticmethod(factory)
2775    def get_datatype(self): return self.datatype
2776    def set_datatype(self, datatype): self.datatype = datatype
2777    def get_id_ref(self): return self.id_ref
2778    def set_id_ref(self, id_ref): self.id_ref = id_ref
2779    def get_ref(self): return self.ref
2780    def set_ref(self, ref): self.ref = ref
2781    def get_applies_to(self): return self.applies_to
2782    def set_applies_to(self, applies_to): self.applies_to = applies_to
2783    def get_unit(self): return self.unit
2784    def set_unit(self, unit): self.unit = unit
2785    def get_valueOf_(self): return self.valueOf_
2786    def set_valueOf_(self, valueOf_): self.valueOf_ = valueOf_
2787    def export(self, outfile, level, namespace_='phy:', name_='Property', namespacedef_=''):
2788        showIndent(outfile, level)
2789        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
2790        already_processed = []
2791        self.exportAttributes(outfile, level, already_processed, namespace_, name_='Property')
2792        outfile.write('>')
2793        if self.valueOf_ is not None:
2794            outfile.write('%s' % (self.valueOf_,))
2795        self.exportChildren(outfile, level + 1, namespace_, name_)
2796        outfile.write('</%s%s>\n' % (namespace_, name_))
2797    def exportAttributes(self, outfile, level, already_processed, namespace_='phy:', name_='Property'):
2798        if self.datatype is not None and 'datatype' not in already_processed:
2799            already_processed.append('datatype')
2800            outfile.write(' datatype=%s' % (quote_attrib(self.datatype), ))
2801        if self.id_ref is not None and 'id_ref' not in already_processed:
2802            already_processed.append('id_ref')
2803            outfile.write(' id_ref=%s' % (quote_attrib(self.id_ref), ))
2804        if self.ref is not None and 'ref' not in already_processed:
2805            already_processed.append('ref')
2806            outfile.write(' ref=%s' % (quote_attrib(self.ref), ))
2807        if self.applies_to is not None and 'applies_to' not in already_processed:
2808            already_processed.append('applies_to')
2809            outfile.write(' applies_to=%s' % (quote_attrib(self.applies_to), ))
2810        if self.unit is not None and 'unit' not in already_processed:
2811            already_processed.append('unit')
2812            outfile.write(' unit=%s' % (quote_attrib(self.unit), ))
2813    def exportChildren(self, outfile, level, namespace_='phy:', name_='Property', fromsubclass_=False):
2814        pass
2815    def hasContent_(self):
2816        if (
2817            self.valueOf_
2818            ):
2819            return True
2820        else:
2821            return False
2822    def exportLiteral(self, outfile, level, name_='Property'):
2823        level += 1
2824        self.exportLiteralAttributes(outfile, level, [], name_)
2825        if self.hasContent_():
2826            self.exportLiteralChildren(outfile, level, name_)
2827        showIndent(outfile, level)
2828        outfile.write('valueOf_ = """%s""",\n' % (self.valueOf_,))
2829    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
2830        if self.datatype is not None and 'datatype' not in already_processed:
2831            already_processed.append('datatype')
2832            showIndent(outfile, level)
2833            outfile.write('datatype = %s,\n' % (self.datatype,))
2834        if self.id_ref is not None and 'id_ref' not in already_processed:
2835            already_processed.append('id_ref')
2836            showIndent(outfile, level)
2837            outfile.write('id_ref = %s,\n' % (self.id_ref,))
2838        if self.ref is not None and 'ref' not in already_processed:
2839            already_processed.append('ref')
2840            showIndent(outfile, level)
2841            outfile.write('ref = %s,\n' % (self.ref,))
2842        if self.applies_to is not None and 'applies_to' not in already_processed:
2843            already_processed.append('applies_to')
2844            showIndent(outfile, level)
2845            outfile.write('applies_to = %s,\n' % (self.applies_to,))
2846        if self.unit is not None and 'unit' not in already_processed:
2847            already_processed.append('unit')
2848            showIndent(outfile, level)
2849            outfile.write('unit = %s,\n' % (self.unit,))
2850    def exportLiteralChildren(self, outfile, level, name_):
2851        pass
2852    def build(self, node):
2853        self.buildAttributes(node, node.attrib, [])
2854        self.valueOf_ = get_all_text_(node)
2855        if node.text is not None:
2856            obj_ = self.mixedclass_(MixedContainer.CategoryText,
2857                MixedContainer.TypeNone, '', node.text)
2858            self.content_.append(obj_)
2859        for child in node:
2860            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
2861            self.buildChildren(child, node, nodeName_)
2862    def buildAttributes(self, node, attrs, already_processed):
2863        value = find_attr_value_('datatype', node)
2864        if value is not None and 'datatype' not in already_processed:
2865            already_processed.append('datatype')
2866            self.datatype = value
2867        value = find_attr_value_('id_ref', node)
2868        if value is not None and 'id_ref' not in already_processed:
2869            already_processed.append('id_ref')
2870            self.id_ref = value
2871        value = find_attr_value_('ref', node)
2872        if value is not None and 'ref' not in already_processed:
2873            already_processed.append('ref')
2874            self.ref = value
2875        value = find_attr_value_('applies_to', node)
2876        if value is not None and 'applies_to' not in already_processed:
2877            already_processed.append('applies_to')
2878            self.applies_to = value
2879        value = find_attr_value_('unit', node)
2880        if value is not None and 'unit' not in already_processed:
2881            already_processed.append('unit')
2882            self.unit = value
2883    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
2884        if not fromsubclass_ and child_.tail is not None:
2885            obj_ = self.mixedclass_(MixedContainer.CategoryText,
2886                MixedContainer.TypeNone, '', child_.tail)
2887            self.content_.append(obj_)
2888        pass
2889# end class Property
2890
2891
2892class Uri(GeneratedsSuper):
2893    """A uniform resource identifier. In general, this is expected to be an
2894    URL (for example, to link to an image on a website, in which
2895    case the 'type' attribute might be 'image' and 'desc' might be
2896    'image of a California sea hare')."""
2897    subclass = None
2898    superclass = None
2899    def __init__(self, type_=None, desc=None, valueOf_=None):
2900        self.type_ = _cast(None, type_)
2901        self.desc = _cast(None, desc)
2902        self.valueOf_ = valueOf_
2903    def factory(*args_, **kwargs_):
2904        if Uri.subclass:
2905            return Uri.subclass(*args_, **kwargs_)
2906        else:
2907            return Uri(*args_, **kwargs_)
2908    factory = staticmethod(factory)
2909    def get_type(self): return self.type_
2910    def set_type(self, type_): self.type_ = type_
2911    def get_desc(self): return self.desc
2912    def set_desc(self, desc): self.desc = desc
2913    def get_valueOf_(self): return self.valueOf_
2914    def set_valueOf_(self, valueOf_): self.valueOf_ = valueOf_
2915    def export(self, outfile, level, namespace_='phy:', name_='Uri', namespacedef_=''):
2916        showIndent(outfile, level)
2917        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
2918        already_processed = []
2919        self.exportAttributes(outfile, level, already_processed, namespace_, name_='Uri')
2920        if self.hasContent_():
2921            outfile.write('>')
2922            outfile.write(str(self.valueOf_).encode(ExternalEncoding))
2923            self.exportChildren(outfile, level + 1, namespace_, name_)
2924            outfile.write('</%s%s>\n' % (namespace_, name_))
2925        else:
2926            outfile.write('/>\n')
2927    def exportAttributes(self, outfile, level, already_processed, namespace_='phy:', name_='Uri'):
2928        if self.type_ is not None and 'type_' not in already_processed:
2929            already_processed.append('type_')
2930            outfile.write(' type=%s' % (self.gds_format_string(quote_attrib(self.type_).encode(ExternalEncoding), input_name='type'), ))
2931        if self.desc is not None and 'desc' not in already_processed:
2932            already_processed.append('desc')
2933            outfile.write(' desc=%s' % (self.gds_format_string(quote_attrib(self.desc).encode(ExternalEncoding), input_name='desc'), ))
2934    def exportChildren(self, outfile, level, namespace_='phy:', name_='Uri', fromsubclass_=False):
2935        pass
2936    def hasContent_(self):
2937        if (
2938            self.valueOf_
2939            ):
2940            return True
2941        else:
2942            return False
2943    def exportLiteral(self, outfile, level, name_='Uri'):
2944        level += 1
2945        self.exportLiteralAttributes(outfile, level, [], name_)
2946        if self.hasContent_():
2947            self.exportLiteralChildren(outfile, level, name_)
2948        showIndent(outfile, level)
2949        outfile.write('valueOf_ = """%s""",\n' % (self.valueOf_,))
2950    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
2951        if self.type_ is not None and 'type_' not in already_processed:
2952            already_processed.append('type_')
2953            showIndent(outfile, level)
2954            outfile.write('type_ = "%s",\n' % (self.type_,))
2955        if self.desc is not None and 'desc' not in already_processed:
2956            already_processed.append('desc')
2957            showIndent(outfile, level)
2958            outfile.write('desc = "%s",\n' % (self.desc,))
2959    def exportLiteralChildren(self, outfile, level, name_):
2960        pass
2961    def build(self, node):
2962        self.buildAttributes(node, node.attrib, [])
2963        self.valueOf_ = get_all_text_(node)
2964        for child in node:
2965            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
2966            self.buildChildren(child, node, nodeName_)
2967    def buildAttributes(self, node, attrs, already_processed):
2968        value = find_attr_value_('type', node)
2969        if value is not None and 'type' not in already_processed:
2970            already_processed.append('type')
2971            self.type_ = value
2972            self.type_ = ' '.join(self.type_.split())
2973        value = find_attr_value_('desc', node)
2974        if value is not None and 'desc' not in already_processed:
2975            already_processed.append('desc')
2976            self.desc = value
2977            self.desc = ' '.join(self.desc.split())
2978    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
2979        pass
2980# end class Uri
2981
2982
2983class Confidence(GeneratedsSuper):
2984    """A general purpose confidence element. For example this can be used
2985    to express the bootstrap support value of a clade (in which case
2986    the 'type' attribute is 'bootstrap')."""
2987    subclass = None
2988    superclass = None
2989    def __init__(self, type_=None, valueOf_=None):
2990        self.type_ = _cast(None, type_)
2991        self.valueOf_ = valueOf_
2992    def factory(*args_, **kwargs_):
2993        if Confidence.subclass:
2994            return Confidence.subclass(*args_, **kwargs_)
2995        else:
2996            return Confidence(*args_, **kwargs_)
2997    factory = staticmethod(factory)
2998    def get_type(self): return self.type_
2999    def set_type(self, type_): self.type_ = type_
3000    def get_valueOf_(self): return self.valueOf_
3001    def set_valueOf_(self, valueOf_): self.valueOf_ = valueOf_
3002    def export(self, outfile, level, namespace_='phy:', name_='Confidence', namespacedef_=''):
3003        showIndent(outfile, level)
3004        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
3005        already_processed = []
3006        self.exportAttributes(outfile, level, already_processed, namespace_, name_='Confidence')
3007        if self.hasContent_():
3008            outfile.write('>')
3009            outfile.write(str(self.valueOf_).encode(ExternalEncoding))
3010            self.exportChildren(outfile, level + 1, namespace_, name_)
3011            outfile.write('</%s%s>\n' % (namespace_, name_))
3012        else:
3013            outfile.write('/>\n')
3014    def exportAttributes(self, outfile, level, already_processed, namespace_='phy:', name_='Confidence'):
3015        if self.type_ is not None and 'type_' not in already_processed:
3016            already_processed.append('type_')
3017            outfile.write(' type=%s' % (self.gds_format_string(quote_attrib(self.type_).encode(ExternalEncoding), input_name='type'), ))
3018    def exportChildren(self, outfile, level, namespace_='phy:', name_='Confidence', fromsubclass_=False):
3019        pass
3020    def hasContent_(self):
3021        if (
3022            self.valueOf_
3023            ):
3024            return True
3025        else:
3026            return False
3027    def exportLiteral(self, outfile, level, name_='Confidence'):
3028        level += 1
3029        self.exportLiteralAttributes(outfile, level, [], name_)
3030        if self.hasContent_():
3031            self.exportLiteralChildren(outfile, level, name_)
3032        showIndent(outfile, level)
3033        outfile.write('valueOf_ = """%s""",\n' % (self.valueOf_,))
3034    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
3035        if self.type_ is not None and 'type_' not in already_processed:
3036            already_processed.append('type_')
3037            showIndent(outfile, level)
3038            outfile.write('type_ = "%s",\n' % (self.type_,))
3039    def exportLiteralChildren(self, outfile, level, name_):
3040        pass
3041    def build(self, node):
3042        self.buildAttributes(node, node.attrib, [])
3043        self.valueOf_ = get_all_text_(node)
3044        for child in node:
3045            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
3046            self.buildChildren(child, node, nodeName_)
3047    def buildAttributes(self, node, attrs, already_processed):
3048        value = find_attr_value_('type', node)
3049        if value is not None and 'type' not in already_processed:
3050            already_processed.append('type')
3051            self.type_ = value
3052            self.type_ = ' '.join(self.type_.split())
3053    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
3054        pass
3055# end class Confidence
3056
3057
3058class Id(GeneratedsSuper):
3059    """A general purpose identifier element. Allows to indicate the
3060    provider (or authority) of an identifier."""
3061    subclass = None
3062    superclass = None
3063    def __init__(self, provider=None, valueOf_=None):
3064        self.provider = _cast(None, provider)
3065        self.valueOf_ = valueOf_
3066    def factory(*args_, **kwargs_):
3067        if Id.subclass:
3068            return Id.subclass(*args_, **kwargs_)
3069        else:
3070            return Id(*args_, **kwargs_)
3071    factory = staticmethod(factory)
3072    def get_provider(self): return self.provider
3073    def set_provider(self, provider): self.provider = provider
3074    def get_valueOf_(self): return self.valueOf_
3075    def set_valueOf_(self, valueOf_): self.valueOf_ = valueOf_
3076    def export(self, outfile, level, namespace_='phy:', name_='Id', namespacedef_=''):
3077        showIndent(outfile, level)
3078        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
3079        already_processed = []
3080        self.exportAttributes(outfile, level, already_processed, namespace_, name_='Id')
3081        if self.hasContent_():
3082            outfile.write('>')
3083            outfile.write(str(self.valueOf_).encode(ExternalEncoding))
3084            self.exportChildren(outfile, level + 1, namespace_, name_)
3085            outfile.write('</%s%s>\n' % (namespace_, name_))
3086        else:
3087            outfile.write('/>\n')
3088    def exportAttributes(self, outfile, level, already_processed, namespace_='phy:', name_='Id'):
3089        if self.provider is not None and 'provider' not in already_processed:
3090            already_processed.append('provider')
3091            outfile.write(' provider=%s' % (self.gds_format_string(quote_attrib(self.provider).encode(ExternalEncoding), input_name='provider'), ))
3092    def exportChildren(self, outfile, level, namespace_='phy:', name_='Id', fromsubclass_=False):
3093        pass
3094    def hasContent_(self):
3095        if (
3096            self.valueOf_
3097            ):
3098            return True
3099        else:
3100            return False
3101    def exportLiteral(self, outfile, level, name_='Id'):
3102        level += 1
3103        self.exportLiteralAttributes(outfile, level, [], name_)
3104        if self.hasContent_():
3105            self.exportLiteralChildren(outfile, level, name_)
3106        showIndent(outfile, level)
3107        outfile.write('valueOf_ = """%s""",\n' % (self.valueOf_,))
3108    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
3109        if self.provider is not None and 'provider' not in already_processed:
3110            already_processed.append('provider')
3111            showIndent(outfile, level)
3112            outfile.write('provider = "%s",\n' % (self.provider,))
3113    def exportLiteralChildren(self, outfile, level, name_):
3114        pass
3115    def build(self, node):
3116        self.buildAttributes(node, node.attrib, [])
3117        self.valueOf_ = get_all_text_(node)
3118        for child in node:
3119            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
3120            self.buildChildren(child, node, nodeName_)
3121    def buildAttributes(self, node, attrs, already_processed):
3122        value = find_attr_value_('provider', node)
3123        if value is not None and 'provider' not in already_processed:
3124            already_processed.append('provider')
3125            self.provider = value
3126            self.provider = ' '.join(self.provider.split())
3127    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
3128        pass
3129# end class Id
3130
3131
3132class Distribution(GeneratedsSuper):
3133    """The geographic distribution of the items of a clade (species,
3134    sequences), intended for phylogeographic applications. The
3135    location can be described either by free text in the 'desc'
3136    element and/or by the coordinates of one or more 'Points'
3137    (similar to the 'Point' element in Google's KML format) or by
3138    'Polygons'."""
3139    subclass = None
3140    superclass = None
3141    def __init__(self, desc=None, point=None, polygon=None, valueOf_=None):
3142        self.desc = desc
3143        if point is None:
3144            self.point = []
3145        else:
3146            self.point = point
3147        if polygon is None:
3148            self.polygon = []
3149        else:
3150            self.polygon = polygon
3151    def factory(*args_, **kwargs_):
3152        if Distribution.subclass:
3153            return Distribution.subclass(*args_, **kwargs_)
3154        else:
3155            return Distribution(*args_, **kwargs_)
3156    factory = staticmethod(factory)
3157    def get_desc(self): return self.desc
3158    def set_desc(self, desc): self.desc = desc
3159    def get_point(self): return self.point
3160    def set_point(self, point): self.point = point
3161    def add_point(self, value): self.point.append(value)
3162    def insert_point(self, index, value): self.point[index] = value
3163    def get_polygon(self): return self.polygon
3164    def set_polygon(self, polygon): self.polygon = polygon
3165    def add_polygon(self, value): self.polygon.append(value)
3166    def insert_polygon(self, index, value): self.polygon[index] = value
3167    def export(self, outfile, level, namespace_='phy:', name_='Distribution', namespacedef_=''):
3168        showIndent(outfile, level)
3169        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
3170        already_processed = []
3171        self.exportAttributes(outfile, level, already_processed, namespace_, name_='Distribution')
3172        if self.hasContent_():
3173            outfile.write('>\n')
3174            self.exportChildren(outfile, level + 1, namespace_, name_)
3175            showIndent(outfile, level)
3176            outfile.write('</%s%s>\n' % (namespace_, name_))
3177        else:
3178            outfile.write('/>\n')
3179    def exportAttributes(self, outfile, level, already_processed, namespace_='phy:', name_='Distribution'):
3180        pass
3181    def exportChildren(self, outfile, level, namespace_='phy:', name_='Distribution', fromsubclass_=False):
3182        if self.desc is not None:
3183            showIndent(outfile, level)
3184            outfile.write('<%sdesc>%s</%sdesc>\n' % (namespace_, self.gds_format_string(quote_xml(self.desc).encode(ExternalEncoding), input_name='desc'), namespace_))
3185        for point_ in self.point:
3186            point_.export(outfile, level, namespace_, name_='point')
3187        for polygon_ in self.polygon:
3188            polygon_.export(outfile, level, namespace_, name_='polygon')
3189    def hasContent_(self):
3190        if (
3191            self.desc is not None or
3192            self.point or
3193            self.polygon
3194            ):
3195            return True
3196        else:
3197            return False
3198    def exportLiteral(self, outfile, level, name_='Distribution'):
3199        level += 1
3200        self.exportLiteralAttributes(outfile, level, [], name_)
3201        if self.hasContent_():
3202            self.exportLiteralChildren(outfile, level, name_)
3203    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
3204        pass
3205    def exportLiteralChildren(self, outfile, level, name_):
3206        if self.desc is not None:
3207            showIndent(outfile, level)
3208            outfile.write('desc=%s,\n' % quote_python(self.desc).encode(ExternalEncoding))
3209        showIndent(outfile, level)
3210        outfile.write('point=[\n')
3211        level += 1
3212        for point_ in self.point:
3213            showIndent(outfile, level)
3214            outfile.write('model_.Point(\n')
3215            point_.exportLiteral(outfile, level, name_='Point')
3216            showIndent(outfile, level)
3217            outfile.write('),\n')
3218        level -= 1
3219        showIndent(outfile, level)
3220        outfile.write('],\n')
3221        showIndent(outfile, level)
3222        outfile.write('polygon=[\n')
3223        level += 1
3224        for polygon_ in self.polygon:
3225            showIndent(outfile, level)
3226            outfile.write('model_.Polygon(\n')
3227            polygon_.exportLiteral(outfile, level, name_='Polygon')
3228            showIndent(outfile, level)
3229            outfile.write('),\n')
3230        level -= 1
3231        showIndent(outfile, level)
3232        outfile.write('],\n')
3233    def build(self, node):
3234        self.buildAttributes(node, node.attrib, [])
3235        for child in node:
3236            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
3237            self.buildChildren(child, node, nodeName_)
3238    def buildAttributes(self, node, attrs, already_processed):
3239        pass
3240    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
3241        if nodeName_ == 'desc':
3242            desc_ = child_.text
3243            desc_ = re_.sub(STRING_CLEANUP_PAT, " ", desc_).strip()
3244            desc_ = self.gds_validate_string(desc_, node, 'desc')
3245            self.desc = desc_
3246        elif nodeName_ == 'point':
3247            obj_ = Point.factory()
3248            obj_.build(child_)
3249            self.point.append(obj_)
3250        elif nodeName_ == 'polygon':
3251            obj_ = Polygon.factory()
3252            obj_.build(child_)
3253            self.polygon.append(obj_)
3254# end class Distribution
3255
3256
3257class Point(GeneratedsSuper):
3258    """The coordinates of a point with an optional altitude (used by
3259    element 'Distribution'). Required attributes are the
3260    'geodetic_datum' used to indicate the geodetic datum (also
3261    called 'map datum', for example Google's KML uses 'WGS84').
3262    Attribute 'alt_unit' is the unit for the altitude (e.g.
3263    'meter')."""
3264    subclass = None
3265    superclass = None
3266    def __init__(self, geodetic_datum=None, alt_unit=None, lat=None, long=None, alt=None, valueOf_=None):
3267        self.geodetic_datum = _cast(None, geodetic_datum)
3268        self.alt_unit = _cast(None, alt_unit)
3269        self.lat = lat
3270        self.long = int
3271        self.alt = alt
3272    def factory(*args_, **kwargs_):
3273        if Point.subclass:
3274            return Point.subclass(*args_, **kwargs_)
3275        else:
3276            return Point(*args_, **kwargs_)
3277    factory = staticmethod(factory)
3278    def get_lat(self): return self.lat
3279    def set_lat(self, lat): self.lat = lat
3280    def get_long(self): return self.long
3281    def set_long(self, long): self.long = int
3282    def get_alt(self): return self.alt
3283    def set_alt(self, alt): self.alt = alt
3284    def get_geodetic_datum(self): return self.geodetic_datum
3285    def set_geodetic_datum(self, geodetic_datum): self.geodetic_datum = geodetic_datum
3286    def get_alt_unit(self): return self.alt_unit
3287    def set_alt_unit(self, alt_unit): self.alt_unit = alt_unit
3288    def export(self, outfile, level, namespace_='phy:', name_='Point', namespacedef_=''):
3289        showIndent(outfile, level)
3290        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
3291        already_processed = []
3292        self.exportAttributes(outfile, level, already_processed, namespace_, name_='Point')
3293        if self.hasContent_():
3294            outfile.write('>\n')
3295            self.exportChildren(outfile, level + 1, namespace_, name_)
3296            showIndent(outfile, level)
3297            outfile.write('</%s%s>\n' % (namespace_, name_))
3298        else:
3299            outfile.write('/>\n')
3300    def exportAttributes(self, outfile, level, already_processed, namespace_='phy:', name_='Point'):
3301        if self.geodetic_datum is not None and 'geodetic_datum' not in already_processed:
3302            already_processed.append('geodetic_datum')
3303            outfile.write(' geodetic_datum=%s' % (self.gds_format_string(quote_attrib(self.geodetic_datum).encode(ExternalEncoding), input_name='geodetic_datum'), ))
3304        if self.alt_unit is not None and 'alt_unit' not in already_processed:
3305            already_processed.append('alt_unit')
3306            outfile.write(' alt_unit=%s' % (self.gds_format_string(quote_attrib(self.alt_unit).encode(ExternalEncoding), input_name='alt_unit'), ))
3307    def exportChildren(self, outfile, level, namespace_='phy:', name_='Point', fromsubclass_=False):
3308        if self.lat is not None:
3309            showIndent(outfile, level)
3310            outfile.write('<%slat>%s</%slat>\n' % (namespace_, self.gds_format_float(self.lat, input_name='lat'), namespace_))
3311        if self.long is not None:
3312            showIndent(outfile, level)
3313            outfile.write('<%slong>%s</%slong>\n' % (namespace_, self.gds_format_float(self.long, input_name='long'), namespace_))
3314        if self.alt is not None:
3315            showIndent(outfile, level)
3316            outfile.write('<%salt>%s</%salt>\n' % (namespace_, self.gds_format_float(self.alt, input_name='alt'), namespace_))
3317    def hasContent_(self):
3318        if (
3319            self.lat is not None or
3320            self.long is not None or
3321            self.alt is not None
3322            ):
3323            return True
3324        else:
3325            return False
3326    def exportLiteral(self, outfile, level, name_='Point'):
3327        level += 1
3328        self.exportLiteralAttributes(outfile, level, [], name_)
3329        if self.hasContent_():
3330            self.exportLiteralChildren(outfile, level, name_)
3331    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
3332        if self.geodetic_datum is not None and 'geodetic_datum' not in already_processed:
3333            already_processed.append('geodetic_datum')
3334            showIndent(outfile, level)
3335            outfile.write('geodetic_datum = "%s",\n' % (self.geodetic_datum,))
3336        if self.alt_unit is not None and 'alt_unit' not in already_processed:
3337            already_processed.append('alt_unit')
3338            showIndent(outfile, level)
3339            outfile.write('alt_unit = "%s",\n' % (self.alt_unit,))
3340    def exportLiteralChildren(self, outfile, level, name_):
3341        if self.lat is not None:
3342            showIndent(outfile, level)
3343            outfile.write('lat=%f,\n' % self.lat)
3344        if self.long is not None:
3345            showIndent(outfile, level)
3346            outfile.write('long=%f,\n' % self.long)
3347        if self.alt is not None:
3348            showIndent(outfile, level)
3349            outfile.write('alt=%f,\n' % self.alt)
3350    def build(self, node):
3351        self.buildAttributes(node, node.attrib, [])
3352        for child in node:
3353            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
3354            self.buildChildren(child, node, nodeName_)
3355    def buildAttributes(self, node, attrs, already_processed):
3356        value = find_attr_value_('geodetic_datum', node)
3357        if value is not None and 'geodetic_datum' not in already_processed:
3358            already_processed.append('geodetic_datum')
3359            self.geodetic_datum = value
3360            self.geodetic_datum = ' '.join(self.geodetic_datum.split())
3361        value = find_attr_value_('alt_unit', node)
3362        if value is not None and 'alt_unit' not in already_processed:
3363            already_processed.append('alt_unit')
3364            self.alt_unit = value
3365            self.alt_unit = ' '.join(self.alt_unit.split())
3366    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
3367        if nodeName_ == 'lat':
3368            sval_ = child_.text
3369            try:
3370                fval_ = float(sval_)
3371            except (TypeError, ValueError) as exp:
3372                raise_parse_error(child_, 'requires float or double: %s' % exp)
3373            fval_ = self.gds_validate_float(fval_, node, 'lat')
3374            self.lat = fval_
3375        elif nodeName_ == 'long':
3376            sval_ = child_.text
3377            try:
3378                fval_ = float(sval_)
3379            except (TypeError, ValueError) as exp:
3380                raise_parse_error(child_, 'requires float or double: %s' % exp)
3381            fval_ = self.gds_validate_float(fval_, node, 'long')
3382            self.long = fval_
3383        elif nodeName_ == 'alt':
3384            sval_ = child_.text
3385            try:
3386                fval_ = float(sval_)
3387            except (TypeError, ValueError) as exp:
3388                raise_parse_error(child_, 'requires float or double: %s' % exp)
3389            fval_ = self.gds_validate_float(fval_, node, 'alt')
3390            self.alt = fval_
3391# end class Point
3392
3393
3394class Polygon(GeneratedsSuper):
3395    """A polygon defined by a list of 'Points' (used by element
3396    'Distribution')."""
3397    subclass = None
3398    superclass = None
3399    def __init__(self, point=None, valueOf_=None):
3400        if point is None:
3401            self.point = []
3402        else:
3403            self.point = point
3404    def factory(*args_, **kwargs_):
3405        if Polygon.subclass:
3406            return Polygon.subclass(*args_, **kwargs_)
3407        else:
3408            return Polygon(*args_, **kwargs_)
3409    factory = staticmethod(factory)
3410    def get_point(self): return self.point
3411    def set_point(self, point): self.point = point
3412    def add_point(self, value): self.point.append(value)
3413    def insert_point(self, index, value): self.point[index] = value
3414    def export(self, outfile, level, namespace_='phy:', name_='Polygon', namespacedef_=''):
3415        showIndent(outfile, level)
3416        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
3417        already_processed = []
3418        self.exportAttributes(outfile, level, already_processed, namespace_, name_='Polygon')
3419        if self.hasContent_():
3420            outfile.write('>\n')
3421            self.exportChildren(outfile, level + 1, namespace_, name_)
3422            showIndent(outfile, level)
3423            outfile.write('</%s%s>\n' % (namespace_, name_))
3424        else:
3425            outfile.write('/>\n')
3426    def exportAttributes(self, outfile, level, already_processed, namespace_='phy:', name_='Polygon'):
3427        pass
3428    def exportChildren(self, outfile, level, namespace_='phy:', name_='Polygon', fromsubclass_=False):
3429        for point_ in self.point:
3430            point_.export(outfile, level, namespace_, name_='point')
3431    def hasContent_(self):
3432        if (
3433            self.point
3434            ):
3435            return True
3436        else:
3437            return False
3438    def exportLiteral(self, outfile, level, name_='Polygon'):
3439        level += 1
3440        self.exportLiteralAttributes(outfile, level, [], name_)
3441        if self.hasContent_():
3442            self.exportLiteralChildren(outfile, level, name_)
3443    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
3444        pass
3445    def exportLiteralChildren(self, outfile, level, name_):
3446        showIndent(outfile, level)
3447        outfile.write('point=[\n')
3448        level += 1
3449        for point_ in self.point:
3450            showIndent(outfile, level)
3451            outfile.write('model_.Point(\n')
3452            point_.exportLiteral(outfile, level, name_='Point')
3453            showIndent(outfile, level)
3454            outfile.write('),\n')
3455        level -= 1
3456        showIndent(outfile, level)
3457        outfile.write('],\n')
3458    def build(self, node):
3459        self.buildAttributes(node, node.attrib, [])
3460        for child in node:
3461            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
3462            self.buildChildren(child, node, nodeName_)
3463    def buildAttributes(self, node, attrs, already_processed):
3464        pass
3465    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
3466        if nodeName_ == 'point':
3467            obj_ = Point.factory()
3468            obj_.build(child_)
3469            self.point.append(obj_)
3470# end class Polygon
3471
3472
3473class Date(GeneratedsSuper):
3474    """A date associated with a clade/node. Its value can be numerical by
3475    using the 'value' element and/or free text with the 'desc'
3476    element' (e.g. 'Silurian'). If a numerical value is used, it is
3477    recommended to employ the 'unit' attribute to indicate the type
3478    of the numerical value (e.g. 'mya' for 'million years ago'). The
3479    elements 'minimum' and 'maximum' are used the indicate a
3480    range/confidence interval"""
3481    subclass = None
3482    superclass = None
3483    def __init__(self, unit=None, desc=None, value=None, minimum=None, maximum=None, valueOf_=None):
3484        self.unit = _cast(None, unit)
3485        self.desc = desc
3486        self.value = value
3487        self.minimum = minimum
3488        self.maximum = maximum
3489    def factory(*args_, **kwargs_):
3490        if Date.subclass:
3491            return Date.subclass(*args_, **kwargs_)
3492        else:
3493            return Date(*args_, **kwargs_)
3494    factory = staticmethod(factory)
3495    def get_desc(self): return self.desc
3496    def set_desc(self, desc): self.desc = desc
3497    def get_value(self): return self.value
3498    def set_value(self, value): self.value = value
3499    def get_minimum(self): return self.minimum
3500    def set_minimum(self, minimum): self.minimum = minimum
3501    def get_maximum(self): return self.maximum
3502    def set_maximum(self, maximum): self.maximum = maximum
3503    def get_unit(self): return self.unit
3504    def set_unit(self, unit): self.unit = unit
3505    def export(self, outfile, level, namespace_='phy:', name_='Date', namespacedef_=''):
3506        showIndent(outfile, level)
3507        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
3508        already_processed = []
3509        self.exportAttributes(outfile, level, already_processed, namespace_, name_='Date')
3510        if self.hasContent_():
3511            outfile.write('>\n')
3512            self.exportChildren(outfile, level + 1, namespace_, name_)
3513            showIndent(outfile, level)
3514            outfile.write('</%s%s>\n' % (namespace_, name_))
3515        else:
3516            outfile.write('/>\n')
3517    def exportAttributes(self, outfile, level, already_processed, namespace_='phy:', name_='Date'):
3518        if self.unit is not None and 'unit' not in already_processed:
3519            already_processed.append('unit')
3520            outfile.write(' unit=%s' % (self.gds_format_string(quote_attrib(self.unit).encode(ExternalEncoding), input_name='unit'), ))
3521    def exportChildren(self, outfile, level, namespace_='phy:', name_='Date', fromsubclass_=False):
3522        if self.desc is not None:
3523            showIndent(outfile, level)
3524            outfile.write('<%sdesc>%s</%sdesc>\n' % (namespace_, self.gds_format_string(quote_xml(self.desc).encode(ExternalEncoding), input_name='desc'), namespace_))
3525        if self.value is not None:
3526            showIndent(outfile, level)
3527            outfile.write('<%svalue>%s</%svalue>\n' % (namespace_, self.gds_format_float(self.value, input_name='value'), namespace_))
3528        if self.minimum is not None:
3529            showIndent(outfile, level)
3530            outfile.write('<%sminimum>%s</%sminimum>\n' % (namespace_, self.gds_format_float(self.minimum, input_name='minimum'), namespace_))
3531        if self.maximum is not None:
3532            showIndent(outfile, level)
3533            outfile.write('<%smaximum>%s</%smaximum>\n' % (namespace_, self.gds_format_float(self.maximum, input_name='maximum'), namespace_))
3534    def hasContent_(self):
3535        if (
3536            self.desc is not None or
3537            self.value is not None or
3538            self.minimum is not None or
3539            self.maximum is not None
3540            ):
3541            return True
3542        else:
3543            return False
3544    def exportLiteral(self, outfile, level, name_='Date'):
3545        level += 1
3546        self.exportLiteralAttributes(outfile, level, [], name_)
3547        if self.hasContent_():
3548            self.exportLiteralChildren(outfile, level, name_)
3549    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
3550        if self.unit is not None and 'unit' not in already_processed:
3551            already_processed.append('unit')
3552            showIndent(outfile, level)
3553            outfile.write('unit = "%s",\n' % (self.unit,))
3554    def exportLiteralChildren(self, outfile, level, name_):
3555        if self.desc is not None:
3556            showIndent(outfile, level)
3557            outfile.write('desc=%s,\n' % quote_python(self.desc).encode(ExternalEncoding))
3558        if self.value is not None:
3559            showIndent(outfile, level)
3560            outfile.write('value=%f,\n' % self.value)
3561        if self.minimum is not None:
3562            showIndent(outfile, level)
3563            outfile.write('minimum=%f,\n' % self.minimum)
3564        if self.maximum is not None:
3565            showIndent(outfile, level)
3566            outfile.write('maximum=%f,\n' % self.maximum)
3567    def build(self, node):
3568        self.buildAttributes(node, node.attrib, [])
3569        for child in node:
3570            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
3571            self.buildChildren(child, node, nodeName_)
3572    def buildAttributes(self, node, attrs, already_processed):
3573        value = find_attr_value_('unit', node)
3574        if value is not None and 'unit' not in already_processed:
3575            already_processed.append('unit')
3576            self.unit = value
3577            self.unit = ' '.join(self.unit.split())
3578    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
3579        if nodeName_ == 'desc':
3580            desc_ = child_.text
3581            desc_ = re_.sub(STRING_CLEANUP_PAT, " ", desc_).strip()
3582            desc_ = self.gds_validate_string(desc_, node, 'desc')
3583            self.desc = desc_
3584        elif nodeName_ == 'value':
3585            sval_ = child_.text
3586            try:
3587                fval_ = float(sval_)
3588            except (TypeError, ValueError) as exp:
3589                raise_parse_error(child_, 'requires float or double: %s' % exp)
3590            fval_ = self.gds_validate_float(fval_, node, 'value')
3591            self.value = fval_
3592        elif nodeName_ == 'minimum':
3593            sval_ = child_.text
3594            try:
3595                fval_ = float(sval_)
3596            except (TypeError, ValueError) as exp:
3597                raise_parse_error(child_, 'requires float or double: %s' % exp)
3598            fval_ = self.gds_validate_float(fval_, node, 'minimum')
3599            self.minimum = fval_
3600        elif nodeName_ == 'maximum':
3601            sval_ = child_.text
3602            try:
3603                fval_ = float(sval_)
3604            except (TypeError, ValueError) as exp:
3605                raise_parse_error(child_, 'requires float or double: %s' % exp)
3606            fval_ = self.gds_validate_float(fval_, node, 'maximum')
3607            self.maximum = fval_
3608# end class Date
3609
3610
3611class BranchColor(GeneratedsSuper):
3612    """This indicates the color of a clade when rendered (the color applies
3613    to the whole clade unless overwritten by the color(s) of sub
3614    clades)."""
3615    subclass = None
3616    superclass = None
3617    def __init__(self, red=None, green=None, blue=None, valueOf_=None):
3618        self.red = red
3619        self.green = green
3620        self.blue = blue
3621    def factory(*args_, **kwargs_):
3622        if BranchColor.subclass:
3623            return BranchColor.subclass(*args_, **kwargs_)
3624        else:
3625            return BranchColor(*args_, **kwargs_)
3626    factory = staticmethod(factory)
3627    def get_red(self): return self.red
3628    def set_red(self, red): self.red = red
3629    def get_green(self): return self.green
3630    def set_green(self, green): self.green = green
3631    def get_blue(self): return self.blue
3632    def set_blue(self, blue): self.blue = blue
3633    def export(self, outfile, level, namespace_='phy:', name_='BranchColor', namespacedef_=''):
3634        showIndent(outfile, level)
3635        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
3636        already_processed = []
3637        self.exportAttributes(outfile, level, already_processed, namespace_, name_='BranchColor')
3638        if self.hasContent_():
3639            outfile.write('>\n')
3640            self.exportChildren(outfile, level + 1, namespace_, name_)
3641            showIndent(outfile, level)
3642            outfile.write('</%s%s>\n' % (namespace_, name_))
3643        else:
3644            outfile.write('/>\n')
3645    def exportAttributes(self, outfile, level, already_processed, namespace_='phy:', name_='BranchColor'):
3646        pass
3647    def exportChildren(self, outfile, level, namespace_='phy:', name_='BranchColor', fromsubclass_=False):
3648        if self.red is not None:
3649            showIndent(outfile, level)
3650            outfile.write('<%sred>%s</%sred>\n' % (namespace_, self.gds_format_integer(self.red, input_name='red'), namespace_))
3651        if self.green is not None:
3652            showIndent(outfile, level)
3653            outfile.write('<%sgreen>%s</%sgreen>\n' % (namespace_, self.gds_format_integer(self.green, input_name='green'), namespace_))
3654        if self.blue is not None:
3655            showIndent(outfile, level)
3656            outfile.write('<%sblue>%s</%sblue>\n' % (namespace_, self.gds_format_integer(self.blue, input_name='blue'), namespace_))
3657    def hasContent_(self):
3658        if (
3659            self.red is not None or
3660            self.green is not None or
3661            self.blue is not None
3662            ):
3663            return True
3664        else:
3665            return False
3666    def exportLiteral(self, outfile, level, name_='BranchColor'):
3667        level += 1
3668        self.exportLiteralAttributes(outfile, level, [], name_)
3669        if self.hasContent_():
3670            self.exportLiteralChildren(outfile, level, name_)
3671    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
3672        pass
3673    def exportLiteralChildren(self, outfile, level, name_):
3674        if self.red is not None:
3675            showIndent(outfile, level)
3676            outfile.write('red=%d,\n' % self.red)
3677        if self.green is not None:
3678            showIndent(outfile, level)
3679            outfile.write('green=%d,\n' % self.green)
3680        if self.blue is not None:
3681            showIndent(outfile, level)
3682            outfile.write('blue=%d,\n' % self.blue)
3683    def build(self, node):
3684        self.buildAttributes(node, node.attrib, [])
3685        for child in node:
3686            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
3687            self.buildChildren(child, node, nodeName_)
3688    def buildAttributes(self, node, attrs, already_processed):
3689        pass
3690    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
3691        if nodeName_ == 'red':
3692            sval_ = child_.text
3693            try:
3694                ival_ = int(sval_)
3695            except (TypeError, ValueError) as exp:
3696                raise_parse_error(child_, 'requires integer: %s' % exp)
3697            ival_ = self.gds_validate_integer(ival_, node, 'red')
3698            self.red = ival_
3699        elif nodeName_ == 'green':
3700            sval_ = child_.text
3701            try:
3702                ival_ = int(sval_)
3703            except (TypeError, ValueError) as exp:
3704                raise_parse_error(child_, 'requires integer: %s' % exp)
3705            ival_ = self.gds_validate_integer(ival_, node, 'green')
3706            self.green = ival_
3707        elif nodeName_ == 'blue':
3708            sval_ = child_.text
3709            try:
3710                ival_ = int(sval_)
3711            except (TypeError, ValueError) as exp:
3712                raise_parse_error(child_, 'requires integer: %s' % exp)
3713            ival_ = self.gds_validate_integer(ival_, node, 'blue')
3714            self.blue = ival_
3715# end class BranchColor
3716
3717
3718class SequenceRelation(GeneratedsSuper):
3719    """This is used to express a typed relationship between two sequences.
3720    For example it could be used to describe an orthology (in which
3721    case attribute 'type' is 'orthology')."""
3722    subclass = None
3723    superclass = None
3724    def __init__(self, id_ref_0=None, id_ref_1=None, type_=None, distance=None, confidence=None, valueOf_=None):
3725        self.id_ref_0 = _cast(None, id_ref_0)
3726        self.id_ref_1 = _cast(None, id_ref_1)
3727        self.type_ = _cast(None, type_)
3728        self.distance = _cast(float, distance)
3729        self.confidence = confidence
3730    def factory(*args_, **kwargs_):
3731        if SequenceRelation.subclass:
3732            return SequenceRelation.subclass(*args_, **kwargs_)
3733        else:
3734            return SequenceRelation(*args_, **kwargs_)
3735    factory = staticmethod(factory)
3736    def get_confidence(self): return self.confidence
3737    def set_confidence(self, confidence): self.confidence = confidence
3738    def get_id_ref_0(self): return self.id_ref_0
3739    def set_id_ref_0(self, id_ref_0): self.id_ref_0 = id_ref_0
3740    def get_id_ref_1(self): return self.id_ref_1
3741    def set_id_ref_1(self, id_ref_1): self.id_ref_1 = id_ref_1
3742    def get_type(self): return self.type_
3743    def set_type(self, type_): self.type_ = type_
3744    def get_distance(self): return self.distance
3745    def set_distance(self, distance): self.distance = distance
3746    def export(self, outfile, level, namespace_='phy:', name_='SequenceRelation', namespacedef_=''):
3747        showIndent(outfile, level)
3748        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
3749        already_processed = []
3750        self.exportAttributes(outfile, level, already_processed, namespace_, name_='SequenceRelation')
3751        if self.hasContent_():
3752            outfile.write('>\n')
3753            self.exportChildren(outfile, level + 1, namespace_, name_)
3754            showIndent(outfile, level)
3755            outfile.write('</%s%s>\n' % (namespace_, name_))
3756        else:
3757            outfile.write('/>\n')
3758    def exportAttributes(self, outfile, level, already_processed, namespace_='phy:', name_='SequenceRelation'):
3759        if self.id_ref_0 is not None and 'id_ref_0' not in already_processed:
3760            already_processed.append('id_ref_0')
3761            outfile.write(' id_ref_0=%s' % (quote_attrib(self.id_ref_0), ))
3762        if self.id_ref_1 is not None and 'id_ref_1' not in already_processed:
3763            already_processed.append('id_ref_1')
3764            outfile.write(' id_ref_1=%s' % (quote_attrib(self.id_ref_1), ))
3765        if self.type_ is not None and 'type_' not in already_processed:
3766            already_processed.append('type_')
3767            outfile.write(' type=%s' % (quote_attrib(self.type_), ))
3768        if self.distance is not None and 'distance' not in already_processed:
3769            already_processed.append('distance')
3770            outfile.write(' distance="%s"' % self.gds_format_double(self.distance, input_name='distance'))
3771    def exportChildren(self, outfile, level, namespace_='phy:', name_='SequenceRelation', fromsubclass_=False):
3772        if self.confidence:
3773            self.confidence.export(outfile, level, namespace_, name_='confidence')
3774    def hasContent_(self):
3775        if (
3776            self.confidence is not None
3777            ):
3778            return True
3779        else:
3780            return False
3781    def exportLiteral(self, outfile, level, name_='SequenceRelation'):
3782        level += 1
3783        self.exportLiteralAttributes(outfile, level, [], name_)
3784        if self.hasContent_():
3785            self.exportLiteralChildren(outfile, level, name_)
3786    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
3787        if self.id_ref_0 is not None and 'id_ref_0' not in already_processed:
3788            already_processed.append('id_ref_0')
3789            showIndent(outfile, level)
3790            outfile.write('id_ref_0 = %s,\n' % (self.id_ref_0,))
3791        if self.id_ref_1 is not None and 'id_ref_1' not in already_processed:
3792            already_processed.append('id_ref_1')
3793            showIndent(outfile, level)
3794            outfile.write('id_ref_1 = %s,\n' % (self.id_ref_1,))
3795        if self.type_ is not None and 'type_' not in already_processed:
3796            already_processed.append('type_')
3797            showIndent(outfile, level)
3798            outfile.write('type_ = %s,\n' % (self.type_,))
3799        if self.distance is not None and 'distance' not in already_processed:
3800            already_processed.append('distance')
3801            showIndent(outfile, level)
3802            outfile.write('distance = %e,\n' % (self.distance,))
3803    def exportLiteralChildren(self, outfile, level, name_):
3804        if self.confidence is not None:
3805            showIndent(outfile, level)
3806            outfile.write('confidence=model_.Confidence(\n')
3807            self.confidence.exportLiteral(outfile, level, name_='confidence')
3808            showIndent(outfile, level)
3809            outfile.write('),\n')
3810    def build(self, node):
3811        self.buildAttributes(node, node.attrib, [])
3812        for child in node:
3813            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
3814            self.buildChildren(child, node, nodeName_)
3815    def buildAttributes(self, node, attrs, already_processed):
3816        value = find_attr_value_('id_ref_0', node)
3817        if value is not None and 'id_ref_0' not in already_processed:
3818            already_processed.append('id_ref_0')
3819            self.id_ref_0 = value
3820        value = find_attr_value_('id_ref_1', node)
3821        if value is not None and 'id_ref_1' not in already_processed:
3822            already_processed.append('id_ref_1')
3823            self.id_ref_1 = value
3824        value = find_attr_value_('type', node)
3825        if value is not None and 'type' not in already_processed:
3826            already_processed.append('type')
3827            self.type_ = value
3828        value = find_attr_value_('distance', node)
3829        if value is not None and 'distance' not in already_processed:
3830            already_processed.append('distance')
3831            try:
3832                self.distance = float(value)
3833            except ValueError as exp:
3834                raise ValueError('Bad float/double attribute (distance): %s' % exp)
3835    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
3836        if nodeName_ == 'confidence':
3837            obj_ = Confidence.factory()
3838            obj_.build(child_)
3839            self.set_confidence(obj_)
3840# end class SequenceRelation
3841
3842
3843class CladeRelation(GeneratedsSuper):
3844    """This is used to express a typed relationship between two clades. For
3845    example it could be used to describe multiple parents of a
3846    clade."""
3847    subclass = None
3848    superclass = None
3849    def __init__(self, id_ref_0=None, id_ref_1=None, type_=None, distance=None, confidence=None, valueOf_=None):
3850        self.id_ref_0 = _cast(None, id_ref_0)
3851        self.id_ref_1 = _cast(None, id_ref_1)
3852        self.type_ = _cast(None, type_)
3853        self.distance = _cast(float, distance)
3854        self.confidence = confidence
3855    def factory(*args_, **kwargs_):
3856        if CladeRelation.subclass:
3857            return CladeRelation.subclass(*args_, **kwargs_)
3858        else:
3859            return CladeRelation(*args_, **kwargs_)
3860    factory = staticmethod(factory)
3861    def get_confidence(self): return self.confidence
3862    def set_confidence(self, confidence): self.confidence = confidence
3863    def get_id_ref_0(self): return self.id_ref_0
3864    def set_id_ref_0(self, id_ref_0): self.id_ref_0 = id_ref_0
3865    def get_id_ref_1(self): return self.id_ref_1
3866    def set_id_ref_1(self, id_ref_1): self.id_ref_1 = id_ref_1
3867    def get_type(self): return self.type_
3868    def set_type(self, type_): self.type_ = type_
3869    def get_distance(self): return self.distance
3870    def set_distance(self, distance): self.distance = distance
3871    def export(self, outfile, level, namespace_='phy:', name_='CladeRelation', namespacedef_=''):
3872        showIndent(outfile, level)
3873        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
3874        already_processed = []
3875        self.exportAttributes(outfile, level, already_processed, namespace_, name_='CladeRelation')
3876        if self.hasContent_():
3877            outfile.write('>\n')
3878            self.exportChildren(outfile, level + 1, namespace_, name_)
3879            showIndent(outfile, level)
3880            outfile.write('</%s%s>\n' % (namespace_, name_))
3881        else:
3882            outfile.write('/>\n')
3883    def exportAttributes(self, outfile, level, already_processed, namespace_='phy:', name_='CladeRelation'):
3884        if self.id_ref_0 is not None and 'id_ref_0' not in already_processed:
3885            already_processed.append('id_ref_0')
3886            outfile.write(' id_ref_0=%s' % (quote_attrib(self.id_ref_0), ))
3887        if self.id_ref_1 is not None and 'id_ref_1' not in already_processed:
3888            already_processed.append('id_ref_1')
3889            outfile.write(' id_ref_1=%s' % (quote_attrib(self.id_ref_1), ))
3890        if self.type_ is not None and 'type_' not in already_processed:
3891            already_processed.append('type_')
3892            outfile.write(' type=%s' % (self.gds_format_string(quote_attrib(self.type_).encode(ExternalEncoding), input_name='type'), ))
3893        if self.distance is not None and 'distance' not in already_processed:
3894            already_processed.append('distance')
3895            outfile.write(' distance="%s"' % self.gds_format_double(self.distance, input_name='distance'))
3896    def exportChildren(self, outfile, level, namespace_='phy:', name_='CladeRelation', fromsubclass_=False):
3897        if self.confidence:
3898            self.confidence.export(outfile, level, namespace_, name_='confidence')
3899    def hasContent_(self):
3900        if (
3901            self.confidence is not None
3902            ):
3903            return True
3904        else:
3905            return False
3906    def exportLiteral(self, outfile, level, name_='CladeRelation'):
3907        level += 1
3908        self.exportLiteralAttributes(outfile, level, [], name_)
3909        if self.hasContent_():
3910            self.exportLiteralChildren(outfile, level, name_)
3911    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
3912        if self.id_ref_0 is not None and 'id_ref_0' not in already_processed:
3913            already_processed.append('id_ref_0')
3914            showIndent(outfile, level)
3915            outfile.write('id_ref_0 = %s,\n' % (self.id_ref_0,))
3916        if self.id_ref_1 is not None and 'id_ref_1' not in already_processed:
3917            already_processed.append('id_ref_1')
3918            showIndent(outfile, level)
3919            outfile.write('id_ref_1 = %s,\n' % (self.id_ref_1,))
3920        if self.type_ is not None and 'type_' not in already_processed:
3921            already_processed.append('type_')
3922            showIndent(outfile, level)
3923            outfile.write('type_ = "%s",\n' % (self.type_,))
3924        if self.distance is not None and 'distance' not in already_processed:
3925            already_processed.append('distance')
3926            showIndent(outfile, level)
3927            outfile.write('distance = %e,\n' % (self.distance,))
3928    def exportLiteralChildren(self, outfile, level, name_):
3929        if self.confidence is not None:
3930            showIndent(outfile, level)
3931            outfile.write('confidence=model_.Confidence(\n')
3932            self.confidence.exportLiteral(outfile, level, name_='confidence')
3933            showIndent(outfile, level)
3934            outfile.write('),\n')
3935    def build(self, node):
3936        self.buildAttributes(node, node.attrib, [])
3937        for child in node:
3938            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
3939            self.buildChildren(child, node, nodeName_)
3940    def buildAttributes(self, node, attrs, already_processed):
3941        value = find_attr_value_('id_ref_0', node)
3942        if value is not None and 'id_ref_0' not in already_processed:
3943            already_processed.append('id_ref_0')
3944            self.id_ref_0 = value
3945        value = find_attr_value_('id_ref_1', node)
3946        if value is not None and 'id_ref_1' not in already_processed:
3947            already_processed.append('id_ref_1')
3948            self.id_ref_1 = value
3949        value = find_attr_value_('type', node)
3950        if value is not None and 'type' not in already_processed:
3951            already_processed.append('type')
3952            self.type_ = value
3953            self.type_ = ' '.join(self.type_.split())
3954        value = find_attr_value_('distance', node)
3955        if value is not None and 'distance' not in already_processed:
3956            already_processed.append('distance')
3957            try:
3958                self.distance = float(value)
3959            except ValueError as exp:
3960                raise ValueError('Bad float/double attribute (distance): %s' % exp)
3961    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
3962        if nodeName_ == 'confidence':
3963            obj_ = Confidence.factory()
3964            obj_.build(child_)
3965            self.set_confidence(obj_)
3966# end class CladeRelation
3967
3968
3969USAGE_TEXT = """
3970Usage: python <Parser>.py [ -s ] <in_xml_file>
3971"""
3972
3973def usage():
3974    print(USAGE_TEXT)
3975    sys.exit(1)
3976
3977
3978def get_root_tag(node):
3979    tag = Tag_pattern_.match(node.tag).groups()[-1]
3980    rootClass = globals().get(tag)
3981    return tag, rootClass
3982
3983
3984def parse(inFileName):
3985    doc = parsexml_(inFileName)
3986    rootNode = doc.getroot()
3987    rootTag, rootClass = get_root_tag(rootNode)
3988    if rootClass is None:
3989        rootTag = 'phyloxml'
3990        rootClass = Phyloxml
3991    rootObj = rootClass.factory()
3992    rootObj.build(rootNode)
3993    # Enable Python to collect the space used by the DOM.
3994    doc = None
3995##     sys.stdout.write('<?xml version="1.0" ?>\n')
3996##     rootObj.export(sys.stdout, 0, name_=rootTag,
3997##         namespacedef_='xmlns:phy="http://www.phyloxml.org/1.10/phyloxml.xsd"')
3998    return rootObj
3999
4000
4001def parseString(inString):
4002    from StringIO import StringIO
4003    doc = parsexml_(StringIO(inString))
4004    rootNode = doc.getroot()
4005    rootTag, rootClass = get_root_tag(rootNode)
4006    if rootClass is None:
4007        rootTag = 'phyloxml'
4008        rootClass = Phyloxml
4009    rootObj = rootClass.factory()
4010    rootObj.build(rootNode)
4011    # Enable Python to collect the space used by the DOM.
4012    doc = None
4013##     sys.stdout.write('<?xml version="1.0" ?>\n')
4014##     rootObj.export(sys.stdout, 0, name_="phyloxml",
4015##         namespacedef_='xmlns:phy="http://www.phyloxml.org/1.10/phyloxml.xsd"')
4016    return rootObj
4017
4018
4019def parseLiteral(inFileName):
4020    doc = parsexml_(inFileName)
4021    rootNode = doc.getroot()
4022    rootTag, rootClass = get_root_tag(rootNode)
4023    if rootClass is None:
4024        rootTag = 'phyloxml'
4025        rootClass = Phyloxml
4026    rootObj = rootClass.factory()
4027    rootObj.build(rootNode)
4028    # Enable Python to collect the space used by the DOM.
4029    doc = None
4030##     sys.stdout.write('#from phyloxml import *\n\n')
4031##     sys.stdout.write('import phyloxml as model_\n\n')
4032##     sys.stdout.write('rootObj = model_.rootTag(\n')
4033##     rootObj.exportLiteral(sys.stdout, 0, name_=rootTag)
4034##     sys.stdout.write(')\n')
4035    return rootObj
4036
4037
4038def main():
4039    args = sys.argv[1:]
4040    if len(args) == 1:
4041        parse(args[0])
4042    else:
4043        usage()
4044
4045
4046if __name__ == '__main__':
4047    #import pdb; pdb.set_trace()
4048    main()
4049
4050
4051__all__ = [
4052    "Accession",
4053    "Annotation",
4054    "BinaryCharacterList",
4055    "BinaryCharacters",
4056    "BranchColor",
4057    "Clade",
4058    "CladeRelation",
4059    "Confidence",
4060    "Date",
4061    "Distribution",
4062    "DomainArchitecture",
4063    "Events",
4064    "Id",
4065    "MolSeq",
4066    "Phylogeny",
4067    "Phyloxml",
4068    "Point",
4069    "Polygon",
4070    "Property",
4071    "ProteinDomain",
4072    "Reference",
4073    "Sequence",
4074    "SequenceRelation",
4075    "Taxonomy",
4076    "Uri"
4077    ]
4078