Package org.pathvisio.libgpml.model
Class GPML2021Writer
java.lang.Object
org.pathvisio.libgpml.model.GPMLFormatAbstract
org.pathvisio.libgpml.model.GPML2021FormatAbstract
org.pathvisio.libgpml.model.GPML2021Writer
- All Implemented Interfaces:
GPMLFormatVersion
,GPMLFormatWriter
public class GPML2021Writer extends GPML2021FormatAbstract implements GPMLFormatWriter
This class writes a PathwayModel to an output (GPML 2021).
NB:
- GPML2021 is the current gpml format.
- In the GUI, Pathways are saved/written in the GPML2021 format.
- Author:
- finterly
-
Field Summary
Fields Modifier and Type Field Description static GPML2021Writer
GPML2021WRITER
Fields inherited from class org.pathvisio.libgpml.model.GPML2021FormatAbstract
ANCHORSHAPETYPE_DEFAULT, ANNOTATIONTYPE_DEFAULT, ARROWHEAD_DEFAULT, BACKGROUNDCOLOR_DEFAULT, BORDERCOLOR_DEFAULT, BORDERSTYLE_DEFAULT, BORDERWIDTH_DEFAULT, CONNECTORTYPE_DEFAULT, DATANODETYPE_DEFAULT, FILLCOLOR_DEFAULT, FONTDECORATION_DEFAULT, FONTNAME_DEFAULT, FONTSIZE_DEFAULT, FONTSTRIKETHRU_DEFAULT, FONTSTYLE_DEFAULT, FONTWEIGHT_DEFAULT, GROUPTYPE_DEFAULT, HALIGN_DEFAULT, LINECOLOR_DEFAULT, LINESTYLE_DEFAULT, LINEWIDTH_DEFAULT, SHAPETYPE_DEFAULT, STATETYPE_DEFAULT, TEXTCOLOR_DEFAULT, VALIGN_DEFAULT
Fields inherited from class org.pathvisio.libgpml.model.GPMLFormatAbstract
BIOPAX_NAMESPACE, OWL_NAMESPACE, RDF_NAMESPACE, RDF_STRING, RDFS_NAMESPACE
-
Constructor Summary
Constructors Modifier Constructor Description protected
GPML2021Writer(java.lang.String xsdFile, org.jdom2.Namespace nsGPML)
Constructor for GPML writer. -
Method Summary
Modifier and Type Method Description org.jdom2.Document
createJdom(PathwayModel pathwayModel)
Creates and returns the JDOM documentDocument
written from given pathwayModelPathwayModel
data.protected void
writeAliasRef(Group aliasRef, org.jdom2.Element e)
Writes aliasRef property information for a data node.protected void
writeAnchors(java.util.List<LineElement.Anchor> anchors, org.jdom2.Element wyps)
Writes anchorLineElement.Anchor
information.protected void
writeAnnotationRefs(java.util.List<PathwayElement.AnnotationRef> annotationRefs, org.jdom2.Element e)
Writes annotation reference information for pathway or pathway element.protected void
writeAnnotations(java.util.List<Annotation> annotations, org.jdom2.Element root)
Writes annotationAnnotation
information.protected void
writeAuthors(java.util.List<Pathway.Author> authors, org.jdom2.Element root)
Writes authorPathway.Author
information.protected void
writeCitationRefs(java.util.List<PathwayElement.CitationRef> citationRefs, org.jdom2.Element e)
Writes citation reference information for pathway or pathway element.protected void
writeCitations(java.util.List<Citation> citations, org.jdom2.Element root)
Writes citationCitation
information.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
writeDynamicProperties(java.util.Map<java.lang.String,java.lang.String> dynamicProperties, org.jdom2.Element e)
Writes dynamic property information for pathway or pathway element.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 forprotected boolean
writeElementRef(GraphLink.LinkableTo elementRef, org.jdom2.Element e)
Writes elementRef property information.protected void
writeEvidenceRefs(java.util.List<PathwayElement.EvidenceRef> evidenceRefs, org.jdom2.Element e)
Writes evidence reference information for pathway or pathway element, ElementInfo#getEvidenceRefs
.protected void
writeEvidences(java.util.List<Evidence> evidences, org.jdom2.Element root)
Writes evidenceEvidence
information.protected void
writeFontProperty(ShapedElement shapedElement, org.jdom2.Element gfx)
Writes font property information.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
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
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
writePathwayInfo(PathwayModel pathwayModel, org.jdom2.Element root)
Writes pathway objectPathway
information and authors list to root element.protected void
writePoints(LineElement lineElement, org.jdom2.Element wyps)
Writes pointLineElement.LinePoint
information.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
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.protected void
writeStates(java.util.List<DataNode.State> states, org.jdom2.Element dn)
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
writeUrl(java.lang.String urlLink, org.jdom2.Element e)
Writes url link information to new element.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.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
-
GPML2021WRITER
-
-
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 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 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 xrefXref
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 ConverterExceptionWrites authorPathway.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 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
-
writeDynamicProperties
protected void writeDynamicProperties(java.util.Map<java.lang.String,java.lang.String> dynamicProperties, org.jdom2.Element e) throws ConverterExceptionWrites 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 ConverterExceptionWrites 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 ConverterExceptionWrites 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 ConverterExceptionWrites 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 ConverterExceptionWrites datanodeDataNode
information.- Parameters:
dataNodes
- the list of datanodes.root
- the root element.- Throws:
ConverterException
-
writeAliasRef
Writes aliasRef property information for a data node. Used inwriteDataNodes(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 ConverterExceptionWrites stateDataNode.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 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 wyps) throws ConverterExceptionWrites pointLineElement.LinePoint
information.- Parameters:
lineElement
- the line element.wyps
- the parent element.- Throws:
ConverterException
-
writeElementRef
Writes elementRef property information. Returns boolean if elementRef is written. Used inwritePoints(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 ConverterExceptionWrites anchorLineElement.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 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.- 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 ConverterExceptionWrites annotationAnnotation
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 ConverterExceptionWrites citationCitation
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 ConverterExceptionWrites evidenceEvidence
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 elementIdPathwayObject
property information.- Parameters:
elementId
- the elementId.e
- the parent element.
-
writeGroupRef
Writes groupRef property information.- Parameters:
groupRef
- the groupRef.e
- the parent element.
-
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 jdom 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- Parameters:
elementInfo
- the pathway element.e
- the parent 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
-
writeFontProperty
protected void writeFontProperty(ShapedElement shapedElement, org.jdom2.Element gfx) throws ConverterExceptionWrites 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 ConverterExceptionWrites 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 ConverterExceptionWrites line style property information.- Parameters:
lineElement
- the line pathway element.gfx
- the parent graphics element.- Throws:
ConverterException
-