Coverage for /home/deng/Projects/ete4/hackathon/ete4/ete4/phyloxml/_phyloxml.py: 23%

3462 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2024-03-21 09:19 +0100

1#!/usr/bin/env python3 

2 

3# 

4# Generated Mon Jun 27 10:13:44 2011 by generateDS.py version 2.5b. 

5# 

6 

7import sys 

8import getopt 

9import re as re_ 

10 

11etree_ = None 

12Verbose_import_ = False 

13( XMLParser_import_none, XMLParser_import_lxml, 

14 XMLParser_import_elementtree 

15 ) = list(range(3)) 

16XMLParser_import_library = None 

17try: 

18 # lxml 

19 from lxml import etree as etree_ 

20 XMLParser_import_library = XMLParser_import_lxml 

21 if Verbose_import_: 

22 print("running with lxml.etree") 

23except ImportError: 

24 try: 

25 # cElementTree from Python 2.5+ 

26 import xml.etree.cElementTree as etree_ 

27 XMLParser_import_library = XMLParser_import_elementtree 

28 if Verbose_import_: 

29 print("running with cElementTree on Python 2.5+") 

30 except ImportError: 

31 try: 

32 # ElementTree from Python 2.5+ 

33 import xml.etree.ElementTree as etree_ 

34 XMLParser_import_library = XMLParser_import_elementtree 

35 if Verbose_import_: 

36 print("running with ElementTree on Python 2.5+") 

37 except ImportError: 

38 try: 

39 # normal cElementTree install 

40 import cElementTree as etree_ 

41 XMLParser_import_library = XMLParser_import_elementtree 

42 if Verbose_import_: 

43 print("running with cElementTree") 

44 except ImportError: 

45 try: 

46 # normal ElementTree install 

47 import elementtree.ElementTree as etree_ 

48 XMLParser_import_library = XMLParser_import_elementtree 

49 if Verbose_import_: 

50 print("running with ElementTree") 

51 except ImportError: 

52 raise ImportError("Failed to import ElementTree from any known place") 

53 

54def parsexml_(*args, **kwargs): 

55 if (XMLParser_import_library == XMLParser_import_lxml and 

56 'parser' not in kwargs): 

57 # Use the lxml ElementTree compatible parser so that, e.g., 

58 # we ignore comments. 

59 kwargs['parser'] = etree_.ETCompatXMLParser() 

60 doc = etree_.parse(*args, **kwargs) 

61 return doc 

62 

63# 

64# User methods 

65# 

66# Calls to the methods in these classes are generated by generateDS.py. 

67# You can replace these methods by re-implementing the following class 

68# in a module named generatedssuper.py. 

69 

70try: 

71 from generatedssuper import GeneratedsSuper 

72except ImportError as exp: 

73 

74 class GeneratedsSuper(object): 

75 def gds_format_string(self, input_data, input_name=''): 

76 return input_data 

77 def gds_validate_string(self, input_data, node, input_name=''): 

78 return input_data 

79 def gds_format_integer(self, input_data, input_name=''): 

80 return '%d' % input_data 

81 def gds_validate_integer(self, input_data, node, input_name=''): 

82 return input_data 

83 def gds_format_integer_list(self, input_data, input_name=''): 

84 return '%s' % input_data 

85 def gds_validate_integer_list(self, input_data, node, input_name=''): 

86 values = input_data.split() 

87 for value in values: 

88 try: 

89 fvalue = float(value) 

90 except (TypeError, ValueError) as exp: 

91 raise_parse_error(node, 'Requires sequence of integers') 

92 return input_data 

93 def gds_format_float(self, input_data, input_name=''): 

94 return '%f' % input_data 

95 def gds_validate_float(self, input_data, node, input_name=''): 

96 return input_data 

97 def gds_format_float_list(self, input_data, input_name=''): 

98 return '%s' % input_data 

99 def gds_validate_float_list(self, input_data, node, input_name=''): 

100 values = input_data.split() 

101 for value in values: 

102 try: 

103 fvalue = float(value) 

104 except (TypeError, ValueError) as exp: 

105 raise_parse_error(node, 'Requires sequence of floats') 

106 return input_data 

107 def gds_format_double(self, input_data, input_name=''): 

108 return '%e' % input_data 

109 def gds_validate_double(self, input_data, node, input_name=''): 

110 return input_data 

111 def gds_format_double_list(self, input_data, input_name=''): 

112 return '%s' % input_data 

113 def gds_validate_double_list(self, input_data, node, input_name=''): 

114 values = input_data.split() 

115 for value in values: 

116 try: 

117 fvalue = float(value) 

118 except (TypeError, ValueError) as exp: 

119 raise_parse_error(node, 'Requires sequence of doubles') 

120 return input_data 

121 def gds_format_boolean(self, input_data, input_name=''): 

122 return '%s' % input_data 

123 def gds_validate_boolean(self, input_data, node, input_name=''): 

124 return input_data 

125 def gds_format_boolean_list(self, input_data, input_name=''): 

126 return '%s' % input_data 

127 def gds_validate_boolean_list(self, input_data, node, input_name=''): 

128 values = input_data.split() 

129 for value in values: 

130 if value not in ('true', '1', 'false', '0', ): 

131 raise_parse_error(node, 'Requires sequence of booleans ("true", "1", "false", "0")') 

132 return input_data 

133 def gds_str_lower(self, instring): 

134 return instring.lower() 

135 def get_path_(self, node): 

136 path_list = [] 

137 self.get_path_list_(node, path_list) 

138 path_list.reverse() 

139 path = '/'.join(path_list) 

140 return path 

141 Tag_strip_pattern_ = re_.compile(r'\{.*\}') 

142 def get_path_list_(self, node, path_list): 

143 if node is None: 

144 return 

145 tag = GeneratedsSuper.Tag_strip_pattern_.sub('', node.tag) 

146 if tag: 

147 path_list.append(tag) 

148 self.get_path_list_(node.getparent(), path_list) 

149 

150 

151# 

152# If you have installed IPython you can uncomment and use the following. 

153# IPython is available from http://ipython.scipy.org/. 

154# 

155 

156## from IPython.Shell import IPShellEmbed 

157## args = '' 

158## ipshell = IPShellEmbed(args, 

159## banner = 'Dropping into IPython', 

160## exit_msg = 'Leaving Interpreter, back to program.') 

161 

162# Then use the following line where and when you want to drop into the 

163# IPython shell: 

164# ipshell('<some message> -- Entering ipshell.\nHit Ctrl-D to exit') 

165 

166# 

167# Globals 

168# 

169 

170ExternalEncoding = 'utf-8' 

171Tag_pattern_ = re_.compile(r'({.*})?(.*)') 

172STRING_CLEANUP_PAT = re_.compile(r"[\n\r\s]+") 

173 

174# 

175# Support/utility functions. 

176# 

177 

178def showIndent(outfile, level): 

179 for idx in range(level): 

180 outfile.write(' ') 

181 

182def quote_xml(inStr): 

183 if not inStr: 

184 return '' 

185 s1 = (isinstance(inStr, str) and inStr or 

186 '%s' % inStr) 

187 s1 = s1.replace('&', '&amp;') 

188 s1 = s1.replace('<', '&lt;') 

189 s1 = s1.replace('>', '&gt;') 

190 return s1 

191 

192def quote_attrib(inStr): 

193 s1 = (isinstance(inStr, str) and inStr or 

194 '%s' % inStr) 

195 s1 = s1.replace('&', '&amp;') 

196 s1 = s1.replace('<', '&lt;') 

197 s1 = s1.replace('>', '&gt;') 

198 if '"' in s1: 

199 if "'" in s1: 

200 s1 = '"%s"' % s1.replace('"', "&quot;") 

201 else: 

202 s1 = "'%s'" % s1 

203 else: 

204 s1 = '"%s"' % s1 

205 return s1 

206 

207def quote_python(inStr): 

208 s1 = inStr 

209 if s1.find("'") == -1: 

210 if s1.find('\n') == -1: 

211 return "'%s'" % s1 

212 else: 

213 return "'''%s'''" % s1 

214 else: 

215 if s1.find('"') != -1: 

216 s1 = s1.replace('"', '\\"') 

217 if s1.find('\n') == -1: 

218 return '"%s"' % s1 

219 else: 

220 return '"""%s"""' % s1 

221 

222def get_all_text_(node): 

223 if node.text is not None: 

224 text = node.text 

225 else: 

226 text = '' 

227 for child in node: 

228 if child.tail is not None: 

229 text += child.tail 

230 return text 

231 

232def find_attr_value_(attr_name, node): 

233 attrs = node.attrib 

234 # First try with no namespace. 

235 value = attrs.get(attr_name) 

236 if value is None: 

237 # Now try the other possible namespaces. 

238 namespaces = node.nsmap.values() 

239 for namespace in namespaces: 

240 value = attrs.get('{%s}%s' % (namespace, attr_name, )) 

241 if value is not None: 

242 break 

243 return value 

244 

245 

246class GDSParseError(Exception): 

247 pass 

248 

249def raise_parse_error(node, msg): 

250 if XMLParser_import_library == XMLParser_import_lxml: 

251 msg = '%s (element %s/line %d)' % (msg, node.tag, node.sourceline, ) 

252 else: 

253 msg = '%s (element %s)' % (msg, node.tag, ) 

254 raise GDSParseError(msg) 

255 

256 

257class MixedContainer: 

258 # Constants for category: 

259 CategoryNone = 0 

260 CategoryText = 1 

261 CategorySimple = 2 

262 CategoryComplex = 3 

263 # Constants for content_type: 

264 TypeNone = 0 

265 TypeText = 1 

266 TypeString = 2 

267 TypeInteger = 3 

268 TypeFloat = 4 

269 TypeDecimal = 5 

270 TypeDouble = 6 

271 TypeBoolean = 7 

272 def __init__(self, category, content_type, name, value): 

273 self.category = category 

274 self.content_type = content_type 

275 self.name = name 

276 self.value = value 

277 def getCategory(self): 

278 return self.category 

279 def getContenttype(self, content_type): 

280 return self.content_type 

281 def getValue(self): 

282 return self.value 

283 def getName(self): 

284 return self.name 

285 def export(self, outfile, level, name, namespace): 

286 if self.category == MixedContainer.CategoryText: 

287 # Prevent exporting empty content as empty lines. 

288 if self.value.strip(): 

289 outfile.write(self.value) 

290 elif self.category == MixedContainer.CategorySimple: 

291 self.exportSimple(outfile, level, name) 

292 else: # category == MixedContainer.CategoryComplex 

293 self.value.export(outfile, level, namespace,name) 

294 def exportSimple(self, outfile, level, name): 

295 if self.content_type == MixedContainer.TypeString: 

296 outfile.write('<%s>%s</%s>' % (self.name, self.value, self.name)) 

297 elif self.content_type == MixedContainer.TypeInteger or \ 

298 self.content_type == MixedContainer.TypeBoolean: 

299 outfile.write('<%s>%d</%s>' % (self.name, self.value, self.name)) 

300 elif self.content_type == MixedContainer.TypeFloat or \ 

301 self.content_type == MixedContainer.TypeDecimal: 

302 outfile.write('<%s>%f</%s>' % (self.name, self.value, self.name)) 

303 elif self.content_type == MixedContainer.TypeDouble: 

304 outfile.write('<%s>%g</%s>' % (self.name, self.value, self.name)) 

305 def exportLiteral(self, outfile, level, name): 

306 if self.category == MixedContainer.CategoryText: 

307 showIndent(outfile, level) 

308 outfile.write('model_.MixedContainer(%d, %d, "%s", "%s"),\n' % \ 

309 (self.category, self.content_type, self.name, self.value)) 

310 elif self.category == MixedContainer.CategorySimple: 

311 showIndent(outfile, level) 

312 outfile.write('model_.MixedContainer(%d, %d, "%s", "%s"),\n' % \ 

313 (self.category, self.content_type, self.name, self.value)) 

314 else: # category == MixedContainer.CategoryComplex 

315 showIndent(outfile, level) 

316 outfile.write('model_.MixedContainer(%d, %d, "%s",\n' % \ 

317 (self.category, self.content_type, self.name,)) 

318 self.value.exportLiteral(outfile, level + 1) 

319 showIndent(outfile, level) 

320 outfile.write(')\n') 

321 

322 

323class MemberSpec_: 

324 def __init__(self, name='', data_type='', container=0): 

325 self.name = name 

326 self.data_type = data_type 

327 self.container = container 

328 def set_name(self, name): self.name = name 

329 def get_name(self): return self.name 

330 def set_data_type(self, data_type): self.data_type = data_type 

331 def get_data_type_chain(self): return self.data_type 

332 def get_data_type(self): 

333 if isinstance(self.data_type, list): 

334 if len(self.data_type) > 0: 

335 return self.data_type[-1] 

336 else: 

337 return 'xs:string' 

338 else: 

339 return self.data_type 

340 def set_container(self, container): self.container = container 

341 def get_container(self): return self.container 

342 

343def _cast(typ, value): 

344 if typ is None or value is None: 

345 return value 

346 return typ(value) 

347 

348# 

349# Data representation classes. 

350# 

351 

352class Phyloxml(GeneratedsSuper): 

353 """'phyloxml' is the name of the root element. Phyloxml contains an 

354 arbitrary number of 'phylogeny' elements (each representing one 

355 phylogeny) possibly followed by elements from other namespaces.""" 

356 subclass = None 

357 superclass = None 

358 def __init__(self, phylogeny=None, valueOf_=None): 

359 if phylogeny is None: 

360 self.phylogeny = [] 

361 else: 

362 self.phylogeny = phylogeny 

363 def factory(*args_, **kwargs_): 

364 if Phyloxml.subclass: 

365 return Phyloxml.subclass(*args_, **kwargs_) 

366 else: 

367 return Phyloxml(*args_, **kwargs_) 

368 factory = staticmethod(factory) 

369 def get_phylogeny(self): return self.phylogeny 

370 def set_phylogeny(self, phylogeny): self.phylogeny = phylogeny 

371 def add_phylogeny(self, value): self.phylogeny.append(value) 

372 def insert_phylogeny(self, index, value): self.phylogeny[index] = value 

373 def export(self, outfile, level, namespace_='phy:', name_='Phyloxml', namespacedef_=''): 

374 showIndent(outfile, level) 

375 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) 

376 already_processed = [] 

377 self.exportAttributes(outfile, level, already_processed, namespace_, name_='Phyloxml') 

378 if self.hasContent_(): 

379 outfile.write('>\n') 

380 self.exportChildren(outfile, level + 1, namespace_, name_) 

381 showIndent(outfile, level) 

382 outfile.write('</%s%s>\n' % (namespace_, name_)) 

383 else: 

384 outfile.write('/>\n') 

385 def exportAttributes(self, outfile, level, already_processed, namespace_='phy:', name_='Phyloxml'): 

386 pass 

387 def exportChildren(self, outfile, level, namespace_='phy:', name_='Phyloxml', fromsubclass_=False): 

388 for phylogeny_ in self.phylogeny: 

389 phylogeny_.export(outfile, level, namespace_, name_='phylogeny') 

390 def hasContent_(self): 

391 if ( 

392 self.phylogeny 

393 ): 

394 return True 

395 else: 

396 return False 

397 def exportLiteral(self, outfile, level, name_='Phyloxml'): 

398 level += 1 

399 self.exportLiteralAttributes(outfile, level, [], name_) 

400 if self.hasContent_(): 

401 self.exportLiteralChildren(outfile, level, name_) 

402 def exportLiteralAttributes(self, outfile, level, already_processed, name_): 

403 pass 

404 def exportLiteralChildren(self, outfile, level, name_): 

405 showIndent(outfile, level) 

406 outfile.write('phylogeny=[\n') 

407 level += 1 

408 for phylogeny_ in self.phylogeny: 

409 showIndent(outfile, level) 

410 outfile.write('model_.Phylogeny(\n') 

411 phylogeny_.exportLiteral(outfile, level, name_='Phylogeny') 

412 showIndent(outfile, level) 

413 outfile.write('),\n') 

414 level -= 1 

415 showIndent(outfile, level) 

416 outfile.write('],\n') 

417 def build(self, node): 

418 self.buildAttributes(node, node.attrib, []) 

419 for child in node: 

420 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 

421 self.buildChildren(child, node, nodeName_) 

422 def buildAttributes(self, node, attrs, already_processed): 

423 pass 

424 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 

425 if nodeName_ == 'phylogeny': 

426 obj_ = Phylogeny.factory() 

427 obj_.build(child_) 

428 self.phylogeny.append(obj_) 

429# end class Phyloxml 

430 

431 

432class Phylogeny(GeneratedsSuper): 

433 """Element Phylogeny is used to represent a phylogeny. The required 

434 attribute 'rooted' is used to indicate whether the phylogeny is 

435 rooted or not. The attribute 'rerootable' can be used to 

436 indicate that the phylogeny is not allowed to be rooted 

437 differently (i.e. because it is associated with root dependent 

438 data, such as gene duplications). The attribute 'type' can be 

439 used to indicate the type of phylogeny (i.e. 'gene tree'). It is 

440 recommended to use the attribute 'branch_length_unit' if the 

441 phylogeny has branch lengths. Element clade is used in a 

442 recursive manner to describe the topology of a phylogenetic 

443 tree.""" 

444 subclass = None 

445 superclass = None 

446 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): 

447 self.rerootable = _cast(bool, rerootable) 

448 self.branch_length_unit = _cast(None, branch_length_unit) 

449 self.type_ = _cast(None, type_) 

450 self.rooted = _cast(bool, rooted) 

451 self.name = name 

452 self.id = id 

453 self.description = description 

454 self.date = date 

455 if confidence is None: 

456 self.confidence = [] 

457 else: 

458 self.confidence = confidence 

459 self.clade = clade 

460 if clade_relation is None: 

461 self.clade_relation = [] 

462 else: 

463 self.clade_relation = clade_relation 

464 if sequence_relation is None: 

465 self.sequence_relation = [] 

466 else: 

467 self.sequence_relation = sequence_relation 

468 if property is None: 

469 self.property = [] 

470 else: 

471 self.property = property 

472 def factory(*args_, **kwargs_): 

473 if Phylogeny.subclass: 

474 return Phylogeny.subclass(*args_, **kwargs_) 

475 else: 

476 return Phylogeny(*args_, **kwargs_) 

477 factory = staticmethod(factory) 

478 def get_name(self): return self.name 

479 def set_name(self, name): self.name = name 

480 def get_id(self): return self.id 

481 def set_id(self, id): self.id = id 

482 def get_description(self): return self.description 

483 def set_description(self, description): self.description = description 

484 def get_date(self): return self.date 

485 def set_date(self, date): self.date = date 

486 def get_confidence(self): return self.confidence 

487 def set_confidence(self, confidence): self.confidence = confidence 

488 def add_confidence(self, value): self.confidence.append(value) 

489 def insert_confidence(self, index, value): self.confidence[index] = value 

490 def get_clade(self): return self.clade 

491 def set_clade(self, clade): self.clade = clade 

492 def get_clade_relation(self): return self.clade_relation 

493 def set_clade_relation(self, clade_relation): self.clade_relation = clade_relation 

494 def add_clade_relation(self, value): self.clade_relation.append(value) 

495 def insert_clade_relation(self, index, value): self.clade_relation[index] = value 

496 def get_sequence_relation(self): return self.sequence_relation 

497 def set_sequence_relation(self, sequence_relation): self.sequence_relation = sequence_relation 

498 def add_sequence_relation(self, value): self.sequence_relation.append(value) 

499 def insert_sequence_relation(self, index, value): self.sequence_relation[index] = value 

500 def get_property(self): return self.property 

501 def set_property(self, property): self.property = property 

502 def add_property(self, value): self.property.append(value) 

503 def insert_property(self, index, value): self.property[index] = value 

504 def get_rerootable(self): return self.rerootable 

505 def set_rerootable(self, rerootable): self.rerootable = rerootable 

506 def get_branch_length_unit(self): return self.branch_length_unit 

507 def set_branch_length_unit(self, branch_length_unit): self.branch_length_unit = branch_length_unit 

508 def get_type(self): return self.type_ 

509 def set_type(self, type_): self.type_ = type_ 

510 def get_rooted(self): return self.rooted 

511 def set_rooted(self, rooted): self.rooted = rooted 

512 def export(self, outfile, level, namespace_='phy:', name_='Phylogeny', namespacedef_=''): 

513 showIndent(outfile, level) 

514 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) 

515 already_processed = [] 

516 self.exportAttributes(outfile, level, already_processed, namespace_, name_='Phylogeny') 

517 if self.hasContent_(): 

518 outfile.write('>\n') 

519 self.exportChildren(outfile, level + 1, namespace_, name_) 

520 showIndent(outfile, level) 

521 outfile.write('</%s%s>\n' % (namespace_, name_)) 

522 else: 

523 outfile.write('/>\n') 

524 def exportAttributes(self, outfile, level, already_processed, namespace_='phy:', name_='Phylogeny'): 

525 if self.rerootable is not None and 'rerootable' not in already_processed: 

526 already_processed.append('rerootable') 

527 outfile.write(' rerootable="%s"' % self.gds_format_boolean(self.gds_str_lower(str(self.rerootable)), input_name='rerootable')) 

528 if self.branch_length_unit is not None and 'branch_length_unit' not in already_processed: 

529 already_processed.append('branch_length_unit') 

530 outfile.write(' branch_length_unit=%s' % (self.gds_format_string(quote_attrib(self.branch_length_unit).encode(ExternalEncoding), input_name='branch_length_unit'), )) 

531 if self.type_ is not None and 'type_' not in already_processed: 

532 already_processed.append('type_') 

533 outfile.write(' type=%s' % (self.gds_format_string(quote_attrib(self.type_).encode(ExternalEncoding), input_name='type'), )) 

534 if self.rooted is not None and 'rooted' not in already_processed: 

535 already_processed.append('rooted') 

536 outfile.write(' rooted="%s"' % self.gds_format_boolean(self.gds_str_lower(str(self.rooted)), input_name='rooted')) 

537 def exportChildren(self, outfile, level, namespace_='phy:', name_='Phylogeny', fromsubclass_=False): 

538 if self.name is not None: 

539 showIndent(outfile, level) 

540 outfile.write('<%sname>%s</%sname>\n' % (namespace_, self.gds_format_string(quote_xml(self.name).encode(ExternalEncoding), input_name='name'), namespace_)) 

541 if self.id: 

542 self.id.export(outfile, level, namespace_, name_='id') 

543 if self.description is not None: 

544 showIndent(outfile, level) 

545 outfile.write('<%sdescription>%s</%sdescription>\n' % (namespace_, self.gds_format_string(quote_xml(self.description).encode(ExternalEncoding), input_name='description'), namespace_)) 

546 if self.date is not None: 

547 showIndent(outfile, level) 

548 outfile.write('<%sdate>%s</%sdate>\n' % (namespace_, self.gds_format_string(quote_xml(self.date).encode(ExternalEncoding), input_name='date'), namespace_)) 

549 for confidence_ in self.confidence: 

550 confidence_.export(outfile, level, namespace_, name_='confidence') 

551 if self.clade: 

552 self.clade.export(outfile, level, namespace_, name_='clade') 

553 for clade_relation_ in self.clade_relation: 

554 clade_relation_.export(outfile, level, namespace_, name_='clade_relation') 

555 for sequence_relation_ in self.sequence_relation: 

556 sequence_relation_.export(outfile, level, namespace_, name_='sequence_relation') 

557 for property_ in self.property: 

558 property_.export(outfile, level, namespace_, name_='property') 

559 def hasContent_(self): 

560 if ( 

561 self.name is not None or 

562 self.id is not None or 

563 self.description is not None or 

564 self.date is not None or 

565 self.confidence or 

566 self.clade is not None or 

567 self.clade_relation or 

568 self.sequence_relation or 

569 self.property 

570 ): 

571 return True 

