Class GPML2013aWriter

All Implemented Interfaces:
GPMLFormatVersion, GPMLFormatWriter

public class GPML2013aWriter
extends GPML2013aFormatAbstract
implements GPMLFormatWriter
This class writes a PathwayModel to an output (GPML 2013a).

NB:

  1. If writing (converting) GPML2021 to GPML2013a, warning messages are thrown.
  2. In the GUI, export allows writing to the GPML2013a format.
Author:
finterly
  • Field Details

  • Constructor Details

    • GPML2013aWriter

      protected GPML2013aWriter​(java.lang.String xsdFile, org.jdom2.Namespace nsGPML)
      Constructor for GPML2013aWriter.
      Parameters:
      xsdFile - the GPML schema file.
      nsGPML - the GPML namespace.
  • Method Details

    • writeToXml

      public void writeToXml​(PathwayModel pathwayModel, java.io.OutputStream output, boolean validate) throws ConverterException
      Writes the JDOM Document document to the outputstream specified.
      Specified by:
      writeToXml in interface GPMLFormatWriter
      Parameters:
      pathwayModel - the pathway model.
      output - the outputstream to which the JDOM document should be written
      validate - if true, validate the dom structure before writing. If there is a validation error, or the xsd is not in the classpath, an exception will be thrown.
      Throws:
      ConverterException
    • writeToXml

      public void writeToXml​(PathwayModel pathwayModel, java.io.File file, boolean validate) throws ConverterException
      Writes the JDOM document to the file specified.
      Specified by:
      writeToXml in interface GPMLFormatWriter
      Parameters:
      pathwayModel - the pathway model.
      file - the file to which the JDOM document should be saved.
      validate - if true, validate the dom structure before writing to file.
      Throws:
      ConverterException
    • createJdom

      public org.jdom2.Document createJdom​(PathwayModel pathwayModel) throws ConverterException
      Creates and returns the JDOM document Document written from given pathwayModel PathwayModel data.
      Specified by:
      createJdom in interface GPMLFormatWriter
      Parameters:
      pathwayModel - the pathway model to be written.
      Returns:
      Throws:
      ConverterException
    • writePathwayInfo

      protected void writePathwayInfo​(PathwayModel pathwayModel, org.jdom2.Element root) throws ConverterException
      Writes pathway object Pathway information to root element.
      Parameters:
      pathwayModel - the pathway model.
      root - the root element.
      Throws:
      ConverterException
    • writeXref

      protected void writeXref​(org.bridgedb.Xref xref, org.jdom2.Element e, boolean required) throws ConverterException
      Writes xref Xref information to new element. In GPML2013a, Xref is required for DataNodes, Interactions, and optional for States.
      Parameters:
      xref - the xref of the pathway or pathway element.
      e - the parent element.
      required - if true, xref is a required property.
      Throws:
      ConverterException
    • writeComments

      protected void writeComments​(java.util.List<PathwayElement.Comment> comments, org.jdom2.Element e) throws ConverterException
      Writes comments PathwayElement.Comment information for pathway or pathway element.
      Parameters:
      comments - the list of comments of pathway or pathway element.
      e - the parent element.
      Throws:
      ConverterException
    • writeBiopaxRefs

      protected void writeBiopaxRefs​(java.util.List<PathwayElement.CitationRef> citationRefs, org.jdom2.Element e) throws ConverterException
      Writes BiopaxRef information from PathwayElement.getCitationRefs() for pathway or pathway element. BiopaxRefs are equivalent to citationRefs in GPML2013a.
      Parameters:
      citationRefs - the list of citation references.
      e - the parent element.
      Throws:
      ConverterException
    • writePathwayDynamicProperties

      protected void writePathwayDynamicProperties​(Pathway pathway, org.jdom2.Element root) throws ConverterException
      Writes dynamic property information for pathway or pathway element. PathwayElement.getDynamicProperty(java.lang.String).
      Parameters:
      pathway - the pathway.
      root - the jdom root element.
      Throws:
      ConverterException
    • writeDataNodes

      protected void writeDataNodes​(java.util.List<DataNode> dataNodes, org.jdom2.Element root) throws ConverterException
      Writes datanode DataNode information.
      Parameters:
      dataNodes - the list of datanodes.
      root - the root element.
      Throws:
      ConverterException
    • writeStates

      protected void writeStates​(java.util.List<DataNode> dataNodes, org.jdom2.Element root) throws ConverterException
      Writes state DataNode.State information.
      Parameters:
      dataNodes - the parent dataNode.
      root - the root element.
      Throws:
      ConverterException
    • convertStateRefToComments

      protected void convertStateRefToComments​(DataNode.State state, org.jdom2.Element st) throws ConverterException
      This method handles converting DataNode.State phosphosite PathwayElement.AnnotationRef and Xref information back to PathwayElement.Comment for writing to GPML2013a. NB: "ptm" and "direction" are specially handled.
      Parameters:
      state -
      st -
      Throws:
      ConverterException
    • writeInteractions

      protected void writeInteractions​(java.util.List<Interaction> interactions, org.jdom2.Element root) throws ConverterException
      Writes interaction Interaction information.
      Parameters:
      interactions - the list of interactions.
      root - the root element;
      Throws:
      ConverterException
    • writeGraphicalLines

      protected void writeGraphicalLines​(java.util.List<GraphicalLine> graphicalLines, org.jdom2.Element root) throws ConverterException
      Writes graphical line GraphicalLine information.
      Parameters:
      graphicalLines - the list of graphical lines.
      root - the root element.
      Throws:
      ConverterException
    • writeLineElement

      protected void writeLineElement​(LineElement lineElement, org.jdom2.Element ln) throws ConverterException
      Writes line element LineElement information for interactions or graphicalLines.
      Parameters:
      lineElement - the interaction or graphicalLine.
      ln - the line element.
      Throws:
      ConverterException
    • writePoints

      protected void writePoints​(LineElement lineElement, org.jdom2.Element gfx) throws ConverterException
      Writes point LineElement.LinePoint information.
      Parameters:
      lineElement - the line element.
      gfx - the parent graphics element.
      Throws:
      ConverterException
    • writeArrowHeadType

      protected void writeArrowHeadType​(ArrowHeadType arrowHead, java.lang.String base, org.jdom2.Element pt) throws ConverterException
      Writes the arrowHead for point jdom element. // TODO arrowhead sub types Handling?
      Parameters:
      arrowHead - the arrow head.
      base - the string for either "Interaction" or "GraphicalLine"
      pt - the point jdom element to write to.
      Throws:
      ConverterException
    • writeAnchors

      protected void writeAnchors​(java.util.List<LineElement.Anchor> anchors, org.jdom2.Element gfx) throws ConverterException
      Writes anchor LineElement.Anchor information.
      Parameters:
      anchors - the list of anchors.
      gfx - the jdom graphics element.
      Throws:
      ConverterException
    • writeLabels

      protected void writeLabels​(java.util.List<Label> labels, org.jdom2.Element root) throws ConverterException
      Writes label Label information.
      Parameters:
      labels - the list of labels.
      root - the root element.
      Throws:
      ConverterException
    • writeShapes

      protected void writeShapes​(java.util.List<Shape> shapes, org.jdom2.Element root) throws ConverterException
      Writes shape Shape information.
      Parameters:
      shapes - the list of shapes.
      root - the root element.
      Throws:
      ConverterException
    • writeGroups

      protected void writeGroups​(java.util.List<Group> groups, org.jdom2.Element root) throws ConverterException
      Writes group Group information.

      NB:

      1. In GPML2013a, group has default font properties and shape style properties which are not written to the gpml.
      2. Group type "Group" (GPML2021) is written as "None" (GPML2013a).
      3. Group type "Transparent" (GPML2021) is written as "Group" (GPML2013a).
      Parameters:
      groups - the list of groups.
      root - the root element.
      Throws:
      ConverterException
    • writeInfoBox

      protected void writeInfoBox​(Pathway pathway, org.jdom2.Element root)
      Writes the infobox x and y coordinate information.
      Parameters:
      pathway - the pathway.
      root - the root element.
    • writeLegend

      protected void writeLegend​(Pathway pathway, org.jdom2.Element root)
      Writes the legend x and y coordinate information.
      Parameters:
      pathway - the pathway.
      root - the root element.
    • writeBiopax

      protected void writeBiopax​(PathwayModel pathwayModel, org.jdom2.Element root) throws ConverterException
      Parameters:
      pathwayModel - the pathway model.
      root - the root element.
      Throws:
      ConverterException
    • writeOpenControlledVocabulary

      protected void writeOpenControlledVocabulary​(PathwayModel pathwayModel, org.jdom2.Element bp) throws ConverterException
      Writes gpml:Biopax bp:OpenControlledVocabulary Annotation information. Because it is not possible to write PathwayElement.AnnotationRef for PathwayObject in GPML2013a, the State annotationRef information is written as PathwayElement.Comment in convertStateRefToComments(org.pathvisio.libgpml.model.DataNode.State, org.jdom2.Element). We avoid writing annotation information if it is for a state annotationRef/comment since it cannot be properly linked to a state pathway element and is duplicate information.
      Parameters:
      pathwayModel - the pathway model.
      bp - the jdom biopax element.
      Throws:
      ConverterException
    • writePublicationXref

      protected void writePublicationXref​(java.util.List<Citation> citations, org.jdom2.Element bp) throws ConverterException
      Writes gpml:Biopax bp:PublicationXref Citation information.
      Parameters:
      citations - the list of citations.
      bp - the jdom biopax element.
      Throws:
      ConverterException
    • writePublicationXrefInfo

      protected void writePublicationXrefInfo​(java.lang.String propertyValue, java.lang.String elementName, org.jdom2.Element pubxf) throws ConverterException
      Writes Biopax PublicationXref information to PublicationXref element. NB: The main purpose of this method is to make writePublicationXref(java.util.List<org.pathvisio.libgpml.model.Citation>, org.jdom2.Element) more concise. If property value is null, writes "".
      Parameters:
      propertyValue - the value of the property.
      elementName - the name for new child element of pubxf element.
      pubxf - the PublicationXref element.
      Throws:
      ConverterException
    • writeElementId

      protected void writeElementId​(java.lang.String elementId, org.jdom2.Element e)
      Writes elementId PathwayObject property information.
      Parameters:
      elementId - the elementId.
      e - the parent element.
    • writeGroupRef

      protected void writeGroupRef​(Group groupRef, org.jdom2.Element e)
      Writes groupRef property information. Group stores GroupId as its elementId.
      Parameters:
      groupRef - the groupRef.
      e - the parent element.
    • writePointElementRef

      protected boolean writePointElementRef​(GraphLink.LinkableTo elementRef, org.jdom2.Element pt)
      Writes point elementRef property information as GraphRef. This method is used only by writePoints(org.pathvisio.libgpml.model.LineElement, org.jdom2.Element)
      Parameters:
      elementRef - the pathway element point refers to. .
      pt - the jdom point element.
      Returns:
      true if elementRef exists and is successfully written.
    • writeShapedElement

      protected void writeShapedElement​(ShapedElement shapedElement, org.jdom2.Element se) throws ConverterException
      Writes shapedElement ShapedElement information for datanodes, labels, shapes, or groups.
      Parameters:
      shapedElement - the datanode, label, shape, or group.
      se - the shape element.
      Throws:
      ConverterException
    • writeElementInfo

      protected void writeElementInfo​(PathwayElement elementInfo, org.jdom2.Element e) throws ConverterException
      Writes elementId, comment group {comment, dynamic property, annotationRef, citationRef) and evidenceRef PathwayElement information for datanodes, interactions, graphicalLines, labels, shapes, and group. NB: writing of dynamic properties (gpml:Attribute) requires special handling of DoubleLineProperty and CellularComponentProperty for shaped, state, or line pathway elements. writeLineDynamicProperties(java.util.Map<java.lang.String, java.lang.String>, org.pathvisio.libgpml.model.LineElement, org.jdom2.Element) , writeShapedOrStateDynamicProperties(java.util.Map<java.lang.String, java.lang.String>, org.pathvisio.libgpml.model.ShapedElement, org.jdom2.Element)
      Parameters:
      elementInfo - the pathway element.
      e - the parent element.
      Throws:
      ConverterException
    • writeShapedOrStateDynamicProperties

      protected void writeShapedOrStateDynamicProperties​(java.util.Map<java.lang.String,​java.lang.String> dynamicProperties, ShapedElement shapedElement, org.jdom2.Element se) throws ConverterException
      Writes dynamic property information for ShapedElement or DataNode.State pathway element. In GPML2013a, cellular component shapeTypes and double lineStyle information are written to dynamic properties because they were not yet defined in the GPML2013a schema/enum classes.
      Parameters:
      dynamicProperties - the list of dynamic properties.
      shapedElement - the shaped pathway element.
      se - the jdom shaped pathway element element.
      Throws:
      ConverterException
    • writeLineDynamicProperties

      protected void writeLineDynamicProperties​(java.util.Map<java.lang.String,​java.lang.String> dynamicProperties, LineElement lineElement, org.jdom2.Element ln) throws ConverterException
      Writes dynamic property information for LineElement. In GPML2013a, double lineStyle information is written to dynamic properties because it was not yet defined in the GPML2013a schema/enum classes.
      Parameters:
      dynamicProperties - the list of dynamic properties.
      lineElement - the line pathway element.
      ln - the jdom line pathway element element.
      Throws:
      ConverterException
    • writeRectProperty

      protected void writeRectProperty​(ShapedElement shapedElement, org.jdom2.Element gfx) throws ConverterException
      Writes rect property information.
      Parameters:
      shapedElement - the shaped pathway element.
      gfx - the parent graphics element.
      Throws:
      ConverterException
    • writeColor

      protected void writeColor​(ShapedElement shapedElement, org.jdom2.Element gfx) throws ConverterException
      Writes color property information for shaped pathway elements. This method is not used by line pathway elements. NB: In GPML2013a, there is only color (textColor and borderColor are the same color unless shapeType is "None" in which case there is no border). Color is written separately to preserve the original order of properties in GPML2013a.
      Parameters:
      shapedElement - the shaped pathway element.
      gfx - the parent graphics element.
      Throws:
      ConverterException
    • writeFontProperty

      protected void writeFontProperty​(ShapedElement shapedElement, org.jdom2.Element gfx) throws ConverterException
      Writes font property information, except color.
      Parameters:
      shapedElement - the shaped pathway element.
      gfx - the parent graphics element.
      Throws:
      ConverterException
    • writeShapeStyleProperty

      protected void writeShapeStyleProperty​(ShapedElement shapedElement, org.jdom2.Element gfx) throws ConverterException
      Writes shape style property information, except borderColor, zOrder, and fillColor. These properties are written separately to preserve the original order of properties in GPML2013a. NB: borderColor is not set, Color is set solely by textColor. zOrder and fillColor are written separately to preserve the order of properties in GPML2013a.
      Parameters:
      shapedElement - the shaped pathway element.
      gfx - the parent graphics element.
      Throws:
      ConverterException
    • writeLineStyleProperty

      protected void writeLineStyleProperty​(LineElement lineElement, org.jdom2.Element gfx) throws ConverterException
      Writes line style property information.
      Parameters:
      lineElement - the line pathway element.
      gfx - the parent graphics element.
      Throws:
      ConverterException