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 GPML2013aWriterGPML2013aWRITERFields 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 protectedGPML2013aWriter(java.lang.String xsdFile, org.jdom2.Namespace nsGPML)Constructor for GPML2013aWriter. -
Method Summary
Modifier and Type Method Description protected voidconvertStateRefToComments(DataNode.State state, org.jdom2.Element st)This method handles convertingDataNode.StatephosphositePathwayElement.AnnotationRefandXrefinformation back toPathwayElement.Commentfor writing to GPML2013a.org.jdom2.DocumentcreateJdom(PathwayModel pathwayModel)Creates and returns the JDOM documentDocumentwritten from given pathwayModelPathwayModeldata.protected voidwriteAnchors(java.util.List<LineElement.Anchor> anchors, org.jdom2.Element gfx)Writes anchorLineElement.Anchorinformation.protected voidwriteArrowHeadType(ArrowHeadType arrowHead, java.lang.String base, org.jdom2.Element pt)Writes the arrowHead for point jdom element.protected voidwriteBiopax(PathwayModel pathwayModel, org.jdom2.Element root)Writes gpml:Biopax information openControlledVocabulary and PublicationXref.protected voidwriteBiopaxRefs(java.util.List<PathwayElement.CitationRef> citationRefs, org.jdom2.Element e)Writes BiopaxRef information fromPathwayElement.getCitationRefs()for pathway or pathway element.protected voidwriteColor(ShapedElement shapedElement, org.jdom2.Element gfx)Writes color property information for shaped pathway elements.protected voidwriteComments(java.util.List<PathwayElement.Comment> comments, org.jdom2.Element e)Writes commentsPathwayElement.Commentinformation for pathway or pathway element.protected voidwriteDataNodes(java.util.List<DataNode> dataNodes, org.jdom2.Element root)Writes datanodeDataNodeinformation.protected voidwriteElementId(java.lang.String elementId, org.jdom2.Element e)Writes elementIdPathwayObjectproperty information.protected voidwriteElementInfo(PathwayElement elementInfo, org.jdom2.Element e)Writes elementId, comment group {comment, dynamic property, annotationRef, citationRef) and evidenceRefPathwayElementinformation for datanodes, interactions, graphicalLines, labels, shapes, and group.protected voidwriteFontProperty(ShapedElement shapedElement, org.jdom2.Element gfx)Writes font property information, except color.protected voidwriteGraphicalLines(java.util.List<GraphicalLine> graphicalLines, org.jdom2.Element root)Writes graphical lineGraphicalLineinformation.protected voidwriteGroupRef(Group groupRef, org.jdom2.Element e)Writes groupRef property information.protected voidwriteGroups(java.util.List<Group> groups, org.jdom2.Element root)Writes groupGroupinformation.protected voidwriteInfoBox(Pathway pathway, org.jdom2.Element root)Writes the infobox x and y coordinate information.protected voidwriteInteractions(java.util.List<Interaction> interactions, org.jdom2.Element root)Writes interactionInteractioninformation.protected voidwriteLabels(java.util.List<Label> labels, org.jdom2.Element root)Writes labelLabelinformation.protected voidwriteLegend(Pathway pathway, org.jdom2.Element root)Writes the legend x and y coordinate information.protected voidwriteLineDynamicProperties(java.util.Map<java.lang.String,java.lang.String> dynamicProperties, LineElement lineElement, org.jdom2.Element ln)Writes dynamic property information forLineElement.protected voidwriteLineElement(LineElement lineElement, org.jdom2.Element ln)Writes line elementLineElementinformation for interactions or graphicalLines.protected voidwriteLineStyleProperty(LineElement lineElement, org.jdom2.Element gfx)Writes line style property information.protected voidwriteOpenControlledVocabulary(PathwayModel pathwayModel, org.jdom2.Element bp)Writes gpml:Biopax bp:OpenControlledVocabularyAnnotationinformation.protected voidwritePathwayDynamicProperties(Pathway pathway, org.jdom2.Element root)Writes dynamic property information for pathway or pathway element.protected voidwritePathwayInfo(PathwayModel pathwayModel, org.jdom2.Element root)Writes pathway objectPathwayinformation to root element.protected booleanwritePointElementRef(GraphLink.LinkableTo elementRef, org.jdom2.Element pt)Writes point elementRef property information as GraphRef.protected voidwritePoints(LineElement lineElement, org.jdom2.Element gfx)Writes pointLineElement.LinePointinformation.protected voidwritePublicationXref(java.util.List<Citation> citations, org.jdom2.Element bp)Writes gpml:Biopax bp:PublicationXrefCitationinformation.protected voidwritePublicationXrefInfo(java.lang.String propertyValue, java.lang.String elementName, org.jdom2.Element pubxf)Writes Biopax PublicationXref information to PublicationXref element.protected voidwriteRectProperty(ShapedElement shapedElement, org.jdom2.Element gfx)Writes rect property information.protected voidwriteShapedElement(ShapedElement shapedElement, org.jdom2.Element se)Writes shapedElementShapedElementinformation for datanodes, labels, shapes, or groups.protected voidwriteShapedOrStateDynamicProperties(java.util.Map<java.lang.String,java.lang.String> dynamicProperties, ShapedElement shapedElement, org.jdom2.Element se)Writes dynamic property information forShapedElementorDataNode.Statepathway element.protected voidwriteShapes(java.util.List<Shape> shapes, org.jdom2.Element root)Writes shapeShapeinformation.protected voidwriteShapeStyleProperty(ShapedElement shapedElement, org.jdom2.Element gfx)Writes shape style property information, except borderColor, zOrder, and fillColor.protected voidwriteStates(java.util.List<DataNode> dataNodes, org.jdom2.Element root)Writes stateDataNode.Stateinformation.voidwriteToXml(PathwayModel pathwayModel, java.io.File file, boolean validate)Writes the JDOM document to the file specified.voidwriteToXml(PathwayModel pathwayModel, java.io.OutputStream output, boolean validate)Writes the JDOMDocumentdocument to the outputstream specified.protected voidwriteXref(org.bridgedb.Xref xref, org.jdom2.Element e, boolean required)Writes xrefXrefinformation to new element.Methods inherited from class org.pathvisio.libgpml.model.GPML2013aFormatAbstract
fromCamelCase, getArrowHeadTypeStr, getAttr, getAttributeInfo, getInteractionPanelType, setAttr, toCamelCaseMethods inherited from class org.pathvisio.libgpml.model.GPMLFormatAbstract
getGpmlNamespace, getSchemaFile, refreshLineElements, updateGroups, validateDocumentMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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 JDOMDocumentdocument to the outputstream specified.- Specified by:
writeToXmlin 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:
writeToXmlin 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 documentDocumentwritten from given pathwayModelPathwayModeldata.- Specified by:
createJdomin 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 objectPathwayinformation 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 xrefXrefinformation 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.Commentinformation 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 datanodeDataNodeinformation.- 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.Stateinformation.- 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.StatephosphositePathwayElement.AnnotationRefandXrefinformation back toPathwayElement.Commentfor 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 interactionInteractioninformation.- 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 lineGraphicalLineinformation.- 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 elementLineElementinformation 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.LinePointinformation.- 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.Anchorinformation.- 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 labelLabelinformation.- 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 shapeShapeinformation.- 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 groupGroupinformation.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:OpenControlledVocabularyAnnotationinformation. Because it is not possible to writePathwayElement.AnnotationRefforPathwayObjectin GPML2013a, the State annotationRef information is written asPathwayElement.CommentinconvertStateRefToComments(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:PublicationXrefCitationinformation.- 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 elementIdPathwayObjectproperty information.- Parameters:
elementId- the elementId.e- the parent element.
-
writeGroupRef
Writes groupRef property information.Groupstores 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 shapedElementShapedElementinformation 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 evidenceRefPathwayElementinformation 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 forShapedElementorDataNode.Statepathway 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
-