572 else: 

573 return False 

574 def exportLiteral(self, outfile, level, name_='Phylogeny'): 

575 level += 1 

576 self.exportLiteralAttributes(outfile, level, [], name_) 

577 if self.hasContent_(): 

578 self.exportLiteralChildren(outfile, level, name_) 

579 def exportLiteralAttributes(self, outfile, level, already_processed, name_): 

580 if self.rerootable is not None and 'rerootable' not in already_processed: 

581 already_processed.append('rerootable') 

582 showIndent(outfile, level) 

583 outfile.write('rerootable = %s,\n' % (self.rerootable,)) 

584 if self.branch_length_unit is not None and 'branch_length_unit' not in already_processed: 

585 already_processed.append('branch_length_unit') 

586 showIndent(outfile, level) 

587 outfile.write('branch_length_unit = "%s",\n' % (self.branch_length_unit,)) 

588 if self.type_ is not None and 'type_' not in already_processed: 

589 already_processed.append('type_') 

590 showIndent(outfile, level) 

591 outfile.write('type_ = "%s",\n' % (self.type_,)) 

592 if self.rooted is not None and 'rooted' not in already_processed: 

593 already_processed.append('rooted') 

594 showIndent(outfile, level) 

595 outfile.write('rooted = %s,\n' % (self.rooted,)) 

596 def exportLiteralChildren(self, outfile, level, name_): 

597 if self.name is not None: 

598 showIndent(outfile, level) 

599 outfile.write('name=%s,\n' % quote_python(self.name).encode(ExternalEncoding)) 

600 if self.id is not None: 

601 showIndent(outfile, level) 

602 outfile.write('id=model_.Id(\n') 

603 self.id.exportLiteral(outfile, level, name_='id') 

604 showIndent(outfile, level) 

605 outfile.write('),\n') 

606 if self.description is not None: 

607 showIndent(outfile, level) 

608 outfile.write('description=%s,\n' % quote_python(self.description).encode(ExternalEncoding)) 

609 if self.date is not None: 

610 showIndent(outfile, level) 

611 outfile.write('date=%s,\n' % quote_python(self.date).encode(ExternalEncoding)) 

612 showIndent(outfile, level) 

613 outfile.write('confidence=[\n') 

614 level += 1 

615 for confidence_ in self.confidence: 

616 showIndent(outfile, level) 

617 outfile.write('model_.Confidence(\n') 

618 confidence_.exportLiteral(outfile, level, name_='Confidence') 

619 showIndent(outfile, level) 

620 outfile.write('),\n') 

621 level -= 1 

622 showIndent(outfile, level) 

623 outfile.write('],\n') 

624 if self.clade is not None: 

625 showIndent(outfile, level) 

626 outfile.write('clade=model_.Clade(\n') 

627 self.clade.exportLiteral(outfile, level, name_='clade') 

628 showIndent(outfile, level) 

629 outfile.write('),\n') 

630 showIndent(outfile, level) 

631 outfile.write('clade_relation=[\n') 

632 level += 1 

633 for clade_relation_ in self.clade_relation: 

634 showIndent(outfile, level) 

635 outfile.write('model_.CladeRelation(\n') 

636 clade_relation_.exportLiteral(outfile, level, name_='CladeRelation') 

637 showIndent(outfile, level) 

638 outfile.write('),\n') 

639 level -= 1 

640 showIndent(outfile, level) 

641 outfile.write('],\n') 

642 showIndent(outfile, level) 

643 outfile.write('sequence_relation=[\n') 

644 level += 1 

645 for sequence_relation_ in self.sequence_relation: 

646 showIndent(outfile, level) 

647 outfile.write('model_.SequenceRelation(\n') 

648 sequence_relation_.exportLiteral(outfile, level, name_='SequenceRelation') 

649 showIndent(outfile, level) 

650 outfile.write('),\n') 

651 level -= 1 

652 showIndent(outfile, level) 

653 outfile.write('],\n') 

654 showIndent(outfile, level) 

655 outfile.write('property=[\n') 

656 level += 1 

657 for property_ in self.property: 

658 showIndent(outfile, level) 

659 outfile.write('model_.Property(\n') 

660 property_.exportLiteral(outfile, level, name_='Property') 

661 showIndent(outfile, level) 

662 outfile.write('),\n') 

663 level -= 1 

664 showIndent(outfile, level) 

665 outfile.write('],\n') 

666 def build(self, node): 

667 self.buildAttributes(node, node.attrib, []) 

668 for child in node: 

669 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 

670 self.buildChildren(child, node, nodeName_) 

671 def buildAttributes(self, node, attrs, already_processed): 

672 value = find_attr_value_('rerootable', node) 

673 if value is not None and 'rerootable' not in already_processed: 

674 already_processed.append('rerootable') 

675 if value in ('true', '1'): 

676 self.rerootable = True 

677 elif value in ('false', '0'): 

678 self.rerootable = False 

679 else: 

680 raise_parse_error(node, 'Bad boolean attribute') 

681 value = find_attr_value_('branch_length_unit', node) 

682 if value is not None and 'branch_length_unit' not in already_processed: 

683 already_processed.append('branch_length_unit') 

684 self.branch_length_unit = value 

685 self.branch_length_unit = ' '.join(self.branch_length_unit.split()) 

686 value = find_attr_value_('type', node) 

687 if value is not None and 'type' not in already_processed: 

688 already_processed.append('type') 

689 self.type_ = value 

690 self.type_ = ' '.join(self.type_.split()) 

691 value = find_attr_value_('rooted', node) 

692 if value is not None and 'rooted' not in already_processed: 

693 already_processed.append('rooted') 

694 if value in ('true', '1'): 

695 self.rooted = True 

696 elif value in ('false', '0'): 

697 self.rooted = False 

698 else: 

699 raise_parse_error(node, 'Bad boolean attribute') 

700 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 

701 if nodeName_ == 'name': 

702 name_ = child_.text 

703 name_ = re_.sub(STRING_CLEANUP_PAT, " ", name_).strip() 

704 name_ = self.gds_validate_string(name_, node, 'name') 

705 self.name = name_ 

706 elif nodeName_ == 'id': 

707 obj_ = Id.factory() 

708 obj_.build(child_) 

709 self.set_id(obj_) 

710 elif nodeName_ == 'description': 

711 description_ = child_.text 

712 description_ = re_.sub(STRING_CLEANUP_PAT, " ", description_).strip() 

713 description_ = self.gds_validate_string(description_, node, 'description') 

714 self.description = description_ 

715 elif nodeName_ == 'date': 

716 date_ = child_.text 

717 date_ = self.gds_validate_string(date_, node, 'date') 

718 self.date = date_ 

719 elif nodeName_ == 'confidence': 

720 obj_ = Confidence.factory() 

721 obj_.build(child_) 

722 self.confidence.append(obj_) 

723 elif nodeName_ == 'clade': 

724 obj_ = Clade.factory() 

725 obj_.build(child_) 

726 self.set_clade(obj_) 

727 elif nodeName_ == 'clade_relation': 

728 obj_ = CladeRelation.factory() 

729 obj_.build(child_) 

730 self.clade_relation.append(obj_) 

731 elif nodeName_ == 'sequence_relation': 

732 obj_ = SequenceRelation.factory() 

733 obj_.build(child_) 

734 self.sequence_relation.append(obj_) 

735 elif nodeName_ == 'property': 

736 obj_ = Property.factory() 

737 obj_.build(child_) 

738 self.property.append(obj_) 

739# end class Phylogeny 

740 

741 

742class Clade(GeneratedsSuper): 

743 """Element Clade is used in a recursive manner to describe the topology 

744 of a phylogenetic tree. The parent branch length of a clade can 

745 be described either with the 'branch_length' element or the 

746 'branch_length' attribute (it is not recommended to use both at 

747 the same time, though). Usage of the 'branch_length' attribute 

748 allows for a less verbose description. Element 'confidence' is 

749 used to indicate the support for a clade/parent branch. Element 

750 'events' is used to describe such events as gene-duplications at 

751 the root node/parent branch of a clade. Element 'width' is the 

752 branch width for this clade (including parent branch). Both 

753 'color' and 'width' elements apply for the whole clade unless 

754 overwritten in-sub clades. Attribute 'id_source' is used to link 

755 other elements to a clade (on the xml-level).""" 

756 subclass = None 

757 superclass = None 

758 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): 

759 self.id_source = _cast(None, id_source) 

760 self.branch_length_attr = _cast(None, branch_length_attr) 

761 self.name = name 

762 self.branch_length = branch_length 

763 if confidence is None: 

764 self.confidence = [] 

765 else: 

766 self.confidence = confidence 

767 self.width = width 

768 self.color = color 

769 self.node_id = node_id 

770 if taxonomy is None: 

771 self.taxonomy = [] 

772 else: 

773 self.taxonomy = taxonomy 

774 if sequence is None: 

775 self.sequence = [] 

776 else: 

777 self.sequence = sequence 

778 self.events = events 

779 self.binary_characters = binary_characters 

780 if distribution is None: 

781 self.distribution = [] 

782 else: 

783 self.distribution = distribution 

784 self.date = date 

785 if reference is None: 

786 self.reference = [] 

787 else: 

788 self.reference = reference 

789 if property is None: 

790 self.property = [] 

791 else: 

792 self.property = property 

793 if clade is None: 

794 self.clade = [] 

795 else: 

796 self.clade = clade 

797 def factory(*args_, **kwargs_): 

798 if Clade.subclass: 

799 return Clade.subclass(*args_, **kwargs_) 

800 else: 

801 return Clade(*args_, **kwargs_) 

802 factory = staticmethod(factory) 

803 def get_name(self): return self.name 

804 def set_name(self, name): self.name = name 

805 def get_branch_length(self): return self.branch_length 

806 def set_branch_length(self, branch_length): self.branch_length = branch_length 

807 def get_confidence(self): return self.confidence 

808 def set_confidence(self, confidence): self.confidence = confidence 

809 def add_confidence(self, value): self.confidence.append(value) 

810 def insert_confidence(self, index, value): self.confidence[index] = value 

811 def get_width(self): return self.width 

812 def set_width(self, width): self.width = width 

813 def get_color(self): return self.color 

814 def set_color(self, color): self.color = color 

815 def get_node_id(self): return self.node_id 

816 def set_node_id(self, node_id): self.node_id = node_id 

817 def get_taxonomy(self): return self.taxonomy 

818 def set_taxonomy(self, taxonomy): self.taxonomy = taxonomy 

819 def add_taxonomy(self, value): self.taxonomy.append(value) 

820 def insert_taxonomy(self, index, value): self.taxonomy[index] = value 

821 def get_sequence(self): return self.sequence 

822 def set_sequence(self, sequence): self.sequence = sequence 

823 def add_sequence(self, value): self.sequence.append(value) 

824 def insert_sequence(self, index, value): self.sequence[index] = value 

825 def get_events(self): return self.events 

826 def set_events(self, events): self.events = events 

827 def get_binary_characters(self): return self.binary_characters 

828 def set_binary_characters(self, binary_characters): self.binary_characters = binary_characters 

829 def get_distribution(self): return self.distribution 

830 def set_distribution(self, distribution): self.distribution = distribution 

831 def add_distribution(self, value): self.distribution.append(value) 

832 def insert_distribution(self, index, value): self.distribution[index] = value 

833 def get_date(self): return self.date 

834 def set_date(self, date): self.date = date 

835 def get_reference(self): return self.reference 

836 def set_reference(self, reference): self.reference = reference 

837 def add_reference(self, value): self.reference.append(value) 

838 def insert_reference(self, index, value): self.reference[index] = value 

839 def get_property(self): return self.property 

840 def set_property(self, property): self.property = property 

841 def add_property(self, value): self.property.append(value) 

842 def insert_property(self, index, value): self.property[index] = value 

843 def get_clade(self): return self.clade 

844 def set_clade(self, clade): self.clade = clade 

845 def add_clade(self, value): self.clade.append(value) 

846 def insert_clade(self, index, value): self.clade[index] = value 

847 def get_id_source(self): return self.id_source 

848 def set_id_source(self, id_source): self.id_source = id_source 

849 def get_branch_length_attr(self): return self.branch_length_attr 

850 def set_branch_length_attr(self, branch_length_attr): self.branch_length_attr = branch_length_attr 

851 def export(self, outfile, level, namespace_='phy:', name_='Clade', namespacedef_=''): 

852 showIndent(outfile, level) 

853 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) 

854 already_processed = [] 

855 self.exportAttributes(outfile, level, already_processed, namespace_, name_='Clade') 

856 if self.hasContent_(): 

857 outfile.write('>\n') 

858 self.exportChildren(outfile, level + 1, namespace_, name_) 

859 showIndent(outfile, level) 

860 outfile.write('</%s%s>\n' % (namespace_, name_)) 

861 else: 

862 outfile.write('/>\n') 

863 def exportAttributes(self, outfile, level, already_processed, namespace_='phy:', name_='Clade'): 

864 if self.id_source is not None and 'id_source' not in already_processed: 

865 already_processed.append('id_source') 

866 outfile.write(' id_source=%s' % (quote_attrib(self.id_source), )) 

867 if self.branch_length_attr is not None and 'branch_length_attr' not in already_processed: 

868 already_processed.append('branch_length_attr') 

869 outfile.write(' branch_length_attr=%s' % (self.gds_format_string(quote_attrib(self.branch_length_attr).encode(ExternalEncoding), input_name='branch_length_attr'), )) 

870 def exportChildren(self, outfile, level, namespace_='phy:', name_='Clade', fromsubclass_=False): 

871 if self.name is not None: 

872 showIndent(outfile, level) 

873 outfile.write('<%sname>%s</%sname>\n' % (namespace_, self.gds_format_string(quote_xml(self.name).encode(ExternalEncoding), input_name='name'), namespace_)) 

874 if self.branch_length is not None: 

875 showIndent(outfile, level) 

876 outfile.write('<%sbranch_length>%s</%sbranch_length>\n' % (namespace_, self.gds_format_double(self.branch_length, input_name='branch_length'), namespace_)) 

877 for confidence_ in self.confidence: 

878 confidence_.export(outfile, level, namespace_, name_='confidence') 

879 if self.width is not None: 

880 showIndent(outfile, level) 

881 outfile.write('<%swidth>%s</%swidth>\n' % (namespace_, self.gds_format_double(self.width, input_name='width'), namespace_)) 

882 if self.color: 

883 self.color.export(outfile, level, namespace_, name_='color') 

884 if self.node_id: 

885 self.node_id.export(outfile, level, namespace_, name_='node_id') 

886 for taxonomy_ in self.taxonomy: 

887 taxonomy_.export(outfile, level, namespace_, name_='taxonomy') 

888 for sequence_ in self.sequence: 

889 sequence_.export(outfile, level, namespace_, name_='sequence') 

890 if self.events: 

891 self.events.export(outfile, level, namespace_, name_='events') 

892 if self.binary_characters: 

893 self.binary_characters.export(outfile, level, namespace_, name_='binary_characters') 

894 for distribution_ in self.distribution: 

895 distribution_.export(outfile, level, namespace_, name_='distribution') 

896 if self.date: 

897 self.date.export(outfile, level, namespace_, name_='date') 

898 for reference_ in self.reference: 

899 reference_.export(outfile, level, namespace_, name_='reference') 

900 for property_ in self.property: 

901 property_.export(outfile, level, namespace_, name_='property') 

902 for clade_ in self.clade: 

903 clade_.export(outfile, level, namespace_, name_='clade') 

904 def hasContent_(self): 

905 if ( 

906 self.name is not None or 

907 self.branch_length is not None or 

908 self.confidence or 

909 self.width is not None or 

910 self.color is not None or 

911 self.node_id is not None or 

912 self.taxonomy or 

913 self.sequence or 

914 self.events is not None or 

915 self.binary_characters is not None or 

916 self.distribution or 

917 self.date is not None or 

918 self.reference or 

919 self.property or 

920 self.clade 

921 ): 

922 return True 

923 else: 

924 return False 

925 def exportLiteral(self, outfile, level, name_='Clade'): 

926 level += 1 

927 self.exportLiteralAttributes(outfile, level, [], name_) 

928 if self.hasContent_(): 

929 self.exportLiteralChildren(outfile, level, name_) 

930 def exportLiteralAttributes(self, outfile, level, already_processed, name_): 

931 if self.id_source is not None and 'id_source' not in already_processed: 

932 already_processed.append('id_source') 

933 showIndent(outfile, level) 

934 outfile.write('id_source = %s,\n' % (self.id_source,)) 

935 if self.branch_length_attr is not None and 'branch_length_attr' not in already_processed: 

936 already_processed.append('branch_length_attr') 

937 showIndent(outfile, level) 

938 outfile.write('branch_length_attr = "%s",\n' % (self.branch_length_attr,)) 

939 def exportLiteralChildren(self, outfile, level, name_): 

940 if self.name is not None: 

941 showIndent(outfile, level) 

942 outfile.write('name=%s,\n' % quote_python(self.name).encode(ExternalEncoding)) 

943 if self.branch_length is not None: 

944 showIndent(outfile, level) 

945 outfile.write('branch_length=%e,\n' % self.branch_length) 

946 showIndent(outfile, level) 

947 outfile.write('confidence=[\n') 

948 level += 1 

949 for confidence_ in self.confidence: 

950 showIndent(outfile, level) 

951 outfile.write('model_.Confidence(\n') 

952 confidence_.exportLiteral(outfile, level, name_='Confidence') 

953 showIndent(outfile, level) 

954 outfile.write('),\n') 

955 level -= 1 

956 showIndent(outfile, level) 

957 outfile.write('],\n') 

958 if self.width is not None: 

959 showIndent(outfile, level) 

960 outfile.write('width=%e,\n' % self.width) 

961 if self.color is not None: 

962 showIndent(outfile, level) 

963 outfile.write('color=model_.BranchColor(\n') 

964 self.color.exportLiteral(outfile, level, name_='color') 

965 showIndent(outfile, level) 

966 outfile.write('),\n') 

967 if self.node_id is not None: 

968 showIndent(outfile, level) 

969 outfile.write('node_id=model_.Id(\n') 

970 self.node_id.exportLiteral(outfile, level, name_='node_id') 

971 showIndent(outfile, level) 

972 outfile.write('),\n') 

973 showIndent(outfile, level) 

974 outfile.write('taxonomy=[\n') 

975 level += 1 

976 for taxonomy_ in self.taxonomy: 

977 showIndent(outfile, level) 

978 outfile.write('model_.Taxonomy(\n') 

979 taxonomy_.exportLiteral(outfile, level, name_='Taxonomy') 

980 showIndent(outfile, level) 

981 outfile.write('),\n') 

982 level -= 1 

983 showIndent(outfile, level) 

984 outfile.write('],\n') 

985 showIndent(outfile, level) 

986 outfile.write('sequence=[\n') 

987 level += 1 

988 for sequence_ in self.sequence: 

989 showIndent(outfile, level) 

990 outfile.write('model_.Sequence(\n') 

991 sequence_.exportLiteral(outfile, level, name_='Sequence') 

992 showIndent(outfile, level) 

993 outfile.write('),\n') 

994 level -= 1 

995 showIndent(outfile, level) 

996 outfile.write('],\n') 

997 if self.events is not None: 

998 showIndent(outfile, level) 

999 outfile.write('events=model_.Events(\n') 

1000 self.events.exportLiteral(outfile, level, name_='events') 

1001 showIndent(outfile, level) 

1002 outfile.write('),\n') 

1003 if self.binary_characters is not None: 

1004 showIndent(outfile, level) 

1005 outfile.write('binary_characters=model_.BinaryCharacters(\n') 

1006 self.binary_characters.exportLiteral(outfile, level, name_='binary_characters') 

1007 showIndent(outfile, level) 

1008 outfile.write('),\n') 

1009 showIndent(outfile, level) 

1010 outfile.write('distribution=[\n') 

1011 level += 1 

1012 for distribution_ in self.distribution: 

1013 showIndent(outfile, level) 

1014 outfile.write('model_.Distribution(\n') 

1015 distribution_.exportLiteral(outfile, level, name_='Distribution') 

1016 showIndent(outfile, level) 

1017 outfile.write('),\n') 

1018 level -= 1 

1019 showIndent(outfile, level) 

1020 outfile.write('],\n') 

1021 if self.date is not None: 

1022 showIndent(outfile, level) 

1023 outfile.write('date=model_.Date(\n') 

1024 self.date.exportLiteral(outfile, level, name_='date') 

1025 showIndent(outfile, level) 

1026 outfile.write('),\n') 

1027 showIndent(outfile, level) 

1028 outfile.write('reference=[\n') 

1029 level += 1 

1030 for reference_ in self.reference: 

1031 showIndent(outfile, level) 

1032 outfile.write('model_.Reference(\n') 

1033 reference_.exportLiteral(outfile, level, name_='Reference') 

1034 showIndent(outfile, level) 

1035 outfile.write('),\n') 

1036 level -= 1 

1037 showIndent(outfile, level) 

1038 outfile.write('],\n') 

1039 showIndent(outfile, level) 

1040 outfile.write('property=[\n') 

1041 level += 1 

1042 for property_ in self.property: 

1043 showIndent(outfile, level) 

1044 outfile.write('model_.Property(\n') 

1045 property_.exportLiteral(outfile, level, name_='Property') 

1046 showIndent(outfile, level) 

1047 outfile.write('),\n') 

1048 level -= 1 

1049 showIndent(outfile, level) 

1050 outfile.write('],\n') 

1051 showIndent(outfile, level) 

1052 outfile.write('clade=[\n') 

1053 level += 1 

1054 for clade_ in self.clade: 

1055 showIndent(outfile, level) 

1056 outfile.write('model_.Clade(\n') 

1057 clade_.exportLiteral(outfile, level, name_='Clade') 

1058 showIndent(outfile, level) 

1059 outfile.write('),\n') 

1060 level -= 1 

1061 showIndent(outfile, level) 

1062 outfile.write('],\n') 

1063 def build(self, node): 

1064 self.buildAttributes(node, node.attrib, []) 

1065 for child in node: 

1066 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 

1067 self.buildChildren(child, node, nodeName_) 

1068 def buildAttributes(self, node, attrs, already_processed): 

1069 value = find_attr_value_('id_source', node) 

1070 if value is not None and 'id_source' not in already_processed: 

1071 already_processed.append('id_source') 

1072 self.id_source = value 

1073 value = find_attr_value_('branch_length_attr', node) 

1074 if value is not None and 'branch_length_attr' not in already_processed: 

1075 already_processed.append('branch_length_attr') 

1076 self.branch_length_attr = value 

1077 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 

1078 if nodeName_ == 'name': 

1079 name_ = child_.text 

1080 name_ = re_.sub(STRING_CLEANUP_PAT, " ", name_).strip() 

1081 name_ = self.gds_validate_string(name_, node, 'name') 

1082 self.name = name_ 

1083 elif nodeName_ == 'branch_length': 

1084 sval_ = child_.text 

1085 try: 

1086 fval_ = float(sval_) 

1087 except (TypeError, ValueError) as exp: 

1088 raise_parse_error(child_, 'requires float or double: %s' % exp) 

1089 fval_ = self.gds_validate_float(fval_, node, 'branch_length') 

1090 self.branch_length = fval_ 

1091 elif nodeName_ == 'confidence': 

1092 obj_ = Confidence.factory() 

1093 obj_.build(child_) 

1094 self.confidence.append(obj_) 

1095 elif nodeName_ == 'width': 

1096 sval_ = child_.text 

1097 try: 

1098 fval_ = float(sval_) 

1099 except (TypeError, ValueError) as exp: 

1100 raise_parse_error(child_, 'requires float or double: %s' % exp) 

1101 fval_ = self.gds_validate_float(fval_, node, 'width') 

1102 self.width = fval_ 

1103 elif nodeName_ == 'color': 

1104 obj_ = BranchColor.factory() 

