scieee AI-readable full text Open interactive document viewer

Development of a GUI for a SAXS data analysis program for modelling proteins in solution

María Antolinos, Alejandro de

Full text

Internship Report Institut Universitaire de Technologie Development of a GUI for a SAXS data analysis program for modelling proteins in solution Alejandro de Maria Antolinos December 1, 2009 Contents 1 About the internship 4 2 Introduction 5 2.1 UnderstandingESRF.............................. 5 2.2 FortranLanguage................................ 6 2.2.1 Portability................................ 6 2.2.2 The evolution of Fortran . . . . . . . . . . . . . . . . . . . . . . . . 6 2.2.3 Example of Fortran Code . . . . . . . . . . . . . . . . . . . . . . . 7 2.3 XUL....................................... 8 2.3.1 WhatisXUL? ............................. 8 2.3.2 HowcanweuseXUL? ......................... 8 3 Analysis 9 3.1 Background ................................... 9 3.2 StructureofGenfit ............................... 9 3.2.1 Folders and files structure . . . . . . . . . . . . . . . . . . . . . . . 9 3.2.2 OutputFolder.............................. 10 3.3 InputFiles.................................... 10 3.3.1 genABCD.datFile ........................... 10 3.3.2 Parameterfile.............................. 14 3.3.3 Scattering curve file . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 3.4 OutputFiles................................... 15 3.4.1 genABCD.outFile ........................... 15 3.4.2 genABCD01.fit File . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 3.4.3 genABCD.logFile ........................... 16 3.5 GenfitScripts.................................. 16 3.5.1 GalloScript............................... 16 3.6 Fortranreadingcode .............................. 16 3.6.1 Readingroutines ............................ 16 3.6.2 Common format codes . . . . . . . . . . . . . . . . . . . . . . . . . 17 3.7 Maindifficulties................................. 17 3.8 Proposalfromtheuser............................. 17 4 Design 19 4.1 Introduction................................... 19 4.2 Methodology .................................. 20 4.2.1 User interface as isolated system . . . . . . . . . . . . . . . . . . . . 20 4.2.2 Technologies involved . . . . . . . . . . . . . . . . . . . . . . . . . . 21 4.3 Users’cases ................................... 22 4.3.1 Usermode................................ 22 4.3.2 Administration mode . . . . . . . . . . . . . . . . . . . . . . . . . . 24 2 4.4 Implementation................................. 24 4.4.1 Two main approaches . . . . . . . . . . . . . . . . . . . . . . . . . 24 4.4.2 Using XML-Fortran reader . . . . . . . . . . . . . . . . . . . . . . . 25 4.4.3 Creating a translator . . . . . . . . . . . . . . . . . . . . . . . . . . 28 4.5 Structure of code and windows . . . . . . . . . . . . . . . . . . . . . . . . . 29 4.5.1 XUL Folder Structure . . . . . . . . . . . . . . . . . . . . . . . . . 29 4.5.2 Code Folder Structure . . . . . . . . . . . . . . . . . . . . . . . . . 29 4.6 Dealing with XML from XUL . . . . . . . . . . . . . . . . . . . . . . . . . 30 4.6.1 Xpath .................................. 30 4.6.2 DOM................................... 30 4.7 Classes...................................... 30 5 Results 32 5.1 Study of complexity of our application . . . . . . . . . . . . . . . . . . . . 32 5.1.1 Application: windows and code . . . . . . . . . . . . . . . . . . . . 32 5.1.2 Libraries................................. 33 5.2 Reusability ................................... 33 6 User’s Guide 35 6.1 Installation ................................... 35 6.1.1 Onlinux................................. 35 6.1.2 OnWindows .............................. 35 6.1.3 OnMozillaFirefox ........................... 36 6.2 Modification of general parameters of the experiment . . . . . . . . . . . . 37 6.3 Calculations................................... 38 6.3.1 Adding a new calculation . . . . . . . . . . . . . . . . . . . . . . . 38 6.3.2 Staticparameters............................ 39 6.3.3 Models.................................. 40 6.3.4 Dynamic parameters . . . . . . . . . . . . . . . . . . . . . . . . . . 42 6.4 Models of the experiment . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 6.4.1 Editamodel .............................. 43 6.4.2 Addamodel .............................. 44 6.5 Parameters of the model . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 6.5.1 Editaparameter ............................ 45 6.5.2 Addaparameter ............................ 45 6.6 Executing SAXS from Genfit GUI . . . . . . . . . . . . . . . . . . . . . . . 47 6.6.1 Overview ................................ 47 6.7 Executing a single experiment . . . . . . . . . . . . . . . . . . . . . . . . . 47 7 Acknowledgments 49 3 Chapter 1 About the internship This project has been carried out in the context of a work placement agreement between ESRF 1and the Universit Joseph Fourier.2Concerning to the university I was enrolled in the final year of professional bachelor degree in computer networks and telecomunications specialising in wireless networks and and security. As french student of last year I must do a work placement in a profesional area. I took this opportunity to do my final project. Doing a work, or project not only challenges in the fact of living in other country, other languages etc... but the real challenge is the cross-communication between people of different countries working with the same aim. Cultural gap between all us can create difficult situations and only open-minded people could solved this situations. The ESRF not only gave me the opportunity to develop myself in my professional area but as well as in a personal area. I worked for the Experimental Division who is in charge of supporting scientifics who are doing their experiments inside of the beamlines. Besides of the opportunity of working with people of more than 20 different nacionalities creating a special environment where the fact of working seems different. 1European Synchroton Radiation Facility 2Specially,A University Institute of Technology 4 Chapter 2 Introduction 2.1 Understanding ESRF ESRF is a company created to carry out advanced scientific research. It represents a very real technological, scientific and human challenge. Budget estimated for 2007 year was around 80 millions. With 600 people of staff members and around 6000 researchers visitors coming each year. They create about 1500 scientific papers per year. It is situated at Grenoble, a small city at the foot of the French Alps where the Drac joins the Isere River. Population is estimated about 560 thousand inhabitants. After Paris is the second city with more amount of technological enterprises of France “A synchrotron is a particular type of cyclic particle accelerator in which the magnetic field (to turn the particles so they circulate) and the electric field (to accelerate the particles) are carefully synchronized with the travelling particle beam.”1 Scientifics worldwide come to ESRF for executing their experiments. The most of the times they have developped themselves their software tools to carry out their purposes. Thus, a wide varity of sofware can be found developped using languages as Fortran, c, c++, python, java, visual basic, etc... 1source: www.wikipedia.com 5 Sometimes this software has not got appropiate manuals and Graphic User Intarface. In fact, most of them haven’t got a Graphic User Interface and people inside of the experimental Division is in charge to create an appropiate GUI. The wide variety of software has favoured the utilisation of script languages to create GUI’s as, for example, python. Combining Python with some linux shell scripting is posible to give a solution to the major part of the software that require an user interface. Of course, a cross-platform environment is required. We can not know which operating system the final user will use. Actually they are working in their unirversities and for a few weeks they come to execute their experiment. So, a cross-platform environment is expected and our programs need to be portables. Concerning to the scientific software the most of the them need a very high calculation level. Experiments estimating the weight of the proteines is just an example where millions of mathematical operations will be carried out. Likeliwise not only we will need a good processor but a good compiler able to run fast applications and carry out millions of mathematical operations per second. 2.2 Fortran Language Fortran is a language created by IBM in the 1950s for scientific and engineering applications. We could say that Fortran is the grandfather of all scientific computer languages. The name Fortran is derived from FORmula and TRANslation, indicating that the language was intended to translate scientific equation into computer code. It is an imperative programming language that is especially suited to numeric computation and scientific computing. We can remark as well as it is one of the most important languages used in the area of high-performance computing and is the language used for programs that benchmark and rank the world’s fastest supercomputers. 2.2.1 Portability Portability was a big problem. Software companies sold incompatibles extensions in order to differenciate their products. In addition, any fortran code standard was published until 1977 when the National Bureau of Standards published FIPS PUB 69, that processors purchased by the U.S. Government were required to diagnose extensions of the standard. Rather than offer two processors, essentially every compiler eventually had at least an option to diagnose extensions. Similarily for numerical, it is important to take account of the characteristics of the arithmetic. 2.2.2 The evolution of Fortran Fortran is a dynamic language that is constantly evolving to keep up on advances in programming practice. Fortran Working Group belongings to ISO has the responsibility for developing new versions. 6 Preparing a new version is a huge job starting by asking for suggestions to the users for new features, deciding which suggestions are feasible to implement, writing and circulating drafts until a general agreement is reached. Designers of new Fortran version have to decide between backward compatibility and the introduction of desirable new features. Although new good programming structures have been introduced, many undesirable structures from earlier version of Fortran have been retained from backward compatibility. 2.2.3 Example of Fortran Code 7 2.3 XUL 2.3.1 What is XUL? XUL means XML User Interface Language and XUL is Mozilla’s XML-based language that lets you build feature-rich cross platform applications that can run connected or disconnected from the Internet. XUL was created to make development of Mozilla browser easier and faster. As XML language all features envolving XML are also avalaible to XUL. For example, we can use DOM or Xpath in order to explore a XUL node. 2.3.2 How can we use XUL? There are several ways for executing a XUL application: •Firefox extension – an extension adds functionality to the browser itself, often in the form of extra toolbars, context menus, or customizations to the browser’s user interface. This is done using a feature of XUL called an overlay, which allows the UI provided from one source, in this case, the Firefox browser, to be merged together with the UI from the extension. Extensions may also be applied to other Mozilla based products such as Thunderbird. •XUL package – in between the other two are applications which are created in the same way as an extension, but they act like a separate application in a separate window. This is used when you don’t want to have the larger size of a complete XULRunner application, but don’t mind requiring a Mozilla browser to be installed to be able to run the application. •Standalone XULRunner application – XULRunner is a packaged version of the Mozilla platform which allows you to create standalone XUL applications. A browser isn’t required to run these applications, as they have their own executable file. •Remote XUL application – you can also just place XUL code on a web server and open it in a browser, as you would any other web page. This method is limited however, as there are security concerns that will limit the kinds of things you will be able to do, such as opening other windows. 8 Chapter 3 Analysis 3.1 Background Genfit is a Fortran application dealing with the weight and form of the proteines. It simulates proteine forms comparing with severals models from an internal data base. Genfit has been developed from ten years ago. It contains more than 40000 lines of code and it is using functions and code from Fortran 77 and Fortran 90. Now, it is beeing compiled using gFortran that it is a g95 compiler. As well as Genfit is a SAXS application. ”Small-angle X-ray scattering (SAXS) is a small-angle scattering (SAS) technique where the elastic scattering of X-rays (wavelength 0.1 ... 0.2 nm) by a sample which has inhomogeneities in the nm-range, is recorded at very low angles (typically 0.1 - 10). This angular range contains information about the shape and size of macromolecules, characteristic distances of partially ordered materials, pore sizes, and other data. SAXS is capable of delivering structural information of macromolecules between 5 and 25 nm, of repeat distances in partially ordered systems of up to 150 nm.[1] USAXS (ultra-small angle X-ray scattering) can resolve even larger dimensions.”1 3.2 Structure of Genfit 3.2.1 Folders and files structure In this section we are going to describe the folders and files that genfit needs for executing. One of the most difficult parts of this project was to understand this structure. Lack of documentation has been a big probleme in order to modify source code and create the GUI. We have to remember that Genfit has been developed to be executed on Windows and Linux. Then non-portable code will need be duplicated for Windows and Linux. I’ll just assume a tree structure like •/SAS This folder is the root folder of the Genfit application. I contains all the folders and several script files. These script files will be described in next sections. •/SAS/GENSTORE 1Wikipedia 9 graph. The easier way to proceed is to create a graph with experimental logI in function of Q2 and the corresponding theoretical logI. genABCD.log It contains the complete list of fitted parameters. It could be used to read the resulting parameters to show as result 3.4.3 genABCD.log File It contains the complete list of fitted parameters. It could be used to read the resulting parameters to show as result. 3.5 Genfit Scripts There are several scripts inside Genfit that It’s worth keeping in mind. One of them is called Gallo and his mission is to execute the application Genfit. The other one is lxgen who is in charge of compiling. 3.5.1 Gallo Script Gallo is in charge of the execution of the application. Gallo calls to lxgen because a precompilation is need before executing genfit. The command to execute Gallo is: gallo 0002 last 1 1 where 0002 is the output prefix name. last is the folder where the input files are and where the output files will be. Thrid parameter is 1 if we are using fourier transform files 4th parameters is 1 if we have modified the parameter file. Basically, Gallo copy the input files (see Input files chapter) inside the root of the application. It executes lxgen with parameter 2 and after with parameter 4. After that all output files are copied to the output directory. 3.6 Fortran reading code Genfit is a huge Fortran application developed for ten years ago. Concerning to this project just the few first thousands of lines are interesting because it is the code where the input file is been read. All this code concerning to the reading of the input file is in genfit.f. ”.f” is the natural extension of the fortran files. ”.f90” and ”.f95” are used as well when a fortran 90 or 95 is been used. 3.6.1 Reading routines Genfit is reading input file line per line. Fortran uses a format statement to indicate wich type of value it is going to read. They are called format edit descriptors. 16 So, fortran code will need to have got a format edit descript for each line that it is going to read. This point in addition to the fact that fortran reads in a sequecial way we can realize that it will be very easy to make a mistake in the input file that it will provoque the failure on the execution of the application. We can see some examples of reading setences: write(*, 900) i, x 900 format (I4,F8.3) In this case the format label 900 is chosen somewhat arbitrarily, but it is common practice to number format statements with higher numbers than the control flow labels. After the keyword format follows the format codes enclosed in parenthesis. The code I4 stands for an integer with width four, while F8.3 means that the number should be printed using fixed point notation with field width 8 and 3 decimal places. 3.6.2 Common format codes The most common format code letters are: 1. A - text string 2. D - double precision numbers, exponent notation 3. E - real numbers, exponent notation 4. F - real numbers, fixed point format 5. I - integer 3.7 Main difficulties 1. Mainly, user needs to know the correct format of the input files. Specially on genABCD.dat, this file is very sensitive to mistakes. If a number is not well placed the fortran program will not be able to read the value and will failure. 2. User needs to know how to execute the application, I mean, which parameters Gallo need and to deal with the linux terminal or with Windows command line. 3. User needs to know how to prepare the output folder in order to Genfit be able to read it. User have to create a outptu folder where genABCD.dat and other input files will be placed in. 4. The fact of users facing with a enormous file with more than 30 thousands parameters and at the momento 50 models and getting bigger represents a too big challenge for users trying to modify the input parameters. 3.8 Proposal from the user At the beginning of the project the client proposes a schema or draft about a possible solution. This solution was given in PowerPoint format and it’s showing how the user wants the application looks like. In our first analysis we saw that this solution was a too much simple solution. It didn’t support all models and even for just one model, It didn’t take account all possible cases that we can have got. 17 Even of been a not realistic solution, it was good due to we can see what the user was expecting more or less. How he was expeting type the values and we could get an idea of ow the user wants to interact with the application. 18 Chapter 4 Design 4.1 Introduction To add a Graphic user interface to make it easier for users is the aim of any GUI. End-users face to software via GUI, it means that by creating a very well-done software is not the unique condition for our software to success. It will need an adequate interface between users and software. Sometimes software developers invest not enough time in the GUI provoking in most of the cases a non-acceptation of the software created. Before starting the description of our design we want to focus on the major problems in the software engineering. Some of them, we can say, are critics. Next lines I will write some of them because I consider important to keep in mind. Major problems developing software: 1. Too much code. Either tens of thousands, or hundreds of thousands, or millions of lines of code for an ”Application”. 2. No one really understands exactly what the code is doing. 3. There is insufficient documentation. In fact, it is so unusual to have documentation, it is ignored when it does exist. 4. We have little chance of ever understanding all of the interactions between different parts of a large system. 5. The people who do have a chance of understanding the code, very often don’t understand the application. 6. People do not reuse existing software either because they don’t trust it or because it is not general enough. Specifically in my case these problems are bigger because application deals with a very complex data analysis calculations. So, it is required to have got a very high level in physics to understand the program is doing. In addition, lack of documentation is present in this situation and obvious things for scientific can provoke a bad understanding for programmers who don’t have got enough knowledge in mechanical, psychical and biological fields. 19 4.2 Methodology The aim of this project is to build an user interface for a single application but the problem we try to solve is the same in most of the cases of fortran applications. We mean that users facing to huge and very complex input files is a trouble at the ESRF and programmers have to deal with. Then, if we are able to give a general solution for this problem or if we are able to give them a new or better solution our project will be more valuable. Given a better solution means for programmers to be able to build users interfaces in a easier and faster way. Furthermore, the quality of the software is even more important than getting it as fast as possible. If we are able to create a software by using a easy and fast way but with a bad quality will provoke a more complex supporting work later. and probably project will be abandoned some months later. Then, our solution will be designed with these priorities and in this order: 1. Quality. 2. Easy to do. 3. Fast to do. 4.2.1 User interface as isolated system An interesting thing we would like to do is to isolate the user interface. It means to be able to execute the application both with user interface and without user interface depending of the user preferences. Advanced users or users having the habit to use his application without user interface will follow using his application in a traditional way. Besides each more time popular remote technologies can provide us abilities to execute user interfaces remotely without security restrictions. We mean, we can have got the fortran program in our server or in a main frame inside of the intranet and users can execute the user interface in remote mode from his home or university. 20 In fact, this last point is very interesting due to two important points: first one is that fortran application require compilers and dependencies that they can not be solved on local machines as well as users can require execute fortran application on a main frame with high calculation performance instead of their home computers. Second one is that users can execute experiments from their home or university in the same way as if they were at the ESRF. We can go further and say that is possible to create a generic user interface system dealing with all fortran applications. 4.2.2 Technologies involved Usually, combining different technologies in the same project could make us to think that the project will be more complex. A developer will need first to learn all languages and later to manage them for programming systems. However, technologies involved in this project are created specifically to make it easier for developers. So we are using several languages and all of them have been created to be easier than predecesors. And by combining all of them we can expect not to increase the complexity of the project if not to reduce it. As programming language we have chosen Javascript, XUL (XML User interface Language) as interface language, XML for storing data and Fortran 95 for our main program. Javascript We have chosen Javascript because is very similar to c++ and java. So the number of new concepts required to learn javascript is very small. Javascript is both procedural and object-oriented language. Then we can create classes or we can develop as a procedural language or we can combine both options. That is really good because programmers who aren’t very familiar with oriented-object programming can develop their software in procedural manner or vice-verse. In fact, Javascript is called first-class function. That means we declare a function and it acts as a procedural function but as well as we can declare another functions inside of this function. Then this first function will become automatically a class. And we will can instantiate objects of this class. XML User interface Language XUL is a XML language created to be easy and faster. Besides we can use behind XUL another languages like javascript, python etc. Developers of XUL were very fanatical of the portability. Then XUL applications can be executed on Linux, Windows, Mac and as Mozilla Firefox Extension without changing any line of code. As XML language we can insert any XML language inside of XUL. For example we can insert a piece of code of HTML, SVG (Scalable Vector Graphics) or MathML (Mathematical Markup Language). We will use XUL to build the user interface. So we will create a .xul file for each window that we need. 21 XML for storing data XML is a standard and portable language for storing data. User interface need load and store information from user or another programs in anywhere. XML gets us the possibility to access information in a standard way. Another advantage of XUL is that practically all programming languages implement libraries to read and store data in XML format. Most of text editors are able to read XML formats and XML has been placed as a standard in facto. We will see later than XML offers as well as the possibility to be used as the input file of the Fortran program just adding a new library in charge of read and write XML for Fortran. This approach will be seen in next chapters. Fortran 95 Of course, we must not forget that this user interface we are thinking in is to be used on a fortran application. This fortran application will receive a input file and we will deal with it. We have got several options or our user interface creates a input file transforming XML data in expected input file or we modify the fortran program in order to get it able to read XML files. This point will discuss with much more details in next chapters. 4.3 Users’ cases Once we have decided which technologies we will use we need to have a look with a details a what this user interface is expected to do. The way to do that will be describing users’ cases. Before starting describing all users cases we are going to organize them in two classes. The fist one will be users cases which only administrator or advanced users can do. And the second one will be theses users cases which everybody can do even administrator. By separating in two different modes is required because there are some tasks that users can not do by themselves. We will describe here with detail which they are. Then this chapter will be divided in two different subchapters: Users cases in administration mode and in user mode. Of course, administration mode extends all features of user mode. 4.3.1 User mode Users can add new calculations and of course to execute the SAS application. This last point can be done in two different ways. In the first one user will can to execute a single input file and in the second one user will can execute several input files. This last one way was though as a kind of batch mode. Scientific can execute a huge experiment and go home to sleep expecting to have results one day later or perhaps two or more. Case number 1. Adding new experiment Then user will be able to insert a new experiment in the application. Managing this experiments is related in case number 2. 22 Case number 2. Editing experiments Once user have added a new experiment it must be able to: 1. Modify all parameters concerning to this experiment. This parameters are static and doesn’t change for each experiment. Some examples of these parameters are: scaling factor, wavelength band, source-sample distance, etc.... 2. Modify models inside of the experiment. It means user can add, remove and modify models of the experiments. Besides each model has got some parameters which user will need deal with. 3. Modify parameters of the experiment. These parameters are not static. It means user can add as more parameters as he want. Depending of the model these parameters will change. User can choose if he adds them or not. Some examples are: weight, concentration, etc... Case number 3. Executing a single experiment The user interface will need to able to execute the Fortran application. It means that one of its tasks will be to call the Fortran application and wait for its results. We have chosen an isolated user interface it means that the fortran application is not inside of the user interface. So a parameters we need will be the path to the Fortran application. Another one will be the path to the file with the scattering curve and of course the path where we want to have got the output files after execution of the program. 1. Path to the folder where GENFIT application is. Perhaps it is in another machine we will need the complete path to it. 2. Path to the folder where we can find the file with the scattering curve. 3. Path to the folder where user wants to have got all the output files. Two more parameters are required. One of them is to know if we are using Fourier transform in our experiment. The second one is to know if we are using error margin file. In positive case we will need the path to the error file we are using. Son, new parameters: 1. Fourier transform parameters 2. Path to margin error file 3. Margin error parameter Case number 4. Executing multiple experiments In this case user wants to execute a very long experiment or perhaps two or more experiments. Then application will execute one experiments after another one. For executing each experiment we will need a complete input file. Then a parameter of this users case will be the path to the XML file and of course, all parameters required for executing a single experiment explained in the users case number three. These parameters will be: 1. Path to all XML files containing input files. 2. Path to the folder where GENFIT application is. Perhaps it is in another machine we will need the complete path to it. 3. Path to the folder where we can find the file with the scattering curve. 4. Path to the folder where user wants to have got all the output files. 23 4.3.2 Administration mode In this section we will describe what are the tasks that the graphic user interface must be able to do in administration mode. Furthermore we will need to plan a system for the user interface for user to switch from user mode and administration mode and vice-verse Case number 1. Adding a new model Administrator can to extend the number of models of the application. It is not a common task and it is reserved to experimented users. Case number 2. Modifying a model Administrator can modify all the settings of a model already created. These settings are values as for example: random point numbers, radial grid, maximum rank harmonics, point of symmetry, etc.... Case number 3. Adding a new parameter For each model we will can have got more than one parameter. For example for the model called ”Gaussian chain with finite cross section” we have got two parameters called: ”Gyration radius” and ”Cross section radius”. User will be able to add new parameters. Case number 4. Modifying parameters Each parameters has a more or less static structure with the next values: starting, lower, upper, flag, kind, grid, lower integer, upper integer, etc... For each model and inside of each model for each parameters the user in administration mode will be able to manipulate all this information about the parameters. 4.4 Implementation This chapter will deals with how this application has been made. At the beginning of the project we had no previous knowledge about XUL, Fortran and user interfaces. So, we can say that this project has been developed completely from scratch. That means a few libraries have been created for us to help the development apart of all things concerning to the user interface: windows, windows code and Fortran code. 4.4.1 Two main approaches From the beginning we thought in two main approaches, one of them more sophisticated but both of them with identical results. In this chapter we will describe these two approaches: •To modify the fortran code of the SAXS application in order to make it to read XML files using a specific library to do that. •Create a translator between XML and the expected input file. 24 4.4.2 Using XML-Fortran reader Using xml-Fortran library we are able to read from Fortran to XML files. This library provided Fortran programmers have an all-Fortran solution for reading and writing XML files. We could use this library for: •Reading the files in much the same way as an ordinary text file - a stream-oriented method • •Directly reading the contents into a data structure that reflects the structure of the XML file •Constructing a tree of data from the XML file with essentially the same structure •Processing the contents using ”events”, in much the same way as the original Expat library. The most difficult challenge with this approach was to modify the Fortran code adding this library. Why was it a challenge?. Because: •No documentation about the code. •More than 40.000 thousand lines in the same code file •Code not structured at all. •Development started ten years ago up to our days using functions of the sixties. •and so on... XML-fortran works in the same way. You must build a schema with the data structure you want to use. Once you have created this data structure we need to run the XM-fortran parser which will convert automatically this schema to a fortran 90 class. This generated class will have got all functions to read and write a XML file with the structure expected. We can see in the next picture the process. We will need to modify all the routines in the fortran program concerning to the reading of the data by our new functions. This step is quite hard because of the number of lines we need to modify and because we will new to understand all the fortran code before executing any changes. In the next listing we can see how the XML schema looks like: 25 Chapter 5 Results 5.1 Study of complexity of our application There are too many opinions about how to measure the complexity of software. In fact it is not very simple to evaluate the complexity of a software because there are too many kind of software different. For example we can not compare easily a Fortran application with a web page. Both of these cases are software but it is quite difficult to compare them. Anyway as far as computing programmer concerns if the complexity of the software is low we will can modify the software easily for fixing bugs or to extend it. The aim of this report and project is not to enter in discussions about how to measure software complexity. So, I will use a system by counting lines of code. Why are we using this way?. Because it is easy to apply and it gives us an idea about the size of the software. Besides we can see clearly how many lines of code we are reusing. It is the way to see if in the future we want to build another user interface knowing how many package, libraries etc... we can reuse we will know how much time we will save developing the software. In our case, we can think the application as two subsystems of code. One of them is our specific application itself, its windows, its code and the other one is a set of general libraries that we will reuse in the future. So, we will see in this section how many files we have got a how many lines inside of each file. Then we will separate the files of our application and the files of the libraries. 5.1.1 Application: windows and code Firstly we are going to see a list with all files referring to Windows code. It means the files which perform task for windows. For example: load the xml file, load and save data, process the input file and answer to event like mouse or keyboard 1 133 ExperimentParameters . j s 2 219 MultipleProcess . js 3 139 ParameterSingleSection . js 4 55 Parameters . j s 5 179 Pr oce ss . j s 6 264 S i n g l e S e c t i o n E d i t . j s 7 326 S i n g l e S e c t i o n M o d e l s . j s 8 139 SingleSectionParameter . js 9 256 editModelMultiple . js 10 146 editMoldeWindow . js 11 67 f i l e E d i t o r . j s 12 291 main . j s 13 158 models . j s 14 15 16 2372 t o t a l Listing 5.1: wc -l *.* in /content/JSWindows 32 We can observe we have got many small pieces of code no more than four hundred lines for each file. It gives us the opportunity to manage our code more comfortable. The total of these lines of code (more than 2000) gives us an idea of the size. We have to remark that all these files have been written in javascript language. We will focus now in the xml code of the windows in our application: 1 2 171 ExperimentParameters . xul 3 105 MultipleProcess . xul 4 51 ParameterSingleSection . xul 5 140 Parameters . x u l 6 124 Pr oce ss . xul 7 191 S i n g l e S e c t i o n E d i t . xul 8 133 S i n g l e S e c t i o n M o d e l s . x ul 9 52 SingleSectionParameter . xul 10 24 XMLWindow. xul 11 78 editModelMultiple . xul 12 93 f i l e E d i t o r . x u l 13 153 main . xul 14 144 models . xu l 15 7 sample . xul 16 17 1466 t o t a l Listing 5.2: wc -l *.xul in /content No more than 1500 lines of xml code to build all our application. We have to say that it has around thirteen windows. Advantages of building application using XUL is that we can not make mistakes in the XML code. For example in languages as Visual Basic, Java or c sharp we will need to create object elements to create buttons, windows and so on... With this way of creating interfaces the number of errors is drastically reduced. 5.1.2 Libraries About our files composing the library we have got: 1 2 167 AddNewModels . j s 3 576 C r e a t e I n p u t F i l e . j s 4 120 CreateJavaData . js 5 392 Execute . j s 6 311 F i l e U t i l i t i e s . j s 7 182 G e n f i t U t i l i t i e s . j s 8 261 I n i t . j s 9 7 InputDirectoryProcess . js 10 217 OldXMLReader . j s 11 136 Parameters . j s 12 114 Pr oce ss . j s 13 325 WindowsEventsFunction . js 14 148 XMLU t ilities . j s 15 260 XMLWriter . j s 16 121 countWords . j s 17 18 3337 t o t a l Listing 5.3: wc -l *.* in /content/JS We have to say, to be honest, that all this files will not be reused for future applications because they are very dependent of the GENFIT structure. For example, GenfitUtilities.js has the classes that out application uses to describe the models of the proteins. However, the most of them are being reused in several parts of our software and the most of them will be reused in the future. For example, FileUilities.js has methods and functions in charge of open, save and execute files as well as open new dialog file windows to open and save files and directories. 5.2 Reusability In software engineering, reusability is the likelihood a piece of source code that can be used again to add new functionalities with small or no modification. In this way we can reduce 33 implementation time, increase the likelihood that prior testing and use has eliminated bugs and localizes code modifications when a change in implementation is required. Next graphic shows us how the code in our application is distributed. That means for example that new developments will be able to reuse the code of the libraries. Then we think is a good signal of quality in the software that the most of the code can be reused. 34 Chapter 6 User’s Guide 6.1 Installation In this section we will explain different ways to install Genfit’s user interface. This application has been conceived to be a very portable application and will can be run on linux, windows, mac and as Firefox extension. 6.1.1 On linux If we want to execute Genfit user interface on linux we will need an addition software called XULRunner. XULRunner is a Mozilla runtime package that can be used to bootstrap XUL+XPCOM applications that are as rich as Firefox or Thunderbird. It will provide mechanisms for installing, upgrading and uninstalling these applications. To make it easier this software has already been package together with genfit. Then end-users will not need to download again from internet. Steps to install the application: 1. Download the package genfit.zip or genfit.tar.bz from the website. 2. Go to the folder where genfit has been uncompressed. 3. Execute the script called ”start”. 6.1.2 On Windows If we want to execute Genfit user interface on linux we will need an addition software called XULRunner. XULRunner is a Mozilla runtime package that can be used to bootstrap XUL+XPCOM applications that are as rich as Firefox or Thunderbird. It will provide mechanisms for installing, upgrading and uninstalling these applications. To make it easier this software has already been package together with genfit. Then end-users will not need to download again from internet. Steps to install the application: 1. Download the package genfit.zip or genfit.tar.bz from the website. 2. Go to the folder where genfit has been uncompressed. 3. Execute the script called ”start.bat”. 35 6.1.3 On Mozilla Firefox Another interesting way to install Genfit user interface is inside of Mozilla Firefox. It makes possible to execute Genfit making an installation easier. With this methods the number of dependencies is reduced and you just will need to have got the browser Firefox installed. File .xpi are package extension of firefox. When Mozilla firefox tries to open a file with this extension it will try to install it automatically. Then we will need to open this package from internet or from local files and it will be installed. Steps to install the application: 1. Open Mozilla Firefox. 2. Go to https://genfitgui.blissgarden.org 3. Click on Genfit.xpi and click ”Install now” button to install 4. Restart Mozilla Firefox 36 5. Check if application is already installed 6.2 Modification of general parameters of the experiment To modify general parameters of the experiment: 1. Go to the menu Edit 2. Click on General Section 37 3. Modify parameters and click ”save” button to save. 6.3 Calculations 6.3.1 Adding a new calculation To add a new calculation: 1. Go to the initial window and on Experimental single section click on button called ”Add Exp.” 38 2. After clicking application will ask if you are sure you want to add a new experiment. Answer yes/not depending of what you want to do. 6.3.2 Static parameters There are two ways for editing a calculation. 1. doing double click on the calculation. 2. Clicking on the button called ”Edit section”. Once the windows has been open we edit the values and click ”Save” to save. We can see this action on the next picture. 39 6.3.3 Models We can edit models of the calculation.This means we can add new models, remove models and change parameters of the models. 1. Select the calculation we want to modify and after by clicking ”Edit models” button the window will appear. 2. Click on the text box called ”Select a model” to select a model to insert into the calculation. e can select several models using control key. After selecting all models click on button ”Add”. 40 Once we have selected models that take part of the calculation we will need to change the values of the experiment. 1. Select the model inside of the second text box in the middle of the window. 2. Modify all the weight parameters (in green) of the experiment. 3. Click ”save” button to save all changes. 41 2. Automatically a ”Processed” folder is suggested for the application inside of the input directory. Anyway user can will change this path to another one where the output files of the SAXS application will be moved there after of the execution. 3. We can edit the files of the scattering curve, we can modify if we consider necessary or we can read the values. As well as we can see easily if the file exists and which is the size of the file. 4. We will need to tell to the application what is the directory of the SAXS application. It can be a local path or a network path. This is very interesting because we don’t need any more to have got the SAXS application stored in our local hard disk. However if the application access is remotely we will need to give it permissions enough to be executed 5. We need to tell if we are going to execute SAXS in windows or in linux. Depending of our choose GUI will call to ”oca” or to ”gallo.bat” 6. We will define as well as paramteres as if we are using Fourier Transform and if we will use a parameter file. In case of use a parameter file we will need to give it the path of the file. Edit option is available too. Here we can see a screenshot of the execute single experiment window. 48 Chapter 7 Acknowledgments At the ESRF, sincere and genuine thanks to Darren Spruce, who was my internship tutor, for his computing experience, his how-to-do and specially for his always positive vision toward this project in particular and life in general. This work would not be possible without Francesco Spinozzi, who was the author of Genfit, a very valuable application for modeling proteins in solution, for his time even on holidays and his lovely skype meetings. To Claudio Ferrero for his complete attention and enthusiasm. At the UJF I am very grateful to Jean-Marc Thiriet who help us a lot during all our erasmus period and in general to the Universidad politecnica de Valencia and Institut Universitaire de Technologie to make this wonderful experience possible. My personal acknowledgment to all my close friends in Spain and Grenoble where we are sharing mountains, snow and good moments. Specially to Adri, Jorge and Mario for their motivation in our climbing training. To Tere, Blanca, Karmele, Antonito, Marga, Claude and Angela for their never-ending support at the freres Berthom. To Valentina, Ben, Paz and Fer for their help in our first steps in France and their trusted friendship. To Mum and Dad who are constantly supporting me even in difficult moments. And finally huge thanks to Ana for sharing with me every single moment and making me a rich man. 49