Tuesday, August 22, 2017

Week 17

I think this week is my final week working on the project. I created the documentation and wiki for the project, please go to GitHub to view them. During this week's meeting, I would like to:
1. Demonstrate how to use the converters
2. Future project idea
3. Answer questions and clarifications
4. Ask for reference

Wednesday, August 16, 2017

Week 16

This week, I finished most of the coding I wanted to do for the project, so the remainder of this month will be devoted to testing, documenting, and integrating. I managed to implement the following converters between SBML and SBGN:

[1] SBML Lv3 core+layout --> SBGN PD
[2] SBGN PD --> SBML Lv3 core+layout
[3] SBML Lv2  core+layout --> SBGN PD (through a libSBML Lv2 to Lv3 converter)
[4] SBGN PD --> SBML Lv2 core+layout (through a libSBML Lv3 to Lv2 converter)
[5] SBML Lv3 core+layout+render --> SBGN PD
[6] SBGN PD --> SBML Lv3 core+layout+render
[7] SBML Lv3 qual+layout+render --> SBGN AF
[8] SBGN AF --> SBML Lv3 qual+layout+render
[9] SBML core+layout --> SBGN PD --> SBML core+layout+render (i.e. roundtrip)
[10] SBGN PD --> SBML core+layout+render --> SBGN PD (i.e. roundtrip)

Some converters were implemented to a greater extent than others. Here are some examples converted by the converters above:

#Original Converted
[1] Complete_Example.xml Complete_Example_SBGN-ML.sbgn Note that this is an image generated a couple of months ago, there is some problem with the rendering software. We are still searching for a software that is able to correctly generate the diagram. The curved arrows has been fixed since then.

[2] compartments.sbgn compartments_SBML.xml Note that this is also an image generated a couple of months ago.

[3] Complete_Example_level2.xml Complete_Example_level2_level3.xml

The image generated should be the same as [1] The image generated should be the same as [1]
[4] adh.sbgn adh_SBML.xml Note that this is also an image generated a couple of months ago. The misplaced center Curve has been fixed since then. I didn't have the converted Lv2 file saved, I will add it later.

[5] e_coli_core_metabolism.sbml.xml e_coli_core_metabolism.sbml_SBGN-ML.sbgn

[6] e_coli_core_metabolism.sbgn e_coli_core_metabolism_SBML.xml
Image: e_coli_core_metabolism_SBML.jpg

[7] 4.1 Simple Logical Regulatory Graph.xml 4.1 Simple Logical Regulatory Graph_SBGN-ML.sbgn

[8] compartment_extended.sbgn Note that I created this example by modifying compartment.sbgn in libsbgn/AF compartment_extended_SBML+qual.xml
Notice how the converted SBML stores semantic information about the diagram inside a MathML element, the interpretation of visual objects to logic equations is a major feature of this converter.

Note that some of the images are outdated. Many problem reflected in the images have been fixed recently.

#Original Converted Roundtrip
[9] e_coli_core_metabolism.sbml.xml e_coli_core_metabolism.sbml_SBGN-ML.sbgn e_coli_core_metabolism.sbml_SBGN-ML_SBML.xml Image: e_coli_core_metabolism.sbml_SBGN-ML_SBML.jpg

[10] SBGN-PD_all.sbgn SBGN-PD_all_SBML.xml SBGN-PD_all_SBML_SBGN-ML.png

One key aspect of the converters that I will not likely be paying attention is preserving information for the original model. For example, if the original SBML model contains many FunctionDefinition and Rule objects, these will not be transfered to SBGN. So, if a roundtrip conversion SBML-SBGN-SBML is done, most of the information that are not involved in the generation of the diagram layout are not preserved. (Although I try to preserve some information such as UnitDefinitions and KineticLaws)

Plans for the upcoming weeks:
Add automated tests SBML 'layout' to SBGN-ML PD 
Add automated tests SBGN-ML PD to SBML 'layout' 
Create a diagram mapping of SBML core <-> SBGN AF 
add 'roles' of Arcs to the mapping diagram 
generate the images for the converted files
Create SBFC Documentation 
Integrate converter to sbfConverterGUI
Implement automated XML validation using existing Validator

Wednesday, August 9, 2017

Week 15

This week I made revisions to the mapping diagrams:

SBML core <-> SBGN AF

SBML core <-> SBGN PD
SBML layout <-> SBGN PD
SBML qual <-> SBGN AF

Then, I spent the majority of the time on refining the rendering graphics of the converted SBGN->SBML diagrams. I created a SBGN styles template file here, and used this template to enrich the SBML glyphs with styles. The example I used is SBGN-PD_all.sbgn. However there are a number of problems that I couldn't fix. These problems are pointed out in the diagram below:

Problem [1]:
The clone markers can't be drawn using the existing object types in SBML 'render' package. See "simple chemical" glyph above. This is because we can't draw "half" of a circle using attributes cx, cy, rx, ry. I think if we have an "angle" attribute for drawing circles, then we can draw parts of a circle by specifying the "start" and "end" degrees. For example, here's something from calculus notes.