1105 obj_.build(child_) 

1106 self.set_color(obj_) 

1107 elif nodeName_ == 'node_id': 

1108 obj_ = Id.factory() 

1109 obj_.build(child_) 

1110 self.set_node_id(obj_) 

1111 elif nodeName_ == 'taxonomy': 

1112 obj_ = Taxonomy.factory() 

1113 obj_.build(child_) 

1114 self.taxonomy.append(obj_) 

1115 elif nodeName_ == 'sequence': 

1116 obj_ = Sequence.factory() 

1117 obj_.build(child_) 

1118 self.sequence.append(obj_) 

1119 elif nodeName_ == 'events': 

1120 obj_ = Events.factory() 

1121 obj_.build(child_) 

1122 self.set_events(obj_) 

1123 elif nodeName_ == 'binary_characters': 

1124 obj_ = BinaryCharacters.factory() 

1125 obj_.build(child_) 

1126 self.set_binary_characters(obj_) 

1127 elif nodeName_ == 'distribution': 

1128 obj_ = Distribution.factory() 

1129 obj_.build(child_) 

1130 self.distribution.append(obj_) 

1131 elif nodeName_ == 'date': 

1132 obj_ = Date.factory() 

1133 obj_.build(child_) 

1134 self.set_date(obj_) 

1135 elif nodeName_ == 'reference': 

1136 obj_ = Reference.factory() 

1137 obj_.build(child_) 

1138 self.reference.append(obj_) 

1139 elif nodeName_ == 'property': 

1140 obj_ = Property.factory() 

1141 obj_.build(child_) 

1142 self.property.append(obj_) 

1143 elif nodeName_ == 'clade': 

1144 obj_ = Clade.factory() 

1145 obj_.build(child_) 

1146 self.clade.append(obj_) 

1147# end class Clade 

1148 

1149 

1150class Taxonomy(GeneratedsSuper): 

1151 """Element Taxonomy is used to describe taxonomic information for a 

1152 clade. Element 'code' is intended to store UniProt/Swiss-Prot 

1153 style organism codes (e.g. 'APLCA' for the California sea hare 

1154 'Aplysia californica') or other styles of mnemonics (e.g. 

1155 'Aca'). Element 'authority' is used to keep the authority, such 

1156 as 'J. G. Cooper, 1863', associated with the 'scientific_name'. 

1157 Element 'id' is used for a unique identifier of a taxon (for 

1158 example '6500' with 'ncbi_taxonomy' as 'provider' for the 

1159 California sea hare). Attribute 'id_source' is used to link 

1160 other elements to a taxonomy (on the xml-level).""" 

1161 subclass = None 

1162 superclass = None 

1163 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): 

1164 self.id_source = _cast(None, id_source) 

1165 self.id = id 

1166 self.code = code 

1167 self.scientific_name = scientific_name 

1168 self.authority = authority 

1169 if common_name is None: 

1170 self.common_name = [] 

1171 else: 

1172 self.common_name = common_name 

1173 if synonym is None: 

1174 self.synonym = [] 

1175 else: 

1176 self.synonym = synonym 

1177 self.rank = rank 

1178 self.uri = uri 

1179 def factory(*args_, **kwargs_): 

1180 if Taxonomy.subclass: 

1181 return Taxonomy.subclass(*args_, **kwargs_) 

1182 else: 

1183 return Taxonomy(*args_, **kwargs_) 

1184 factory = staticmethod(factory) 

1185 def get_id(self): return self.id 

1186 def set_id(self, id): self.id = id 

1187 def get_code(self): return self.code 

1188 def set_code(self, code): self.code = code 

1189 def validate_TaxonomyCode(self, value): 

1190 # Validate type TaxonomyCode, a restriction on xs:token. 

1191 pass 

1192 def get_scientific_name(self): return self.scientific_name 

1193 def set_scientific_name(self, scientific_name): self.scientific_name = scientific_name 

1194 def get_authority(self): return self.authority 

1195 def set_authority(self, authority): self.authority = authority 

1196 def get_common_name(self): return self.common_name 

1197 def set_common_name(self, common_name): self.common_name = common_name 

1198 def add_common_name(self, value): self.common_name.append(value) 

1199 def insert_common_name(self, index, value): self.common_name[index] = value 

1200 def get_synonym(self): return self.synonym 

1201 def set_synonym(self, synonym): self.synonym = synonym 

1202 def add_synonym(self, value): self.synonym.append(value) 

1203 def insert_synonym(self, index, value): self.synonym[index] = value 

1204 def get_rank(self): return self.rank 

1205 def set_rank(self, rank): self.rank = rank 

1206 def validate_Rank(self, value): 

1207 # Validate type Rank, a restriction on xs:token. 

1208 pass 

1209 def get_uri(self): return self.uri 

1210 def set_uri(self, uri): self.uri = uri 

1211 def get_id_source(self): return self.id_source 

1212 def set_id_source(self, id_source): self.id_source = id_source 

1213 def export(self, outfile, level, namespace_='phy:', name_='Taxonomy', namespacedef_=''): 

1214 showIndent(outfile, level) 

1215 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) 

1216 already_processed = [] 

1217 self.exportAttributes(outfile, level, already_processed, namespace_, name_='Taxonomy') 

1218 if self.hasContent_(): 

1219 outfile.write('>\n') 

1220 self.exportChildren(outfile, level + 1, namespace_, name_) 

1221 showIndent(outfile, level) 

1222 outfile.write('</%s%s>\n' % (namespace_, name_)) 

1223 else: 

1224 outfile.write('/>\n') 

1225 def exportAttributes(self, outfile, level, already_processed, namespace_='phy:', name_='Taxonomy'): 

1226 if self.id_source is not None and 'id_source' not in already_processed: 

1227 already_processed.append('id_source') 

1228 outfile.write(' id_source=%s' % (quote_attrib(self.id_source), )) 

1229 def exportChildren(self, outfile, level, namespace_='phy:', name_='Taxonomy', fromsubclass_=False): 

1230 if self.id: 

1231 self.id.export(outfile, level, namespace_, name_='id') 

1232 if self.code is not None: 

1233 showIndent(outfile, level) 

1234 outfile.write('<%scode>%s</%scode>\n' % (namespace_, self.gds_format_string(quote_xml(self.code).encode(ExternalEncoding), input_name='code'), namespace_)) 

1235 if self.scientific_name is not None: 

1236 showIndent(outfile, level) 

1237 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_)) 

1238 if self.authority is not None: 

1239 showIndent(outfile, level) 

1240 outfile.write('<%sauthority>%s</%sauthority>\n' % (namespace_, self.gds_format_string(quote_xml(self.authority).encode(ExternalEncoding), input_name='authority'), namespace_)) 

1241 for common_name_ in self.common_name: 

1242 showIndent(outfile, level) 

1243 outfile.write('<%scommon_name>%s</%scommon_name>\n' % (namespace_, self.gds_format_string(quote_xml(common_name_).encode(ExternalEncoding), input_name='common_name'), namespace_)) 

1244 for synonym_ in self.synonym: 

1245 showIndent(outfile, level) 

1246 outfile.write('<%ssynonym>%s</%ssynonym>\n' % (namespace_, self.gds_format_string(quote_xml(synonym_).encode(ExternalEncoding), input_name='synonym'), namespace_)) 

1247 if self.rank is not None: 

1248 showIndent(outfile, level) 

1249 outfile.write('<%srank>%s</%srank>\n' % (namespace_, self.gds_format_string(quote_xml(self.rank).encode(ExternalEncoding), input_name='rank'), namespace_)) 

1250 if self.uri: 

1251 self.uri.export(outfile, level, namespace_, name_='uri') 

1252 def hasContent_(self): 

1253 if ( 

1254 self.id is not None or 

1255 self.code is not None or 

1256 self.scientific_name is not None or 

1257 self.authority is not None or 

1258 self.common_name or 

1259 self.synonym or 

1260 self.rank is not None or 

1261 self.uri is not None 

1262 ): 

1263 return True 

1264 else: 

1265 return False 

1266 def exportLiteral(self, outfile, level, name_='Taxonomy'): 

1267 level += 1 

1268 self.exportLiteralAttributes(outfile, level, [], name_) 

1269 if self.hasContent_(): 

1270 self.exportLiteralChildren(outfile, level, name_) 

1271 def exportLiteralAttributes(self, outfile, level, already_processed, name_): 

1272 if self.id_source is not None and 'id_source' not in already_processed: 

1273 already_processed.append('id_source') 

1274 showIndent(outfile, level) 

1275 outfile.write('id_source = %s,\n' % (self.id_source,)) 

1276 def exportLiteralChildren(self, outfile, level, name_): 

1277 if self.id is not None: 

1278 showIndent(outfile, level) 

1279 outfile.write('id=model_.Id(\n') 

1280 self.id.exportLiteral(outfile, level, name_='id') 

1281 showIndent(outfile, level) 

1282 outfile.write('),\n') 

1283 if self.code is not None: 

1284 showIndent(outfile, level) 

1285 outfile.write('code=%s,\n' % quote_python(self.code).encode(ExternalEncoding)) 

1286 if self.scientific_name is not None: 

1287 showIndent(outfile, level) 

1288 outfile.write('scientific_name=%s,\n' % quote_python(self.scientific_name).encode(ExternalEncoding)) 

1289 if self.authority is not None: 

1290 showIndent(outfile, level) 

1291 outfile.write('authority=%s,\n' % quote_python(self.authority).encode(ExternalEncoding)) 

1292 showIndent(outfile, level) 

1293 outfile.write('common_name=[\n') 

1294 level += 1 

1295 for common_name_ in self.common_name: 

1296 showIndent(outfile, level) 

1297 outfile.write('%s,\n' % quote_python(common_name_).encode(ExternalEncoding)) 

1298 level -= 1 

1299 showIndent(outfile, level) 

1300 outfile.write('],\n') 

1301 showIndent(outfile, level) 

1302 outfile.write('synonym=[\n') 

1303 level += 1 

1304 for synonym_ in self.synonym: 

1305 showIndent(outfile, level) 

1306 outfile.write('%s,\n' % quote_python(synonym_).encode(ExternalEncoding)) 

1307 level -= 1 

1308 showIndent(outfile, level) 

1309 outfile.write('],\n') 

1310 if self.rank is not None: 

1311 showIndent(outfile, level) 

1312 outfile.write('rank=%s,\n' % quote_python(self.rank).encode(ExternalEncoding)) 

1313 if self.uri is not None: 

1314 showIndent(outfile, level) 

1315 outfile.write('uri=model_.Uri(\n') 

1316 self.uri.exportLiteral(outfile, level, name_='uri') 

1317 showIndent(outfile, level) 

1318 outfile.write('),\n') 

1319 def build(self, node): 

1320 self.buildAttributes(node, node.attrib, []) 

1321 for child in node: 

1322 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 

1323 self.buildChildren(child, node, nodeName_) 

1324 def buildAttributes(self, node, attrs, already_processed): 

1325 value = find_attr_value_('id_source', node) 

1326 if value is not None and 'id_source' not in already_processed: 

1327 already_processed.append('id_source') 

1328 self.id_source = value 

1329 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 

1330 if nodeName_ == 'id': 

1331 obj_ = Id.factory() 

1332 obj_.build(child_) 

1333 self.set_id(obj_) 

1334 elif nodeName_ == 'code': 

1335 code_ = child_.text 

1336 code_ = re_.sub(STRING_CLEANUP_PAT, " ", code_).strip() 

1337 code_ = self.gds_validate_string(code_, node, 'code') 

1338 self.code = code_ 

1339 self.validate_TaxonomyCode(self.code) # validate type TaxonomyCode 

1340 elif nodeName_ == 'scientific_name': 

1341 scientific_name_ = child_.text 

1342 scientific_name_ = re_.sub(STRING_CLEANUP_PAT, " ", scientific_name_).strip() 

1343 scientific_name_ = self.gds_validate_string(scientific_name_, node, 'scientific_name') 

1344 self.scientific_name = scientific_name_ 

1345 elif nodeName_ == 'authority': 

1346 authority_ = child_.text 

1347 authority_ = re_.sub(STRING_CLEANUP_PAT, " ", authority_).strip() 

1348 authority_ = self.gds_validate_string(authority_, node, 'authority') 

1349 self.authority = authority_ 

1350 elif nodeName_ == 'common_name': 

1351 common_name_ = child_.text 

1352 if common_name_: 

1353 common_name_ = re_.sub(STRING_CLEANUP_PAT, " ", common_name_).strip() 

1354 common_name_ = self.gds_validate_string(common_name_, node, 'common_name') 

1355 self.common_name.append(common_name_) 

1356 elif nodeName_ == 'synonym': 

1357 synonym_ = child_.text 

1358 synonym_ = re_.sub(STRING_CLEANUP_PAT, " ", synonym_).strip() 

1359 synonym_ = self.gds_validate_string(synonym_, node, 'synonym') 

1360 self.synonym.append(synonym_) 

1361 elif nodeName_ == 'rank': 

1362 rank_ = child_.text 

1363 rank_ = re_.sub(STRING_CLEANUP_PAT, " ", rank_).strip() 

1364 rank_ = self.gds_validate_string(rank_, node, 'rank') 

1365 self.rank = rank_ 

1366 self.validate_Rank(self.rank) # validate type Rank 

1367 elif nodeName_ == 'uri': 

1368 obj_ = Uri.factory() 

1369 obj_.build(child_) 

1370 self.set_uri(obj_) 

1371# end class Taxonomy 

1372 

1373 

1374class Sequence(GeneratedsSuper): 

1375 """Element Sequence is used to represent a molecular sequence (Protein, 

1376 DNA, RNA) associated with a node. 'symbol' is a short (maximal 

1377 ten characters) symbol of the sequence (e.g. 'ACTM') whereas 

1378 'name' is used for the full name (e.g. 'muscle Actin'). 

1379 'location' is used for the location of a sequence on a 

1380 genome/chromosome. The actual sequence can be stored with the 

1381 'mol_seq' element. Attribute 'type' is used to indicate the type 

1382 of sequence ('dna', 'rna', or 'protein'). One intended use for 

1383 'id_ref' is to link a sequence to a taxonomy (via the taxonomy's 

1384 'id_source') in case of multiple sequences and taxonomies per 

1385 node.""" 

1386 subclass = None 

1387 superclass = None 

1388 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): 

1389 self.id_source = _cast(None, id_source) 

1390 self.id_ref = _cast(None, id_ref) 

1391 self.type_ = _cast(None, type_) 

1392 self.symbol = symbol 

1393 self.accession = accession 

1394 self.name = name 

1395 self.location = location 

1396 self.mol_seq = mol_seq 

1397 self.uri = uri 

1398 if annotation is None: 

1399 self.annotation = [] 

1400 else: 

1401 self.annotation = annotation 

1402 self.domain_architecture = domain_architecture 

1403 def factory(*args_, **kwargs_): 

1404 if Sequence.subclass: 

1405 return Sequence.subclass(*args_, **kwargs_) 

1406 else: 

1407 return Sequence(*args_, **kwargs_) 

1408 factory = staticmethod(factory) 

1409 def get_symbol(self): return self.symbol 

1410 def set_symbol(self, symbol): self.symbol = symbol 

1411 def validate_SequenceSymbol(self, value): 

1412 # Validate type SequenceSymbol, a restriction on xs:token. 

1413 pass 

1414 def get_accession(self): return self.accession 

1415 def set_accession(self, accession): self.accession = accession 

1416 def get_name(self): return self.name 

1417 def set_name(self, name): self.name = name 

1418 def get_location(self): return self.location 

1419 def set_location(self, location): self.location = location 

1420 def get_mol_seq(self): return self.mol_seq 

1421 def set_mol_seq(self, mol_seq): self.mol_seq = mol_seq 

1422 def get_uri(self): return self.uri 

1423 def set_uri(self, uri): self.uri = uri 

1424 def get_annotation(self): return self.annotation 

1425 def set_annotation(self, annotation): self.annotation = annotation 

1426 def add_annotation(self, value): self.annotation.append(value) 

1427 def insert_annotation(self, index, value): self.annotation[index] = value 

1428 def get_domain_architecture(self): return self.domain_architecture 

1429 def set_domain_architecture(self, domain_architecture): self.domain_architecture = domain_architecture 

1430 def get_id_source(self): return self.id_source 

1431 def set_id_source(self, id_source): self.id_source = id_source 

1432 def get_id_ref(self): return self.id_ref 

1433 def set_id_ref(self, id_ref): self.id_ref = id_ref 

1434 def get_type(self): return self.type_ 

1435 def set_type(self, type_): self.type_ = type_ 

1436 def export(self, outfile, level, namespace_='phy:', name_='Sequence', namespacedef_=''): 

1437 showIndent(outfile, level) 

1438 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) 

1439 already_processed = [] 

1440 self.exportAttributes(outfile, level, already_processed, namespace_, name_='Sequence') 

1441 if self.hasContent_(): 

1442 outfile.write('>\n') 

1443 self.exportChildren(outfile, level + 1, namespace_, name_) 

1444 showIndent(outfile, level) 

1445 outfile.write('</%s%s>\n' % (namespace_, name_)) 

1446 else: 

1447 outfile.write('/>\n') 

1448 def exportAttributes(self, outfile, level, already_processed, namespace_='phy:', name_='Sequence'): 

1449 if self.id_source is not None and 'id_source' not in already_processed: 

1450 already_processed.append('id_source') 

1451 outfile.write(' id_source=%s' % (quote_attrib(self.id_source), )) 

1452 if self.id_ref is not None and 'id_ref' not in already_processed: 

1453 already_processed.append('id_ref') 

1454 outfile.write(' id_ref=%s' % (quote_attrib(self.id_ref), )) 

1455 if self.type_ is not None and 'type_' not in already_processed: 

1456 already_processed.append('type_') 

1457 outfile.write(' type=%s' % (quote_attrib(self.type_), )) 

1458 def exportChildren(self, outfile, level, namespace_='phy:', name_='Sequence', fromsubclass_=False): 

1459 if self.symbol is not None: 

1460 showIndent(outfile, level) 

1461 outfile.write('<%ssymbol>%s</%ssymbol>\n' % (namespace_, self.gds_format_string(quote_xml(self.symbol).encode(ExternalEncoding), input_name='symbol'), namespace_)) 

1462 if self.accession: 

1463 self.accession.export(outfile, level, namespace_, name_='accession') 

1464 if self.name is not None: 

1465 showIndent(outfile, level) 

1466 outfile.write('<%sname>%s</%sname>\n' % (namespace_, self.gds_format_string(quote_xml(self.name).encode(ExternalEncoding), input_name='name'), namespace_)) 

1467 if self.location is not None: 

1468 showIndent(outfile, level) 

1469 outfile.write('<%slocation>%s</%slocation>\n' % (namespace_, self.gds_format_string(quote_xml(self.location).encode(ExternalEncoding), input_name='location'), namespace_)) 

1470 if self.mol_seq: 

1471 self.mol_seq.export(outfile, level, namespace_, name_='mol_seq') 

1472 if self.uri: 

1473 self.uri.export(outfile, level, namespace_, name_='uri') 

1474 for annotation_ in self.annotation: 

1475 annotation_.export(outfile, level, namespace_, name_='annotation') 

1476 if self.domain_architecture: 

1477 self.domain_architecture.export(outfile, level, namespace_, name_='domain_architecture') 

1478 def hasContent_(self): 

1479 if ( 

1480 self.symbol is not None or 

1481 self.accession is not None or 

1482 self.name is not None or 

1483 self.location is not None or 

1484 self.mol_seq is not None or 

1485 self.uri is not None or 

1486 self.annotation or 

1487 self.domain_architecture is not None 

1488 ): 

1489 return True 

1490 else: 

1491 return False 

1492 def exportLiteral(self, outfile, level, name_='Sequence'): 

1493 level += 1 

1494 self.exportLiteralAttributes(outfile, level, [], name_) 

1495 if self.hasContent_(): 

1496 self.exportLiteralChildren(outfile, level, name_) 

1497 def exportLiteralAttributes(self, outfile, level, already_processed, name_): 

1498 if self.id_source is not None and 'id_source' not in already_processed: 

1499 already_processed.append('id_source') 

1500 showIndent(outfile, level) 

1501 outfile.write('id_source = %s,\n' % (self.id_source,)) 

1502 if self.id_ref is not None and 'id_ref' not in already_processed: 

1503 already_processed.append('id_ref') 

1504 showIndent(outfile, level) 

1505 outfile.write('id_ref = %s,\n' % (self.id_ref,)) 

1506 if self.type_ is not None and 'type_' not in already_processed: 

1507 already_processed.append('type_') 

1508 showIndent(outfile, level) 

1509 outfile.write('type_ = %s,\n' % (self.type_,)) 

1510 def exportLiteralChildren(self, outfile, level, name_): 

1511 if self.symbol is not None: 

1512 showIndent(outfile, level) 

1513 outfile.write('symbol=%s,\n' % quote_python(self.symbol).encode(ExternalEncoding)) 

1514 if self.accession is not None: 

1515 showIndent(outfile, level) 

1516 outfile.write('accession=model_.Accession(\n') 

1517 self.accession.exportLiteral(outfile, level, name_='accession') 

1518 showIndent(outfile, level) 

1519 outfile.write('),\n') 

1520 if self.name is not None: 

1521 showIndent(outfile, level) 

1522 outfile.write('name=%s,\n' % quote_python(self.name).encode(ExternalEncoding)) 

1523 if self.location is not None: 

1524 showIndent(outfile, level) 

1525 outfile.write('location=%s,\n' % quote_python(self.location).encode(ExternalEncoding)) 

1526 if self.mol_seq is not None: 

1527 showIndent(outfile, level) 

1528 outfile.write('mol_seq=model_.MolSeq(\n') 

1529 self.mol_seq.exportLiteral(outfile, level, name_='mol_seq') 

1530 showIndent(outfile, level) 

1531 outfile.write('),\n') 

1532 if self.uri is not None: 

1533 showIndent(outfile, level) 

1534 outfile.write('uri=model_.Uri(\n') 

1535 self.uri.exportLiteral(outfile, level, name_='uri') 

1536 showIndent(outfile, level) 

1537 outfile.write('),\n') 

1538 showIndent(outfile, level) 

1539 outfile.write('annotation=[\n') 

1540 level += 1 

1541 for annotation_ in self.annotation: 

1542 showIndent(outfile, level) 

1543 outfile.write('model_.Annotation(\n') 

1544 annotation_.exportLiteral(outfile, level, name_='Annotation') 

1545 showIndent(outfile, level) 

1546 outfile.write('),\n') 

1547 level -= 1 

1548 showIndent(outfile, level) 

1549 outfile.write('],\n') 

1550 if self.domain_architecture is not None: 

1551 showIndent(outfile, level) 

1552 outfile.write('domain_architecture=model_.DomainArchitecture(\n') 

1553 self.domain_architecture.exportLiteral(outfile, level, name_='domain_architecture') 

1554 showIndent(outfile, level) 

1555 outfile.write('),\n') 

1556 def build(self, node): 

1557 self.buildAttributes(node, node.attrib, []) 

1558 for child in node: 

1559 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 

1560 self.buildChildren(child, node, nodeName_) 

1561 def buildAttributes(self, node, attrs, already_processed): 

1562 value = find_attr_value_('id_source', node) 

1563 if value is not None and 'id_source' not in already_processed: 

1564 already_processed.append('id_source') 

1565 self.id_source = value 

1566 value = find_attr_value_('id_ref', node) 

1567 if value is not None and 'id_ref' not in already_processed: 

1568 already_processed.append('id_ref') 

1569 self.id_ref = value 

1570 value = find_attr_value_('type', node) 

1571 if value is not None and 'type' not in already_processed: 

1572 already_processed.append('type') 

1573 self.type_ = value 

1574 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 

1575 if nodeName_ == 'symbol': 

1576 symbol_ = child_.text 

