def test_sequence_conversion(self): pseq = PX.Sequence( type="protein", # id_ref=None, # id_source=None, symbol="ADHX", accession=PX.Accession("P81431", source="UniProtKB"), name="Alcohol dehydrogenase class-3", # location=None, mol_seq=PX.MolSeq( "TDATGKPIKCMAAIAWEAKKPLSIEEVEVAPPKSGEVRIKILHSGVCHTD"), uri=None, annotations=[ PX.Annotation(ref="EC:1.1.1.1"), PX.Annotation(ref="GO:0004022") ], domain_architecture=PX.DomainArchitecture( length=50, domains=[ PX.ProteinDomain(*args) for args in ( # value, start, end, confidence ("FOO", 0, 5, 7.0e-26), ("BAR", 8, 13, 7.2e-117), ("A-OK", 21, 34, 2.4e-06), ("WD40", 40, 50, 0.3)) ], )) srec = pseq.to_seqrecord() # TODO: check seqrec-specific traits (see args) # Seq(letters, alphabet), id, name, description, features pseq2 = PX.Sequence.from_seqrecord(srec)
def test_sequence_conversion(self): pseq = PX.Sequence( type='protein', # id_ref=None, # id_source=None, symbol='ADHX', accession=PX.Accession('P81431', source='UniProtKB'), name='Alcohol dehydrogenase class-3', # location=None, mol_seq=PX.MolSeq( 'TDATGKPIKCMAAIAWEAKKPLSIEEVEVAPPKSGEVRIKILHSGVCHTD'), uri=None, annotations=[ PX.Annotation(ref='EC:1.1.1.1'), PX.Annotation(ref='GO:0004022') ], domain_architecture=PX.DomainArchitecture( length=50, domains=[ PX.ProteinDomain(*args) for args in ( # value, start, end, confidence ('FOO', 0, 5, 7.0e-26), ('BAR', 8, 13, 7.2e-117), ('A-OK', 21, 34, 2.4e-06), ('WD40', 40, 50, 0.3)) ], )) srec = pseq.to_seqrecord() # TODO: check seqrec-specific traits (see args) # Seq(letters, alphabet), id, name, description, features pseq2 = PX.Sequence.from_seqrecord(srec)
def annotation(self, elem): return PX.Annotation( desc=_collapse_wspace(_get_child_text(elem, 'desc')), confidence=_get_child_as(elem, 'confidence', self.confidence), properties=_get_children_as(elem, 'property', self.property), uri=_get_child_as(elem, 'uri', self.uri), **elem.attrib)
def annotation(self, elem): """Create annotation object.""" return PX.Annotation( desc=_collapse_wspace(_get_child_text(elem, "desc")), confidence=_get_child_as(elem, "confidence", self.confidence), properties=_get_children_as(elem, "property", self.property), uri=_get_child_as(elem, "uri", self.uri), **elem.attrib)
def main(): ##################### get parser ############################### parser = get_parser() ######## Print parser help if arguments missed ################# if len(sys.argv) == 1: parser.print_help() sys.exit(1) ########### Manage workflow accorded to Args ################## Arguments = parser.parse_args() # parser = etree.XMLParser(remove_blank_text=True) # xmlfile = Arguments.xml # tree = etree.ElementTree() # tree =etree.parse(xmlfile,parser) # print tree # root = tree.getroot() # print root # test = root.xpath("phylogeny") # print test # for var in test : # toto = var.findall("clade")[0] # print toto.text # print var tree = Phylo.read("jpp2.xml", 'phyloxml') for clade in tree.find_clades(name=True): clade.other = [ PhyloXML.Other(tag="annotation", namespace="", children=[ PhyloXML.Other('desc', value='youpi'), PhyloXML.Other('uri', value='http://lol.com') ]) ] clade.annotation = PhyloXML.Annotation(desc="youpi", uri="http://lol.com") Phylo.write(tree, "jpp.xml", 'phyloxml')