def test_RDFAnnotation_testMissingAbout(self): withAbout = wrapString( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + " <annotation>\n" + " <rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:dcterms=\"http://purl.org/dc/terms/\" xmlns:vCard=\"http://www.w3.org/2001/vcard-rdf/3.0#\" xmlns:bqbiol=\"http://biomodels.net/biology-qualifiers/\" xmlns:bqmodel=\"http://biomodels.net/model-qualifiers/\">\n" + " <rdf:Description rdf:about=\"#_000004\">\n" + " <bqbiol:is>\n" + " <rdf:Bag>\n" + " <rdf:li rdf:resource=\"http://www.geneontology.org/#GO:0007274\"/>\n" + " </rdf:Bag>\n" + " </bqbiol:is>\n" + " </rdf:Description>\n" + " </rdf:RDF>\n" + " </annotation>") emptyAbout = wrapString( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + " <annotation>\n" + " <rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:dcterms=\"http://purl.org/dc/terms/\" xmlns:vCard=\"http://www.w3.org/2001/vcard-rdf/3.0#\" xmlns:bqbiol=\"http://biomodels.net/biology-qualifiers/\" xmlns:bqmodel=\"http://biomodels.net/model-qualifiers/\">\n" + " <rdf:Description rdf:about=\"\">\n" + " <bqbiol:is>\n" + " <rdf:Bag>\n" + " <rdf:li rdf:resource=\"http://www.geneontology.org/#GO:0007274\"/>\n" + " </rdf:Bag>\n" + " </bqbiol:is>\n" + " </rdf:Description>\n" + " </rdf:RDF>\n" + " </annotation>") noAbout = wrapString( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + " <annotation>\n" + " <rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:dcterms=\"http://purl.org/dc/terms/\" xmlns:vCard=\"http://www.w3.org/2001/vcard-rdf/3.0#\" xmlns:bqbiol=\"http://biomodels.net/biology-qualifiers/\" xmlns:bqmodel=\"http://biomodels.net/model-qualifiers/\">\n" + " <rdf:Description>\n" + " <bqbiol:is>\n" + " <rdf:Bag>\n" + " <rdf:li rdf:resource=\"http://www.geneontology.org/#GO:0007274\"/>\n" + " </rdf:Bag>\n" + " </bqbiol:is>\n" + " </rdf:Description>\n" + " </rdf:RDF>\n" + " </annotation>") cvTerms = libsbml.CVTermList() stream = libsbml.XMLInputStream(withAbout, False) node = libsbml.XMLNode(stream) libsbml.RDFAnnotationParser.parseRDFAnnotation(node, cvTerms) self.assert_(cvTerms.getSize() == 1) cvTerms = None cvTerms = libsbml.CVTermList() libsbml.RDFAnnotationParser.parseRDFAnnotation(node, cvTerms) self.assert_(cvTerms.getSize() == 1) cvTerms = None cvTerms = None cvTerms = libsbml.CVTermList() stream1 = libsbml.XMLInputStream(emptyAbout, False) node1 = libsbml.XMLNode(stream1) libsbml.RDFAnnotationParser.parseRDFAnnotation(node1, cvTerms) self.assert_(cvTerms.getSize() == 0) cvTerms = None cvTerms = None cvTerms = libsbml.CVTermList() stream2 = libsbml.XMLInputStream(noAbout, False) node2 = libsbml.XMLNode(stream2) libsbml.RDFAnnotationParser.parseRDFAnnotation(node2, cvTerms) self.assert_(cvTerms.getSize() == 0) cvTerms = None cvTerms = None pass
def test_sbase_has_read(self): compartment = libsbml.Compartment(3, 1) assert compartment is not None stream = libsbml.XMLInputStream( """<?xml version="1.0" encoding="utf-8"?> <compartment id="vol1" name="compartment 1" size="2.0" />""", False) compartment.read(stream) assert compartment.id == 'vol1' assert compartment.name == 'compartment 1' assert compartment.volume == 2.0
def test_read_stylesheet_24(self): info = libsbml.LocalRenderInformation(2, 4) stream = libsbml.XMLInputStream(STYLE_SHEET, True) info.read(stream) assert info.id == 'SBGN_default' line = info.getLineEnding('inhibitor') assert isinstance(line, libsbml.LineEnding) assert line.id == 'inhibitor' group = line.getGroup() assert isinstance(group, libsbml.RenderGroup) assert group.stroke == 'black' assert group.fill == 'black' assert group.stroke_width == 0.1 assert group.getNumElements() > 0 p = group.getElement(0) assert isinstance(p, libsbml.Polygon) for elt in p.getListOfElements(): assert (isinstance(elt, libsbml.RenderPoint))
def test_downcast_polygon(self): group = libsbml.RenderGroup(3, 1) stream = libsbml.XMLInputStream( """<?xml version="1.0" encoding="utf-8"?> <g stroke="black" stroke-width="0.1" fill="black"> <polygon> <listOfElements> <element xsi:type="RenderPoint" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" x="0.0" y="0.0"/> <element xsi:type="RenderPoint" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" x="0.3" y="0.0"/> <element xsi:type="RenderPoint" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" x="0.3" y="8.0"/> <element xsi:type="RenderPoint" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" x="0.0" y="8.0"/> </listOfElements> </polygon> </g> """, False) group.read(stream) assert group.stroke == 'black' assert group.fill == 'black' assert group.stroke_width == 0.1 assert group.getNumElements() > 0 p = group.getElement(0) assert isinstance(p, libsbml.Polygon) for elt in p.getListOfElements(): assert (isinstance(elt, libsbml.RenderPoint))
import libsbml info = libsbml.LocalRenderInformation() #stream = libsbml.XMLInputStream("/Development/sbwBuild/source/SBMLLayout/SBMLExtension/SBGNstyles.xml") stream = libsbml.XMLInputStream("SBGNstyles.xml") info.read(stream) print("lri: ", info.getLevel(), info.getVersion()) les = info.getListOfLineEndings() print("les: ", type(les), len(les)) for le in les: if le.getId() == "product": element = le.getGroup().getElement(0) if element.getElementName() == "polygon": print("list of elements: ", len(element.getListOfElements()))