1577 symbol_ = re_.sub(STRING_CLEANUP_PAT, " ", symbol_).strip() 

1578 symbol_ = self.gds_validate_string(symbol_, node, 'symbol') 

1579 self.symbol = symbol_ 

1580 self.validate_SequenceSymbol(self.symbol) # validate type SequenceSymbol 

1581 elif nodeName_ == 'accession': 

1582 obj_ = Accession.factory() 

1583 obj_.build(child_) 

1584 self.set_accession(obj_) 

1585 elif nodeName_ == 'name': 

1586 name_ = child_.text 

1587 name_ = re_.sub(STRING_CLEANUP_PAT, " ", name_).strip() 

1588 name_ = self.gds_validate_string(name_, node, 'name') 

1589 self.name = name_ 

1590 elif nodeName_ == 'location': 

1591 location_ = child_.text 

1592 location_ = re_.sub(STRING_CLEANUP_PAT, " ", location_).strip() 

1593 location_ = self.gds_validate_string(location_, node, 'location') 

1594 self.location = location_ 

1595 elif nodeName_ == 'mol_seq': 

1596 obj_ = MolSeq.factory() 

1597 obj_.build(child_) 

1598 self.set_mol_seq(obj_) 

1599 elif nodeName_ == 'uri': 

1600 obj_ = Uri.factory() 

1601 obj_.build(child_) 

1602 self.set_uri(obj_) 

1603 elif nodeName_ == 'annotation': 

1604 obj_ = Annotation.factory() 

1605 obj_.build(child_) 

1606 self.annotation.append(obj_) 

1607 elif nodeName_ == 'domain_architecture': 

1608 obj_ = DomainArchitecture.factory() 

1609 obj_.build(child_) 

1610 self.set_domain_architecture(obj_) 

1611# end class Sequence 

1612 

1613 

1614class MolSeq(GeneratedsSuper): 

1615 """Element 'mol_seq' is used to store molecular sequences. The 

1616 'is_aligned' attribute is used to indicated that this molecular 

1617 sequence is aligned with all other sequences in the same 

1618 phylogeny for which 'is aligned' is true as well (which, in most 

1619 cases, means that gaps were introduced, and that all sequences 

1620 for which 'is aligned' is true must have the same length).""" 

1621 subclass = None 

1622 superclass = None 

1623 def __init__(self, is_aligned=None, valueOf_=None): 

1624 self.is_aligned = _cast(bool, is_aligned) 

1625 self.valueOf_ = valueOf_ 

1626 def factory(*args_, **kwargs_): 

1627 if MolSeq.subclass: 

1628 return MolSeq.subclass(*args_, **kwargs_) 

1629 else: 

1630 return MolSeq(*args_, **kwargs_) 

1631 factory = staticmethod(factory) 

1632 def get_is_aligned(self): return self.is_aligned 

1633 def set_is_aligned(self, is_aligned): self.is_aligned = is_aligned 

1634 def get_valueOf_(self): return self.valueOf_ 

1635 def set_valueOf_(self, valueOf_): self.valueOf_ = valueOf_ 

1636 def export(self, outfile, level, namespace_='phy:', name_='MolSeq', namespacedef_=''): 

1637 showIndent(outfile, level) 

1638 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) 

1639 already_processed = [] 

1640 self.exportAttributes(outfile, level, already_processed, namespace_, name_='MolSeq') 

1641 if self.hasContent_(): 

1642 outfile.write('>') 

1643 outfile.write(str(self.valueOf_).encode(ExternalEncoding)) 

1644 self.exportChildren(outfile, level + 1, namespace_, name_) 

1645 outfile.write('</%s%s>\n' % (namespace_, name_)) 

1646 else: 

1647 outfile.write('/>\n') 

1648 def exportAttributes(self, outfile, level, already_processed, namespace_='phy:', name_='MolSeq'): 

1649 if self.is_aligned is not None and 'is_aligned' not in already_processed: 

1650 already_processed.append('is_aligned') 

1651 outfile.write(' is_aligned="%s"' % self.gds_format_boolean(self.gds_str_lower(str(self.is_aligned)), input_name='is_aligned')) 

1652 def exportChildren(self, outfile, level, namespace_='phy:', name_='MolSeq', fromsubclass_=False): 

1653 pass 

1654 def hasContent_(self): 

1655 if ( 

1656 self.valueOf_ 

1657 ): 

1658 return True 

1659 else: 

1660 return False 

1661 def exportLiteral(self, outfile, level, name_='MolSeq'): 

1662 level += 1 

1663 self.exportLiteralAttributes(outfile, level, [], name_) 

1664 if self.hasContent_(): 

1665 self.exportLiteralChildren(outfile, level, name_) 

1666 showIndent(outfile, level) 

1667 outfile.write('valueOf_ = """%s""",\n' % (self.valueOf_,)) 

1668 def exportLiteralAttributes(self, outfile, level, already_processed, name_): 

1669 if self.is_aligned is not None and 'is_aligned' not in already_processed: 

1670 already_processed.append('is_aligned') 

1671 showIndent(outfile, level) 

1672 outfile.write('is_aligned = %s,\n' % (self.is_aligned,)) 

1673 def exportLiteralChildren(self, outfile, level, name_): 

1674 pass 

1675 def build(self, node): 

1676 self.buildAttributes(node, node.attrib, []) 

1677 self.valueOf_ = get_all_text_(node) 

1678 for child in node: 

1679 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 

1680 self.buildChildren(child, node, nodeName_) 

1681 def buildAttributes(self, node, attrs, already_processed): 

1682 value = find_attr_value_('is_aligned', node) 

1683 if value is not None and 'is_aligned' not in already_processed: 

1684 already_processed.append('is_aligned') 

1685 if value in ('true', '1'): 

1686 self.is_aligned = True 

1687 elif value in ('false', '0'): 

1688 self.is_aligned = False 

1689 else: 

1690 raise_parse_error(node, 'Bad boolean attribute') 

1691 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 

1692 pass 

1693# end class MolSeq 

1694 

1695 

1696class Accession(GeneratedsSuper): 

1697 """Element Accession is used to capture the local part in a sequence 

1698 identifier (e.g. 'P17304' in 'UniProtKB:P17304', in which case 

1699 the 'source' attribute would be 'UniProtKB').""" 

1700 subclass = None 

1701 superclass = None 

1702 def __init__(self, source=None, valueOf_=None): 

1703 self.source = _cast(None, source) 

1704 self.valueOf_ = valueOf_ 

1705 def factory(*args_, **kwargs_): 

1706 if Accession.subclass: 

1707 return Accession.subclass(*args_, **kwargs_) 

1708 else: 

1709 return Accession(*args_, **kwargs_) 

1710 factory = staticmethod(factory) 

1711 def get_source(self): return self.source 

1712 def set_source(self, source): self.source = source 

1713 def get_valueOf_(self): return self.valueOf_ 

1714 def set_valueOf_(self, valueOf_): self.valueOf_ = valueOf_ 

1715 def export(self, outfile, level, namespace_='phy:', name_='Accession', namespacedef_=''): 

1716 showIndent(outfile, level) 

1717 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) 

1718 already_processed = [] 

1719 self.exportAttributes(outfile, level, already_processed, namespace_, name_='Accession') 

1720 if self.hasContent_(): 

1721 outfile.write('>') 

1722 outfile.write(str(self.valueOf_).encode(ExternalEncoding)) 

1723 self.exportChildren(outfile, level + 1, namespace_, name_) 

1724 outfile.write('</%s%s>\n' % (namespace_, name_)) 

1725 else: 

1726 outfile.write('/>\n') 

1727 def exportAttributes(self, outfile, level, already_processed, namespace_='phy:', name_='Accession'): 

1728 if self.source is not None and 'source' not in already_processed: 

1729 already_processed.append('source') 

1730 outfile.write(' source=%s' % (self.gds_format_string(quote_attrib(self.source).encode(ExternalEncoding), input_name='source'), )) 

1731 def exportChildren(self, outfile, level, namespace_='phy:', name_='Accession', fromsubclass_=False): 

1732 pass 

1733 def hasContent_(self): 

1734 if ( 

1735 self.valueOf_ 

1736 ): 

1737 return True 

1738 else: 

1739 return False 

1740 def exportLiteral(self, outfile, level, name_='Accession'): 

1741 level += 1 

1742 self.exportLiteralAttributes(outfile, level, [], name_) 

1743 if self.hasContent_(): 

1744 self.exportLiteralChildren(outfile, level, name_) 

1745 showIndent(outfile, level) 

1746 outfile.write('valueOf_ = """%s""",\n' % (self.valueOf_,)) 

1747 def exportLiteralAttributes(self, outfile, level, already_processed, name_): 

1748 if self.source is not None and 'source' not in already_processed: 

1749 already_processed.append('source') 

1750 showIndent(outfile, level) 

1751 outfile.write('source = "%s",\n' % (self.source,)) 

1752 def exportLiteralChildren(self, outfile, level, name_): 

1753 pass 

1754 def build(self, node): 

1755 self.buildAttributes(node, node.attrib, []) 

1756 self.valueOf_ = get_all_text_(node) 

1757 for child in node: 

1758 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 

1759 self.buildChildren(child, node, nodeName_) 

1760 def buildAttributes(self, node, attrs, already_processed): 

1761 value = find_attr_value_('source', node) 

1762 if value is not None and 'source' not in already_processed: 

1763 already_processed.append('source') 

1764 self.source = value 

1765 self.source = ' '.join(self.source.split()) 

1766 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 

1767 pass 

1768# end class Accession 

1769 

1770 

1771class DomainArchitecture(GeneratedsSuper): 

1772 """This is used describe the domain architecture of a protein. 

1773 Attribute 'length' is the total length of the protein""" 

1774 subclass = None 

1775 superclass = None 

1776 def __init__(self, length=None, domain=None, valueOf_=None): 

1777 self.length = _cast(int, length) 

1778 if domain is None: 

1779 self.domain = [] 

1780 else: 

1781 self.domain = domain 

1782 def factory(*args_, **kwargs_): 

1783 if DomainArchitecture.subclass: 

1784 return DomainArchitecture.subclass(*args_, **kwargs_) 

1785 else: 

1786 return DomainArchitecture(*args_, **kwargs_) 

1787 factory = staticmethod(factory) 

1788 def get_domain(self): return self.domain 

1789 def set_domain(self, domain): self.domain = domain 

1790 def add_domain(self, value): self.domain.append(value) 

1791 def insert_domain(self, index, value): self.domain[index] = value 

1792 def get_length(self): return self.length 

1793 def set_length(self, length): self.length = length 

1794 def export(self, outfile, level, namespace_='phy:', name_='DomainArchitecture', namespacedef_=''): 

1795 showIndent(outfile, level) 

1796 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) 

1797 already_processed = [] 

1798 self.exportAttributes(outfile, level, already_processed, namespace_, name_='DomainArchitecture') 

1799 if self.hasContent_(): 

1800 outfile.write('>\n') 

1801 self.exportChildren(outfile, level + 1, namespace_, name_) 

1802 showIndent(outfile, level) 

1803 outfile.write('</%s%s>\n' % (namespace_, name_)) 

1804 else: 

1805 outfile.write('/>\n') 

1806 def exportAttributes(self, outfile, level, already_processed, namespace_='phy:', name_='DomainArchitecture'): 

1807 if self.length is not None and 'length' not in already_processed: 

1808 already_processed.append('length') 

1809 outfile.write(' length="%s"' % self.gds_format_integer(self.length, input_name='length')) 

1810 def exportChildren(self, outfile, level, namespace_='phy:', name_='DomainArchitecture', fromsubclass_=False): 

1811 for domain_ in self.domain: 

1812 domain_.export(outfile, level, namespace_, name_='domain') 

1813 def hasContent_(self): 

1814 if ( 

1815 self.domain 

1816 ): 

1817 return True 

1818 else: 

1819 return False 

1820 def exportLiteral(self, outfile, level, name_='DomainArchitecture'): 

1821 level += 1 

1822 self.exportLiteralAttributes(outfile, level, [], name_) 

1823 if self.hasContent_(): 

1824 self.exportLiteralChildren(outfile, level, name_) 

1825 def exportLiteralAttributes(self, outfile, level, already_processed, name_): 

1826 if self.length is not None and 'length' not in already_processed: 

1827 already_processed.append('length') 

1828 showIndent(outfile, level) 

1829 outfile.write('length = %d,\n' % (self.length,)) 

1830 def exportLiteralChildren(self, outfile, level, name_): 

1831 showIndent(outfile, level) 

1832 outfile.write('domain=[\n') 

1833 level += 1 

1834 for domain_ in self.domain: 

1835 showIndent(outfile, level) 

1836 outfile.write('model_.ProteinDomain(\n') 

1837 domain_.exportLiteral(outfile, level, name_='ProteinDomain') 

1838 showIndent(outfile, level) 

1839 outfile.write('),\n') 

1840 level -= 1 

1841 showIndent(outfile, level) 

1842 outfile.write('],\n') 

1843 def build(self, node): 

1844 self.buildAttributes(node, node.attrib, []) 

1845 for child in node: 

1846 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 

1847 self.buildChildren(child, node, nodeName_) 

1848 def buildAttributes(self, node, attrs, already_processed): 

1849 value = find_attr_value_('length', node) 

1850 if value is not None and 'length' not in already_processed: 

1851 already_processed.append('length') 

1852 try: 

1853 self.length = int(value) 

1854 except ValueError as exp: 

1855 raise_parse_error(node, 'Bad integer attribute: %s' % exp) 

1856 if self.length < 0: 

1857 raise_parse_error(node, 'Invalid NonNegativeInteger') 

1858 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 

1859 if nodeName_ == 'domain': 

1860 obj_ = ProteinDomain.factory() 

1861 obj_.build(child_) 

1862 self.domain.append(obj_) 

1863# end class DomainArchitecture 

1864 

1865 

1866class ProteinDomain(GeneratedsSuper): 

1867 """To represent an individual domain in a domain architecture. The 

1868 name/unique identifier is described via the 'id' attribute. 

1869 'confidence' can be used to store (i.e.) E-values.""" 

1870 subclass = None 

1871 superclass = None 

1872 def __init__(self, to=None, confidence=None, fromxx=None, id=None, valueOf_=None): 

1873 self.to = _cast(int, to) 

1874 self.confidence = _cast(float, confidence) 

1875 self.fromxx = _cast(int, fromxx) 

1876 self.id = _cast(None, id) 

1877 self.valueOf_ = valueOf_ 

1878 def factory(*args_, **kwargs_): 

1879 if ProteinDomain.subclass: 

1880 return ProteinDomain.subclass(*args_, **kwargs_) 

1881 else: 

1882 return ProteinDomain(*args_, **kwargs_) 

1883 factory = staticmethod(factory) 

1884 def get_to(self): return self.to 

1885 def set_to(self, to): self.to = to 

1886 def get_confidence(self): return self.confidence 

1887 def set_confidence(self, confidence): self.confidence = confidence 

1888 def get_from(self): return self.fromxx 

1889 def set_from(self, fromxx): self.fromxx = fromxx 

1890 def get_id(self): return self.id 

1891 def set_id(self, id): self.id = id 

1892 def get_valueOf_(self): return self.valueOf_ 

1893 def set_valueOf_(self, valueOf_): self.valueOf_ = valueOf_ 

1894 def export(self, outfile, level, namespace_='phy:', name_='ProteinDomain', namespacedef_=''): 

1895 showIndent(outfile, level) 

1896 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) 

1897 already_processed = [] 

1898 self.exportAttributes(outfile, level, already_processed, namespace_, name_='ProteinDomain') 

1899 if self.hasContent_(): 

1900 outfile.write('>') 

1901 outfile.write(str(self.valueOf_).encode(ExternalEncoding)) 

1902 self.exportChildren(outfile, level + 1, namespace_, name_) 

1903 outfile.write('</%s%s>\n' % (namespace_, name_)) 

1904 else: 

1905 outfile.write('/>\n') 

1906 def exportAttributes(self, outfile, level, already_processed, namespace_='phy:', name_='ProteinDomain'): 

1907 if self.to is not None and 'to' not in already_processed: 

1908 already_processed.append('to') 

1909 outfile.write(' to="%s"' % self.gds_format_integer(self.to, input_name='to')) 

1910 if self.confidence is not None and 'confidence' not in already_processed: 

1911 already_processed.append('confidence') 

1912 outfile.write(' confidence="%s"' % self.gds_format_double(self.confidence, input_name='confidence')) 

1913 if self.fromxx is not None and 'fromxx' not in already_processed: 

1914 already_processed.append('fromxx') 

1915 outfile.write(' from="%s"' % self.gds_format_integer(self.fromxx, input_name='from')) 

1916 if self.id is not None and 'id' not in already_processed: 

1917 already_processed.append('id') 

1918 outfile.write(' id=%s' % (self.gds_format_string(quote_attrib(self.id).encode(ExternalEncoding), input_name='id'), )) 

1919 def exportChildren(self, outfile, level, namespace_='phy:', name_='ProteinDomain', fromsubclass_=False): 

1920 pass 

1921 def hasContent_(self): 

1922 if ( 

1923 self.valueOf_ 

1924 ): 

1925 return True 

1926 else: 

1927 return False 

1928 def exportLiteral(self, outfile, level, name_='ProteinDomain'): 

1929 level += 1 

1930 self.exportLiteralAttributes(outfile, level, [], name_) 

1931 if self.hasContent_(): 

1932 self.exportLiteralChildren(outfile, level, name_) 

1933 showIndent(outfile, level) 

1934 outfile.write('valueOf_ = """%s""",\n' % (self.valueOf_,)) 

1935 def exportLiteralAttributes(self, outfile, level, already_processed, name_): 

1936 if self.to is not None and 'to' not in already_processed: 

1937 already_processed.append('to') 

1938 showIndent(outfile, level) 

1939 outfile.write('to = %d,\n' % (self.to,)) 

1940 if self.confidence is not None and 'confidence' not in already_processed: 

1941 already_processed.append('confidence') 

1942 showIndent(outfile, level) 

1943 outfile.write('confidence = %e,\n' % (self.confidence,)) 

1944 if self.fromxx is not None and 'fromxx' not in already_processed: 

1945 already_processed.append('fromxx') 

1946 showIndent(outfile, level) 

1947 outfile.write('fromxx = %d,\n' % (self.fromxx,)) 

1948 if self.id is not None and 'id' not in already_processed: 

1949 already_processed.append('id') 

1950 showIndent(outfile, level) 

1951 outfile.write('id = "%s",\n' % (self.id,)) 

1952 def exportLiteralChildren(self, outfile, level, name_): 

1953 pass 

1954 def build(self, node): 

1955 self.buildAttributes(node, node.attrib, []) 

1956 self.valueOf_ = get_all_text_(node) 

1957 for child in node: 

1958 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 

1959 self.buildChildren(child, node, nodeName_) 

1960 def buildAttributes(self, node, attrs, already_processed): 

1961 value = find_attr_value_('to', node) 

1962 if value is not None and 'to' not in already_processed: 

1963 already_processed.append('to') 

1964 try: 

1965 self.to = int(value) 

1966 except ValueError as exp: 

1967 raise_parse_error(node, 'Bad integer attribute: %s' % exp) 

1968 if self.to < 0: 

1969 raise_parse_error(node, 'Invalid NonNegativeInteger') 

1970 value = find_attr_value_('confidence', node) 

1971 if value is not None and 'confidence' not in already_processed: 

1972 already_processed.append('confidence') 

1973 try: 

1974 self.confidence = float(value) 

1975 except ValueError as exp: 

1976 raise ValueError('Bad float/double attribute (confidence): %s' % exp) 

1977 value = find_attr_value_('from', node) 

1978 if value is not None and 'from' not in already_processed: 

1979 already_processed.append('from') 

1980 try: 

1981 self.fromxx = int(value) 

1982 except ValueError as exp: 

1983 raise_parse_error(node, 'Bad integer attribute: %s' % exp) 

1984 if self.fromxx < 0: 

1985 raise_parse_error(node, 'Invalid NonNegativeInteger') 

1986 value = find_attr_value_('id', node) 

1987 if value is not None and 'id' not in already_processed: 

1988 already_processed.append('id') 

1989 self.id = value 

1990 self.id = ' '.join(self.id.split()) 

1991 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 

1992 pass 

1993# end class ProteinDomain 

1994 

1995 

1996class Events(GeneratedsSuper): 

1997 """Events at the root node of a clade (e.g. one gene duplication).""" 

1998 subclass = None 

1999 superclass = None 

2000 def __init__(self, type_=None, duplications=None, speciations=None, losses=None, confidence=None, valueOf_=None): 

2001 self.type_ = type_ 

2002 self.duplications = duplications 

2003 self.speciations = speciations 

2004 self.losses = losses 

2005 self.confidence = confidence 

2006 def factory(*args_, **kwargs_): 

2007 if Events.subclass: 

2008 return Events.subclass(*args_, **kwargs_) 

2009 else: 

2010 return Events(*args_, **kwargs_) 

2011 factory = staticmethod(factory) 

2012 def get_type(self): return self.type_ 

2013 def set_type(self, type_): self.type_ = type_ 

2014 def validate_EventType(self, value): 

2015 # Validate type EventType, a restriction on xs:token. 

2016 pass 

2017 def get_duplications(self): return self.duplications 

2018 def set_duplications(self, duplications): self.duplications = duplications 

2019 def get_speciations(self): return self.speciations 

2020 def set_speciations(self, speciations): self.speciations = speciations 

2021 def get_losses(self): return self.losses 

2022 def set_losses(self, losses): self.losses = losses 

2023 def get_confidence(self): return self.confidence 

2024 def set_confidence(self, confidence): self.confidence = confidence 

2025 def export(self, outfile, level, namespace_='phy:', name_='Events', namespacedef_=''): 

2026 showIndent(outfile, level) 

2027 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) 

2028 already_processed = [] 

2029 self.exportAttributes(outfile, level, already_processed, namespace_, name_='Events') 

2030 if self.hasContent_(): 

2031 outfile.write('>\n') 

2032 self.exportChildren(outfile, level + 1, namespace_, name_) 

2033 showIndent(outfile, level) 

2034 outfile.write('</%s%s>\n' % (namespace_, name_)) 

2035 else: 

2036 outfile.write('/>\n') 

2037 def exportAttributes(self, outfile, level, already_processed, namespace_='phy:', name_='Events'): 

2038 pass 

2039 def exportChildren(self, outfile, level, namespace_='phy:', name_='Events', fromsubclass_=False): 

2040 if self.type_ is not None: 

2041 showIndent(outfile, level) 

2042 outfile.write('<%stype>%s</%stype>\n' % (namespace_, self.gds_format_string(quote_xml(self.type_).encode(ExternalEncoding), input_name='type'), namespace_)) 

2043 if self.duplications is not None: 

2044 showIndent(outfile, level) 

2045 outfile.write('<%sduplications>%s</%sduplications>\n' % (namespace_, self.gds_format_integer(self.duplications, input_name='duplications'), namespace_)) 

2046 if self.speciations is not None: 

2047 showIndent(outfile, level) 

2048 outfile.write('<%sspeciations>%s</%sspeciations>\n' % (namespace_, self.gds_format_integer(self.speciations, input_name='speciations'), namespace_)) 

2049 if self.losses is not None: 

2050 showIndent(outfile, level) 

2051 outfile.write('<%slosses>%s</%slosses>\n' % (namespace_, self.gds_format_integer(self.losses, input_name='losses'), namespace_)) 

2052 if self.confidence: 

2053 self.confidence.export(outfile, level, namespace_, name_='confidence') 

2054 def hasContent_(self): 

2055 if ( 

2056 self.type_ is not None or 

2057 self.duplications is not None or 

2058 self.speciations is not None or 

2059 self.losses is not None or 

2060 self.confidence is not None 

2061 ): 

2062 return True 

2063 else: 

2064 return False 

2065 def exportLiteral(self, outfile, level, name_='Events'): 

