Class GPML2021Writer

All Implemented Interfaces:
GPMLFormatVersion, GPMLFormatWriter

public class GPML2021Writer
extends GPML2021FormatAbstract
implements GPMLFormatWriter
This class writes a PathwayModel to an output (GPML 2021).

NB:

  1. GPML2021 is the current gpml format.
  2. In the GUI, Pathways are saved/written in the GPML2021 format.
Author:
finterly
  • Field Details

  • Constructor Details

    • GPML2021Writer

      protected GPML2021Writer​(java.lang.String xsdFile, org.jdom2.Namespace nsGPML)
      Constructor for GPML writer.
      Parameters:
      xsdFile - the 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 and authors list 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)
      Writes xref Xref information to new element. Xref is required for Evidences. Xref is optional for the Pathway, DataNodes, States, Interactions, Groups, and Annotations. For Citations, either Xref and/or Url are required.
      Parameters:
      xref - the xref of the pathway or pathway element.
      e - the parent element.
      required - if true, xref is a required property.
    • writeUrl

      protected void writeUrl​(java.lang.String urlLink, org.jdom2.Element e)
      Writes url link information to new element. Url is optional for Annotations and Evidences. For Citations, either Xref and/or Url are required.
      Parameters:
      urlLink - the url link.
      e - the jdom element.
    • writeAuthors

      protected void writeAuthors​(java.util.List<Pathway.Author> authors, org.jdom2.Element root) throws ConverterException
      Writes author Pathway.Author information.
      Parameters:
      authors - the list of authors.
      root - the root element.
      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
    • writeDynamicProperties

      protected void writeDynamicProperties​(java.util.Map<java.lang.String,​java.lang.String> dynamicProperties, org.jdom2.Element e) throws ConverterException
      Writes dynamic property information for pathway or pathway element. PathwayElement.getDynamicProperty(java.lang.String)
      Parameters:
      dynamicProperties - the list of dynamic properties.
      e - the parent element.
      Throws:
      ConverterException
    • writeAnnotationRefs

      protected void writeAnnotationRefs​(java.util.List<PathwayElement.AnnotationRef> annotationRefs, org.jdom2.Element e) throws ConverterException
      Writes annotation reference information for pathway or pathway element. , ElementInfo#getAnnotationRefs. In GPML2021, annotationRef can have citationRefs and/or evidenceRefs nested inside.
      Parameters:
      annotationRefs - the list of annotation references.
      e - the parent element.
      Throws:
      ConverterException
    • writeCitationRefs

      protected void writeCitationRefs​(java.util.List<PathwayElement.CitationRef> citationRefs, org.jdom2.Element e) throws ConverterException
      Writes citation reference information for pathway or pathway element. , ElementInfo#getCitationRefs.
      Parameters:
      citationRefs - the list of citation references.
      e - the parent element.
      Throws:
      ConverterException
    • writeEvidenceRefs

      protected void writeEvidenceRefs​(java.util.List<PathwayElement.EvidenceRef> evidenceRefs, org.jdom2.Element e) throws ConverterException
      Writes evidence reference information for pathway or pathway element , ElementInfo#getEvidenceRefs.
      Parameters:
      evidenceRefs - the list of evidence references.
      e - the parent 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
    • writeAliasRef

      protected void writeAliasRef​(Group aliasRef, org.jdom2.Element e)
      Writes aliasRef property information for a data node. Used in writeDataNodes(java.util.List<org.pathvisio.libgpml.model.DataNode>, org.jdom2.Element).
      Parameters:
      aliasRef - the group for which data node is an alias.
      e - the parent jdom element.
    • writeStates

      protected void writeStates​(java.util.List<DataNode.State> states, org.jdom2.Element dn) throws ConverterException
      Writes state DataNode.State information.
      Parameters:
      states - the list of states.
      dn - the parent data node element.
      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 wyps) throws ConverterException
      Writes point LineElement.LinePoint information.
      Parameters:
      lineElement - the line element.
      wyps - the parent element.
      Throws:
      ConverterException
    • writeElementRef

      protected boolean writeElementRef​(GraphLink.LinkableTo elementRef, org.jdom2.Element e)
      Writes elementRef property information. Returns boolean if elementRef is written. Used in writePoints(org.pathvisio.libgpml.model.LineElement, org.jdom2.Element).
      Parameters:
      elementRef - the elementRef.
      e - the parent jdom element.
      Returns:
      true if elementRef exists and is successfully written.
    • writeAnchors

      protected void writeAnchors​(java.util.List<LineElement.Anchor> anchors, org.jdom2.Element wyps) throws ConverterException
      Writes anchor LineElement.Anchor information.
      Parameters:
      anchors - the list of anchors.
      wyps - the parent 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.
      Parameters:
      groups - the list of groups.
      root - the root element.
      Throws:
      ConverterException
    • writeAnnotations

      protected void writeAnnotations​(java.util.List<Annotation> annotations, org.jdom2.Element root) throws ConverterException
      Writes annotation Annotation information.
      Parameters:
      annotations - the list of annotations.
      root - the root element.
      Throws:
      ConverterException
    • writeCitations

      protected void writeCitations​(java.util.List<Citation> citations, org.jdom2.Element root) throws ConverterException
      Writes citation Citation information.
      Parameters:
      citations - the list of citations.
      root - the root element.
      Throws:
      ConverterException
    • writeEvidences

      protected void writeEvidences​(java.util.List<Evidence> evidences, org.jdom2.Element root) throws ConverterException
      Writes evidence Evidence information.
      Parameters:
      evidences - the list of evidences.
      root - the root 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.
      Parameters:
      groupRef - the groupRef.
      e - the parent element.
    • 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 jdom 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
      Parameters:
      elementInfo - the pathway element.
      e - the parent 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
    • writeFontProperty

      protected void writeFontProperty​(ShapedElement shapedElement, org.jdom2.Element gfx) throws ConverterException
      Writes font property information.
      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.
      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