Package org.pathvisio.libgpml.model
Class GPML2013aWriter
java.lang.Object
org.pathvisio.libgpml.model.GPMLFormatAbstract
org.pathvisio.libgpml.model.GPML2013aFormatAbstract
org.pathvisio.libgpml.model.GPML2013aWriter
- All Implemented Interfaces:
GPMLFormatVersion
,GPMLFormatWriter
public class GPML2013aWriter extends GPML2013aFormatAbstract implements GPMLFormatWriter
This class writes a PathwayModel to an output (GPML 2013a).
NB:
- If writing (converting) GPML2021 to GPML2013a, warning messages are thrown.
- In the GUI, export allows writing to the GPML2013a format.
- Author:
- finterly
-
Nested Class Summary
Nested classes/interfaces inherited from class org.pathvisio.libgpml.model.GPML2013aFormatAbstract
GPML2013aFormatAbstract.AttributeInfo
-
Field Summary
Fields Modifier and Type Field Description static GPML2013aWriter
GPML2013aWRITER
Fields inherited from class org.pathvisio.libgpml.model.GPML2013aFormatAbstract
BINDING_LIST, BIOPAX_NAMESPACE, CATALYSIS_LIST, CELL_CMPNT_KEY, CELL_CMPNT_MAP, CONVERSION_LIST, DEPRECATED_MAP, DIRECTED_LIST, DIRECTION, DOUBLE_LINE_KEY, GPML2013A_KEY_SET, IA_PANEL_MAP, INFOBOX_CENTER_X, INFOBOX_CENTER_Y, INHIBITION_LIST, LEGEND_CENTER_X, LEGEND_CENTER_Y, OCV_ONTOLOGY_MAP, OWL_NAMESPACE, PARENT, PARENTID, PARENTID_DB, PARENTSYMBOL, PARENTSYMBOL_DB, PATHWAY_AUTHOR, PATHWAY_EMAIL, PATHWAY_LASTMODIFIED, PATHWAY_MAINTAINER, POSITION, PTM, RDF_NAMESPACE, RDF_STRING, RDFS_NAMESPACE, SHAPETYPE_TO_CAMELCASE, SITE, SITEGRPID, SITEGRPID_DB, STATE_DIRECTION_MAP, STATE_PTM_MAP, STATE_REF_LIST, STATE_ROTATION, STIMULATION_LIST, TRANSCRIPTION_TRANSLATION_LIST, TRANSLOCATION_LIST, UNDIRECTED_LIST, WP_DESCRIPTION
-
Constructor Summary
Constructors Modifier Constructor Description protected
GPML2013aWriter(java.lang.String xsdFile, org.jdom2.Namespace nsGPML)
Constructor for GPML2013aWriter. -
Method Summary
Modifier and Type Method Description protected void
convertStateRefToComments(DataNode.State state, org.jdom2.Element st)
This method handles convertingDataNode.State
phosphositePathwayElement.AnnotationRef
andXref
information back toPathwayElement.Comment
for writing to GPML2013a.org.jdom2.Document
createJdom(PathwayModel pathwayModel)
Creates and returns the JDOM documentDocument
written from given pathwayModelPathwayModel
data.protected void
writeAnchors(java.util.List<LineElement.Anchor> anchors, org.jdom2.Element gfx)
Writes anchorLineElement.Anchor
information.protected void
writeArrowHeadType(ArrowHeadType arrowHead, java.lang.String base, org.jdom2.Element pt)
Writes the arrowHead for point jdom element.protected void
writeBiopax(PathwayModel pathwayModel, org.jdom2.Element root)
Writes gpml:Biopax information openControlledVocabulary and PublicationXref.protected void
writeBiopaxRefs(java.util.List<PathwayElement.CitationRef> citationRefs, org.jdom2.Element e)
Writes BiopaxRef information fromPathwayElement.getCitationRefs()
for pathway or pathway element.protected void
writeColor(ShapedElement shapedElement, org.jdom2.Element gfx)
Writes color property information for shaped pathway elements.protected void
writeComments(java.util.List<PathwayElement.Comment> comments, org.jdom2.Element e)
Writes commentsPathwayElement.Comment
information for pathway or pathway element.protected void
writeDataNodes(java.util.List<DataNode> dataNodes, org.jdom2.Element root)
Writes datanodeDataNode
information.protected void
writeElementId(java.lang.String elementId, org.jdom2.Element e)
Writes elementIdPathwayObject
property information.protected void
writeElementInfo(PathwayElement elementInfo, org.jdom2.Element e)
Writes elementId, comment group {comment, dynamic property, annotationRef, citationRef) and evidenceRefPathwayElement
information for datanodes, interactions, graphicalLines, labels, shapes, and group.protected void
writeFontProperty(ShapedElement shapedElement, org.jdom2.Element gfx)
Writes font property information, except color.protected void
writeGraphicalLines(java.util.List<GraphicalLine> graphicalLines, org.jdom2.Element root)
Writes graphical lineGraphicalLine
information.protected void
writeGroupRef(Group groupRef, org.jdom2.Element e)
Writes groupRef property information.protected void
writeGroups(java.util.List<Group> groups, org.jdom2.Element root)
Writes groupGroup
information.protected void
writeInfoBox(Pathway pathway, org.jdom2.Element root)
Writes the infobox x and y coordinate information.protected void
writeInteractions(java.util.List<Interaction> interactions, org.jdom2.Element root)
Writes interactionInteraction
information.protected void
writeLabels(java.util.List<Label> labels, org.jdom2.Element root)
Writes labelLabel
information.protected void
writeLegend(Pathway pathway, org.jdom2.Element root)
Writes the legend x and y coordinate information.protected void
writeLineDynamicProperties(java.util.Map<java.lang.String,java.lang.String> dynamicProperties, LineElement lineElement, org.jdom2.Element ln)
Writes dynamic property information forLineElement
.protected void
writeLineElement(LineElement lineElement, org.jdom2.Element ln)
Writes line elementLineElement
information for interactions or graphicalLines.protected void
writeLineStyleProperty(LineElement lineElement, org.jdom2.Element gfx)
Writes line style property information.protected void
writeOpenControlledVocabulary(PathwayModel pathwayModel, org.jdom2.Element bp)
Writes gpml:Biopax bp:OpenControlledVocabularyAnnotation
information.protected void
writePathwayDynamicProperties(Pathway pathway, org.jdom2.Element root)
Writes dynamic property information for pathway or pathway element.protected void
writePathwayInfo(PathwayModel pathwayModel, org.jdom2.Element root)
Writes pathway objectPathway
information to root element.protected boolean
writePointElementRef(GraphLink.LinkableTo elementRef, org.jdom2.Element pt)
Writes point elementRef property information as GraphRef.protected void
writePoints(LineElement lineElement, org.jdom2.Element gfx)
Writes pointLineElement.LinePoint
information.protected void
writePublicationXref(java.util.List<Citation> citations, org.jdom2.Element bp)
Writes gpml:Biopax bp:PublicationXrefCitation
information.protected void
writePublicationXrefInfo(java.lang.String propertyValue, java.lang.String elementName, org.jdom2.Element pubxf)
Writes Biopax PublicationXref information to PublicationXref element.protected void
writeRectProperty(ShapedElement shapedElement, org.jdom2.Element gfx)
Writes rect property information.protected void
writeShapedElement(ShapedElement shapedElement, org.jdom2.Element se)
Writes shapedElementShapedElement
information for datanodes, labels, shapes, or groups.protected void
writeShapedOrStateDynamicProperties(java.util.Map<java.lang.String,java.lang.String> dynamicProperties, ShapedElement shapedElement, org.jdom2.Element se)
Writes dynamic property information forShapedElement
orDataNode.State
pathway element.protected void
writeShapes(java.util.List<Shape> shapes, org.jdom2.Element root)
Writes shapeShape
information.protected void
writeShapeStyleProperty(ShapedElement shapedElement, org.jdom2.Element gfx)
Writes shape style property information, except borderColor, zOrder, and fillColor.protected void
writeStates(java.util.List<DataNode> dataNodes, org.jdom2.Element root)
Writes stateDataNode.State
information.void
writeToXml(PathwayModel pathwayModel, java.io.File file, boolean validate)
Writes the JDOM document to the file specified.void
writeToXml(PathwayModel pathwayModel, java.io.OutputStream output, boolean validate)
Writes the JDOMDocument
document to the outputstream specified.protected void
writeXref(org.bridgedb.Xref xref, org.jdom2.Element e, boolean required)
Writes xrefXref
information to new element.Methods inherited from class org.pathvisio.libgpml.model.GPML2013aFormatAbstract
fromCamelCase, getArrowHeadTypeStr, getAttr, getAttributeInfo, getInteractionPanelType, setAttr, toCamelCase
Methods inherited from class org.pathvisio.libgpml.model.GPMLFormatAbstract
getGpmlNamespace, getSchemaFile, refreshLineElements, updateGroups, validateDocument
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.pathvisio.libgpml.model.GPMLFormatVersion
getGpmlNamespace, getSchemaFile, validateDocument
-
Field Details
-
GPML2013aWRITER
-
-
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 ConverterExceptionWrites the JDOMDocument
document to the outputstream specified.- Specified by:
writeToXml
in interfaceGPMLFormatWriter
- Parameters:
pathwayModel
- the pathway model.output
- the outputstream to which the JDOM document should be writtenvalidate
- 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 ConverterExceptionWrites the JDOM document to the file specified.- Specified by:
writeToXml
in interfaceGPMLFormatWriter
- 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
Creates and returns the JDOM documentDocument
written from given pathwayModelPathwayModel
data.- Specified by:
createJdom
in interfaceGPMLFormatWriter
- Parameters:
pathwayModel
- the pathway model to be written.- Returns:
- Throws:
ConverterException
-
writePathwayInfo
protected void writePathwayInfo(PathwayModel pathwayModel, org.jdom2.Element root) throws ConverterExceptionWrites pathway objectPathway
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 ConverterExceptionWrites xrefXref
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 ConverterExceptionWrites commentsPathwayElement.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 ConverterExceptionWrites BiopaxRef information fromPathwayElement.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 ConverterExceptionWrites 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 ConverterExceptionWrites datanodeDataNode
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 ConverterExceptionWrites stateDataNode.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 ConverterExceptionThis method handles convertingDataNode.State
phosphositePathwayElement.AnnotationRef
andXref
information back toPathwayElement.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 ConverterExceptionWrites interactionInteraction
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 ConverterExceptionWrites graphical lineGraphicalLine
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 ConverterExceptionWrites line elementLineElement
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 ConverterExceptionWrites pointLineElement.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 ConverterExceptionWrites 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 ConverterExceptionWrites anchorLineElement.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 ConverterExceptionWrites labelLabel
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 ConverterExceptionWrites shapeShape
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 ConverterExceptionWrites groupGroup
information.NB:
- In GPML2013a, group has default font properties and shape style properties which are not written to the gpml.
- Group type "Group" (GPML2021) is written as "None" (GPML2013a).
- Group type "Transparent" (GPML2021) is written as "Group" (GPML2013a).
- Parameters:
groups
- the list of groups.root
- the root element.- Throws:
ConverterException
-
writeInfoBox
Writes the infobox x and y coordinate information.- Parameters:
pathway
- the pathway.root
- the root element.
-
writeLegend
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 ConverterExceptionWrites gpml:Biopax information openControlledVocabulary and PublicationXref.writeOpenControlledVocabulary(org.pathvisio.libgpml.model.PathwayModel, org.jdom2.Element)
fromAnnotation
, andwritePublicationXref(java.util.List<org.pathvisio.libgpml.model.Citation>, org.jdom2.Element)
fromCitation
.- Parameters:
pathwayModel
- the pathway model.root
- the root element.- Throws:
ConverterException
-
writeOpenControlledVocabulary
protected void writeOpenControlledVocabulary(PathwayModel pathwayModel, org.jdom2.Element bp) throws ConverterExceptionWrites gpml:Biopax bp:OpenControlledVocabularyAnnotation
information. Because it is not possible to writePathwayElement.AnnotationRef
forPathwayObject
in GPML2013a, the State annotationRef information is written asPathwayElement.Comment
inconvertStateRefToComments(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 ConverterExceptionWrites gpml:Biopax bp:PublicationXrefCitation
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 ConverterExceptionWrites Biopax PublicationXref information to PublicationXref element. NB: The main purpose of this method is to makewritePublicationXref(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 elementIdPathwayObject
property information.- Parameters:
elementId
- the elementId.e
- the parent element.
-
writeGroupRef
Writes groupRef property information.Group
stores GroupId as its elementId.- Parameters:
groupRef
- the groupRef.e
- the parent element.
-
writePointElementRef
Writes point elementRef property information as GraphRef. This method is used only bywritePoints(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 ConverterExceptionWrites shapedElementShapedElement
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 ConverterExceptionWrites elementId, comment group {comment, dynamic property, annotationRef, citationRef) and evidenceRefPathwayElement
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 ConverterExceptionWrites dynamic property information forShapedElement
orDataNode.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 ConverterExceptionWrites dynamic property information forLineElement
. 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 ConverterExceptionWrites 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 ConverterExceptionWrites 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 ConverterExceptionWrites 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 ConverterExceptionWrites 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 ConverterExceptionWrites line style property information.- Parameters:
lineElement
- the line pathway element.gfx
- the parent graphics element.- Throws:
ConverterException
-