2066 level += 1 

2067 self.exportLiteralAttributes(outfile, level, [], name_) 

2068 if self.hasContent_(): 

2069 self.exportLiteralChildren(outfile, level, name_) 

2070 def exportLiteralAttributes(self, outfile, level, already_processed, name_): 

2071 pass 

2072 def exportLiteralChildren(self, outfile, level, name_): 

2073 if self.type_ is not None: 

2074 showIndent(outfile, level) 

2075 outfile.write('type_=%s,\n' % quote_python(self.type_).encode(ExternalEncoding)) 

2076 if self.duplications is not None: 

2077 showIndent(outfile, level) 

2078 outfile.write('duplications=%d,\n' % self.duplications) 

2079 if self.speciations is not None: 

2080 showIndent(outfile, level) 

2081 outfile.write('speciations=%d,\n' % self.speciations) 

2082 if self.losses is not None: 

2083 showIndent(outfile, level) 

2084 outfile.write('losses=%d,\n' % self.losses) 

2085 if self.confidence is not None: 

2086 showIndent(outfile, level) 

2087 outfile.write('confidence=model_.Confidence(\n') 

2088 self.confidence.exportLiteral(outfile, level, name_='confidence') 

2089 showIndent(outfile, level) 

2090 outfile.write('),\n') 

2091 def build(self, node): 

2092 self.buildAttributes(node, node.attrib, []) 

2093 for child in node: 

2094 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 

2095 self.buildChildren(child, node, nodeName_) 

2096 def buildAttributes(self, node, attrs, already_processed): 

2097 pass 

2098 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 

2099 if nodeName_ == 'type': 

2100 type_ = child_.text 

2101 type_ = re_.sub(STRING_CLEANUP_PAT, " ", type_).strip() 

2102 type_ = self.gds_validate_string(type_, node, 'type') 

2103 self.type_ = type_ 

2104 self.validate_EventType(self.type_) # validate type EventType 

2105 elif nodeName_ == 'duplications': 

2106 sval_ = child_.text 

2107 try: 

2108 ival_ = int(sval_) 

2109 except (TypeError, ValueError) as exp: 

2110 raise_parse_error(child_, 'requires integer: %s' % exp) 

2111 if ival_ < 0: 

2112 raise_parse_error(child_, 'requires nonNegativeInteger') 

2113 ival_ = self.gds_validate_integer(ival_, node, 'duplications') 

2114 self.duplications = ival_ 

2115 elif nodeName_ == 'speciations': 

2116 sval_ = child_.text 

2117 try: 

2118 ival_ = int(sval_) 

2119 except (TypeError, ValueError) as exp: 

2120 raise_parse_error(child_, 'requires integer: %s' % exp) 

2121 if ival_ < 0: 

2122 raise_parse_error(child_, 'requires nonNegativeInteger') 

2123 ival_ = self.gds_validate_integer(ival_, node, 'speciations') 

2124 self.speciations = ival_ 

2125 elif nodeName_ == 'losses': 

2126 sval_ = child_.text 

2127 try: 

2128 ival_ = int(sval_) 

2129 except (TypeError, ValueError) as exp: 

2130 raise_parse_error(child_, 'requires integer: %s' % exp) 

2131 if ival_ < 0: 

2132 raise_parse_error(child_, 'requires nonNegativeInteger') 

2133 ival_ = self.gds_validate_integer(ival_, node, 'losses') 

2134 self.losses = ival_ 

2135 elif nodeName_ == 'confidence': 

2136 obj_ = Confidence.factory() 

2137 obj_.build(child_) 

2138 self.set_confidence(obj_) 

2139# end class Events 

2140 

2141 

2142class BinaryCharacters(GeneratedsSuper): 

2143 """The names and/or counts of binary characters present, gained, and 

2144 lost at the root of a clade.""" 

2145 subclass = None 

2146 superclass = None 

2147 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): 

2148 self.lost_count = _cast(int, lost_count) 

2149 self.absent_count = _cast(int, absent_count) 

2150 self.present_count = _cast(int, present_count) 

2151 self.type_ = _cast(None, type_) 

2152 self.gained_count = _cast(int, gained_count) 

2153 self.gained = gained 

2154 self.lost = lost 

2155 self.present = present 

2156 self.absent = absent 

2157 def factory(*args_, **kwargs_): 

2158 if BinaryCharacters.subclass: 

2159 return BinaryCharacters.subclass(*args_, **kwargs_) 

2160 else: 

2161 return BinaryCharacters(*args_, **kwargs_) 

2162 factory = staticmethod(factory) 

2163 def get_gained(self): return self.gained 

2164 def set_gained(self, gained): self.gained = gained 

2165 def get_lost(self): return self.lost 

2166 def set_lost(self, lost): self.lost = lost 

2167 def get_present(self): return self.present 

2168 def set_present(self, present): self.present = present 

2169 def get_absent(self): return self.absent 

2170 def set_absent(self, absent): self.absent = absent 

2171 def get_lost_count(self): return self.lost_count 

2172 def set_lost_count(self, lost_count): self.lost_count = lost_count 

2173 def get_absent_count(self): return self.absent_count 

2174 def set_absent_count(self, absent_count): self.absent_count = absent_count 

2175 def get_present_count(self): return self.present_count 

2176 def set_present_count(self, present_count): self.present_count = present_count 

2177 def get_type(self): return self.type_ 

2178 def set_type(self, type_): self.type_ = type_ 

2179 def get_gained_count(self): return self.gained_count 

2180 def set_gained_count(self, gained_count): self.gained_count = gained_count 

2181 def export(self, outfile, level, namespace_='phy:', name_='BinaryCharacters', namespacedef_=''): 

2182 showIndent(outfile, level) 

2183 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) 

2184 already_processed = [] 

2185 self.exportAttributes(outfile, level, already_processed, namespace_, name_='BinaryCharacters') 

2186 if self.hasContent_(): 

2187 outfile.write('>\n') 

2188 self.exportChildren(outfile, level + 1, namespace_, name_) 

2189 showIndent(outfile, level) 

2190 outfile.write('</%s%s>\n' % (namespace_, name_)) 

2191 else: 

2192 outfile.write('/>\n') 

2193 def exportAttributes(self, outfile, level, already_processed, namespace_='phy:', name_='BinaryCharacters'): 

2194 if self.lost_count is not None and 'lost_count' not in already_processed: 

2195 already_processed.append('lost_count') 

2196 outfile.write(' lost_count="%s"' % self.gds_format_integer(self.lost_count, input_name='lost_count')) 

2197 if self.absent_count is not None and 'absent_count' not in already_processed: 

2198 already_processed.append('absent_count') 

2199 outfile.write(' absent_count="%s"' % self.gds_format_integer(self.absent_count, input_name='absent_count')) 

2200 if self.present_count is not None and 'present_count' not in already_processed: 

2201 already_processed.append('present_count') 

2202 outfile.write(' present_count="%s"' % self.gds_format_integer(self.present_count, input_name='present_count')) 

2203 if self.type_ is not None and 'type_' not in already_processed: 

2204 already_processed.append('type_') 

2205 outfile.write(' type=%s' % (self.gds_format_string(quote_attrib(self.type_).encode(ExternalEncoding), input_name='type'), )) 

2206 if self.gained_count is not None and 'gained_count' not in already_processed: 

2207 already_processed.append('gained_count') 

2208 outfile.write(' gained_count="%s"' % self.gds_format_integer(self.gained_count, input_name='gained_count')) 

2209 def exportChildren(self, outfile, level, namespace_='phy:', name_='BinaryCharacters', fromsubclass_=False): 

2210 if self.gained: 

2211 self.gained.export(outfile, level, namespace_, name_='gained') 

2212 if self.lost: 

2213 self.lost.export(outfile, level, namespace_, name_='lost') 

2214 if self.present: 

2215 self.present.export(outfile, level, namespace_, name_='present') 

2216 if self.absent: 

2217 self.absent.export(outfile, level, namespace_, name_='absent') 

2218 def hasContent_(self): 

2219 if ( 

2220 self.gained is not None or 

2221 self.lost is not None or 

2222 self.present is not None or 

2223 self.absent is not None 

2224 ): 

2225 return True 

2226 else: 

2227 return False 

2228 def exportLiteral(self, outfile, level, name_='BinaryCharacters'): 

2229 level += 1 

2230 self.exportLiteralAttributes(outfile, level, [], name_) 

2231 if self.hasContent_(): 

2232 self.exportLiteralChildren(outfile, level, name_) 

2233 def exportLiteralAttributes(self, outfile, level, already_processed, name_): 

2234 if self.lost_count is not None and 'lost_count' not in already_processed: 

2235 already_processed.append('lost_count') 

2236 showIndent(outfile, level) 

2237 outfile.write('lost_count = %d,\n' % (self.lost_count,)) 

2238 if self.absent_count is not None and 'absent_count' not in already_processed: 

2239 already_processed.append('absent_count') 

2240 showIndent(outfile, level) 

2241 outfile.write('absent_count = %d,\n' % (self.absent_count,)) 

2242 if self.present_count is not None and 'present_count' not in already_processed: 

2243 already_processed.append('present_count') 

2244 showIndent(outfile, level) 

2245 outfile.write('present_count = %d,\n' % (self.present_count,)) 

2246 if self.type_ is not None and 'type_' not in already_processed: 

2247 already_processed.append('type_') 

2248 showIndent(outfile, level) 

2249 outfile.write('type_ = "%s",\n' % (self.type_,)) 

2250 if self.gained_count is not None and 'gained_count' not in already_processed: 

2251 already_processed.append('gained_count') 

2252 showIndent(outfile, level) 

2253 outfile.write('gained_count = %d,\n' % (self.gained_count,)) 

2254 def exportLiteralChildren(self, outfile, level, name_): 

2255 if self.gained is not None: 

2256 showIndent(outfile, level) 

2257 outfile.write('gained=model_.BinaryCharacterList(\n') 

2258 self.gained.exportLiteral(outfile, level, name_='gained') 

2259 showIndent(outfile, level) 

2260 outfile.write('),\n') 

2261 if self.lost is not None: 

2262 showIndent(outfile, level) 

2263 outfile.write('lost=model_.BinaryCharacterList(\n') 

2264 self.lost.exportLiteral(outfile, level, name_='lost') 

2265 showIndent(outfile, level) 

2266 outfile.write('),\n') 

2267 if self.present is not None: 

2268 showIndent(outfile, level) 

2269 outfile.write('present=model_.BinaryCharacterList(\n') 

2270 self.present.exportLiteral(outfile, level, name_='present') 

2271 showIndent(outfile, level) 

2272 outfile.write('),\n') 

2273 if self.absent is not None: 

2274 showIndent(outfile, level) 

2275 outfile.write('absent=model_.BinaryCharacterList(\n') 

2276 self.absent.exportLiteral(outfile, level, name_='absent') 

2277 showIndent(outfile, level) 

2278 outfile.write('),\n') 

2279 def build(self, node): 

2280 self.buildAttributes(node, node.attrib, []) 

2281 for child in node: 

2282 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 

2283 self.buildChildren(child, node, nodeName_) 

2284 def buildAttributes(self, node, attrs, already_processed): 

2285 value = find_attr_value_('lost_count', node) 

2286 if value is not None and 'lost_count' not in already_processed: 

2287 already_processed.append('lost_count') 

2288 try: 

2289 self.lost_count = int(value) 

2290 except ValueError as exp: 

2291 raise_parse_error(node, 'Bad integer attribute: %s' % exp) 

2292 if self.lost_count < 0: 

2293 raise_parse_error(node, 'Invalid NonNegativeInteger') 

2294 value = find_attr_value_('absent_count', node) 

2295 if value is not None and 'absent_count' not in already_processed: 

2296 already_processed.append('absent_count') 

2297 try: 

2298 self.absent_count = int(value) 

2299 except ValueError as exp: 

2300 raise_parse_error(node, 'Bad integer attribute: %s' % exp) 

2301 if self.absent_count < 0: 

2302 raise_parse_error(node, 'Invalid NonNegativeInteger') 

2303 value = find_attr_value_('present_count', node) 

2304 if value is not None and 'present_count' not in already_processed: 

2305 already_processed.append('present_count') 

2306 try: 

2307 self.present_count = int(value) 

2308 except ValueError as exp: 

2309 raise_parse_error(node, 'Bad integer attribute: %s' % exp) 

2310 if self.present_count < 0: 

2311 raise_parse_error(node, 'Invalid NonNegativeInteger') 

2312 value = find_attr_value_('type', node) 

2313 if value is not None and 'type' not in already_processed: 

2314 already_processed.append('type') 

2315 self.type_ = value 

2316 self.type_ = ' '.join(self.type_.split()) 

2317 value = find_attr_value_('gained_count', node) 

2318 if value is not None and 'gained_count' not in already_processed: 

2319 already_processed.append('gained_count') 

2320 try: 

2321 self.gained_count = int(value) 

2322 except ValueError as exp: 

2323 raise_parse_error(node, 'Bad integer attribute: %s' % exp) 

2324 if self.gained_count < 0: 

2325 raise_parse_error(node, 'Invalid NonNegativeInteger') 

2326 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 

2327 if nodeName_ == 'gained': 

2328 obj_ = BinaryCharacterList.factory() 

2329 obj_.build(child_) 

2330 self.set_gained(obj_) 

2331 elif nodeName_ == 'lost': 

2332 obj_ = BinaryCharacterList.factory() 

2333 obj_.build(child_) 

2334 self.set_lost(obj_) 

2335 elif nodeName_ == 'present': 

2336 obj_ = BinaryCharacterList.factory() 

2337 obj_.build(child_) 

2338 self.set_present(obj_) 

2339 elif nodeName_ == 'absent': 

2340 obj_ = BinaryCharacterList.factory() 

2341 obj_.build(child_) 

2342 self.set_absent(obj_) 

2343# end class BinaryCharacters 

2344 

2345 

2346class BinaryCharacterList(GeneratedsSuper): 

2347 subclass = None 

2348 superclass = None 

2349 def __init__(self, bc=None, valueOf_=None): 

2350 if bc is None: 

2351 self.bc = [] 

2352 else: 

2353 self.bc = bc 

2354 def factory(*args_, **kwargs_): 

2355 if BinaryCharacterList.subclass: 

2356 return BinaryCharacterList.subclass(*args_, **kwargs_) 

2357 else: 

2358 return BinaryCharacterList(*args_, **kwargs_) 

2359 factory = staticmethod(factory) 

2360 def get_bc(self): return self.bc 

2361 def set_bc(self, bc): self.bc = bc 

2362 def add_bc(self, value): self.bc.append(value) 

2363 def insert_bc(self, index, value): self.bc[index] = value 

2364 def export(self, outfile, level, namespace_='phy:', name_='BinaryCharacterList', namespacedef_=''): 

2365 showIndent(outfile, level) 

2366 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) 

2367 already_processed = [] 

2368 self.exportAttributes(outfile, level, already_processed, namespace_, name_='BinaryCharacterList') 

2369 if self.hasContent_(): 

2370 outfile.write('>\n') 

2371 self.exportChildren(outfile, level + 1, namespace_, name_) 

2372 showIndent(outfile, level) 

2373 outfile.write('</%s%s>\n' % (namespace_, name_)) 

2374 else: 

2375 outfile.write('/>\n') 

2376 def exportAttributes(self, outfile, level, already_processed, namespace_='phy:', name_='BinaryCharacterList'): 

2377 pass 

2378 def exportChildren(self, outfile, level, namespace_='phy:', name_='BinaryCharacterList', fromsubclass_=False): 

2379 for bc_ in self.bc: 

2380 showIndent(outfile, level) 

2381 outfile.write('<%sbc>%s</%sbc>\n' % (namespace_, self.gds_format_string(quote_xml(bc_).encode(ExternalEncoding), input_name='bc'), namespace_)) 

2382 def hasContent_(self): 

2383 if ( 

2384 self.bc 

2385 ): 

2386 return True 

2387 else: 

2388 return False 

2389 def exportLiteral(self, outfile, level, name_='BinaryCharacterList'): 

2390 level += 1 

2391 self.exportLiteralAttributes(outfile, level, [], name_) 

2392 if self.hasContent_(): 

2393 self.exportLiteralChildren(outfile, level, name_) 

2394 def exportLiteralAttributes(self, outfile, level, already_processed, name_): 

2395 pass 

2396 def exportLiteralChildren(self, outfile, level, name_): 

2397 showIndent(outfile, level) 

2398 outfile.write('bc=[\n') 

2399 level += 1 

2400 for bc_ in self.bc: 

2401 showIndent(outfile, level) 

2402 outfile.write('%s,\n' % quote_python(bc_).encode(ExternalEncoding)) 

2403 level -= 1 

2404 showIndent(outfile, level) 

2405 outfile.write('],\n') 

2406 def build(self, node): 

2407 self.buildAttributes(node, node.attrib, []) 

2408 for child in node: 

2409 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 

2410 self.buildChildren(child, node, nodeName_) 

2411 def buildAttributes(self, node, attrs, already_processed): 

2412 pass 

2413 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 

2414 if nodeName_ == 'bc': 

2415 bc_ = child_.text 

2416 bc_ = re_.sub(STRING_CLEANUP_PAT, " ", bc_).strip() 

2417 bc_ = self.gds_validate_string(bc_, node, 'bc') 

2418 self.bc.append(bc_) 

2419# end class BinaryCharacterList 

2420 

2421 

2422class Reference(GeneratedsSuper): 

2423 """A literature reference for a clade. It is recommended to use the 

2424 'doi' attribute instead of the free text 'desc' element whenever 

2425 possible.""" 

2426 subclass = None 

2427 superclass = None 

2428 def __init__(self, doi=None, desc=None, valueOf_=None): 

2429 self.doi = _cast(None, doi) 

2430 self.desc = desc 

2431 def factory(*args_, **kwargs_): 

2432 if Reference.subclass: 

2433 return Reference.subclass(*args_, **kwargs_) 

2434 else: 

2435 return Reference(*args_, **kwargs_) 

2436 factory = staticmethod(factory) 

2437 def get_desc(self): return self.desc 

2438 def set_desc(self, desc): self.desc = desc 

2439 def get_doi(self): return self.doi 

2440 def set_doi(self, doi): self.doi = doi 

2441 def export(self, outfile, level, namespace_='phy:', name_='Reference', namespacedef_=''): 

2442 showIndent(outfile, level) 

2443 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) 

2444 already_processed = [] 

2445 self.exportAttributes(outfile, level, already_processed, namespace_, name_='Reference') 

2446 if self.hasContent_(): 

2447 outfile.write('>\n') 

2448 self.exportChildren(outfile, level + 1, namespace_, name_) 

2449 showIndent(outfile, level) 

2450 outfile.write('</%s%s>\n' % (namespace_, name_)) 

2451 else: 

2452 outfile.write('/>\n') 

2453 def exportAttributes(self, outfile, level, already_processed, namespace_='phy:', name_='Reference'): 

2454 if self.doi is not None and 'doi' not in already_processed: 

2455 already_processed.append('doi') 

2456 outfile.write(' doi=%s' % (quote_attrib(self.doi), )) 

2457 def exportChildren(self, outfile, level, namespace_='phy:', name_='Reference', fromsubclass_=False): 

2458 if self.desc is not None: 

2459 showIndent(outfile, level) 

2460 outfile.write('<%sdesc>%s</%sdesc>\n' % (namespace_, self.gds_format_string(quote_xml(self.desc).encode(ExternalEncoding), input_name='desc'), namespace_)) 

2461 def hasContent_(self): 

2462 if ( 

2463 self.desc is not None 

2464 ): 

2465 return True 

2466 else: 

2467 return False 

2468 def exportLiteral(self, outfile, level, name_='Reference'): 

2469 level += 1 

2470 self.exportLiteralAttributes(outfile, level, [], name_) 

2471 if self.hasContent_(): 

2472 self.exportLiteralChildren(outfile, level, name_) 

2473 def exportLiteralAttributes(self, outfile, level, already_processed, name_): 

2474 if self.doi is not None and 'doi' not in already_processed: 

2475 already_processed.append('doi') 

2476 showIndent(outfile, level) 

2477 outfile.write('doi = %s,\n' % (self.doi,)) 

2478 def exportLiteralChildren(self, outfile, level, name_): 

2479 if self.desc is not None: 

2480 showIndent(outfile, level) 

2481 outfile.write('desc=%s,\n' % quote_python(self.desc).encode(ExternalEncoding)) 

2482 def build(self, node): 

2483 self.buildAttributes(node, node.attrib, []) 

2484 for child in node: 

2485 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 

2486 self.buildChildren(child, node, nodeName_) 

2487 def buildAttributes(self, node, attrs, already_processed): 

2488 value = find_attr_value_('doi', node) 

2489 if value is not None and 'doi' not in already_processed: 

2490 already_processed.append('doi') 

2491 self.doi = value 

2492 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 

2493 if nodeName_ == 'desc': 

2494 desc_ = child_.text 

2495 desc_ = re_.sub(STRING_CLEANUP_PAT, " ", desc_).strip() 

2496 desc_ = self.gds_validate_string(desc_, node, 'desc') 

2497 self.desc = desc_ 

2498# end class Reference 

2499 

2500 

2501class Annotation(GeneratedsSuper): 

2502 """The annotation of a molecular sequence. It is recommended to 

2503 annotate by using the optional 'ref' attribute (some examples of 

2504 acceptable values for the ref attribute: 'GO:0008270', 

2505 'KEGG:Tetrachloroethene degradation', 'EC:1.1.1.1'). Optional 

2506 element 'desc' allows for a free text description. Optional 

2507 element 'confidence' is used to state the type and value of 

2508 support for a annotation. Similarly, optional attribute 

2509 'evidence' is used to describe the evidence for a annotation as 

2510 free text (e.g. 'experimental'). Optional element 'property' 

2511 allows for further, typed and referenced annotations from 

2512 external resources.""" 

2513 subclass = None 

2514 superclass = None 

2515 def __init__(self, source=None, type_=None, ref=None, evidence=None, desc=None, confidence=None, property=None, uri=None, valueOf_=None): 

2516 self.source = _cast(None, source) 

2517 self.type_ = _cast(None, type_) 

2518 self.ref = _cast(None, ref) 

2519 self.evidence = _cast(None, evidence) 

2520 self.desc = desc 

2521 self.confidence = confidence 

2522 if property is None: 

2523 self.property = [] 

2524 else: 

2525 self.property = property 

2526 self.uri = uri 

2527 def factory(*args_, **kwargs_): 

2528 if Annotation.subclass: 

2529 return Annotation.subclass(*args_, **kwargs_) 

2530 else: 

2531 return Annotation(*args_, **kwargs_) 

2532 factory = staticmethod(factory) 

2533 def get_desc(self): return self.desc 

2534 def set_desc(self, desc): self.desc = desc 

2535 def get_confidence(self): return self.confidence 

2536 def set_confidence(self, confidence): self.confidence = confidence 

2537 def get_property(self): return self.property 

2538 def set_property(self, property): self.property = property 

2539 def add_property(self, value): self.property.append(value) 

2540 def insert_property(self, index, value): self.property[index] = value 

2541 def get_uri(self): return self.uri 

2542 def set_uri(self, uri): self.uri = uri 

2543 def get_source(self): return self.source 

2544 def set_source(self, source): self.source = source 

2545 def get_type(self): return self.type_ 

2546 def set_type(self, type_): self.type_ = type_ 

2547 def get_ref(self): return self.ref 

2548 def set_ref(self, ref): self.ref = ref 

2549 def get_evidence(self): return self.evidence 

2550 def set_evidence(self, evidence): self.evidence = evidence 

2551 def export(self, outfile, level, namespace_='phy:', name_='Annotation', namespacedef_=''): 

2552 showIndent(outfile, level) 

2553 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) 

2554 already_processed = [] 

2555 self.exportAttributes(outfile, level, already_processed, namespace_, name_='Annotation') 

