Tuesday, July 19, 2016

Week 13

Still Work in Progress....

Tests

Last week a compilable class goal was achieved.So this week was about setting up tests.
Since deviser generates and select random UUID and prime number, the two methods were adapted for running tests. In the case of prime number, random.seed was set to 0 as for the UUID to a fixed number,as random seed would not affect it.
The foundation of java tests served test_cpp_code files, which were adapted for the java files generation. The path separator was changed to os.sep, so it uses OS specific separator.

javap parser 

jsbml jar was put inside deviser package and javap works under Windows as well.

List of modifications

  1. added lo_element writer
  2. fixed problem with brackets for equals and copy constructor.




Tuesday, July 12, 2016

Week 12

Hello all,

Here's the summary:

Compilable Class

Deviser generates a compilable QualitativeSpecie.java(Fig.1). The class also worked as a replacement in the official jsbml code, but since deviser does not generate not generate   QualitativeSpecies(species) constructor, that part of the code had to be commented in the official jsbml code, after that the compilation was successful(https://gist.github.com/hovo1990/c3ce45eb0d61cefe5c2440d65a45d5be).

Fig.1 Compilable QualitativeSpecies.java

UUID generator

Dr. Bergmann gave valuable help and recommendation for the generation of UUIDs.
Python includes uuid module, that can be used for the generation of uuids, but since Java uses long 64 bit, while python generates 128 bit, the generated uuid had to be masked.
After changing to 56 bit, java compiler would not give more errors for being too long.

hashCode method changes

Generated prime numbers were changed to a global variable, so that the numbers are only generated once.

Implemented Methods

Here's the list of the methods, that were implemented during this week:
  1. prototype writeXMLAttributes
  2. fixed functions with same name generator
  3. prototype toString
  4. prototype readAttribute

Tuesday, July 5, 2016

Week 11

Organize helper functions

Removed duplicate codes and  placed frequent helper functions inside a new module: jsbmlHelperFunctions.py, which includes functions for determining whether a method has to be overriden, javap argument parser, get javadoc comments, finding methods with same name that take different argument and prime number generator.

Constructor generator

Deviser now generates copy constructors.

Method generators

Deviser can generate get_instance, is_set_instance, equals and hashCode methods.

hashCode method

The generator uses algorithm found from stackoverflow.  Right now generates  up to 10 to the 6th power(has to be changed) and than uses pythons random.choice  method for selecting a prime number, but this part needs to be discussed with the mentors. 

Things to do

With the generation of the new methods, previous errors during compilation would vanish, but new ones appeared.Only 3 methods are left to be implemented: readAttribute, writeAttributes and toString.
Finish readAttribute method, which turned out to be a little problematic, write writeAttributes and create the last method generator,which is for toString method.
As for fixing the order of the functions, the idea is to create a dictionary with the function name as key,sort keys and write methods, but that approach would consume more memory, I think it'll be nice to discuss it during TC.






Tuesday, June 28, 2016

Week 10

Class methods detector

This week involved devising a system for automatic override key detection.
For that I came with the idea to create javap parser and look inside import modules and see which methods are abstract.It works, but maybe I overcomplicated things slightly. For the future I think  I will insert all the data from javap for a particular class inside a dictionary. It will change the implementation, but the logic about how to detect override methods won't.
It can also be used for the detection of the missing constructors,that need to be generated as well as get Instance methods.

Mandatory methods generator

This weeks also included the creation of the Mandatory methods generator.
Dr. Bergmann gave a valuable insight about devisers attribute['reqd'] key,which facilitated the detection of return value for the method.Here's the link.

Things to do

Go back to constructor generator.
In the case of QualitativeSpecies.java, the current generator creates setCompartment(java.lang.String) method, but during compilation I get an error(QualitativeSpecies.java:36: error: QualitativeSpecies is not abstract and does not override abstract method setCompartment(Compartment) in CompartmentalizedSBase), which is visible during javap output,so that is something that has to be addressed. Also will take care of the generation of Instance methods.

 

Monday, June 20, 2016

Week 9

Hi everyone,

Unfortunately last week not much was done because I had a exam at the university.I passed it and got an idea.

The idea came to fruition when last week Dr. Dräger mentioned about java reflection and  jython, but I thought there should to be an alternative.

As to me the alternative can be pyjnius, which is a Python module to access Java classes as Python classes using JNI. It has an active community that comes from Android development, easy to use and does not depend on many dependencies.
These are the dependencies.
  1. Java JDK(OpenJDK also works)
  2. Cython and six
  3. Setup JAVA_HOME environment
  4. Setup JRE_HOME environment

Just with a couple of lines it's possible to see all the methods of the class(raw),
but again  it turns out that java reflection is not enough for imports.For example, IDEs' such as Eclipse have their own parser to determine what to import. Still this approach can be used to get instance() methods which are not available in the Deviser xml descriptions.

I think it'll be nice to discuss it during TC.

Tuesday, June 14, 2016

Week 8

This week involved a lot of investigation and figuring out how to use Devisers' key attributes to import modules necessary for JSBML.
Here's the summary what was done during this weekend.
  1. Removed mId and mName from variable generation
  2. Removed Id and Name methods generation from SetGetFunctions.py
  3. Added simple constructor for JSBML
My previous idea to create the jsbml class hierarchy was not sufficient to determine the import modules unfortunately. So I examined again if there's any pattern for Deviser 'type'( here is the Speadsheet), but there is none, that could be used.

Looks like the best approach will be hybrid and one idea is to use attributes' 'name' or 'xml_name', for example if it is 'compartment', then import org.sbml.jsbml.Compartment and org.sbml.jsbml.CompartmentalizedSBase or if it is 'reaction' then import org.sbml.jsbml.Reaction and associated modules.
The idea is to create a dictionary with the package name and attribute name and to use previous tree structure to detect if it is an interface or not, but this part needs to be discussed with the mentors.