示例#1
0
 def add_original_metadata(self, key, value):
     '''Create an original data key/value pair
     
     key - the original metadata's key name, for instance OM_PHOTOMETRIC_INTERPRETATION
     
     value - the value, for instance, "RGB"
     
     returns the ID for the structured annotation.
     '''
     dom = get_dom(self.node)
     xml_annotation = dom.createElementNS(NS_SA, "XMLAnnotation")
     self.node.appendChild(xml_annotation)
     node_id = str(uuid.uuid4())
     xml_annotation.setAttribute("ID", node_id)
     xa_value = dom.createElementNS(NS_SA, "Value")
     xml_annotation.appendChild(xa_value)
     ov = dom.createElementNS(NS_ORIGINAL_METADATA, "OriginalMetadata")
     xa_value.appendChild(ov)
     ov_key = dom.createElementNS(NS_ORIGINAL_METADATA, "Key")
     ov.appendChild(ov_key)
     set_text(ov_key, key)
     ov_value = dom.createElementNS(NS_ORIGINAL_METADATA, "Value")
     ov.appendChild(ov_value)
     set_text(ov_value, value)
     return node_id
示例#2
0
def _testElementReprAndStrUnicodeNS():
    dom = Document()
    el = dom.appendChild(
        dom.createElementNS(u"http://www.slashdot.org", u"slash:abc"))
    string1 = repr(el)
    string2 = str(el)
    confirm(string1 == string2)
    confirm(string1.find("slash:abc") != -1)
    dom.unlink()
def _testElementReprAndStrUnicodeNS():
    dom = Document()
    el = dom.appendChild(
        dom.createElementNS(u"http://www.slashdot.org", u"slash:abc"))
    string1 = repr(el)
    string2 = str(el)
    confirm(string1 == string2)
    confirm(string1.find("slash:abc") != -1)
    dom.unlink()
示例#4
0
 def set_AcquiredDate(self, date):
     acquired_dates = self.node.getElementsByTagNameNS(NS_OME, "AcquiredDate")
     if len(acquired_dates) == 0:
         dom = get_dom(self.node)
         acquired_date = dom.createElementNS(NS_OME, "AcquiredDate")
         self.node.appendChild(acquired_date)
     else:
         acquired_date = acquired_dates[0]
     set_text(acquired_date, date)
示例#5
0
def testRemoveAttrNS():
    dom = Document()
    child = dom.appendChild(
        dom.createElementNS("http://www.python.org", "python:abc"))
    child.setAttributeNS("http://www.w3.org", "xmlns:python",
                         "http://www.python.org")
    child.setAttributeNS("http://www.python.org", "python:abcattr", "foo")
    confirm(len(child.attributes) == 2)
    child.removeAttributeNS("http://www.python.org", "abcattr")
    confirm(len(child.attributes) == 1)

    dom.unlink()
def testRemoveAttrNS():
    dom = Document()
    child = dom.appendChild(
            dom.createElementNS("http://www.python.org", "python:abc"))
    child.setAttributeNS("http://www.w3.org", "xmlns:python",
                                            "http://www.python.org")
    child.setAttributeNS("http://www.python.org", "python:abcattr", "foo")
    confirm(len(child.attributes) == 2)
    child.removeAttributeNS("http://www.python.org", "abcattr")
    confirm(len(child.attributes) == 1)

    dom.unlink()
示例#7
0
 def set_plane_count(self, value):
     assert value >= 0
     dom = get_dom(self.node)
     while(self.plane_count > value):
         last = self.node.getElementsByTagNameNS(NS_OME, "Plane")[-1]
         self.node.removeChild(last)
         last.unlink()
     
     while(self.plane_count < value):
         new_plane = OMEXML.Plane(dom.createElementNS(NS_OME, "Plane"))
         if self.plane_count > 0:
             last = self.node.getElementsByTagNameNS(NS_OME, "Plane")[-1]
             insert_after(last, new_plane.node)
         else:
             self.node.appendChild(new_plane.node)
示例#8
0
 def set_channel_count(self, value):
     assert value > 0
     dom = get_dom(self.node)
     while(self.channel_count > value):
         last = self.node.getElementsByTagNameNS(NS_OME, "Channel")[-1]
         self.node.removeChild(last)
         last.unlink()
     
     while(self.channel_count < value):
         last = self.node.getElementsByTagNameNS(NS_OME, "Channel")[-1]
         new_channel = OMEXML.Channel(dom.createElementNS(NS_OME, "Channel"))
         insert_after(last, new_channel.node)
         new_channel.ID = str(uuid.uuid4())
         new_channel.Name = new_channel.ID
         new_channel.SamplesPerPixel = 1
示例#9
0
 def new(self, row, column, well_id = str(uuid.uuid4())):
     '''Create a new well at the given row and column
     
     row - index of well's row
     column - index of well's column
     well_id - the ID attribute for the well
     '''
     dom = get_dom(self.plate_node)
     well_node = dom.createElementNS(NS_SPW, "Well")
     self.plate_node.appendChild(well_node)
     well = OMEXML.Well(well_node)
     well.Row = row
     well.Column = column
     well.ID = well_id
     return well