2556 if self.hasContent_(): 

2557 outfile.write('>\n') 

2558 self.exportChildren(outfile, level + 1, namespace_, name_) 

2559 showIndent(outfile, level) 

2560 outfile.write('</%s%s>\n' % (namespace_, name_)) 

2561 else: 

2562 outfile.write('/>\n') 

2563 def exportAttributes(self, outfile, level, already_processed, namespace_='phy:', name_='Annotation'): 

2564 if self.source is not None and 'source' not in already_processed: 

2565 already_processed.append('source') 

2566 outfile.write(' source=%s' % (self.gds_format_string(quote_attrib(self.source).encode(ExternalEncoding), input_name='source'), )) 

2567 if self.type_ is not None and 'type_' not in already_processed: 

2568 already_processed.append('type_') 

2569 outfile.write(' type=%s' % (self.gds_format_string(quote_attrib(self.type_).encode(ExternalEncoding), input_name='type'), )) 

2570 if self.ref is not None and 'ref' not in already_processed: 

2571 already_processed.append('ref') 

2572 outfile.write(' ref=%s' % (quote_attrib(self.ref), )) 

2573 if self.evidence is not None and 'evidence' not in already_processed: 

2574 already_processed.append('evidence') 

2575 outfile.write(' evidence=%s' % (self.gds_format_string(quote_attrib(self.evidence).encode(ExternalEncoding), input_name='evidence'), )) 

2576 def exportChildren(self, outfile, level, namespace_='phy:', name_='Annotation', fromsubclass_=False): 

2577 if self.desc is not None: 

2578 showIndent(outfile, level) 

2579 outfile.write('<%sdesc>%s</%sdesc>\n' % (namespace_, self.gds_format_string(quote_xml(self.desc).encode(ExternalEncoding), input_name='desc'), namespace_)) 

2580 if self.confidence: 

2581 self.confidence.export(outfile, level, namespace_, name_='confidence') 

2582 for property_ in self.property: 

2583 property_.export(outfile, level, namespace_, name_='property') 

2584 if self.uri: 

2585 self.uri.export(outfile, level, namespace_, name_='uri') 

2586 def hasContent_(self): 

2587 if ( 

2588 self.desc is not None or 

2589 self.confidence is not None or 

2590 self.property or 

2591 self.uri is not None 

2592 ): 

2593 return True 

2594 else: 

2595 return False 

2596 def exportLiteral(self, outfile, level, name_='Annotation'): 

2597 level += 1 

2598 self.exportLiteralAttributes(outfile, level, [], name_) 

2599 if self.hasContent_(): 

2600 self.exportLiteralChildren(outfile, level, name_) 

2601 def exportLiteralAttributes(self, outfile, level, already_processed, name_): 

2602 if self.source is not None and 'source' not in already_processed: 

2603 already_processed.append('source') 

2604 showIndent(outfile, level) 

2605 outfile.write('source = "%s",\n' % (self.source,)) 

2606 if self.type_ is not None and 'type_' not in already_processed: 

2607 already_processed.append('type_') 

2608 showIndent(outfile, level) 

2609 outfile.write('type_ = "%s",\n' % (self.type_,)) 

2610 if self.ref is not None and 'ref' not in already_processed: 

2611 already_processed.append('ref') 

2612 showIndent(outfile, level) 

2613 outfile.write('ref = %s,\n' % (self.ref,)) 

2614 if self.evidence is not None and 'evidence' not in already_processed: 

2615 already_processed.append('evidence') 

2616 showIndent(outfile, level) 

2617 outfile.write('evidence = "%s",\n' % (self.evidence,)) 

2618 def exportLiteralChildren(self, outfile, level, name_): 

2619 if self.desc is not None: 

2620 showIndent(outfile, level) 

2621 outfile.write('desc=%s,\n' % quote_python(self.desc).encode(ExternalEncoding)) 

2622 if self.confidence is not None: 

2623 showIndent(outfile, level) 

2624 outfile.write('confidence=model_.Confidence(\n') 

2625 self.confidence.exportLiteral(outfile, level, name_='confidence') 

2626 showIndent(outfile, level) 

2627 outfile.write('),\n') 

2628 showIndent(outfile, level) 

2629 outfile.write('property=[\n') 

2630 level += 1 

2631 for property_ in self.property: 

2632 showIndent(outfile, level) 

2633 outfile.write('model_.Property(\n') 

2634 property_.exportLiteral(outfile, level, name_='Property') 

2635 showIndent(outfile, level) 

2636 outfile.write('),\n') 

2637 level -= 1 

2638 showIndent(outfile, level) 

2639 outfile.write('],\n') 

2640 if self.uri is not None: 

2641 showIndent(outfile, level) 

2642 outfile.write('uri=model_.Uri(\n') 

2643 self.uri.exportLiteral(outfile, level, name_='uri') 

2644 showIndent(outfile, level) 

2645 outfile.write('),\n') 

2646 def build(self, node): 

2647 self.buildAttributes(node, node.attrib, []) 

2648 for child in node: 

2649 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 

2650 self.buildChildren(child, node, nodeName_) 

2651 def buildAttributes(self, node, attrs, already_processed): 

2652 value = find_attr_value_('source', node) 

2653 if value is not None and 'source' not in already_processed: 

2654 already_processed.append('source') 

2655 self.source = value 

2656 self.source = ' '.join(self.source.split()) 

2657 value = find_attr_value_('type', node) 

2658 if value is not None and 'type' not in already_processed: 

2659 already_processed.append('type') 

2660 self.type_ = value 

2661 self.type_ = ' '.join(self.type_.split()) 

2662 value = find_attr_value_('ref', node) 

2663 if value is not None and 'ref' not in already_processed: 

2664 already_processed.append('ref') 

2665 self.ref = value 

2666 value = find_attr_value_('evidence', node) 

2667 if value is not None and 'evidence' not in already_processed: 

2668 already_processed.append('evidence') 

2669 self.evidence = value 

2670 self.evidence = ' '.join(self.evidence.split()) 

2671 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 

2672 if nodeName_ == 'desc': 

2673 desc_ = child_.text 

2674 desc_ = re_.sub(STRING_CLEANUP_PAT, " ", desc_).strip() 

2675 desc_ = self.gds_validate_string(desc_, node, 'desc') 

2676 self.desc = desc_ 

2677 elif nodeName_ == 'confidence': 

2678 obj_ = Confidence.factory() 

2679 obj_.build(child_) 

2680 self.set_confidence(obj_) 

2681 elif nodeName_ == 'property': 

2682 obj_ = Property.factory() 

2683 obj_.build(child_) 

2684 self.property.append(obj_) 

2685 elif nodeName_ == 'uri': 

2686 obj_ = Uri.factory() 

2687 obj_.build(child_) 

2688 self.set_uri(obj_) 

2689# end class Annotation 

2690 

2691 

2692class Property(GeneratedsSuper): 

2693 """Property allows for typed and referenced properties from external 

2694 resources to be attached to 'Phylogeny', 'Clade', and 

2695 'Annotation'. The value of a property is its mixed (free text) 

2696 content. Attribute 'datatype' indicates the type of a property 

2697 and is limited to xsd-datatypes (e.g. 'xsd:string', 

2698 'xsd:boolean', 'xsd:integer', 'xsd:decimal', 'xsd:float', 

2699 'xsd:double', 'xsd:date', 'xsd:anyURI'). Attribute 'applies_to' 

2700 indicates the item to which a property applies to (e.g. 'node' 

2701 for the parent node of a clade, 'parent_branch' for the parent 

2702 branch of a clade). Attribute 'id_ref' allows to attached a 

2703 property specifically to one element (on the xml-level). 

2704 Optional attribute 'unit' is used to indicate the unit of the 

2705 property. An example: <property datatype="xsd:integer" 

2706 ref="NOAA:depth" applies_to="clade" unit="METRIC:m"> 200 

2707 </property>""" 

2708 subclass = None 

2709 superclass = None 

2710 def __init__(self, datatype=None, id_ref=None, ref=None, applies_to=None, unit=None, valueOf_=None, mixedclass_=None, content_=None): 

2711 self.datatype = _cast(None, datatype) 

2712 self.id_ref = _cast(None, id_ref) 

2713 self.ref = _cast(None, ref) 

2714 self.applies_to = _cast(None, applies_to) 

2715 self.unit = _cast(None, unit) 

2716 self.valueOf_ = valueOf_ 

2717 if mixedclass_ is None: 

2718 self.mixedclass_ = MixedContainer 

2719 else: 

2720 self.mixedclass_ = mixedclass_ 

2721 if content_ is None: 

2722 self.content_ = [] 

2723 else: 

2724 self.content_ = content_ 

2725 self.valueOf_ = valueOf_ 

2726 def factory(*args_, **kwargs_): 

2727 if Property.subclass: 

2728 return Property.subclass(*args_, **kwargs_) 

2729 else: 

2730 return Property(*args_, **kwargs_) 

2731 factory = staticmethod(factory) 

2732 def get_datatype(self): return self.datatype 

2733 def set_datatype(self, datatype): self.datatype = datatype 

2734 def get_id_ref(self): return self.id_ref 

2735 def set_id_ref(self, id_ref): self.id_ref = id_ref 

2736 def get_ref(self): return self.ref 

2737 def set_ref(self, ref): self.ref = ref 

2738 def get_applies_to(self): return self.applies_to 

2739 def set_applies_to(self, applies_to): self.applies_to = applies_to 

2740 def get_unit(self): return self.unit 

2741 def set_unit(self, unit): self.unit = unit 

2742 def get_valueOf_(self): return self.valueOf_ 

2743 def set_valueOf_(self, valueOf_): self.valueOf_ = valueOf_ 

2744 def export(self, outfile, level, namespace_='phy:', name_='Property', namespacedef_=''): 

2745 showIndent(outfile, level) 

2746 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) 

2747 already_processed = [] 

2748 self.exportAttributes(outfile, level, already_processed, namespace_, name_='Property') 

2749 outfile.write('>') 

2750 if self.valueOf_ is not None: 

2751 outfile.write('%s' % (self.valueOf_,)) 

2752 self.exportChildren(outfile, level + 1, namespace_, name_) 

2753 outfile.write('</%s%s>\n' % (namespace_, name_)) 

2754 def exportAttributes(self, outfile, level, already_processed, namespace_='phy:', name_='Property'): 

2755 if self.datatype is not None and 'datatype' not in already_processed: 

2756 already_processed.append('datatype') 

2757 outfile.write(' datatype=%s' % (quote_attrib(self.datatype), )) 

2758 if self.id_ref is not None and 'id_ref' not in already_processed: 

2759 already_processed.append('id_ref') 

2760 outfile.write(' id_ref=%s' % (quote_attrib(self.id_ref), )) 

2761 if self.ref is not None and 'ref' not in already_processed: 

2762 already_processed.append('ref') 

2763 outfile.write(' ref=%s' % (quote_attrib(self.ref), )) 

2764 if self.applies_to is not None and 'applies_to' not in already_processed: 

2765 already_processed.append('applies_to') 

2766 outfile.write(' applies_to=%s' % (quote_attrib(self.applies_to), )) 

2767 if self.unit is not None and 'unit' not in already_processed: 

2768 already_processed.append('unit') 

2769 outfile.write(' unit=%s' % (quote_attrib(self.unit), )) 

2770 def exportChildren(self, outfile, level, namespace_='phy:', name_='Property', fromsubclass_=False): 

2771 pass 

2772 def hasContent_(self): 

2773 if ( 

2774 self.valueOf_ 

2775 ): 

2776 return True 

2777 else: 

2778 return False 

2779 def exportLiteral(self, outfile, level, name_='Property'): 

2780 level += 1 

2781 self.exportLiteralAttributes(outfile, level, [], name_) 

2782 if self.hasContent_(): 

2783 self.exportLiteralChildren(outfile, level, name_) 

2784 showIndent(outfile, level) 

2785 outfile.write('valueOf_ = """%s""",\n' % (self.valueOf_,)) 

2786 def exportLiteralAttributes(self, outfile, level, already_processed, name_): 

2787 if self.datatype is not None and 'datatype' not in already_processed: 

2788 already_processed.append('datatype') 

2789 showIndent(outfile, level) 

2790 outfile.write('datatype = %s,\n' % (self.datatype,)) 

2791 if self.id_ref is not None and 'id_ref' not in already_processed: 

2792 already_processed.append('id_ref') 

2793 showIndent(outfile, level) 

2794 outfile.write('id_ref = %s,\n' % (self.id_ref,)) 

2795 if self.ref is not None and 'ref' not in already_processed: 

2796 already_processed.append('ref') 

2797 showIndent(outfile, level) 

2798 outfile.write('ref = %s,\n' % (self.ref,)) 

2799 if self.applies_to is not None and 'applies_to' not in already_processed: 

2800 already_processed.append('applies_to') 

2801 showIndent(outfile, level) 

2802 outfile.write('applies_to = %s,\n' % (self.applies_to,)) 

2803 if self.unit is not None and 'unit' not in already_processed: 

2804 already_processed.append('unit') 

2805 showIndent(outfile, level) 

2806 outfile.write('unit = %s,\n' % (self.unit,)) 

2807 def exportLiteralChildren(self, outfile, level, name_): 

2808 pass 

2809 def build(self, node): 

2810 self.buildAttributes(node, node.attrib, []) 

2811 self.valueOf_ = get_all_text_(node) 

2812 if node.text is not None: 

2813 obj_ = self.mixedclass_(MixedContainer.CategoryText, 

2814 MixedContainer.TypeNone, '', node.text) 

2815 self.content_.append(obj_) 

2816 for child in node: 

2817 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 

2818 self.buildChildren(child, node, nodeName_) 

2819 def buildAttributes(self, node, attrs, already_processed): 

2820 value = find_attr_value_('datatype', node) 

2821 if value is not None and 'datatype' not in already_processed: 

2822 already_processed.append('datatype') 

2823 self.datatype = value 

2824 value = find_attr_value_('id_ref', node) 

2825 if value is not None and 'id_ref' not in already_processed: 

2826 already_processed.append('id_ref') 

2827 self.id_ref = value 

2828 value = find_attr_value_('ref', node) 

2829 if value is not None and 'ref' not in already_processed: 

2830 already_processed.append('ref') 

2831 self.ref = value 

2832 value = find_attr_value_('applies_to', node) 

2833 if value is not None and 'applies_to' not in already_processed: 

2834 already_processed.append('applies_to') 

2835 self.applies_to = value 

2836 value = find_attr_value_('unit', node) 

2837 if value is not None and 'unit' not in already_processed: 

2838 already_processed.append('unit') 

2839 self.unit = value 

2840 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 

2841 if not fromsubclass_ and child_.tail is not None: 

2842 obj_ = self.mixedclass_(MixedContainer.CategoryText, 

2843 MixedContainer.TypeNone, '', child_.tail) 

2844 self.content_.append(obj_) 

2845 pass 

2846# end class Property 

2847 

2848 

2849class Uri(GeneratedsSuper): 

2850 """A uniform resource identifier. In general, this is expected to be an 

2851 URL (for example, to link to an image on a website, in which 

2852 case the 'type' attribute might be 'image' and 'desc' might be 

2853 'image of a California sea hare').""" 

2854 subclass = None 

2855 superclass = None 

2856 def __init__(self, type_=None, desc=None, valueOf_=None): 

2857 self.type_ = _cast(None, type_) 

2858 self.desc = _cast(None, desc) 

2859 self.valueOf_ = valueOf_ 

2860 def factory(*args_, **kwargs_): 

2861 if Uri.subclass: 

2862 return Uri.subclass(*args_, **kwargs_) 

2863 else: 

2864 return Uri(*args_, **kwargs_) 

2865 factory = staticmethod(factory) 

2866 def get_type(self): return self.type_ 

2867 def set_type(self, type_): self.type_ = type_ 

2868 def get_desc(self): return self.desc 

2869 def set_desc(self, desc): self.desc = desc 

2870 def get_valueOf_(self): return self.valueOf_ 

2871 def set_valueOf_(self, valueOf_): self.valueOf_ = valueOf_ 

2872 def export(self, outfile, level, namespace_='phy:', name_='Uri', namespacedef_=''): 

2873 showIndent(outfile, level) 

2874 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) 

2875 already_processed = [] 

2876 self.exportAttributes(outfile, level, already_processed, namespace_, name_='Uri') 

2877 if self.hasContent_(): 

2878 outfile.write('>') 

2879 outfile.write(str(self.valueOf_).encode(ExternalEncoding)) 

2880 self.exportChildren(outfile, level + 1, namespace_, name_) 

2881 outfile.write('</%s%s>\n' % (namespace_, name_)) 

2882 else: 

2883 outfile.write('/>\n') 

2884 def exportAttributes(self, outfile, level, already_processed, namespace_='phy:', name_='Uri'): 

2885 if self.type_ is not None and 'type_' not in already_processed: 

2886 already_processed.append('type_') 

2887 outfile.write(' type=%s' % (self.gds_format_string(quote_attrib(self.type_).encode(ExternalEncoding), input_name='type'), )) 

2888 if self.desc is not None and 'desc' not in already_processed: 

2889 already_processed.append('desc') 

2890 outfile.write(' desc=%s' % (self.gds_format_string(quote_attrib(self.desc).encode(ExternalEncoding), input_name='desc'), )) 

2891 def exportChildren(self, outfile, level, namespace_='phy:', name_='Uri', fromsubclass_=False): 

2892 pass 

2893 def hasContent_(self): 

2894 if ( 

2895 self.valueOf_ 

2896 ): 

2897 return True 

2898 else: 

2899 return False 

2900 def exportLiteral(self, outfile, level, name_='Uri'): 

2901 level += 1 

2902 self.exportLiteralAttributes(outfile, level, [], name_) 

2903 if self.hasContent_(): 

2904 self.exportLiteralChildren(outfile, level, name_) 

2905 showIndent(outfile, level) 

2906 outfile.write('valueOf_ = """%s""",\n' % (self.valueOf_,)) 

2907 def exportLiteralAttributes(self, outfile, level, already_processed, name_): 

2908 if self.type_ is not None and 'type_' not in already_processed: 

2909 already_processed.append('type_') 

2910 showIndent(outfile, level) 

2911 outfile.write('type_ = "%s",\n' % (self.type_,)) 

2912 if self.desc is not None and 'desc' not in already_processed: 

2913 already_processed.append('desc') 

2914 showIndent(outfile, level) 

2915 outfile.write('desc = "%s",\n' % (self.desc,)) 

2916 def exportLiteralChildren(self, outfile, level, name_): 

2917 pass 

2918 def build(self, node): 

2919 self.buildAttributes(node, node.attrib, []) 

2920 self.valueOf_ = get_all_text_(node) 

2921 for child in node: 

2922 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 

2923 self.buildChildren(child, node, nodeName_) 

2924 def buildAttributes(self, node, attrs, already_processed): 

2925 value = find_attr_value_('type', node) 

2926 if value is not None and 'type' not in already_processed: 

2927 already_processed.append('type') 

2928 self.type_ = value 

2929 self.type_ = ' '.join(self.type_.split()) 

2930 value = find_attr_value_('desc', node) 

2931 if value is not None and 'desc' not in already_processed: 

2932 already_processed.append('desc') 

2933 self.desc = value 

2934 self.desc = ' '.join(self.desc.split()) 

2935 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 

2936 pass 

2937# end class Uri 

2938 

2939 

2940class Confidence(GeneratedsSuper): 

2941 """A general purpose confidence element. For example this can be used 

2942 to express the bootstrap support value of a clade (in which case 

2943 the 'type' attribute is 'bootstrap').""" 

2944 subclass = None 

2945 superclass = None 

2946 def __init__(self, type_=None, valueOf_=None): 

2947 self.type_ = _cast(None, type_) 

2948 self.valueOf_ = valueOf_ 

2949 def factory(*args_, **kwargs_): 

2950 if Confidence.subclass: 

2951 return Confidence.subclass(*args_, **kwargs_) 

2952 else: 

2953 return Confidence(*args_, **kwargs_) 

2954 factory = staticmethod(factory) 

2955 def get_type(self): return self.type_ 

2956 def set_type(self, type_): self.type_ = type_ 

2957 def get_valueOf_(self): return self.valueOf_ 

2958 def set_valueOf_(self, valueOf_): self.valueOf_ = valueOf_ 

2959 def export(self, outfile, level, namespace_='phy:', name_='Confidence', namespacedef_=''): 

2960 showIndent(outfile, level) 

2961 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) 

2962 already_processed = [] 

2963 self.exportAttributes(outfile, level, already_processed, namespace_, name_='Confidence') 

2964 if self.hasContent_(): 

2965 outfile.write('>') 

2966 outfile.write(str(self.valueOf_).encode(ExternalEncoding)) 

2967 self.exportChildren(outfile, level + 1, namespace_, name_) 

2968 outfile.write('</%s%s>\n' % (namespace_, name_)) 

2969 else: 

2970 outfile.write('/>\n') 

2971 def exportAttributes(self, outfile, level, already_processed, namespace_='phy:', name_='Confidence'): 

2972 if self.type_ is not None and 'type_' not in already_processed: 

2973 already_processed.append('type_') 

2974 outfile.write(' type=%s' % (self.gds_format_string(quote_attrib(self.type_).encode(ExternalEncoding), input_name='type'), )) 

2975 def exportChildren(self, outfile, level, namespace_='phy:', name_='Confidence', fromsubclass_=False): 

2976 pass 

2977 def hasContent_(self): 

2978 if ( 

2979 self.valueOf_ 

2980 ): 

2981 return True 

2982 else: 

2983 return False 

2984 def exportLiteral(self, outfile, level, name_='Confidence'): 

2985 level += 1 

2986 self.exportLiteralAttributes(outfile, level, [], name_) 

2987 if self.hasContent_(): 

2988 self.exportLiteralChildren(outfile, level, name_) 

2989 showIndent(outfile, level) 

2990 outfile.write('valueOf_ = """%s""",\n' % (self.valueOf_,)) 

2991 def exportLiteralAttributes(self, outfile, level, already_processed, name_): 

2992 if self.type_ is not None and 'type_' not in already_processed: 

2993 already_processed.append('type_') 

2994 showIndent(outfile, level) 

2995 outfile.write('type_ = "%s",\n' % (self.type_,)) 

2996 def exportLiteralChildren(self, outfile, level, name_): 

2997 pass 

2998 def build(self, node): 

2999 self.buildAttributes(node, node.attrib, []) 

3000 self.valueOf_ = get_all_text_(node) 

3001 for child in node: 

3002 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 

3003 self.buildChildren(child, node, nodeName_) 

3004 def buildAttributes(self, node, attrs, already_processed): 

3005 value = find_attr_value_('type', node) 

3006 if value is not None and 'type' not in already_processed: 

3007 already_processed.append('type') 

3008 self.type_ = value 

3009 self.type_ = ' '.join(self.type_.split()) 

3010 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 

3011 pass 

3012# end class Confidence 

3013 

3014 

3015class Id(GeneratedsSuper): 

3016 """A general purpose identifier element. Allows to indicate the 

3017 provider (or authority) of an identifier.""" 

3018 subclass = None 

3019 superclass = None 

3020 def __init__(self, provider=None, valueOf_=None): 

3021 self.provider = _cast(None, provider) 

3022 self.valueOf_ = valueOf_ 

3023 def factory(*args_, **kwargs_): 

3024 if Id.subclass: 

3025 return Id.subclass(*args_, **kwargs_) 

3026 else: 

3027 return Id(*args_, **kwargs_) 

3028 factory = staticmethod(factory) 

3029 def get_provider(self): return self.provider 

3030 def set_provider(self, provider): self.provider = provider 

3031 def get_valueOf_(self): return self.valueOf_ 

3032 def set_valueOf_(self, valueOf_): self.valueOf_ = valueOf_ 

3033 def export(self, outfile, level, namespace_='phy:', name_='Id', namespacedef_=''): 

