To create a pathway use the createPathway function. It takes string arguments indicating the name of the pathway, author of the pathway, name of the organism in which the pathway is found and the folder where the pathway should be saved.
The input arguments are all optional, in case you provide all empty strings to the method a pathway with the name “.gpml” will be created in your home directory. It is advised to provide at least a pathway name, in order to refer to the pathway later or to edit it.

R code:

xml.rpc(server,"PathVisio.createPathway","Test Pathway","Anwesha","Homo Sapiens","/home/anwesha/Results")

Python code:

server.PathVisio.createPathway("Test Pathway","Anwesha","Homo Sapiens","/home/anwesha/Results")

Exercise 3.1 : Adding Datanodes

Once a pathway is created you can then add DataNodes to it. A datanode is a term used in PathVisio to denote a gene, metabolite, protein etc. Essentially any biological entity that forms a node in a pathway and has some biological meaning associated with it.
Datanodes can be added using the addDataNode function. It takes two strings as an input, one specifying the name of the gene/protein … and the other specifying the biological type of the DataNode, i.e whether it is a Gene, Protein or a Metabolite and returns a Datanode ID, an unique identifier using which you can refer to the added DataNode later.
Datanodes can also be directly annotated at this point, by providing an identifier and datasource for each gene/protein …. Annotation can also be done later using the annotateElement function.

R code:

xml.rpc(server,"PathVisio.addDataNode", "/home/anwesha/Results/Test Pathway.gpml", "Glucose","Metabolite"," HMDB00122","HMDB")

xml.rpc(server,"PathVisio.addDataNode", "/home/anwesha/Results/Test Pathway.gpml", "Glucose-6-P","Metabolite"," HMDB01401","HMDB")

Python code:

server.PathVisio.addDataNode("/home/anwesha/Results/Test Pathway.gpml", "Glucose","Metabolite"," HMDB00122","HMDB")

server.PathVisio.addDataNode("/home/anwesha/Results/Test Pathway.gpml", "Glucose-6-P","Metabolite"," HMDB01401","HMDB")

Exercise 3.2 : Adding Lines

An interaction in PathVisio denotes a reaction or an interaction. For eg. a metabolic reaction or a protein protein interaction, etc. Once some DataNodes have been added to a pathway, you can add some interactions describing the relationships between the DataNodes. To add interactions to a pathway the addInteraction function can be used, it takes strings as input specifying the DataNode IDs of the two nodes which are to be connected, the startlinetype and the endlinetype and returns a unique Line ID.
The start/endlinetypes can be any one of the following : Line, TBar, Arrow and the many mim glyphs a comprehensive list of which can be obtained from the API using the function getInteractionTypes. By default the starttlineype and endlinetype of a interaction is set to Line.

R code:

xml.rpc(server,"PathVisio.addInteraction", "/home/anwesha/Results/Test Pathway.gpml","Glucose->Glucose-6-P","Glucose","Glucose-6-P","","mim-conversion")

Python code:

server.PathVisio.addInteraction("/home/anwesha/Results/Test Pathway.gpml","Glucose->Glucose-6-P","Glucose","Glucose-6-P","","mim-conversion")