Problem [2]:
The centre curve seems to overlap with a glyph if the "fill" attribute is not set to a color or gradient. See the "AND" logic operator above. However, this seems to be reasonable. But there is another problem, discussed in [3].

Problem [3]:
If the "fill" attribute is set to a color or gradient, then the TextGlyph will get covered up. This problem was previously mentioned by me, but it still couldn't be fixed. I think this is due to the drawing order of the objects in layout. If the TextGlyph is drawn last, then it should not get covered up by any other objects. For now, I didn't set any color to the Units of Information and State Variable glyphs, this is why the texts seem to collide with lines of other objects.

Problem [4]:
I couldn't figure out how the translation of an object was done for one specific glyph. See the Arc between the "NOT" and the "phenotype" glyph above. The "inhibition" LineEnding doesn't seem to show up in the diagram. It should have a horizontal "bar". 

Problem [5]:
The CubicBezier in layout can be drawn, the RenderCubicBezier in render couldn't be draw in the converted diagram. See "multimer nucleic acid feature" glyph above. Notice that the bottom part of the glyph should be round, but instead, it's a straight line. I noticed that the "render:basepoint1_x", etc attributes has no effect on the graphics, is this a bug in the 'render' package or misconfiguration in my styles template?

Problem [6]:
The position of the text cannot be specified consistently, this is due to the lack of information in the SBGN model. See the "macromolecule" glyph above. If there is an extra field in SBGN that specifies the location of the Label, such as "top", "middle", or "bottom", then the texts could be placed at a specific location in the BoundingBox.

Update: Problem [4] and Problem [6] have been fixed since then.

Next, I started a roundtrip conversion using the SBGN-PD_all.sbgn example, it is first converted to SBML with layout and render, then converted back to SBGN. Unfortunately, this doesn't work very well. It would take me more time to fine-tune the converter to transfer information back to SBGN correctly.


Plans for next week:
Roundtrip conversion of SBGNML -> SBML+layout+render -> SBGNML 
Roundtrip conversion of SBML+layout -> SBGNML -> SBML+layout+render
Convert real SBML examples.xml 
Add automated tests SBGN-ML PD to SBML 'layout' 
Implement converter from the SBML core packge with 'qual' extension to SBGN AF 

Wednesday, August 2, 2017

Week 14

This week, I fixed a number of things for the SBML2SBGN converter, and starting working on a new set of SBML2SBGN diagrams.

1. SBML2SBGN converter

A number of new features were added, including the support for SBML 'qual', preserving lost SBML information inside SBGN Extension, adding mapping using SBO term and MIRIAM Annotation, and possibly solving the Logic Arc + Logic Operator problem by preserving the MathML elemement.

1.1 support for SBML 'qual'

I worked on the SBGN2SBML converter with qual before, now I've implemented the other direction. The converter can convert SBML models with qual, but more complexes were not considered. Here's an example:

Original SBML Converted SBGN
4.1 Simple Logical Regulatory Graph.sbml 4.1 Simple Logical Regulatory Graph_SBGN-ML.sbgn
The original example did not have layout. I added the layout information based on the picture drawn in the SBML qual specification. Note that the FunctionTerm MathML in Transitions are preserved (see the .sbgn file). The preserved information could be restored when a roundtrip conversion SBML->SBGN->SBML is done. This is on the todo list.

1.2 adding SBO + MIRIAM, and preserving lost SBML information

From the discussion last week, I incorporated SBO and MIRIAM information to the mapping function, so that more accurate SBGN 'shapes' can be predicted using more abundant information. Here's an example (see the .sbgn file):

Original SBML Converted SBGN
UnitTest_SBML_layout-L3V1.sbml UnitTest_SBML_layout-L3V1_SBGN-ML.sbgn
Notice how the UnitDefinitions are preserved as Extension elements in SBGN. There are still some glitches, those will be fixed later.

2. SBML2SBGN diagrams

I  started to make modifications to the 4 diagrams I created last week. Here's one completed:
SBML core <-> SBGN PD with MIRIAM and SBO

Some feedback is appreciated before I finish the other 3 diagrams.

3. Plans next week

Convert real SBML examples
  • I'm going to start with e_coli_core_metabolism.sbgn.xml from the Escher converter.
SBML<->SBGNML converter : better Render graphics
  •  Using Frank's rendering style xml templates from https://sourceforge.net/p/sbmllayout/code/HEAD/tree/trunk/SBMLLayout/SBMLExtension/SBGNstyles.xml
Create SBFC Documentation
  • I can't edit the wiki page, http://sbfc.sourceforge.net/mediawiki/index.php/SBML2SBGNML, it seems I cannot log in as a user using my sourgeforge account.
Add a ModelCompleter to fill missing values
  • using the SBGN example file  https://github.com/sbgn/libsbgn/commit/f6264009acf57c357f885d3adfd0c5c1bec0a08c