3034 showIndent(outfile, level) 

3035 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) 

3036 already_processed = [] 

3037 self.exportAttributes(outfile, level, already_processed, namespace_, name_='Id') 

3038 if self.hasContent_(): 

3039 outfile.write('>') 

3040 outfile.write(str(self.valueOf_).encode(ExternalEncoding)) 

3041 self.exportChildren(outfile, level + 1, namespace_, name_) 

3042 outfile.write('</%s%s>\n' % (namespace_, name_)) 

3043 else: 

3044 outfile.write('/>\n') 

3045 def exportAttributes(self, outfile, level, already_processed, namespace_='phy:', name_='Id'): 

3046 if self.provider is not None and 'provider' not in already_processed: 

3047 already_processed.append('provider') 

3048 outfile.write(' provider=%s' % (self.gds_format_string(quote_attrib(self.provider).encode(ExternalEncoding), input_name='provider'), )) 

3049 def exportChildren(self, outfile, level, namespace_='phy:', name_='Id', fromsubclass_=False): 

3050 pass 

3051 def hasContent_(self): 

3052 if ( 

3053 self.valueOf_ 

3054 ): 

3055 return True 

3056 else: 

3057 return False 

3058 def exportLiteral(self, outfile, level, name_='Id'): 

3059 level += 1 

3060 self.exportLiteralAttributes(outfile, level, [], name_) 

3061 if self.hasContent_(): 

3062 self.exportLiteralChildren(outfile, level, name_) 

3063 showIndent(outfile, level) 

3064 outfile.write('valueOf_ = """%s""",\n' % (self.valueOf_,)) 

3065 def exportLiteralAttributes(self, outfile, level, already_processed, name_): 

3066 if self.provider is not None and 'provider' not in already_processed: 

3067 already_processed.append('provider') 

3068 showIndent(outfile, level) 

3069 outfile.write('provider = "%s",\n' % (self.provider,)) 

3070 def exportLiteralChildren(self, outfile, level, name_): 

3071 pass 

3072 def build(self, node): 

3073 self.buildAttributes(node, node.attrib, []) 

3074 self.valueOf_ = get_all_text_(node) 

3075 for child in node: 

3076 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 

3077 self.buildChildren(child, node, nodeName_) 

3078 def buildAttributes(self, node, attrs, already_processed): 

3079 value = find_attr_value_('provider', node) 

3080 if value is not None and 'provider' not in already_processed: 

3081 already_processed.append('provider') 

3082 self.provider = value 

3083 self.provider = ' '.join(self.provider.split()) 

3084 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 

3085 pass 

3086# end class Id 

3087 

3088 

3089class Distribution(GeneratedsSuper): 

3090 """The geographic distribution of the items of a clade (species, 

3091 sequences), intended for phylogeographic applications. The 

3092 location can be described either by free text in the 'desc' 

3093 element and/or by the coordinates of one or more 'Points' 

3094 (similar to the 'Point' element in Google's KML format) or by 

3095 'Polygons'.""" 

3096 subclass = None 

3097 superclass = None 

3098 def __init__(self, desc=None, point=None, polygon=None, valueOf_=None): 

3099 self.desc = desc 

3100 if point is None: 

3101 self.point = [] 

3102 else: 

3103 self.point = point 

3104 if polygon is None: 

3105 self.polygon = [] 

3106 else: 

3107 self.polygon = polygon 

3108 def factory(*args_, **kwargs_): 

3109 if Distribution.subclass: 

3110 return Distribution.subclass(*args_, **kwargs_) 

3111 else: 

3112 return Distribution(*args_, **kwargs_) 

3113 factory = staticmethod(factory) 

3114 def get_desc(self): return self.desc 

3115 def set_desc(self, desc): self.desc = desc 

3116 def get_point(self): return self.point 

3117 def set_point(self, point): self.point = point 

3118 def add_point(self, value): self.point.append(value) 

3119 def insert_point(self, index, value): self.point[index] = value 

3120 def get_polygon(self): return self.polygon 

3121 def set_polygon(self, polygon): self.polygon = polygon 

3122 def add_polygon(self, value): self.polygon.append(value) 

3123 def insert_polygon(self, index, value): self.polygon[index] = value 

3124 def export(self, outfile, level, namespace_='phy:', name_='Distribution', namespacedef_=''): 

3125 showIndent(outfile, level) 

3126 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) 

3127 already_processed = [] 

3128 self.exportAttributes(outfile, level, already_processed, namespace_, name_='Distribution') 

3129 if self.hasContent_(): 

3130 outfile.write('>\n') 

3131 self.exportChildren(outfile, level + 1, namespace_, name_) 

3132 showIndent(outfile, level) 

3133 outfile.write('</%s%s>\n' % (namespace_, name_)) 

3134 else: 

3135 outfile.write('/>\n') 

3136 def exportAttributes(self, outfile, level, already_processed, namespace_='phy:', name_='Distribution'): 

3137 pass 

3138 def exportChildren(self, outfile, level, namespace_='phy:', name_='Distribution', fromsubclass_=False): 

3139 if self.desc is not None: 

3140 showIndent(outfile, level) 

3141 outfile.write('<%sdesc>%s</%sdesc>\n' % (namespace_, self.gds_format_string(quote_xml(self.desc).encode(ExternalEncoding), input_name='desc'), namespace_)) 

3142 for point_ in self.point: 

3143 point_.export(outfile, level, namespace_, name_='point') 

3144 for polygon_ in self.polygon: 

3145 polygon_.export(outfile, level, namespace_, name_='polygon') 

3146 def hasContent_(self): 

3147 if ( 

3148 self.desc is not None or 

3149 self.point or 

3150 self.polygon 

3151 ): 

3152 return True 

3153 else: 

3154 return False 

3155 def exportLiteral(self, outfile, level, name_='Distribution'): 

3156 level += 1 

3157 self.exportLiteralAttributes(outfile, level, [], name_) 

3158 if self.hasContent_(): 

3159 self.exportLiteralChildren(outfile, level, name_) 

3160 def exportLiteralAttributes(self, outfile, level, already_processed, name_): 

3161 pass 

3162 def exportLiteralChildren(self, outfile, level, name_): 

3163 if self.desc is not None: 

3164 showIndent(outfile, level) 

3165 outfile.write('desc=%s,\n' % quote_python(self.desc).encode(ExternalEncoding)) 

3166 showIndent(outfile, level) 

3167 outfile.write('point=[\n') 

3168 level += 1 

3169 for point_ in self.point: 

3170 showIndent(outfile, level) 

3171 outfile.write('model_.Point(\n') 

3172 point_.exportLiteral(outfile, level, name_='Point') 

3173 showIndent(outfile, level) 

3174 outfile.write('),\n') 

3175 level -= 1 

3176 showIndent(outfile, level) 

3177 outfile.write('],\n') 

3178 showIndent(outfile, level) 

3179 outfile.write('polygon=[\n') 

3180 level += 1 

3181 for polygon_ in self.polygon: 

3182 showIndent(outfile, level) 

3183 outfile.write('model_.Polygon(\n') 

3184 polygon_.exportLiteral(outfile, level, name_='Polygon') 

3185 showIndent(outfile, level) 

3186 outfile.write('),\n') 

3187 level -= 1 

3188 showIndent(outfile, level) 

3189 outfile.write('],\n') 

3190 def build(self, node): 

3191 self.buildAttributes(node, node.attrib, []) 

3192 for child in node: 

3193 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 

3194 self.buildChildren(child, node, nodeName_) 

3195 def buildAttributes(self, node, attrs, already_processed): 

3196 pass 

3197 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 

3198 if nodeName_ == 'desc': 

3199 desc_ = child_.text 

3200 desc_ = re_.sub(STRING_CLEANUP_PAT, " ", desc_).strip() 

3201 desc_ = self.gds_validate_string(desc_, node, 'desc') 

3202 self.desc = desc_ 

3203 elif nodeName_ == 'point': 

3204 obj_ = Point.factory() 

3205 obj_.build(child_) 

3206 self.point.append(obj_) 

3207 elif nodeName_ == 'polygon': 

3208 obj_ = Polygon.factory() 

3209 obj_.build(child_) 

3210 self.polygon.append(obj_) 

3211# end class Distribution 

3212 

3213 

3214class Point(GeneratedsSuper): 

3215 """The coordinates of a point with an optional altitude (used by 

3216 element 'Distribution'). Required attributes are the 

3217 'geodetic_datum' used to indicate the geodetic datum (also 

3218 called 'map datum', for example Google's KML uses 'WGS84'). 

3219 Attribute 'alt_unit' is the unit for the altitude (e.g. 

3220 'meter').""" 

3221 subclass = None 

3222 superclass = None 

3223 def __init__(self, geodetic_datum=None, alt_unit=None, lat=None, long=None, alt=None, valueOf_=None): 

3224 self.geodetic_datum = _cast(None, geodetic_datum) 

3225 self.alt_unit = _cast(None, alt_unit) 

3226 self.lat = lat 

3227 self.long = int 

3228 self.alt = alt 

3229 def factory(*args_, **kwargs_): 

3230 if Point.subclass: 

3231 return Point.subclass(*args_, **kwargs_) 

3232 else: 

3233 return Point(*args_, **kwargs_) 

3234 factory = staticmethod(factory) 

3235 def get_lat(self): return self.lat 

3236 def set_lat(self, lat): self.lat = lat 

3237 def get_long(self): return self.long 

3238 def set_long(self, long): self.long = int 

3239 def get_alt(self): return self.alt 

3240 def set_alt(self, alt): self.alt = alt 

3241 def get_geodetic_datum(self): return self.geodetic_datum 

3242 def set_geodetic_datum(self, geodetic_datum): self.geodetic_datum = geodetic_datum 

3243 def get_alt_unit(self): return self.alt_unit 

3244 def set_alt_unit(self, alt_unit): self.alt_unit = alt_unit 

3245 def export(self, outfile, level, namespace_='phy:', name_='Point', namespacedef_=''): 

3246 showIndent(outfile, level) 

3247 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) 

3248 already_processed = [] 

3249 self.exportAttributes(outfile, level, already_processed, namespace_, name_='Point') 

3250 if self.hasContent_(): 

3251 outfile.write('>\n') 

3252 self.exportChildren(outfile, level + 1, namespace_, name_) 

3253 showIndent(outfile, level) 

3254 outfile.write('</%s%s>\n' % (namespace_, name_)) 

3255 else: 

3256 outfile.write('/>\n') 

3257 def exportAttributes(self, outfile, level, already_processed, namespace_='phy:', name_='Point'): 

3258 if self.geodetic_datum is not None and 'geodetic_datum' not in already_processed: 

3259 already_processed.append('geodetic_datum') 

3260 outfile.write(' geodetic_datum=%s' % (self.gds_format_string(quote_attrib(self.geodetic_datum).encode(ExternalEncoding), input_name='geodetic_datum'), )) 

3261 if self.alt_unit is not None and 'alt_unit' not in already_processed: 

3262 already_processed.append('alt_unit') 

3263 outfile.write(' alt_unit=%s' % (self.gds_format_string(quote_attrib(self.alt_unit).encode(ExternalEncoding), input_name='alt_unit'), )) 

3264 def exportChildren(self, outfile, level, namespace_='phy:', name_='Point', fromsubclass_=False): 

3265 if self.lat is not None: 

3266 showIndent(outfile, level) 

3267 outfile.write('<%slat>%s</%slat>\n' % (namespace_, self.gds_format_float(self.lat, input_name='lat'), namespace_)) 

3268 if self.long is not None: 

3269 showIndent(outfile, level) 

3270 outfile.write('<%slong>%s</%slong>\n' % (namespace_, self.gds_format_float(self.long, input_name='long'), namespace_)) 

3271 if self.alt is not None: 

3272 showIndent(outfile, level) 

3273 outfile.write('<%salt>%s</%salt>\n' % (namespace_, self.gds_format_float(self.alt, input_name='alt'), namespace_)) 

3274 def hasContent_(self): 

3275 if ( 

3276 self.lat is not None or 

3277 self.long is not None or 

3278 self.alt is not None 

3279 ): 

3280 return True 

3281 else: 

3282 return False 

3283 def exportLiteral(self, outfile, level, name_='Point'): 

3284 level += 1 

3285 self.exportLiteralAttributes(outfile, level, [], name_) 

3286 if self.hasContent_(): 

3287 self.exportLiteralChildren(outfile, level, name_) 

3288 def exportLiteralAttributes(self, outfile, level, already_processed, name_): 

3289 if self.geodetic_datum is not None and 'geodetic_datum' not in already_processed: 

3290 already_processed.append('geodetic_datum') 

3291 showIndent(outfile, level) 

3292 outfile.write('geodetic_datum = "%s",\n' % (self.geodetic_datum,)) 

3293 if self.alt_unit is not None and 'alt_unit' not in already_processed: 

3294 already_processed.append('alt_unit') 

3295 showIndent(outfile, level) 

3296 outfile.write('alt_unit = "%s",\n' % (self.alt_unit,)) 

3297 def exportLiteralChildren(self, outfile, level, name_): 

3298 if self.lat is not None: 

3299 showIndent(outfile, level) 

3300 outfile.write('lat=%f,\n' % self.lat) 

3301 if self.long is not None: 

3302 showIndent(outfile, level) 

3303 outfile.write('long=%f,\n' % self.long) 

3304 if self.alt is not None: 

3305 showIndent(outfile, level) 

3306 outfile.write('alt=%f,\n' % self.alt) 

3307 def build(self, node): 

3308 self.buildAttributes(node, node.attrib, []) 

3309 for child in node: 

3310 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 

3311 self.buildChildren(child, node, nodeName_) 

3312 def buildAttributes(self, node, attrs, already_processed): 

3313 value = find_attr_value_('geodetic_datum', node) 

3314 if value is not None and 'geodetic_datum' not in already_processed: 

3315 already_processed.append('geodetic_datum') 

3316 self.geodetic_datum = value 

3317 self.geodetic_datum = ' '.join(self.geodetic_datum.split()) 

3318 value = find_attr_value_('alt_unit', node) 

3319 if value is not None and 'alt_unit' not in already_processed: 

3320 already_processed.append('alt_unit') 

3321 self.alt_unit = value 

3322 self.alt_unit = ' '.join(self.alt_unit.split()) 

3323 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 

3324 if nodeName_ == 'lat': 

3325 sval_ = child_.text 

3326 try: 

3327 fval_ = float(sval_) 

3328 except (TypeError, ValueError) as exp: 

3329 raise_parse_error(child_, 'requires float or double: %s' % exp) 

3330 fval_ = self.gds_validate_float(fval_, node, 'lat') 

3331 self.lat = fval_ 

3332 elif nodeName_ == 'long': 

3333 sval_ = child_.text 

3334 try: 

3335 fval_ = float(sval_) 

3336 except (TypeError, ValueError) as exp: 

3337 raise_parse_error(child_, 'requires float or double: %s' % exp) 

3338 fval_ = self.gds_validate_float(fval_, node, 'long') 

3339 self.long = fval_ 

3340 elif nodeName_ == 'alt': 

3341 sval_ = child_.text 

3342 try: 

3343 fval_ = float(sval_) 

3344 except (TypeError, ValueError) as exp: 

3345 raise_parse_error(child_, 'requires float or double: %s' % exp) 

3346 fval_ = self.gds_validate_float(fval_, node, 'alt') 

3347 self.alt = fval_ 

3348# end class Point 

3349 

3350 

3351class Polygon(GeneratedsSuper): 

3352 """A polygon defined by a list of 'Points' (used by element 

3353 'Distribution').""" 

3354 subclass = None 

3355 superclass = None 

3356 def __init__(self, point=None, valueOf_=None): 

3357 if point is None: 

3358 self.point = [] 

3359 else: 

3360 self.point = point 

3361 def factory(*args_, **kwargs_): 

3362 if Polygon.subclass: 

3363 return Polygon.subclass(*args_, **kwargs_) 

3364 else: 

3365 return Polygon(*args_, **kwargs_) 

3366 factory = staticmethod(factory) 

3367 def get_point(self): return self.point 

3368 def set_point(self, point): self.point = point 

3369 def add_point(self, value): self.point.append(value) 

3370 def insert_point(self, index, value): self.point[index] = value 

3371 def export(self, outfile, level, namespace_='phy:', name_='Polygon', namespacedef_=''): 

3372 showIndent(outfile, level) 

3373 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) 

3374 already_processed = [] 

3375 self.exportAttributes(outfile, level, already_processed, namespace_, name_='Polygon') 

3376 if self.hasContent_(): 

3377 outfile.write('>\n') 

3378 self.exportChildren(outfile, level + 1, namespace_, name_) 

3379 showIndent(outfile, level) 

3380 outfile.write('</%s%s>\n' % (namespace_, name_)) 

3381 else: 

3382 outfile.write('/>\n') 

3383 def exportAttributes(self, outfile, level, already_processed, namespace_='phy:', name_='Polygon'): 

3384 pass 

3385 def exportChildren(self, outfile, level, namespace_='phy:', name_='Polygon', fromsubclass_=False): 

3386 for point_ in self.point: 

3387 point_.export(outfile, level, namespace_, name_='point') 

3388 def hasContent_(self): 

3389 if ( 

3390 self.point 

3391 ): 

3392 return True 

3393 else: 

3394 return False 

3395 def exportLiteral(self, outfile, level, name_='Polygon'): 

3396 level += 1 

3397 self.exportLiteralAttributes(outfile, level, [], name_) 

3398 if self.hasContent_(): 

3399 self.exportLiteralChildren(outfile, level, name_) 

3400 def exportLiteralAttributes(self, outfile, level, already_processed, name_): 

3401 pass 

3402 def exportLiteralChildren(self, outfile, level, name_): 

3403 showIndent(outfile, level) 

3404 outfile.write('point=[\n') 

3405 level += 1 

3406 for point_ in self.point: 

3407 showIndent(outfile, level) 

3408 outfile.write('model_.Point(\n') 

3409 point_.exportLiteral(outfile, level, name_='Point') 

3410 showIndent(outfile, level) 

3411 outfile.write('),\n') 

3412 level -= 1 

3413 showIndent(outfile, level) 

3414 outfile.write('],\n') 

3415 def build(self, node): 

3416 self.buildAttributes(node, node.attrib, []) 

3417 for child in node: 

3418 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 

3419 self.buildChildren(child, node, nodeName_) 

3420 def buildAttributes(self, node, attrs, already_processed): 

3421 pass 

3422 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 

3423 if nodeName_ == 'point': 

3424 obj_ = Point.factory() 

3425 obj_.build(child_) 

3426 self.point.append(obj_) 

3427# end class Polygon 

3428 

3429 

3430class Date(GeneratedsSuper): 

3431 """A date associated with a clade/node. Its value can be numerical by 

3432 using the 'value' element and/or free text with the 'desc' 

3433 element' (e.g. 'Silurian'). If a numerical value is used, it is 

3434 recommended to employ the 'unit' attribute to indicate the type 

3435 of the numerical value (e.g. 'mya' for 'million years ago'). The 

3436 elements 'minimum' and 'maximum' are used the indicate a 

3437 range/confidence interval""" 

3438 subclass = None 

3439 superclass = None 

3440 def __init__(self, unit=None, desc=None, value=None, minimum=None, maximum=None, valueOf_=None): 

3441 self.unit = _cast(None, unit) 

3442 self.desc = desc 

3443 self.value = value 

3444 self.minimum = minimum 

3445 self.maximum = maximum 

3446 def factory(*args_, **kwargs_): 

3447 if Date.subclass: 

3448 return Date.subclass(*args_, **kwargs_) 

3449 else: 

3450 return Date(*args_, **kwargs_) 

3451 factory = staticmethod(factory) 

3452 def get_desc(self): return self.desc 

3453 def set_desc(self, desc): self.desc = desc 

3454 def get_value(self): return self.value 

3455 def set_value(self, value): self.value = value 

3456 def get_minimum(self): return self.minimum 

3457 def set_minimum(self, minimum): self.minimum = minimum 

3458 def get_maximum(self): return self.maximum 

3459 def set_maximum(self, maximum): self.maximum = maximum 

3460 def get_unit(self): return self.unit 

3461 def set_unit(self, unit): self.unit = unit 

3462 def export(self, outfile, level, namespace_='phy:', name_='Date', namespacedef_=''): 

3463 showIndent(outfile, level) 

3464 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) 

3465 already_processed = [] 

3466 self.exportAttributes(outfile, level, already_processed, namespace_, name_='Date') 

3467 if self.hasContent_(): 

3468 outfile.write('>\n') 

3469 self.exportChildren(outfile, level + 1, namespace_, name_) 

3470 showIndent(outfile, level) 

3471 outfile.write('</%s%s>\n' % (namespace_, name_)) 

3472 else: 

3473 outfile.write('/>\n') 

3474 def exportAttributes(self, outfile, level, already_processed, namespace_='phy:', name_='Date'): 

3475 if self.unit is not None and 'unit' not in already_processed: 

3476 already_processed.append('unit') 

3477 outfile.write(' unit=%s' % (self.gds_format_string(quote_attrib(self.unit).encode(ExternalEncoding), input_name='unit'), )) 

3478 def exportChildren(self, outfile, level, namespace_='phy:', name_='Date', fromsubclass_=False): 

3479 if self.desc is not None: 

3480 showIndent(outfile, level) 

3481 outfile.write('<%sdesc>%s</%sdesc>\n' % (namespace_, self.gds_format_string(quote_xml(self.desc).encode(ExternalEncoding), input_name='desc'), namespace_)) 

3482 if self.value is not None: 

3483 showIndent(outfile, level) 

3484 outfile.write('<%svalue>%s</%svalue>\n' % (namespace_, self.gds_format_float(self.value, input_name='value'), namespace_)) 

3485 if self.minimum is not None: 

3486 showIndent(outfile, level) 

3487 outfile.write('<%sminimum>%s</%sminimum>\n' % (namespace_, self.gds_format_float(self.minimum, input_name='minimum'), namespace_)) 

3488 if self.maximum is not None: 

3489 showIndent(outfile, level) 

3490 outfile.write('<%smaximum>%s</%smaximum>\n' % (namespace_, self.gds_format_float(self.maximum, input_name='maximum'), namespace_)) 

3491 def hasContent_(self): 

3492 if ( 

3493 self.desc is not None or 

3494 self.value is not None or 

3495 self.minimum is not None or 

3496 self.maximum is not None 

3497 ): 

3498 return True 

3499 else: 

3500 return False 

3501 def exportLiteral(self, outfile, level, name_='Date'): 

3502 level += 1 

3503 self.exportLiteralAttributes(outfile, level, [], name_) 

3504 if self.hasContent_(): 

3505 self.exportLiteralChildren(outfile, level, name_) 

3506 def exportLiteralAttributes(self, outfile, level, already_processed, name_): 

3507 if self.unit is not None and 'unit' not in already_processed: 

3508 already_processed.append('unit') 

3509 showIndent(outfile, level) 

3510 outfile.write('unit = "%s",\n' % (self.unit,)) 

3511 def exportLiteralChildren(self, outfile, level, name_): 

3512 if self.desc is not None: 

3513 showIndent(outfile, level) 

3514 outfile.write('desc=%s,\n' % quote_python(self.desc).encode(ExternalEncoding)) 

3515 if self.value is not None: 

3516 showIndent(outfile, level) 

3517 outfile.write('value=%f,\n' % self.value) 

3518 if self.minimum is not None: 

3519 showIndent(outfile, level) 

3520 outfile.write('minimum=%f,\n' % self.minimum) 

3521 if self.maximum is not None: 

3522 showIndent(outfile, level) 

3523 outfile.write('maximum=%f,\n' % self.maximum) 

3524 def build(self, node): 

3525 self.buildAttributes(node, node.attrib, []) 

3526 for child in node: 

3527 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 

3528 self.buildChildren(child, node, nodeName_) 

3529 def buildAttributes(self, node, attrs, already_processed): 

3530 value = find_attr_value_('unit', node) 

3531 if value is not None and 'unit' not in already_processed: 

3532 already_processed.append('unit') 

3533 self.unit = value 

3534 self.unit = ' '.join(self.unit.split()) 

3535 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 

3536 if nodeName_ == 'desc': 

3537 desc_ = child_.text 

3538 desc_ = re_.sub(STRING_CLEANUP_PAT, " ", desc_).strip() 

3539 desc_ = self.gds_validate_string(desc_, node, 'desc') 

3540 self.desc = desc_ 

3541 elif nodeName_ == 'value': 

3542 sval_ = child_.text 

3543 try: 

3544 fval_ = float(sval_) 

3545 except (TypeError, ValueError) as exp: 

3546 raise_parse_error(child_, 'requires float or double: %s' % exp) 

3547 fval_ = self.gds_validate_float(fval_, node, 'value') 

3548 self.value = fval_ 

3549 elif nodeName_ == 'minimum': 

3550 sval_ = child_.text 

3551 try: 

3552 fval_ = float(sval_) 

3553 except (TypeError, ValueError) as exp: 

3554 raise_parse_error(child_, 'requires float or double: %s' % exp) 

3555 fval_ = self.gds_validate_float(fval_, node, 'minimum') 

3556 self.minimum = fval_ 

3557 elif nodeName_ == 'maximum': 

3558 sval_ = child_.text 

3559 try: 

3560 fval_ = float(sval_) 

3561 except (TypeError, ValueError) as exp: 

3562 raise_parse_error(child_, 'requires float or double: %s' % exp) 

3563 fval_ = self.gds_validate_float(fval_, node, 'maximum') 

3564 self.maximum = fval_ 

3565# end class Date 

3566 

3567 

3568class BranchColor(GeneratedsSuper): 

3569 """This indicates the color of a clade when rendered (the color applies 

3570 to the whole clade unless overwritten by the color(s) of sub 

3571 clades).""" 

3572 subclass = None 

3573 superclass = None 

3574 def __init__(self, red=None, green=None, blue=None, valueOf_=None): 

3575 self.red = red 

3576 self.green = green 

3577 self.blue = blue 

3578 def factory(*args_, **kwargs_): 

3579 if BranchColor.subclass: 

3580 return BranchColor.subclass(*args_, **kwargs_) 

3581 else: 

3582 return BranchColor(*args_, **kwargs_) 

3583 factory = staticmethod(factory) 

3584 def get_red(self): return self.red 

3585 def set_red(self, red): self.red = red 

3586 def get_green(self): return self.green 

3587 def set_green(self, green): self.green = green 

3588 def get_blue(self): return self.blue 

3589 def set_blue(self, blue): self.blue = blue 

3590 def export(self, outfile, level, namespace_='phy:', name_='BranchColor', namespacedef_=''): 

3591 showIndent(outfile, level) 

3592 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) 

3593 already_processed = [] 

3594 self.exportAttributes(outfile, level, already_processed, namespace_, name_='BranchColor') 

3595 if self.hasContent_(): 

3596 outfile.write('>\n') 

3597 self.exportChildren(outfile, level + 1, namespace_, name_) 

3598 showIndent(outfile, level) 

3599 outfile.write('</%s%s>\n' % (namespace_, name_)) 

3600 else: 

3601 outfile.write('/>\n') 

3602 def exportAttributes(self, outfile, level, already_processed, namespace_='phy:', name_='BranchColor'): 

3603 pass 

3604 def exportChildren(self, outfile, level, namespace_='phy:', name_='BranchColor', fromsubclass_=False): 

3605 if self.red is not None: 

3606 showIndent(outfile, level) 

3607 outfile.write('<%sred>%s</%sred>\n' % (namespace_, self.gds_format_integer(self.red, input_name='red'), namespace_)) 

3608 if self.green is not None: 

3609 showIndent(outfile, level) 

3610 outfile.write('<%sgreen>%s</%sgreen>\n' % (namespace_, self.gds_format_integer(self.green, input_name='green'), namespace_)) 

3611 if self.blue is not None: 

3612 showIndent(outfile, level) 

3613 outfile.write('<%sblue>%s</%sblue>\n' % (namespace_, self.gds_format_integer(self.blue, input_name='blue'), namespace_)) 

3614 def hasContent_(self): 

3615 if ( 

3616 self.red is not None or 

3617 self.green is not None or 

3618 self.blue is not None 

3619 ): 

3620 return True 

3621 else: 

3622 return False 

3623 def exportLiteral(self, outfile, level, name_='BranchColor'): 

3624 level += 1 

3625 self.exportLiteralAttributes(outfile, level, [], name_) 

3626 if self.hasContent_(): 

3627 self.exportLiteralChildren(outfile, level, name_) 

3628 def exportLiteralAttributes(self, outfile, level, already_processed, name_): 

3629 pass 

3630 def exportLiteralChildren(self, outfile, level, name_): 

3631 if self.red is not None: 

3632 showIndent(outfile, level) 

3633 outfile.write('red=%d,\n' % self.red) 

3634 if self.green is not None: 

3635 showIndent(outfile, level) 

3636 outfile.write('green=%d,\n' % self.green) 

3637 if self.blue is not None: 

3638 showIndent(outfile, level) 

3639 outfile.write('blue=%d,\n' % self.blue) 

3640 def build(self, node): 

3641 self.buildAttributes(node, node.attrib, []) 

3642 for child in node: 

3643 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 

3644 self.buildChildren(child, node, nodeName_) 

3645 def buildAttributes(self, node, attrs, already_processed): 

3646 pass 

3647 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 

3648 if nodeName_ == 'red': 

3649 sval_ = child_.text 

3650 try: 

3651 ival_ = int(sval_) 

3652 except (TypeError, ValueError) as exp: 

3653 raise_parse_error(child_, 'requires integer: %s' % exp) 

3654 ival_ = self.gds_validate_integer(ival_, node, 'red') 

3655 self.red = ival_ 

3656 elif nodeName_ == 'green': 

3657 sval_ = child_.text 

3658 try: 

3659 ival_ = int(sval_) 

3660 except (TypeError, ValueError) as exp: 

3661 raise_parse_error(child_, 'requires integer: %s' % exp) 

3662 ival_ = self.gds_validate_integer(ival_, node, 'green') 

3663 self.green = ival_ 

3664 elif nodeName_ == 'blue': 

3665 sval_ = child_.text 

3666 try: 

3667 ival_ = int(sval_) 

3668 except (TypeError, ValueError) as exp: 

3669 raise_parse_error(child_, 'requires integer: %s' % exp) 

3670 ival_ = self.gds_validate_integer(ival_, node, 'blue') 

3671 self.blue = ival_ 

3672# end class BranchColor 

3673 

3674 

3675class SequenceRelation(GeneratedsSuper): 

3676 """This is used to express a typed relationship between two sequences. 

3677 For example it could be used to describe an orthology (in which 

3678 case attribute 'type' is 'orthology').""" 

3679 subclass = None 

3680 superclass = None 

3681 def __init__(self, id_ref_0=None, id_ref_1=None, type_=None, distance=None, confidence=None, valueOf_=None): 

3682 self.id_ref_0 = _cast(None, id_ref_0) 

3683 self.id_ref_1 = _cast(None, id_ref_1) 

3684 self.type_ = _cast(None, type_) 

3685 self.distance = _cast(float, distance) 

3686 self.confidence = confidence 

3687 def factory(*args_, **kwargs_): 

3688 if SequenceRelation.subclass: 

3689 return SequenceRelation.subclass(*args_, **kwargs_) 

3690 else: 

3691 return SequenceRelation(*args_, **kwargs_) 

3692 factory = staticmethod(factory) 

3693 def get_confidence(self): return self.confidence 

3694 def set_confidence(self, confidence): self.confidence = confidence 

3695 def get_id_ref_0(self): return self.id_ref_0 

3696 def set_id_ref_0(self, id_ref_0): self.id_ref_0 = id_ref_0 

3697 def get_id_ref_1(self): return self.id_ref_1 

3698 def set_id_ref_1(self, id_ref_1): self.id_ref_1 = id_ref_1 

3699 def get_type(self): return self.type_ 

3700 def set_type(self, type_): self.type_ = type_ 

3701 def get_distance(self): return self.distance 

3702 def set_distance(self, distance): self.distance = distance 

3703 def export(self, outfile, level, namespace_='phy:', name_='SequenceRelation', namespacedef_=''): 

3704 showIndent(outfile, level) 

3705 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) 

3706 already_processed = [] 

3707 self.exportAttributes(outfile, level, already_processed, namespace_, name_='SequenceRelation') 

3708 if self.hasContent_(): 

3709 outfile.write('>\n') 

3710 self.exportChildren(outfile, level + 1, namespace_, name_) 

3711 showIndent(outfile, level) 

3712 outfile.write('</%s%s>\n' % (namespace_, name_)) 

3713 else: 

3714 outfile.write('/>\n') 

3715 def exportAttributes(self, outfile, level, already_processed, namespace_='phy:', name_='SequenceRelation'): 

3716 if self.id_ref_0 is not None and 'id_ref_0' not in already_processed: 

3717 already_processed.append('id_ref_0') 

3718 outfile.write(' id_ref_0=%s' % (quote_attrib(self.id_ref_0), )) 

3719 if self.id_ref_1 is not None and 'id_ref_1' not in already_processed: 

3720 already_processed.append('id_ref_1') 

3721 outfile.write(' id_ref_1=%s' % (quote_attrib(self.id_ref_1), )) 

3722 if self.type_ is not None and 'type_' not in already_processed: 

3723 already_processed.append('type_') 

3724 outfile.write(' type=%s' % (quote_attrib(self.type_), )) 

3725 if self.distance is not None and 'distance' not in already_processed: 

3726 already_processed.append('distance') 

3727 outfile.write(' distance="%s"' % self.gds_format_double(self.distance, input_name='distance')) 

3728 def exportChildren(self, outfile, level, namespace_='phy:', name_='SequenceRelation', fromsubclass_=False): 

3729 if self.confidence: 

3730 self.confidence.export(outfile, level, namespace_, name_='confidence') 

3731 def hasContent_(self): 

3732 if ( 

3733 self.confidence is not None 

3734 ): 

3735 return True 

3736 else: 

3737 return False 

3738 def exportLiteral(self, outfile, level, name_='SequenceRelation'): 

3739 level += 1 

3740 self.exportLiteralAttributes(outfile, level, [], name_) 

3741 if self.hasContent_(): 

3742 self.exportLiteralChildren(outfile, level, name_) 

3743 def exportLiteralAttributes(self, outfile, level, already_processed, name_): 

3744 if self.id_ref_0 is not None and 'id_ref_0' not in already_processed: 

3745 already_processed.append('id_ref_0') 

3746 showIndent(outfile, level) 

3747 outfile.write('id_ref_0 = %s,\n' % (self.id_ref_0,)) 

3748 if self.id_ref_1 is not None and 'id_ref_1' not in already_processed: 

3749 already_processed.append('id_ref_1') 

3750 showIndent(outfile, level) 

3751 outfile.write('id_ref_1 = %s,\n' % (self.id_ref_1,)) 

3752 if self.type_ is not None and 'type_' not in already_processed: 

3753 already_processed.append('type_') 

3754 showIndent(outfile, level) 

3755 outfile.write('type_ = %s,\n' % (self.type_,)) 

3756 if self.distance is not None and 'distance' not in already_processed: 

3757 already_processed.append('distance') 

3758 showIndent(outfile, level) 

3759 outfile.write('distance = %e,\n' % (self.distance,)) 

3760 def exportLiteralChildren(self, outfile, level, name_): 

3761 if self.confidence is not None: 

3762 showIndent(outfile, level) 

3763 outfile.write('confidence=model_.Confidence(\n') 

3764 self.confidence.exportLiteral(outfile, level, name_='confidence') 

3765 showIndent(outfile, level) 

3766 outfile.write('),\n') 

3767 def build(self, node): 

3768 self.buildAttributes(node, node.attrib, []) 

3769 for child in node: 

3770 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 

3771 self.buildChildren(child, node, nodeName_) 

3772 def buildAttributes(self, node, attrs, already_processed): 

3773 value = find_attr_value_('id_ref_0', node) 

3774 if value is not None and 'id_ref_0' not in already_processed: 

3775 already_processed.append('id_ref_0') 

3776 self.id_ref_0 = value 

3777 value = find_attr_value_('id_ref_1', node) 

3778 if value is not None and 'id_ref_1' not in already_processed: 

3779 already_processed.append('id_ref_1') 

3780 self.id_ref_1 = value 

3781 value = find_attr_value_('type', node) 

3782 if value is not None and 'type' not in already_processed: 

3783 already_processed.append('type') 

3784 self.type_ = value 

3785 value = find_attr_value_('distance', node) 

3786 if value is not None and 'distance' not in already_processed: 

3787 already_processed.append('distance') 

3788 try: 

3789 self.distance = float(value) 

3790 except ValueError as exp: 

3791 raise ValueError('Bad float/double attribute (distance): %s' % exp) 

3792 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 

3793 if nodeName_ == 'confidence': 

3794 obj_ = Confidence.factory() 

3795 obj_.build(child_) 

3796 self.set_confidence(obj_) 

3797# end class SequenceRelation 

3798 

3799 

3800class CladeRelation(GeneratedsSuper): 

3801 """This is used to express a typed relationship between two clades. For 

3802 example it could be used to describe multiple parents of a 

3803 clade.""" 

3804 subclass = None 

3805 superclass = None 

3806 def __init__(self, id_ref_0=None, id_ref_1=None, type_=None, distance=None, confidence=None, valueOf_=None): 

3807 self.id_ref_0 = _cast(None, id_ref_0) 

3808 self.id_ref_1 = _cast(None, id_ref_1) 

3809 self.type_ = _cast(None, type_) 

3810 self.distance = _cast(float, distance) 

3811 self.confidence = confidence 

3812 def factory(*args_, **kwargs_): 

3813 if CladeRelation.subclass: 

3814 return CladeRelation.subclass(*args_, **kwargs_) 

3815 else: 

3816 return CladeRelation(*args_, **kwargs_) 

3817 factory = staticmethod(factory) 

3818 def get_confidence(self): return self.confidence 

3819 def set_confidence(self, confidence): self.confidence = confidence 

3820 def get_id_ref_0(self): return self.id_ref_0 

3821 def set_id_ref_0(self, id_ref_0): self.id_ref_0 = id_ref_0 

3822 def get_id_ref_1(self): return self.id_ref_1 

3823 def set_id_ref_1(self, id_ref_1): self.id_ref_1 = id_ref_1 

3824 def get_type(self): return self.type_ 

3825 def set_type(self, type_): self.type_ = type_ 

3826 def get_distance(self): return self.distance 

3827 def set_distance(self, distance): self.distance = distance 

3828 def export(self, outfile, level, namespace_='phy:', name_='CladeRelation', namespacedef_=''): 

3829 showIndent(outfile, level) 

3830 outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', )) 

3831 already_processed = [] 

3832 self.exportAttributes(outfile, level, already_processed, namespace_, name_='CladeRelation') 

3833 if self.hasContent_(): 

3834 outfile.write('>\n') 

3835 self.exportChildren(outfile, level + 1, namespace_, name_) 

3836 showIndent(outfile, level) 

3837 outfile.write('</%s%s>\n' % (namespace_, name_)) 

3838 else: 

3839 outfile.write('/>\n') 

3840 def exportAttributes(self, outfile, level, already_processed, namespace_='phy:', name_='CladeRelation'): 

3841 if self.id_ref_0 is not None and 'id_ref_0' not in already_processed: 

3842 already_processed.append('id_ref_0') 

3843 outfile.write(' id_ref_0=%s' % (quote_attrib(self.id_ref_0), )) 

3844 if self.id_ref_1 is not None and 'id_ref_1' not in already_processed: 

3845 already_processed.append('id_ref_1') 

3846 outfile.write(' id_ref_1=%s' % (quote_attrib(self.id_ref_1), )) 

3847 if self.type_ is not None and 'type_' not in already_processed: 

3848 already_processed.append('type_') 

3849 outfile.write(' type=%s' % (self.gds_format_string(quote_attrib(self.type_).encode(ExternalEncoding), input_name='type'), )) 

3850 if self.distance is not None and 'distance' not in already_processed: 

3851 already_processed.append('distance') 

3852 outfile.write(' distance="%s"' % self.gds_format_double(self.distance, input_name='distance')) 

3853 def exportChildren(self, outfile, level, namespace_='phy:', name_='CladeRelation', fromsubclass_=False): 

3854 if self.confidence: 

3855 self.confidence.export(outfile, level, namespace_, name_='confidence') 

3856 def hasContent_(self): 

3857 if ( 

3858 self.confidence is not None 

3859 ): 

3860 return True 

3861 else: 

3862 return False 

3863 def exportLiteral(self, outfile, level, name_='CladeRelation'): 

3864 level += 1 

3865 self.exportLiteralAttributes(outfile, level, [], name_) 

3866 if self.hasContent_(): 

3867 self.exportLiteralChildren(outfile, level, name_) 

3868 def exportLiteralAttributes(self, outfile, level, already_processed, name_): 

3869 if self.id_ref_0 is not None and 'id_ref_0' not in already_processed: 

3870 already_processed.append('id_ref_0') 

3871 showIndent(outfile, level) 

3872 outfile.write('id_ref_0 = %s,\n' % (self.id_ref_0,)) 

3873 if self.id_ref_1 is not None and 'id_ref_1' not in already_processed: 

3874 already_processed.append('id_ref_1') 

3875 showIndent(outfile, level) 

3876 outfile.write('id_ref_1 = %s,\n' % (self.id_ref_1,)) 

3877 if self.type_ is not None and 'type_' not in already_processed: 

3878 already_processed.append('type_') 

3879 showIndent(outfile, level) 

3880 outfile.write('type_ = "%s",\n' % (self.type_,)) 

3881 if self.distance is not None and 'distance' not in already_processed: 

3882 already_processed.append('distance') 

3883 showIndent(outfile, level) 

3884 outfile.write('distance = %e,\n' % (self.distance,)) 

3885 def exportLiteralChildren(self, outfile, level, name_): 

3886 if self.confidence is not None: 

3887 showIndent(outfile, level) 

3888 outfile.write('confidence=model_.Confidence(\n') 

3889 self.confidence.exportLiteral(outfile, level, name_='confidence') 

3890 showIndent(outfile, level) 

3891 outfile.write('),\n') 

3892 def build(self, node): 

3893 self.buildAttributes(node, node.attrib, []) 

3894 for child in node: 

3895 nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] 

3896 self.buildChildren(child, node, nodeName_) 

3897 def buildAttributes(self, node, attrs, already_processed): 

3898 value = find_attr_value_('id_ref_0', node) 

3899 if value is not None and 'id_ref_0' not in already_processed: 

3900 already_processed.append('id_ref_0') 

3901 self.id_ref_0 = value 

3902 value = find_attr_value_('id_ref_1', node) 

3903 if value is not None and 'id_ref_1' not in already_processed: 

3904 already_processed.append('id_ref_1') 

3905 self.id_ref_1 = value 

3906 value = find_attr_value_('type', node) 

3907 if value is not None and 'type' not in already_processed: 

3908 already_processed.append('type') 

3909 self.type_ = value 

3910 self.type_ = ' '.join(self.type_.split()) 

3911 value = find_attr_value_('distance', node) 

3912 if value is not None and 'distance' not in already_processed: 

3913 already_processed.append('distance') 

3914 try: 

3915 self.distance = float(value) 

3916 except ValueError as exp: 

3917 raise ValueError('Bad float/double attribute (distance): %s' % exp) 

3918 def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): 

3919 if nodeName_ == 'confidence': 

3920 obj_ = Confidence.factory() 

3921 obj_.build(child_) 

3922 self.set_confidence(obj_) 

3923# end class CladeRelation 

3924 

3925 

3926USAGE_TEXT = """ 

3927Usage: python <Parser>.py [ -s ] <in_xml_file> 

3928""" 

3929 

3930def usage(): 

3931 print(USAGE_TEXT) 

3932 sys.exit(1) 

3933 

3934 

3935def get_root_tag(node): 

3936 tag = Tag_pattern_.match(node.tag).groups()[-1] 

3937 rootClass = globals().get(tag) 

3938 return tag, rootClass 

3939 

3940 

3941def parse(inFileName): 

3942 doc = parsexml_(inFileName) 

3943 rootNode = doc.getroot() 

3944 rootTag, rootClass = get_root_tag(rootNode) 

3945 if rootClass is None: 

3946 rootTag = 'phyloxml' 

3947 rootClass = Phyloxml 

3948 rootObj = rootClass.factory() 

3949 rootObj.build(rootNode) 

3950 # Enable Python to collect the space used by the DOM. 

3951 doc = None 

3952## sys.stdout.write('<?xml version="1.0" ?>\n') 

3953## rootObj.export(sys.stdout, 0, name_=rootTag, 

3954## namespacedef_='xmlns:phy="http://www.phyloxml.org/1.10/phyloxml.xsd"') 

3955 return rootObj 

3956 

3957 

3958def parseString(inString): 

3959 from StringIO import StringIO 

3960 doc = parsexml_(StringIO(inString)) 

3961 rootNode = doc.getroot() 

3962 rootTag, rootClass = get_root_tag(rootNode) 

3963 if rootClass is None: 

3964 rootTag = 'phyloxml' 

3965 rootClass = Phyloxml 

3966 rootObj = rootClass.factory() 

3967 rootObj.build(rootNode) 

3968 # Enable Python to collect the space used by the DOM. 

3969 doc = None 

3970## sys.stdout.write('<?xml version="1.0" ?>\n') 

3971## rootObj.export(sys.stdout, 0, name_="phyloxml", 

3972## namespacedef_='xmlns:phy="http://www.phyloxml.org/1.10/phyloxml.xsd"') 

3973 return rootObj 

3974 

3975 

3976def parseLiteral(inFileName): 

3977 doc = parsexml_(inFileName) 

3978 rootNode = doc.getroot() 

3979 rootTag, rootClass = get_root_tag(rootNode) 

3980 if rootClass is None: 

3981 rootTag = 'phyloxml' 

3982 rootClass = Phyloxml 

3983 rootObj = rootClass.factory() 

3984 rootObj.build(rootNode) 

3985 # Enable Python to collect the space used by the DOM. 

3986 doc = None 

3987## sys.stdout.write('#from phyloxml import *\n\n') 

3988## sys.stdout.write('import phyloxml as model_\n\n') 

3989## sys.stdout.write('rootObj = model_.rootTag(\n') 

3990## rootObj.exportLiteral(sys.stdout, 0, name_=rootTag) 

3991## sys.stdout.write(')\n') 

3992 return rootObj 

3993 

3994 

3995def main(): 

3996 args = sys.argv[1:] 

3997 if len(args) == 1: 

3998 parse(args[0]) 

3999 else: 

4000 usage() 

4001 

4002 

4003if __name__ == '__main__': 

4004 #import pdb; pdb.set_trace() 

4005 main() 

4006 

4007 

4008__all__ = [ 

4009 "Accession", 

4010 "Annotation", 

4011 "BinaryCharacterList", 

4012 "BinaryCharacters", 

4013 "BranchColor", 

4014 "Clade", 

4015 "CladeRelation", 

4016 "Confidence", 

4017 "Date", 

4018 "Distribution", 

4019 "DomainArchitecture", 

4020 "Events", 

4021 "Id", 

4022 "MolSeq", 

4023 "Phylogeny", 

4024 "Phyloxml", 

4025 "Point", 

4026 "Polygon", 

4027 "Property", 

4028 "ProteinDomain", 

4029 "Reference", 

4030 "Sequence", 

4031 "SequenceRelation", 

4032 "Taxonomy", 

4033 "Uri" 

4034 ]