Generating Interactive Protein Structure Tutorial Using WebGL and HTML5 ______
______Elizabeth Montes April 25, 2014 CS 698 – Master’s Project in Computer Science California State University San Marcos (CSUSM)
Master’s Project Committee Members: Dr. Xiaoyu Zhang, CSUSM Department of Computer Science Dr. Ahmad Hadaegh, CSUSM Department of Computer Science Dr. Sajith Jayasinghe, CSUSM Department of Chemistry and Biochemistry
ii
DEDICATIONS I dedicate this project to the memory of my mother who has been an inspirational
human being and a great example of strength, courage, passion and love; to my father
who is a great example of hard work and loyalty to his family; and to my siblings who
are always there for me and who have become my strength in these past years; and to
my nieces and nephews who always fill me with joy.
iii ACKNOWLEDGEMENTS I would like to thank each and every committee member for their dedication of
time, advice, supervision, feedback and encouragement required for the completion of
this project. This project would not be possible if not were for their guidance,
encouragement and expertise.
iv
ABSTRACT
Proteins are large biological molecules of long polymers of amino acid residues, typically containing thousands of atoms and consisting of a uniform repetitive backbone and variable side chains attached to each residue. They fold into complex
3D structures to perform a vast array of functions within living organisms. In order to help students to better understand the protein structures, it is important that the student can visualize the details of 3D structures, and manipulate them interactively to focus on aspects of interest. Recent developments in web technologies such as WebGL and
HTML5, available in a wide range of browser on different platforms, made them the perfect choice to build cross-platform interactive tutorials for learning protein structures. This project, WebGL and HTML5 Interactive Protein Structure Tutorial
Generator (WHIPSTG: http://montes.co.nf/whipst.html), made it possible for biochemistry or biology professors to easily generate web tutorials that can facilitate students’ learning of protein structures. The generated tutorials allow the user to interact with protein visualization in 3D, answer true/false questions and multiple- choice questions, and read text. WHIPSTG uses GLmol – a 3D molecular viewer based on WebGL and JavaScript – to visualize and interactively manipulate the 3D protein. For the scope of this project, GLmol has been modified to include functionality for highlighting amino acids and highlighting a part of a protein sequence. I developed a web interface that provides the user with a short introduction about the project, the ability to easily generate an interactive tutorial and various examples of generated tutorials.
v
Table of Contents DEDICATIONS ...... iii ACKNOWLEDGEMENTS ...... iv ABSTRACT ...... v 1. INTRODUCTION...... 1 2. BACKGROUND ...... 3 2.1 WebGL ...... 3 2.2 HTML5 ...... 3 2.3 JavaScript ...... 4 2.3.1 Three.js ...... 4 2.3.2 jQuery ...... 4 2.3.3 jQuery UI ...... 5 2.4 Related Work ...... 6 3. DESIGN ...... 7 3.1 Web Interface Description ...... 7 3.2 Tutorial Description ...... 8 3.3 Web Interface View ...... 11 3.3.1 Web Interface Mapping Diagram ...... 11 3.3.2 Web Interface Website Flow ...... 12 3.3.3 WHIPSTG Interaction with the User ...... 25 3.3.4 WHIPSTG Data Flow ...... 29 3.3.5 Widget Information ...... 31 3.4 Tutorial View ...... 36 3.4.1 Tutorial Mapping Diagram ...... 36 3.4.2 Tutorial Website Flow ...... 37 4. IMPLEMENTATION ...... 39 4.1 Web Interface Implementation ...... 39 4.2 Tutorial Implementation ...... 50 5. TEST CASES ...... 65 5.1 Test Case Create a WHIPSTG Tutorial ...... 65 5.2 Test Case GLmol Highlight Amino Acids PDB ID 2POR ...... 74 5.3 Test Case GLmol Highlight Sequence PDB ID 2POR ...... 79 5.4 Negative Test Case WHIPSTG Missing Information ...... 82 5.5 Negative Test Case GLmol Highlight Amino acids PDB ID 1111 ...... 85 6. CONCLUSION AND FUTURE WORK ...... 88 7. REFERENCES ...... 89 APPENDICES...... 92 1. whipst.html ...... 92 2. file.html ...... 99 3. whipst.js ...... 103 4. GLmol.js ...... 118 5. widgetFunctionality.js ...... 131 vi
6. whipst.css ...... 133 7. simple.css...... 141 8. left.css ...... 145 9. right.css ...... 151
vii
List of Figures Figure 1 Web Interface ...... 8 Figure 2 WHIPSTG Simple Layout ...... 9 Figure 3 WHIPSTG Left Layout ...... 10 Figure 4 WHIPSTG Right Layout ...... 11 Figure 5 WHIPSTG Web Interface Mapping Diagram ...... 12 Figure 6 Web Interface Welcome Tab ...... 13 Figure 7 WHIPSTG Tab ...... 14 Figure 8 Fill Out True False Question Widget ...... 16 Figure 9 Adding GLmol Widgets ...... 17 Figure 10 Title and Save File ...... 18 Figure 11 WHIPSTG Help Tab ...... 20 Figure 12 WHIPSTG Simple Tab ...... 21 Figure 13 WHIPSTG Left Tab ...... 22 Figure 14 WHIPSTG Right Tab ...... 23 Figure 15 WHIPSTG GLHAA Tab ...... 24 Figure 16 WHIPSTG GLHS Tab ...... 25 Figure 17 WHIPSTG Use Case Diagram ...... 29 Figure 18 WHIPSTG Data Flow Diagram...... 31 Figure 19 True False Question Widget ...... 32 Figure 20 Multiple Choice Question Widget ...... 33 Figure 21 GLmol Widget ...... 34 Figure 22 GLmol Highlight Amino Acids Widget ...... 35 Figure 23 GLmol Highlight Sequence Widget ...... 35 Figure 24 Text Widget ...... 36 Figure 25 WHIPSTG Tutorial Mapping Diagram ...... 37 Figure 26 ShortTutorial.html Website Uses Simple Template ...... 38 Figure 27 Test Case Create a Tutorial Welcome Tab ...... 66 Figure 28 Test Case Create a Tutorial WHIPSTG Tab ...... 67 Figure 29 Test Case Create a Tutorial Enter Title ...... 68 Figure 30 Test Case Create a Tutorial Enter Text ...... 69 Figure 31 Test Case Create a Tutorial False Question ...... 70 Figure 32 Test Case Create a Tutorial Multiple Choice Question ...... 71 Figure 33 Test Case Create a Tutorial GLmol Widgets ...... 72 Figure 34 Test Case Create a Tutorial Save File ...... 73 Figure 35 Test Case GLmol Highlight Amino Acids PDB ID 2POR Browser Display .... 74 Figure 36 Test Case GLmol Highlight Amino Acids PDB ID 2POR Highlight Valine .... 75 Figure 37 Test Case GLmol Highlight Amino Acids PDB ID 2POR Highlight E, L, and I ...... 76 Figure 38 Test Case GLmol Highlight Amino Acids PDB ID 2POR Rotate and Zoom .... 77 Figure 39 Test Case GLmol Highlight Amino Acids PDB ID 2POR Side Chains ...... 78 Figure 40 Test Case GLmol Highlight Amino Acids PDB ID 2POR Valine Side Chain .. 79 Figure 41 Test Case GLmol Highlight Sequence PDB ID 2POR Navigate Link ...... 80 Figure 42 Test Case GLmol Highlight Sequence PDB ID 2POR Highlight Sequence ...... 81 Figure 43 Test Case GLmol Highlight Sequence PDB ID 2POR Rotate ...... 82 Figure 44 Negative Test Case WHIPSTG Missing Widget Info all Widgets ...... 83
viii
Figure 45 Negative Test Case WHIPSTG Missing Widget Info Error Messages ...... 84 Figure 46 Negative Test Case WHIPSTG No Widgets Error Message ...... 85 Figure 47 Negative Test Case GLmol Highlight Amino Acids Save File ...... 86 Figure 48 Negative Test Case GLmol Highlight Amino Acids Widget Error Message .... 87
ix
1. INTRODUCTION
Biochemistry is the study of living organisms and of the molecular basis of the transformations that occur in living cells. It is an important field because it “…has become the foundation for understanding all biological processes. It has provided explanations for the causes of many diseases in humans, animals and plants [22].” Much of biochemistry deals with structures such as proteins. Proteins are large biological molecules of long polymers of amino acid residues, typically containing thousands of atoms and consisting of a uniform repetitive backbone and variable side chains attached to each residue. They fold into complex 3D structures to perform a vast array of functions within living organisms. In order to help students to better understand the protein structures, it is important that the student can visualize the details of 3D structures, and manipulate them interactively to focus on aspects of interest.
Bioinformatics is a scientific field that develops methods for storing, retrieving organizing and analyzing biological data. This field provides molecular graphic systems that are used for visualizing macromolecules, such as protein structures.
The purpose of this project, WebGL and HTML5 Interactive Protein Structure Tutorial
Generator or WHIPSTG, is to generate an interactive tutorial for learning protein structures. WHIPSTG provides an interactive web interface that allows the user to determine what contents will be on the interactive tutorial. The interactive tutorial, which is the output of this project, provides protein visualization using GLmol; a web based molecular graphic system. The WHIPSTG project utilizes GLmol (WebGL based), HTML5, Cascading Style
Sheets (CSS), jQuery UI and jQuery TE. The web interface contents are created using
HTML5 and styled using CSS. The drag and drop functionality is applied from jQuery UI, see Background below for more information. A text editor from jQuery TE is included as one of the widgets. The tutorial uses HTML5 and CSS for displaying contents on the web and JavaScript to load visualization capabilities from GLmol. The tabs to show the GLmol widgets are created using jQuery UI.
Before the creation of this project, Dr. Jayasinghe used a tutorial showing text and
Jmol 3D protein structure visualization. Jmol [9] is a molecular graphic system that requires the use of Java plugin and has several limitations. This tutorial was coded by hand, so their implementation required many hours. These features allow the improvement of the tutorial thereof. So, the project presented in this paper (WHIPSTG) provides a generator for creating an interactive tutorial that adds several features to the previous tutorial. These are the true or false questions and multiple choice questions. In addition, it also has the last tutorial functions: display text and include 3D protein visualization but instead of using Jmol uses GLmol to load the protein. Moreover, it uses WebGL and
HTML5 to load 3D protein visualization and eliminate the need of using plugins.
Therefore, WHIPSTG improves the previous tutorial by adding more features and eliminating the use of plugins.
The outline of the rest of the paper is detailed next:
Chapter 2 describes background ideas used by WHIPSTG.
Chapter 3 describes the design of WHIPSTG.
Chapter 4 explains implementation of WHIPSTG in detail.
2
Chapter 5 demonstrates the functionality of WHIPSTG by providing several
test cases.
Chapter 6 concludes the report and discusses future work.
The appendix section at the end contains the code of the contributions of this
project.
2. BACKGROUND There are five major technologies utilized in the WHIPSTG implementation, including WebGL, GLmol, HTML5, JavaScript and jQuery UI. At the end of this chapter, a description of related work is provided as well.
2.1 WebGL WebGL is a cross-platform, royalty-free web standard for a low-level 3D graphics
API based on OpenGL ES 2.0, exposed throughout the HTML5 Canvas element as
Document Object Model Interfaces [19]. Semantically, WebGL is very similar to OpenGL
ES 2.0. The specification is very close to the OpenGL ES 2.0 specification, with some concessions made for what developers expect out of memory-managed languages such as
JavaScript. WebGL allows browsers to implement and run 3D content without the need of a plugin. WebGL Working Group vendors are major browsers vendors such as Apple
(Safari), Google (Chrome), Mozilla (Firefox), and Opera (Opera).
2.2 HTML5
HTML5 is a work in progress that will be the new standard for HTML in the near future. HTML5 is cooperation between the World Wide Web Consortium (W3C) and the
Web Hypertext Application Technology Working Group (WHATWG). WHATWG was
3 working with web forms and applications, and W3C was working with XHTML 2.0. In
2006, they decided to cooperate and create a new version of HTML [7].
Some rules of HTML5 were established: a) new features should be based on
HTML, CSS, DOM, and JavaScript, b) reduce the need for external plugins (like flash), c) better error handling, d) more markup to replace scripting, e) HTML5 should be device independent, f) the development process should be visible to the public [7].
Also, new features were included in HTML5: a) the
Even though HTML5 is not yet official standard, and no browsers have full
HTML5 support, all major browsers (Safari, Chrome, Firefox, Opera, and Internet
Explorer) continue to add new HTML5 features to their latest versions.
2.3 JavaScript JavaScript is the scripting language of the Web. All modern HTML pages are using JavaScript to add functionality, validate input, communicate with web servers, and much more [19]. There are two JavaScript libraries used in this project: Three.js and jQuery. Description of both libraries is provided next.
2.3.1 Three.js
Three.js is a lightweight cross-browser JavaScript library/API used to create and display animated 3D computer graphics on a web browser. Three.js scripts may be used in conjunction with the HTML5 canvas element, or WebGL [13]. The file,
Three49custom.js, contains the Three.js library. GLmol uses this library for drawing,
4 coloring, lighting and viewing the protein structure in 3D. But also for rotating, translating and slab.
2.3.2 jQuery
jQuery is a fast, small and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, and Ajax much simpler with an easy-to-use API that works across many browsers [10]. In this project, there are two versions of jQuery used: version 1.7 and version 1.10.2.
The file jquery-1.7.min.js contains version 1.7. GLmol uses this library to select html elements, using either the class selector “.” or the id selector “$”.
The file jquery-1.10.2.js contains version 1.10.2. This library is needed for jQuery UI and jQuery TE to run properly. Also, it is used by WHIPSTG to select html elements with id or with class, using the “$” or “.” selectors.
This project also uses a jQuery Plugin, jQuery TE, which provides a very helpful
HTML editor. The plugin is kept on the file jquery-te-1.4.0.js. The functions it offers are headings, bold, italic, superscripts, subscript, centered, left aligned, right aligned, strike through, and links.
2.3.3 jQuery UI
jQuery UI is a curated set of user interface interactions, effects, widgets, and themes built on top of the jQuery JavaScript library [12]. It significantly facilitates building an interactive web page or application. This project uses version 1.8.9 and version 1.10.4 of this library.
5
The file, jquery-ui-1.8.9, contains version 1.8.9 which is used in the tutorial website. Since the tutorial uses GLmol and GLmol authors implemented it using jQuery
1.7, a jQuery UI library compatible to jQuery 1.7 was needed. So, that is the reason why we use version 1.8.9 for the tutorial website of this project. jQuery UI 1.8.9 provides interaction the tabs in the tutorial website when using the left and right templates.
The file, jquery-ui-1.10.4.js, contains library version 1.10.4 and provides the dragging, dropping, sorting, tabs and accordion capabilities used in WHIPSTG. This provides user interactivity in the system and also a user interface.
2.4 Related Work
Two themes that have inspired this project have been interactive learning using the
Internet and visualization of proteins using the viewer GLmol.
The incorporation of the Internet into face-to-face instruction improves students’ academic achievement. The principal cause of the improvement is not the increase in the time spent studying online that using the Internet for educational purposes may entail.
Rather, increasing the time spent studying online is only useful when it takes place as some form of interactive learning. The interactive content of a website engages the student to stay longer or to visit often, broadening her learning [3].
GLmol (http://webglmol.sourceforge.jp/glmol/viewer.html) is an open-source molecular viewer based on WebGL and JavaScript. Molecular models can be embedded in webpages without using Java or plugins. Presently, GLmol has several features but the most important to note here is that it can read and load Protein Data Bank (PDB) files into a webpage as 3D images. It also features the basic GL operations such as rotation, scale, and zoom of the 3D image. GLmol uses two JavaScript libraries jQuery and Three.js [6].
6
GLmol source code and demo can be found in [6]. Next, we will provide some details of a Protein Data Bank.
Protein Data Bank (PDB) is a repository of atomic coordinates and other information describing proteins and other important biological macromolecules. Structural biologists use methods such as X-ray crystallography, NMR spectroscopy, and cryo- electron microscopy to determine the location of each atom relative to each other in the molecule. Then they deposit, annotate and publicly release these locations into the archive by the wwPDB [21]. PDB file encodes the information obtained from these methods and are found in the PDB. These files contain information about the protein such as the protein sequence, protein chain and other information.
WHIPSTG adds interactivity to the web interface part of the project and in the tutorial website that is generated from the web interface. Its interactive features will allow students to interact with true or false questions and multiple-choice questions. One interactive feature is the feedback that will be displayed when students answer a question wrong. Moreover, this project provides protein visualization by using GLmol that adds interactivity to the websites.
3. DESIGN The WHIPSTG project is implemented using interpreted and scripting languages. The technologies used are WebGL, HTML5, JavaScript, Cascading Style Sheets (CSS), jQuery, and Three.js. As mentioned in the Introduction, this project is divided into two parts: a web interface and a tutorial.
The following sections will describe the web interface, the tutorial, the web interface view, and the tutorial view. The next section provides a description for the web interface.
7
3.1 Web Interface Description
The web interface contains eight tabs: Welcome, WHIPSTG, Help, Simple, Left,
Right, GLHAA and GLHS. The objective of every tab is explained in the Web Interface
View section of this paper. Figure 1 below shows how the web interface looks.
Figure 1 Web Interface 3.2 Tutorial Description There are three template options for generating a tutorial: simple, left and right.
The simple layout shows the contents of the widgets ordered vertically and in top to bottom order. Figure 2 below shows a simple layout.
8
Figure 2 WHIPSTG Simple Layout The left layout has two sides, the left side that has the GLmol widgets shown each on one tab, and the right side where the content from the rest of the widgets are shown in order. Figure 3 below shows a left layout.
9
Figure 3 WHIPSTG Left Layout Similarly, the right layout has two sides, the left side that has the contents from the true false question, multiple choice question and text widgets displayed in order, and the right side that has the GLmol widgets shown each on one tab. Figure 4 below shows a right layout.
10
Figure 4 WHIPSTG Right Layout This section described the tutorial. The next section will describe the web interface view.
3.3 Web Interface View This section will explain the web interface mapping diagram, the web interface website flow, WHIPSTG interaction with the user, WHIPSTG data flow and the widget information required to be entered by the user.
3.3.1 Web Interface Mapping Diagram
Figure 5 below shows a mapping diagram of the web interface. It specifies that whipst.html, the main file, contains seven links. Three of those links are CSS files and four of them are JavaScript files.
11 Figure 5 WHIPSTG Web Interface Mapping Diagram
3.3.2 Web Interface Website Flow
If we navigate to http://montes.co.nf/whipst.html, we see a page looking like Figure 6 below. It can be easily noted that the web interface contains eight tabs: Welcome,
WHIPSTG, Help, Simple, Left, Right, GLHAA and GLHS. In continuation, the tabs will be briefly explained.
12 Welcome Tab
The Welcome tab is selected as default. The Welcome tab provides a short introduction explaining the topic and the scope of the project. Also, it displays a GLmol widget with a
3D visualization of protein structure 2POR.
Figure 6 Web Interface Welcome Tab WHIPSTG Tab
The WHIPSTG tab has four areas each with a different functionality: left area, middle area, top right area, and bottom right area. The four areas are described next.
13
Figure 7 WHIPSTG Tab Left Area In the left area, there are six widgets that are crucial for the file to be created. The
six widgets are named: true false question, multiple choice question, GLmol,
GLmol highlight amino acids, GLmol highlight sequence and text. In the middle
area, there is a rectangle. Each of the six elements can be dragged and dropped into
the middle area but they cannot be dropped into the trash section.
Middle Area In the middle area, there is a prompt for a page title to name the tutorial. Every
widget asks for information as well, please see section 3.5 for more details. When
14
each element is dropped on the middle area, the widget changes interactively and
displays input fields for the user to enter information. Every item in the middle
area can be sorted by dragging it up or down. Also, dragging it out of the middle
area and then dropping it into the trash section can delete it.
Top Right Area In the top right area, there is a trash section and a template section. The trash
section’s holds elements that are not wanted in the middle area. Items dropped on
the trash section are added to an invisible list. The template section chooses what
template to use for the tutorial website.
Bottom Right Area In the bottom right area, there are two buttons: reset, save file. The reset button
removes all elements from the middle area so the user can start from zero again.
The save file button saves the file (tutorial) to the computer.
As noted previously, WHIPSTG objective is to create a tutorial to help in the study of proteins. This section will describe the process to create a short tutorial, and the next section will show the tutorial created.
First, we drag a True False Question from the left area into the middle area and enter some information on the text input fields. The browser will look like Figure 8 below.
15
Figure 8 Fill Out True False Question Widget
Now, we add a GLmol widget from the left area to the middle area and we enter 2POR as the PDB id. We add a GLmol Highlight Amino Acids widget to the middle area and enter
2DHB as the PDB id. We add a GLmol Highlight Sequence widget into the middle area and enter 2POS as the PDB id. Figure 9 below displays these steps.
16
Figure 9 Adding GLmol Widgets Then, enter Short Tutorial as the title of the tutorial. Finally, click on Save
File. Figure 10 below shows that the file has been saved as ShortTutorial.html. The title for the tutorial is optional and it has a default value of "file.html".
17
Figure 10 Title and Save File This concludes this short tutorial that has been created in the WHIPSTG tab.
Help Tab
Figure 11 below shows the Help Tab, which provides the user with basic information in case she has a question on how to use WHIPSTG. The tab shows an accordion menu where the user can click on an accordion tab and see the content of that sub-section. For example, on Figure 11 we can see that the “What is WHIPSTG?” accordion tab is selected and its content is shown.
18
There are nine help topics:
What is WHIPSTG?
What are the WHIPSTG Components?
What information is required by widgets?
What is a tutorial?
How to delete an unnecessary widget?
How to delete all widgets?
How do the templates look?
What do I do if the tutorial I created does not work?
19
Figure 11 WHIPSTG Help Tab Simple Tab
The simple tab displays an embedded reference of the page located at http://montes.co.nf/testcase/SimpleTutorial.html. The webpage is a tutorial created using the six widgets. It is included in the Simple tab as an example of how the user can interact with the tutorial using this template. The Simple tab looks like Figure 12 below.
20
Figure 12 WHIPSTG Simple Tab Left Tab
The left tab displays an embedded reference of the web page located at http://montes.co.nf/testcase/LeftTutorial.html. The embedded webpage is a tutorial created using the six widgets. It is included in the Left tab to portray an example of how the user can interact with a tutorial using the left template. The Left tab looks like Figure 13 below.
21
Figure 13 WHIPSTG Left Tab Right Tab
The right tab displays an embedded reference of the web page located at http://montes.co.nf/testcase/RightTutorial.html. The embedded webpage is a tutorial created using the six widgets. It is included in the Right tab to portray an example of how the user can interact with a tutorial using the left template. The Left tab looks like Figure
14 below.
22
Figure 14 WHIPSTG Right Tab GLHAA Tab
The GLHAA tab displays an embedded reference of the webpage located at http://montes.co.nf/testcase/GLHAA.html. The embedded webpage is included in the
GLHAA tab to portray how the user can interact with the GLmol Highlighting Amino
Acids functionality added to GLmol. The GLHAA tab should look like Figure 15 below.
23
Figure 15 WHIPSTG GLHAA Tab GLHS Tab
The GLHS tab displays an embedded reference of the webpage located at http://montes.co.nf/testcase//GLHS.html. The embedded webpage is included in the
GLHS tab to portray how the user can interact with the GLmol Highlighting Amino Acids functionality added to GLmol. The GLHS tab should look like Figure 16 below.
24
Figure 16 WHIPSTG GLHS Tab
3.3.3 WHIPSTG Interaction with the User
Figure 17 below contains an UML use case diagram that shows all entities and the actions they can perform in WHIPSTG. An explanation of these will be detailed next.
User
The user is any person that uses the system. Every user has the ability to perform all actions described in this chapter.
25
Drags Widget
The user is able to drag every widget from the left and middle area. Please see section
3.3.5 to know what information is required by widgets. Every time the user drags a widget from the left area, it is cloned. This allows the user to create several instances of the same widget. The dragged widget can only be dropped into sortable areas that accept it.
Drops Widget
The user is able to drop every widget into a sortable area. If the user tries to drop the widget into a not sortable area, the widget will go back to its original place. This will not produce any changes in the page. There are two sortable areas where the widgets can be dropped: the middle area and the trash area. The behavior of the widgets in both areas will be explained next.
Widget Behavior in Middle Area
When the widget is dropped in the middle area, the widget changes its form according to what information will be required from the user. For example, for a GLmol widget, only the PDB id is asked for. So, the widget changes interactively and an html input field is shown to obtain necessary information. Please see Section 3.3.5 to see what information is required by each widget. Every widget that is dropped on the middle area is sortable. This means that it can be dragged up or down to change its order on the list. Every widget can also be dragged horizontally, but this will not change its order on the list.
26
Widget Behavior in Trash Area
Every widget can be dragged horizontally. This characteristic is what allows a widget to get to the trash area. Only widgets from the middle area will be accepted from the trash area. Those widgets coming from the left area will be returned to their destination.
Deletes Widget
If for some reason, the user made a mistake and drags the incorrect widget into the middle area, the user can delete the widget. A widget is deleted by dragging the widget into the trash area. We explained above how the widget behaves in the trash area.
Selects Template
The user is able to choose from three basic templates. Each template defines a different style for the tutorial file created by WHIPSTG. To see an example of a tutorial using the simple template go to http://montes.co.nf/whipst.html and click on the Simple tab.
Similarly, to see an example of a tutorial using the left template, click on the Left tab.
Also, click on the Right tab to see an example of an interactive tutorial using the right template.
Saves File
At any time, the user can choose to save the file. There are times where WHIPSTG indicates the lack of or missing information once the user tries to save the file. For example:
When nothing has been dropped on the middle area. The message is given
as a JavaScript alert box.
27
When information on the widget has not been filled out. The message is
shown next to the empty field.
When the user drops a widget in the middle area and then deletes it. The
message is given as a JavaScript alert box.
The file will be saved when something has been dropped on the middle area, and every field required is filled out.
File
The file created, referred to as the tutorial, will contain the information written on the widgets dropped into the middle area. It will display this information according to the template selected.
28
Figure 17 WHIPSTG Use Case Diagram This section covered WHIPSTG interaction with the user. The next section will cover how data flows in this system.
3.3.4 WHIPSTG Data Flow
Figure 18 shows a data flow diagram that describes how data flows in the WHIPSTG system. It also shows the actions needed for the creation of the tutorial. The following sections will explain what happens during the interaction between entities and processes.
29
User and Drop Interaction
In this interaction, the user drags a widget and drops it into the middle area. Once the widget is dropped, the widget asks for information. Widgets display input prompts where information will be written. Then, the user enters the appropriate information. This information will be available for the system when the user requests to save the file.
User and Template Interaction
The user selects a template from three options: simple, left and right. The user selection is available for when the user requests to save the file.
User and Save File Interaction
The user requests to save the file. If all the information on the widgets has been entered, the file will be saved. If there is some information missing, a negative response will be sent to the user. The word “Required” in red will be displayed next to the input field missing. Once all issues of this type are corrected, the message will disappear and the file will be saved.
Saves File and File interaction
At this point, the information required must be in the correct form to save the file. This means that all the information required must be filled out and a template must be selected.
If information is missing, the system will display a message asking to correct the problem.
When everything is correct, the file will be saved.
30
Figure 18 WHIPSTG Data Flow Diagram This section described how data flows in the system. The next section will explain what information is needed for every widget.
3.3.5 Widget Information
WHIPSTG consists of six widgets that the user can select from. Every widget asks for specific information. Below, it will be specified what information is required by every widget.
31
True False Question
Figure 19 True False Question Widget Figure 19 shows how the True False Question widget looks like. This widget asks for:
Question This is asking for a true false question that the user wants to be in the tutorial. A
true false question is a statement that is either true or false. Write this question on
the input field in the widget.
Correct Answer This is the correct answer of the question given in 3.3.1.1. For example, true.
Select one answer from the select menu in the widget.
Explanation Correct This is a message to be displayed when the person using the tutorial selects the
correct answer. For example, the user might want to encourage the person using
the tutorial with a message like: “Great job! Keep up the good work!”
Explanation Incorrect This is a message to be displayed when the person using the tutorial selects the
incorrect answer. In this case, the user might want to encourage the person using
the tutorial to keep studying. For example, the user might use a message like: “Not
quite right! Please review Chapter 2, Section 3 of our textbook!”
32
Multiple Choice Question
Figure 20 Multiple Choice Question Widget Figure 20 shows how the Multiple Choice Question widget looks like. This widget asks for:
Question This is the multiple-choice question. A multiple-choice question is a type of
question that provides a question and four possible answers in which only one
answer is correct. Write this question in the input field provided.
A This is the first answer/choice. Write it in the input field provided.
Explanation This is an explanation for the A answer. If answer A is correct or incorrect, what
message does the user want to give to the person using the tutorial? Consider a
positive or negative message. Write this in the input field provided.
B This is the second answer/choice. Write it in the input field provided.
33
Explanation This is an explanation for the B answer. If answer B is correct or incorrect, what
message does the user want to give to the person using the tutorial? Consider a
positive or negative message. Write it in the input field provided.
C This is the third answer/choice. Write it in the input field provided.
Explanation This is an explanation for the C answer. If answer C is correct or incorrect, what
message does the user want to give to the person using the tutorial? Consider a
positive or negative message. Write it in the input field provided.
D This is the fourth answer/choice. Write it in the input field provided.
Explanation This is an explanation for the D answer. If answer D is correct or incorrect, what
message does the user want to give to the person using the tutorial? Consider a
positive or negative message. Write it in the input field provided.
Correct Value This is the correct value of the question. Select one answer (A, B, C or D) from the
select menu provided.
GLmol
Figure 21 GLmol Widget
Figure 21 shows how GLmol widget looks like. This widget asks for:
34
PDB Id This is the id of the protein structure displayed on the tutorial. Write it in the input
field provided.
GLmol Highlight Amino Acids
Figure 22 GLmol Highlight Amino Acids Widget Figure 22 shows how GLmol Highlight Amino Acids widget looks like. This widget asks for:
PDB Id This is the id of the protein structure displayed on the tutorial. Write it in the input
field provided.
GLmol Highlight Sequence
Figure 23 GLmol Highlight Sequence Widget Figure 23 shows how GLmol Highlight Sequence looks like. This widget asks for:
PDB Id This is the id of the protein structure displayed on the tutorial. Write it in the input
field provided.
35
Text
Figure 24 Text Widget Figure 24 shows how the Text widget looks like. This widget asks for:
Text This is some text that the user wants to display in the tutorial, for example, text
describing a protein structure or a set of instructions to perform during the tutorial.
This section described the web-interface mapping diagram, the web-interface website flow, WHIPSTG interaction with the user, WHIPSTG data flow and widget information.
The next section will describe the tutorial mapping diagram and tutorial website flow.
3.4 Tutorial View The tutorial generated by WHIPSTG is an interactive website. The interactivity comes from JavaScript files that shall be included in the html page. In this section, we will describe the tutorial mapping diagram and the tutorial website flow.
3.4.1 Tutorial Mapping Diagram
Figure 25 shows the tutorial mapping diagram. In this diagram, we can see that file.html or title.html (title is the text inputted by the user) is composed of four CSS files and five JavaScript files. However, there are three CSS files that do not need to be included all at the same time. These files are simple.css, left.css and right.css. These are
36 the template files; only one template is loaded at a time. Thus, the tutorial will include whatever file the user chooses.
Figure 25 WHIPSTG Tutorial Mapping Diagram
3.4.2 Tutorial Website Flow
37
Figure 26 shows the contents of the tutorial named ShortTutorial.html previously created. It contains a true false question widget, a GLmol widget, a GLmol Highlight
Amino Acids widget and a GLmol Highlight Sequence widget. The tutorial uses the simple template, which shows everything in vertical top to bottom order. This is the order given to the widgets in the middle area when creating the tutorial.
Figure 26 ShortTutorial.html Website Uses Simple Template
38
Go to http://montes.co.nf/testcase/SimpleTutorial.html to interact with a very similar tutorial.
This chapter covered the design of WHIPSTG. The next chapter will cover the system’s implementation.
4. IMPLEMENTATION In the last chapter, we explained WHIPSTG’s design by providing web interface and tutorial information. In this chapter, we will explain the web interface and the tutorial implementation. We will be referring to code included in the Appendix section at the end of this paper.
4.1 Web Interface Implementation The web interface is implemented using HTML5, JavaScript and CSS. There are a total of seven files that take part of the implementation. There is one HTML5 file,
“whipst.html”, which is the main file of the web interface. There are three CSS files:
“whipst.css”, “jquery-te-1.4.0.css” and “jquery-tabs-accordion.css”. There are four
JavaScript files: “whipst.js”, “jquery-1.10.2.js”, “jquery-te-1.4.0.js” and “jquery-ui-
1.10.4.js”. Some of the files contain libraries that have been explained in the Background chapter, so they will not be explained next. However, the key functionality of the rest will be detailed next.
The main file of the system “whipst.html” (appendix 1) is responsible for defining the areas of WHIPSTG and keeping the text contents of the entire webpage. This file includes JavaScript and CSS files needed for proper execution. Three JavaScript files have been included (lines 10 - 13 below). Three of these JavaScript files are default libraries: jQuery library is used for selecting objects from the Document Object Model (DOM),
39 jQuery TE includes the text editor plugin for the text widget and jQuery UI loads the user interface for the web interface. The last JavaScript file is “whipst.js” which functionality is explained later in this section. There are also three CSS files included (lines 14 - 16 below), which define the style for the main page, the jQuery TE text editor and the jQuery
UI accordion and tabs respectively.
10 11 12 13 14 15 16
The GLmol widget shown in the Welcome tab of the web interface needs three
JavaScript files for its proper execution. The files are included at the end of the document.
Line 294 below loads the Three.js library that is required to display 3D objects in the browser. The file, “GLmol.js”, is responsible for reading the Protein Data Bank file, parse its contents and draw the atomic coordinates into 3D protein visualization (line 295). Also,
“widgetFunctionality.js” file is included in line 296 which functionality is explained later in this section.
294 295 296
40
The body of the page contains a header (line 19), a div to hold the tabs for navigation in the web interface (line 22), and a footer (line 291).
19 Generating Interactive Protein Structure Tutorial Using WebGL and HTML5
21
22 above). To define a tab we need two elements: a header and content. Headers are defined with an unordered list where every list element contains a header for a tab (line 25 below). In this case, “Welcome” is the header for tab-1.
23
- 24
- 25 Welcome 26 48
49
The web interface also utilizes a jQuery UI accordion menu. Similar to the tab, the accordion menu also has a header and content. However, the header of the accordion menu is defined with a heading tag, in this case with
(line 122 below). The accordion contents are placed inside a div element written right after the heading tag as in line 123 below.
41
121
What is WHIPSTG?
123Now, that the tabs and accordion menu are properly defined in HTML5 we attach the required functionality using JavaScript. We select the tabs by id “whipstTabs” using jQuery id selector “#” and then calling the tabs() jQuery UI function (line 299 below).
Similarly, we select the accordion menus by id “helpAccordion” using jQuery id selector
“#” and then call the accordion() jQuery UI function (line 300 below).
298 $(function(){ 299 $('#whipstTabs').tabs(); 300 $('#helpAccordion').accordion(); 301 });
In the second tab, we define the widgets. They are defined using a list where every list item is a widget. Every list item is assigned an id to identify each widget. For example, the first item in the list is assigned id “trueFalseQuestion” to define a true false question widget (line 78 below). Also, every widget is assigned a class “boxes” and has a
77
- 78
- 79 80 81
- 82 83 84
- 85 86 87
- 88 89 90
- 91 92 93
- 94 95
42
96
The file “whipst.css” (appendix 6) is responsible for the style of the webpage. This file specifies the style of the body, the header and the footer of the page. It also styles all the components of WHIPSTG. It sets the color, width, height and position of the widgets, the middle area, and the right areas. It contains the style for the buttons and the picture of the trash section.
The file “whipst.js” (appendix 3) is responsible for dragging and sorting widgets, generating and saving the file. These capabilities will be explained next.
As indicated previously, every widget is assigned a CSS class “boxes.” To add the dragging functionalities to each widget, we select every widget by class “boxes” using jQuery class selector “.” and call the jQuery UI function draggable() (line 17 below). In the draggable function, we set up options and events. We choose the helper option with the clone value so we could create more than one instance for every widget (line 21 below). Also, we use the stop event to increment a counter that helps us keep track of how many widgets are cloned (line 25 below).
17 $(".boxes").draggable({ 18 appendTo: "body", 19 cursor: "crosshair", 20 cursorAt: { top: 56, left: 56 }, 21 helper: "clone", 22 revert: "invalid", 23 connectToSortable: ".sortableList", 24 stop: function(event,ui){ 25 counter++; 26 } 27 });
Similarly, we create a sortable area by selecting the list by id “sortList” using jQuery id selector “#” and calling the sortable() jQuery UI function (line 30 below). We can
43 assign options and events to the sortable function as well. Before dropping the widget into a sortable list, the current widget is accessible in the beforeStop event. So, we use the beforeStop event to grab the current item and store it in a variable “newItem” for later access (line 40 below). When we drop a widget into the sortable list, the default receive event is called automatically. The receive event can be modified as we did in line 42 below. We grabbed the “idName” and the “counter” variables and we concatenated them together to form the unique current id and stored the value in “current” (line 43 below).
The “idName” is the id of the current widget and the counter is the value incremented every time a widget is cloned.
We passed the “newItem” and “current” variables into a function promptInformation
(line 48 below). The promptInformation function attaches HTML5 code to “newItem” so it displays input and select fields for the user to enter information. It also attaches CSS properties to “newItem” to change the width and height of the current widget.
30 $("#sortList").sortable({ 31 tolerance: 'pointer', 32 items: "li:not(.placeholder)", 33 dropOnEmpty: true, 34 connectWith: '.trash', 35 appendTo: "#sortList", 36 sort: function(event, ui){ 37 $(this).removeClass("ui-state-default"); 38 }, 39 beforeStop: function(event, ui){ 40 newItem = ui.item; 41 }, 42 receive: function(event, ui){ 43 current = idName + counter; 44 if($(this).find(".placeholder").length > 0){ 45 promptInformation($(newItem), current); 46 $(this).find(".placeholder").remove(); 47 }else{ 48 promptInformation($(newItem), current); 49 } 50 } 51 });
44
This file also has a reset function which resets the middle area by deleting all the widgets on it (see line 186 below). This function is attached to an html button.
186 function reset(){ 187 $(".sortableList").empty(); 188 }
Another important function in this file is the save function. The save function gathers all the information from the generated widgets and downloads that information to the computer in a file. Next, we will explain the several steps this function performs.
First, there are several variables defined in this function. In the following code segment, there are six variables: “nameTemplate”, “str_right”, “str_tab_list”, “str_header”,
“simple_str”, and “titlePage”. The “nameTemplate” variable holds the selection of the template to use in the tutorial. If the left or right template is selected, the “str_right” variable defines a new section for dividing the page in two sides (line 207 below). Also, the variable “str_tab_list” creates an undordered list that will be populated later as needed
(line 208 below). Moreover, the variable “str_header” is assigned the header contents returned by the writeHeader function (line 209 below). If the simple template is selected, the variable “simple_str” is assigned the header contents returned by the writeHeader function as well (line 212 below).
206 if(nameTemplate == "left" || nameTemplate == "right"){ 207 str_right += ""; 209 str_header += writeHeader(titlePage, nameTemplate); 210 } 211 else { 212 simple_str += writeHeader(titlePage, nameTemplate); 213 }
45
Next, we need to determine what widgets have been selected to appear in the tutorial.
To do this, we check if the list is empty (line 214 below) and then we loop through the sortable list (line 215 and 216 below).
214 if(($(".sortableList").length >= 1) && ($(".sortableList").find(".placeholder").length == 0)){ 215 $(".sortableList").each(function(){ 216 $(this).find('li').each(function(){
Afterwards, we check the id of the list elements to see if they contain the id of the widget. The id of the current list element is stored in the variable currentId. We do this by searching for the widget id in the “currentId” variable. For example, in line 219 we search for the “multipleChoiceQuestion” value in the “currentId” string. If the value is found, we know that the current widget corresponds to a multiple choice question widget and we should get the information it requires. Recall that the unique widget id is the concatenation of “idName” and “counter”. So far, we checked for the first part, the “idName”: multipleChoiceQuestion. Next, we find the value of “counter” which is the second part of the “currentId” variable (line 222 below). After, we validate to know if all information has been entered for the multiple choice widget (line 224 below). If we have all the information available, we call the writeMultipleChoice function and store the returned value into variables str_right (line 225 below) and simple_str (line 226 below).
219 if(currentId.search("multipleChoiceQuestion") != -1){ 220 221 len = currentId.length; 222 num = currentId.slice(22, len); 223 224 if(mcqValid(num)){ 225 str_right += writeMultipleChoice(num); 226 simple_str += writeMultipleChoice(num); 227 } 228 flag = mcqValid(num); 229 }
46
We perform exactly the same steps to check for the true false question, and text widgets. However, different functions are called for validation in line 224, the tfValid(num) for validating true false question widgets and txtValid(num) for validating text widgets. The methods for checking for the GLmol widgets differ from the previous method.
When GLmol widgets are selected, we also find the second part of the id value (line
243 below) and we also check for validation (line 244 below). Once that the information is entered, we check to see what template was selected for the user. If the left or right template is selected, the “str_tab_list” string is concatenated with a list item that encloses a reference to a tab id and the PDB id of the GLmol widget becomes the title of the tab (line
248 below). Then, the function writeGLmolObject is called and its returned value is stored in the variables str_left (line 251 below) and simple_string (line 252 below). Then, the glmolObject function is called and its returned value is pushed into an array “objects”
(line 253 above). The glmolObject function returns JavaScript code that defines the
GLmol widgets found in the sort list. The same functionality applies for the other GLmol widgets; the only difference is the widget id.
240 else if(currentId.search("glmolwidget1_") != -1){ 241 242 len = currentId.length; 243 num = currentId.slice(13, len); 244 if(gl1Valid(num)){ 245 246 var pdbid = $("#pdbid1_"+num).val(); 247 if(nameTemplate == "left" || nameTemplate == "right"){ 248 str_tab_list += '
47
256 }
Once outside of the loop, a variable “str_tabs_js” is created to hold the JavaScript code for initializing the tabs for the tutorial (line 305 below). This variable is then pushed into the array “objects” (line 306 below).
303 }); 304 }); 305 var str_tabs_js = '$(function(){$("#myTabs").tabs();});'; 306 objects.push(str_tabs_js); 307 }
Then, if the left or right template is selected, the “str_tab_list” is concatenated with the html list closing tag (line 310 below). Also, the “str_right” variable is concatenated with the section closing tag (line 311 below) and the “str_left” variable is concatenated with the div and section closing tags (line 312 below). After that, the writeFooter function is called and its returned value is concatenated with the “str_footer” variable (line 313 below). Then, the “str” variable is assigned with the values of header, tabs list, left side of template, right side of template and the footer respectively (line 314 below). If the simple template is selected, the writeFooter function is called and its returned value is concatenated with “simple_str” (line 316 below). At this point, “simple_str” contains the whole contents of the generated file, so we assign its values to “str” variable (line 317 below).
309 if(nameTemplate == "left" || nameTemplate == "right"){ 310 str_tab_list += ""; 311 str_right += ""; 312 str_left += "
48
Once that the “str” variable holds the final file contents, we check the flag that indicates there is no missing information. If everything is correct, we check if a title has been entered for the tutorial (line 321 below). If there is no title written by the user, we perform a call to downloadFile function(filename, str) (line 323 below). The first parameter is the name of the file to be downloaded and the second parameter is the “str” variable. On the other hand, if the user specifies a title name, we call the downloadFile function, but this time we enter titlePage+“.html” value to name the file for downloading purposes (line 327 below). For example, if the user enters “Short Tutorial” as the title, the file name is “ShortTutorial.html” instead of “file.html.”
If flag variable returns a false value, this means that there is missing information in some or all of the widgets. So, a message indicating there is missing information is displayed to the user via an alert box (line 331 below).
320 if(flag){ 321 if(titlePage.length == 0){ 322 $("#buttonMsg").html("Look for file in Downloads folder."); 323 downloadFile("file.html", str); 324 }else{ 325 titlePage = titlePage.replace(/\s/g, ''); //Remove space in file 326 $("#buttonMsg").html("Look for file in Downloads folder."); 327 downloadFile(titlePage+".html", str); 328 } 329 } 330 else { 331 alert("Please add items to the 'Add your items here' area \n or correct 'Required errors'"); 332 } 333 return flag;
Previously, we have described functions draggable, sortable, and save contained in this file. At the end of this file, there are eight writing functions: one for each of the six widgets, one for the header and one for the footer. Their functionalities are very similar
49 and there is no need to explain all of them. So, here we will explain how the writeTrueFalse function works.
The writeTrueFalse function defines a variable “str” (line 336 below) that is concatenated with dynamic html values throughout the function (line 337 below). Then, the function returns the “str” variable containing the dynamic html code (line 347 below).
334 function writeTrueFalse(count){ 335 var number = parseInt(count); 336 var str = ''; 337 str += '\n'; 338 str += '\n'; 339 str += '\n'; 340 str += '\n'; 341 str += '
Num | Question | Your answer | Result/Explanation | \n'; 343 str += '
---|---|---|---|
1 | ' + $("#tfq"+count).val() + ' | \n'; 344 str += 'True\n'; 345 str += 'False\n'; 346 str += ' |
\n'; 347 return str; 348 }
Thus, the basic functionality of the writing functions is to add html code to string variables, and then return those strings containing the html code that define the widget.
We have described the writeTrueFalse function above, and the remaining writing functions have its same functionality.
4.2 Tutorial Implementation
As Figure 15 shows, there are ten files in the tutorial implementation. There is the output file of WHIPSTG system, “file.html”. There are four CSS files “simple.css”,
“left.css”, “right.css” and “tabs.css”. There are five JavaScript files:
50
“widgetFuncionality.js”, “GLmol.js”, “Three49custom.js”, “jquery-1.7.min.js”, and
“jquery-ui-1.8.9.js". The jQuery and Three.js files are detailed in the Background chapter of this paper; the rest will be detailed next.
The “file.html” file (appendix 2) is the output of the WHIPSTG system. This file uses the simple template because it provides a link to CSS file “simple.css” (line 10 below).
The included file could be also, “left.css” which loads the left template and “right.css” which loads the right template. This will change according to the template selected by the user.
10
Some files are also included at the bottom of the page. The jQuery library is included and is used for selecting objects from the Document Object Model (DOM) (line 147 below). The Three.js library is included and is required so that GLmol can run properly
(line 148 below). The “GLmol.js” file is also included (line 149 below). Then, the
“widgetFunctionality.js” file is included and this is required so that the widgets can run properly (line 150 below). Last, the jQuery UI library is included and is required for the tabs in the left and right templates (line 151 below).
147 148 149 150 151
The code segment above contains html code that will always be generated and written to the file “file.html”. However, there are html code contents that define the widgets which
51 sometimes could be omitted and sometimes repeated. Next, we will explain what html code segment defines each widget.
The text widget contains a paragraph tag
which encloses the text that should be displayed on the page (line 18 below). The html code for a text widget looks like the code segment below.
18
Protein structure is the biomolecular structure of a protein molecule. Proteins are polymers 19 -specifically polypeptides - sequences formed from various L-α-amino acids. Each unit of a protein 20 is called an amino acid residue because it is the residue of every amino acid that forms the protein 21 by losing a water molecule. 22
The true false question widget comprises four input fields that are invisible which objective is to pass the information from the html file to the corresponding JavaScript file
(lines 23 – 26 below). Also, it encompasses a table for displaying the question (line 34 below), one radio button to select true (line 36 below), one radio button to select false
(line 37 below), and a result or explanation message (line 39 below). The two input radio buttons call the function isTrueFalse when the onchange event is triggered.
23 24 25 26 27
Num | 29Question | 30Your answer | 31Result/Explanation | 32
---|---|---|---|
1 | 34The basic monomers of proteins are amino acids. | 35 36 True 37 False 52 38 | 39 40 |
The multiple choice question widget comprises eight input text fields that are invisible but needed to pass information from the html page to the JavaScript file (lines 42 – 50 below). There are four input radio buttons one in each row of the table. They call the function multipleChoice to check the correctness of the answer when the onchange event is triggered (line 58, 62, 66 and 68). There is an explanation message that is displayed when the user answers the question and shows a message according to the user’s answer
(line 59, 63, 67 and 69).
42 43 44 45 46 47 48 49 50 51
How many different amino acids are used in making proteins?? | 53|
---|---|
Answer | 55Explanation | 56
A12 | 5960 |
B 32 | 6364 |
C 20 | 67|
D 22 | 6970 |
The GLmol widget comprises the following html code. There are divs and spans with assigned ids that define a place in the document where the object will be placed. The ids are used by JavaScript to create the content dynamically.
The id of several divs and their reason to be in the code segment are listed next:
glmol5 - unique id for the GLmol object (line 72 below),
glmol5_src - holds the source from the PDB file (line 73 below),
glmol5_infobox - defines the about tab info (line 74 below),
glmol5_inInfoBox - holds the information of the about tab (line 76 below),
glmol5_srcbox – defines the load tab (line 78 below),
glmol5_srccontents - hold the contents of the load tab (line 80 below).
glmol5_viewbox – defines the view tab (line 82 below)
glmol5_viewcontents – holds the contents of the view tab (line 84 below)
glmol5_options – shows the options rotate, translate, zoom, slab, and reset (line
86 below)
glmol5_loading – shows the loading message (line 87 below)
glmol5_pdbTitle – shows the title of the loaded molecule (line 88 below).
72
54
78
Similarly, the GLmol highlighting amino acids widget also contains divs with assigned ids. The ids for this widget and their reason for their definition are listed next:
glmol6 – unique id of the GLmol object (line 92 below),
glmol6_src – holds the source of the PDB file (line 93 below),
glmol6_options – shows rotate, translate, zoom and slab (line 118 below),
glmol6_loading – shows the loading message (line 119 below), and
glmol6_pdbTitle – shows the title of loaded molecule (line 120 below).
For the highlighting abilities to be included twenty checkboxes are placed in the widget to select the amino acids (lines 95 – 114 below). There is also an html div that has a checkbox to select if the user wants to show the side chains of the protein sequence or not (line 116 below). Also, there is a highlight button that will send the request for highlighting (line 117 below).
92
96 R
113 Y
55
114 V
115
Similarly, the GLmol highlighting sequence has divs and spans as the previous GLmol widgets. The id names followed for their reason to be in the html code are listed next:
glmol10 – unique id of GLmol widget (line 124 below),
glmol10_src – holds the source of PDB file (line 125 below),
glmol10_highlight – turns on or off highlighting (line 126 below),
glmol10_hgcolor – color for highlighting (line 128 below),
glmol10_seqHigh – holds the sequence of loaded molecule (line 134 below),
glmol10_options – shows rotate, translate, zoom and slab (line 137 below),
glmol10_loading – shows the loading message (line 138 below),
glmol10_pdbTitle - shows the title of loaded molecule (line 139 below).
This widget is composed of a select menu with four colors that the user can choose from to highlight the sequence (line 128 below). Also, a text area contains the protein sequence for selection (line 134 below). Likewise, a button to highlight the sequence is defined (line 136 below).
124
Previously, we have defined the html code that defines the widgets. Now, we will explain the JavaScript code needed to define the GLmol widgets. First, we take the id for the GLmol widget, which is the first id of each code segment. For this example, we will use the id “glmol5.” First, we define a variable “strId” and assign the id value to the variable (line 153 below). Then, we declare a new GLmol object by passing the parameters strId and true (line 154 below). Then, we call the download function by passing the parameters pdb id of the protein and the GLmol object created previously (line
155 and 156).
153 var strId = "glmol5"; 154 var glmol5 = new GLmol(strId, true); var query = window.location.search.substring(1); 155 if (query == '') download('pdb:2POR',glmol5); 156 else download(query, glmol5);
When we are defining the GLmol widget with tabs, we call the addGLmolObject function and we passed the GLmol object on line 154 as a parameter (line 157 below). The addGLmolObject function defines everything needed for showing the tabs with dynamic html.
157 addGLmolObject(glmol5);
57
Similarly, for the GLmol highlighting widgets, we assign the definition of the defineRepCheckHighlight function to the defineRepresentation function (line 162 below).
The defineRepresentation function calls the functions for coloring and drawing the atoms contained in the atom list array. The defineRepCheckHighlight function contains the same functions as defineRepresentation. However, it adds extra calls to highlighting functions before drawing the atoms.
162 glmol6.defineRepresentation = glmol6.defineRepCheckHighlight;
The style of the three templates is defined by cascading style sheets. In style sheets, we assign CSS properties to html tags such as p, h3, body and header, etc. As mentioned before, there are three templates defined by style sheets in this project which are explained next.
The “simple.css” file (appendix 7) shows a style sheet for the simple template. This template includes values in style such as color, background, width, height and position.
Similarly, the “left.css” file (appendix 8) shows a style sheet for the left template.
Using this style sheet, the tutorial displays tabs on the left side that include GLmol widgets. On the right side, the true false question, multiple choice question and text are displayed in the order they are in the middle area in WHIPSTG tab. The right side is scrollable if needed.
On the other hand, the “right.css” file (appendix 9) shows a style sheet for the right template. Using this style sheet, the tutorial displays tabs on the right side that include
GLmol widgets. On the left side, the true false question, multiple choice question and text are displayed in the order they are in the middle area in WHIPSTG tab. The left side is scrollable if needed.
58
We have described the html file, and now we will describe the required functions in
“widgetFunctionality.js” file. This file is responsible for functions that add interactivity to the tutorial.
The function isTrueFalse checks whether the selected response is right or wrong each time the radio buttons are changed (line 79 below). If the response is right, a message displaying a check mark and the word “Correct” is shown in the corresponding cell in the table (line 80 below). If the response is wrong, an x mark and the word “Incorrect” is shown in the corresponding cell in the table (line 83 below).
73 function isTrueFalse(name, count){ 74 var value = $("#correctValue"+count).val(); 75 var msgId = $("#answerid"+count).val(); 76 var msg1 = $("#msg1"+count).val(); 77 var msg2 = $("#msg2"+count).val(); 78 if(value == "True") { value = "true"; } if(value == "False") { value = "false"; } 79 if(value == name.value){ 80 $("#" + msgId).html("✓ Correct. " + msg1); 81 } 82 else{ 83 $("#" + msgId).html("✘ Incorrect. " + msg2); 84 } 85 }
Similarly, the multipleChoice function checks if the selected input is the right answer for the four options A, B, C or D. For example, if the correct answer is A, then an explanation is displayed in the corresponding cell in the table (line 91 below). For example, if option B is incorrect, and explanation indicating so is displayed in the corresponding cell in the table (line 106 below).
87 function multipleChoice(name, count){ 88 var value = $("#cValue").val(); 89 if(name.id == value){ 90 if( name.id == "A" ) 91 {$("#displayMsg1"+count).html(" ✓" + $("#fcExplanation").val()); } 59
92 else if( name.id == "B" ) 93 { $("#displayMsg2"+count).html("✓" + $("#scExplanation").val());} 94 else if( name.id == "C" ) 95 { $("#displayMsg3"+count).html("✓" + $("#tcExplanation").val()); } 96 else if ( name.id == "D" ) 97 {$("#displayMsg4"+count).html("✓" + $("#fourExplanation").val());} 98 var names = document.getElementsByName(name.name); 99 for(var i = 0; i < names.length; ++i) 100 names[i].disabled=true; 101 } 102 else{ 103 if( name.id == "A" ) 104 { $("#displayMsg1"+count).html("✘" + $("#fcExplanation").val());} 105 else if( name.id == "B" ) 106 { $("#displayMsg2"+count).html("✘" + $("#scExplanation").val()); } 107 else if( name.id == "C" ) 108 { $("#displayMsg3"+count).html("✘" + $("#tcExplanation").val());} 109 else if( name.id == "D" ) 110 { $("#displayMsg4"+count).html("✘" + $("#fourExplanation").val()); } 111 } 112 }
The “GLmol.js” file has been modified for its use in this project (appendix 4). The modifications performed allow the highlighting of amino acids, and the highlighting of a part of the protein sequence.
The highlightAminoacid function loops through an array containing the twenty amino acid names as three letter codes (line 1987 below). Then, it checks if the checkbox corresponding to each amino acid is selected (see line 1989). Every time a checkbox is selected, the function loops through all atoms in the protein and searches for the selected amino acid (line 1995 below). If the atom is found in the atom list, the atom color is assigned the value for the amino acid stored in the array this.aminoColors (line 1996 below). Also, the background for the checkbox is colored with the same color the atom is highlighted (line 1997 below). If nothing is selected, no changes are performed. If a
60 previously checked checkbox has been unchecked, the current checkbox background color is cleared (line 2000 below).
1984 GLmol.prototype.highlightAminoacids = function(all){ 1985 var idHeader = "#" + this.id + "_"; 1986 var name=""; 1987 for( var i in this.aminoNames ){ 1988 name = this.aminoNames[i]; 1989 if( $(idHeader + name).attr('checked') ) { 1990 var atomlist = all; 1991 for(var i in atomlist) { 1992 var atom = this.atoms[atomlist[i]]; 1993 if (atom == undefined) continue; 1994 if (atom.hetflag) continue; 1995 if($(idHeader + name).val() == atom.resn) { 1996 atom.color = this.aminoColor[atom.resn]; 1997 $(idHeader + name + "_bc").css("background-color", this.aminoColors[atom.resn]); 1998 } 1999 } 2000 } else{ $(idHeader + name + "_bc").css("background-color", "transparent"); } 2001 } 2002 };
The highlightSequenceOLC function highlights a part of the sequence that the user selects (line 1944 below). The protein sequence value is obtained from the text area with id “this.id + ‘_seqHigh’” using jQuery id selector “#” and is stored in a variable “element”
(line 1945 below). Then, we check if the sequence is empty or not. If it is not empty, we call the function getResiFromSequence and assign its returned value to a variable resiNo
(line 1948 below). The variable resiNo should contain an array of residue numbers of the atoms that have been selected from the sequence. So, we loop through the resiNo array and call the function getSerialByResi to get the serial number of each residue number and store it into a passed by reference array named seriales (line 1951 below). The function returns an array "seriales" that holds the serial numbers of the atoms selected from the sequence (line 1954 below).
1944 GLmol.prototype.highlightSequenceOLC = function(color){
61
1945 var element = $('#' + this.id + '_seqHigh'); 1946 if(element.length) { 1947 var seriales = []; 1948 var resiNo = this.getResiFromSequence(element[0]); 1949 1950 for(var k in resiNo){ 1951 this.getSerialByResi(seriales, k, resiNo[k],color); 1952 } 1953 } 1954 return seriales; 1955 };
We will describe the getResiFromSequence function next. The function fills the resi_numbers array by pushing the contents of a function findResiSequenceNumbers into it (see line 1903 below). The resi_numbers array contains a map of the chain and the resi number, for example chain A is mapped with resi number 1. The function creates a variable k which purpose is to iterate through every amino acid in the sequence (line 1905 below). The function loops through this two-dimensional array (lines 1906 and 1907 below) and also increments k in each iteration (line 1917 below). Now, we have a mapping in such way that we have k, chain and resi number. For example, in iteration 0 we will have 0, chain A, and resi number 1 in a map representation. This means the first value, 0, is the serial number of the current atom in chain A with resi number 1. So, k also serves for checking the start position and the end position of the sequence selection. We check if k is in the selection interval and if it is we assign the current chain and the current resi number to an array resi_map (line 1912 and 1915). This array maps the resi numbers with the chains of the amino acids that are selected from the sequence. For example, if an atom in chain B with resi number 20 is selected, the array will contain entry {B: 20}. The function returns the resi_map array (line 1921).
1893 GLmol.prototype.getResiFromSequence = function(element){ 1894 if(element.selectionStart != undefined){ //works on chrome and mozilla 1895 var startPos = element.selectionStart;
62
1896 var endPos = element.selectionEnd; 1897 var selText = element.value.substring(startPos, endPos); 1898 1899 var resiNumbers = {}; 1900 var resi_map = {}; 1901 1902 var resi_numbers = new Array(); 1903 resi_numbers.push(this.findResiSequenceNumbers()); 1904 1905 var k = 0; //k iterates through every amino acid in sequence 1906 for(var i in resi_numbers[0]){ 1907 for(var j in resi_numbers[0][i]){ 1908 var current_resi = j; 1909 var current_chain = resi_numbers[0][i][j]; 1910 1911 if(k == startPos && (selText.length == 1)){ 1912 resi_map[current_resi] = current_chain; 1913 } 1914 if(k >= startPos && k < endPos){ 1915 resi_map[current_resi] = current_chain; 1916 } 1917 ++k; 1918 } 1919 } 1920 } 1921 return resi_map; 1922 };
The function findResiSequenceNumbers calls the mapChainSize function that returns a map of the chain and the chain size of every atom in the protein sequence and stores them in variable seqChain, i.e. { A : 94 } (line 1870 below). The size of the chain is the number of amino acids that a chain contains; this is not the total number of amino acids.
The function iterates through seqChain, and inside the loop we assign the current chain size into a variable l (line 1879 below). We loop from 0 to l to map resi numbers to the current chain and store them in an array named numbers (line 1881 below). Outside of the loop, we push the numbers array into array resi_numbers (line 1883). Finally, the function returns the resi_numbers array that holds the residue numbers of the protein sequence (line
1886).
63
1868 GLmol.prototype.findResiSequenceNumbers = function(){ 1869 var seq_length = this.protein.sequence.length; 1870 var seqChain = this.mapChainSize(); 1871 var resi_numbers = []; 1872 var numbers = {}; 1873 for(var i in seqChain){ 1874 var current_chain = i; 1875 var current_chain_size = seqChain[i]; 1876 1877 //get the new length and assign it to seq_length 1878 var new_length = seq_length - current_chain_size; 1879 var l = seq_length - new_length; 1880 for(var j = 0; j < l; ++j){ 1881 numbers[j+1] = current_chain; 1882 } 1883 resi_numbers.push(numbers); 1884 numbers = {}; 1885 } 1886 return resi_numbers; 1887 };
Next we will describe the getSerialByResi function (line 1928 below). The function loops through all the atoms in the protein, and checks to see if each atom’s chain and atom’s residue number is equal to the values passed by value resiNum and chain_value (line 1932). If they are equal, the atom color is assigned the value of the passed by value variable color (line 1933). Also, the atom serial number is pushed into the seriales array which is passed by reference (line 1934 below). Since the seriales array is passed by reference, the function does not return a value.
1928 GLmol.prototype.getSerialByResi = function(seriales, resiNum, chain_value, color){ 1929 for(var i in this.atoms){ 1930 if (this.atoms[i] == undefined) continue; 1931 if (this.atoms[i].hetflag) continue; 1932 if(this.atoms[i].chain == chain_value && this.atoms[i].resi == resiNum){ 1933 this.atoms[i].color = color; 1934 seriales.push(this.atoms[i].serial); 1935 } 1936 } 1937 };
64
This chapter covered the Implementation. The next chapter will provide several test cases to test the functionality of WHIPSTG and contributions made to GLmol.
5. TEST CASES This chapter provides various WHIPSTG and GLmol test cases to demonstrate how they work. For GLmol, the test case will show the modifications made to GLmol mentioned previously on this paper. The first section of this chapter will explain how to create a WHIPSTG tutorial.
5.1 Test Case Create a WHIPSTG Tutorial This test case demonstrates the steps required to create a tutorial including the six widgets at least once using the simple template.
Step 1: Navigate browser to WHIPSTG site. (http://montes.co.nf/whipst.html)
65
Figure 27 Test Case Create a Tutorial Welcome Tab
Step 1 Confirmation: Browser should display the Welcome tab similar to Figure 27 above.
Step 2: Click on WHIPSTG tab in browser.
66
Figure 28 Test Case Create a Tutorial WHIPSTG Tab Step 2 Confirmation: Browser should display the WHIPSTG tab similar to Figure 28. By looking at Figure 28 or at the browser, one can easily identify the left area, middle area, the top right area and the top bottom area. The left area contains the six widgets, the middle area accepts an optional tutorial title, the top right area has a trash container and the template selection, and finally the top bottom area has a reset button and a save file button.
Step 3: Enter “Simple Tutorial” as the title in the middle area.
67
Figure 29 Test Case Create a Tutorial Enter Title
Step 3 Confirmation: The WHIPSTG tab in the browser should look like Figure 29.
Step 4: Drag a Text widget into middle area, and enter the information below:
Protein structure is the biomolecular structure of a protein molecule. Proteins are polymers -specifically polypeptides - sequences formed from various L-α-amino acids. Each unit of a protein is called an amino acid residue because it is the residue of every amino acid that forms the protein by losing a water molecule.
68
Figure 30 Test Case Create a Tutorial Enter Text Step 4 Confirmation: The WHIPSTG tab in the browser should look like Figure 30.
Step 5: Drag a True False Question widget into the middle area.
Question: The basic monomers of proteins are amino acids. Correct Answer: Select true Explanation Correct: Great! Keep up the good work! Explanation Incorrect: That’s not right! Keep on studying!
69
Figure 31 Test Case Create a Tutorial False Question
Step 5 Confirmation: The WHIPSTG tab in browser should look like Figure 31.
Step 6: Drag a Multiple Choice Question widget into the middle area. Enter the required information, for example: Question: How many different amino acids are used in making proteins? A: 12 Explanation: Incorrect. 12 is too low. B: 32 Explanation: Incorrect. 32 is too high. C: 20 Explanation: Great job! D: 22 Explanation: Incorrect. 22 is close but not right. Correct Value: Select C from the select menu.
70
Figure 32 Test Case Create a Tutorial Multiple Choice Question Step 6 Confirmation: The WHIPSTG tab should look like Figure 32 in the browser.
Step 7: Drag a GLmol widget into the middle area. Enter PDB Id “2POR.”
Step 8: Drag a GLmol Highlighting Amino Acids widget into the middle area. Enter PDB Id “2POS.”
Step 9: Drag a GLmol Highlight Sequence widget into the middle area. Enter PDB Id “2DHB.”
71
Figure 33 Test Case Create a Tutorial GLmol Widgets Step 7, 8 and 9 Confirmation: The WHIPSTG tab should look like Figure 33 in the browser.
Step 10: Select the simple template from the Template section in the top right area of the screen.
Step 11: Click on save file to save the tutorial in your computer.
72
Figure 34 Test Case Create a Tutorial Save File
Step 10 and 11 Confirmation: The WHIPSTG tab should look like Figure 34. The tutorial has been saved as SimpleTutorial.html in the Downloads folder. Navigate in a web browser to http://montes.co.nf/whipst.html and click on the Simple tab to interact with this tutorial using the simple template.
Step 12: Go back to Step 10 and select the left template instead. Then, click on save file. You will see a screen similar to Figure 34 in your browser, but now the file should be saved as LeftTutorial.html. Navigate to http://montes.co.nf/whipst.html and click on the Left tab to interact with this tutorial using the left template.
Step 13: Go back to Step 10 and select the left template instead. Then, click on save file. You will see a screen similar to Figure 34 in your browser, but now the file should be saved as RightTutorial.html. Navigate to http://montes.co.nf/whipst.html and click on the Right tab to interact with this tutorial using the right template.
73
5.2 Test Case GLmol Highlight Amino Acids PDB ID 2POR This test case will demonstrate the highlighting amino acids functionality added to
GLmol. The webpage shown in Figure 35 was generated using WHIPSTG with a simple tab.
Step 1: Navigate to http://montes.co.nf/testcase/GLHAA.html
Figure 35 Test Case GLmol Highlight Amino Acids PDB ID 2POR Browser Display
Step 1 Confirmation: Figure 35 shows that the web page contains a 3D visualization for protein structure 2POR. The widget has an html div on the left that contains: a box with the twenty amino acids represented by their one letter code, a checkbox that serves to check the amino acid and to display the highlighting color of the amino acid, and a button to highlight the checked amino acids. The widget also contains another html div on the bottom right corner that has a group of four radio buttons and a button: rotate radio button turns on rotation capabilities started by clicking and performed by moving the mouse, translate radio button turns on translation capabilities performed by clicking and dragging the visualization up, down, left or right, zoom turns on zoom capabilities, slab, and the reset view button resets the view of the 3D visualization.
Step 2: Check the Valine (V) amino acid, and click on the button “Highlight.”
74
Figure 36 Test Case GLmol Highlight Amino Acids PDB ID 2POR Highlight Valine
Step 2 Confirmation: The result should look like Figure 36. When an amino acid is checked and Highlight button is clicked, the amino acid is highlighted in the protein visualization showing its locations in the structure. Also, the checkbox is highlighted with the same color to indicate what color corresponds to each amino acid.
Step 3: The user can check more than one amino acid. Select E, L and I amino acids and click on Highlight.
75
Figure 37 Test Case GLmol Highlight Amino Acids PDB ID 2POR Highlight E, L, and I Step 3 Confirmation: The result of Step 3 should look like Figure 37. The four amino acids are highlighted. However the protein orientation can block the view of some amino acids. For this, we can perform rotation and translation to make them viewable. We will do this in the next step.
Step 4: Rotate by clicking down in the protein and moving the mouse down and a little to the right. Also, zoom in using the mouse.
76
Figure 38 Test Case GLmol Highlight Amino Acids PDB ID 2POR Rotate and Zoom Step 4 Confirmation: The result should look like Figure 38. The four amino acids are easily identified and their positions in the structure chain are recognized.
Step 5: Click on the reset view button at the bottom right. Also, click on the Side chains checkbox at the bottom left and then click on Highlight.
77
Figure 39 Test Case GLmol Highlight Amino Acids PDB ID 2POR Side Chains
Step 9 Confirmation: The result should look like Figure 39. The side chains of the protein are shown.
Step 10: Zoom in to see the direction of Valine side chain.
78
Figure 40 Test Case GLmol Highlight Amino Acids PDB ID 2POR Valine Side Chain
Step 10 Confirmation: The result should look like Figure 40. The side chain pointing up out of Valine is visible.
5.3 Test Case GLmol Highlight Sequence PDB ID 2POR This test case will demonstrate the highlighting sequence functionality added to
GLmol. WHIPSTG will be used for creating the tutorial that will contain the visualization of protein 2POR in this case.
Step 1: Navigate to http://montes.co.nf/testcase//GLHS.html
79
Figure 41 Test Case GLmol Highlight Sequence PDB ID 2POR Navigate Link Step 1 Confirmation: The browser should display protein structure 2POR similar to Figure 41. The GLmol Highlight Sequence widget contains an html div on the top of the widget and has: a checkbox that turns ON and OFF the highlighting sequence functionality, a select menu that selects the color of the highlighted sequence, and a button that calls a function to select the sequence. It has another html div on the bottom right of the widget described in the previous section on Step 1 Confirmation.
Step 2: Check the ON/OFF checkbox to turn ON highlighting the sequence functionality. Then select the first line of the sequence: EVKLSGDARMGVMYNG DDWNFSSRSRVLFTMSGTTDSGLEFGASFKAHESVGAETGEDGTVFLSGAFGKI. After making the selection, click on select sequence.
80
Figure 42 Test Case GLmol Highlight Sequence PDB ID 2POR Highlight Sequence Step 6 Confirmation: The widget should look like Figure 42 above. The widget displays all the atoms that have been selected from the sequence in their specific location. The default color is white, but there are more options in the color menu. The color options are white, yellow, red and lime green.
Step 7: Select the lime green color by selecting it from the color menu. Click on select sequence.
Step 8: Rotate the highlighted sequence by clicking anywhere in the widget and moving the mouse right or left to explore the part of the sequence.
81
Figure 43 Test Case GLmol Highlight Sequence PDB ID 2POR Rotate Step 8 Confirmation: Figure 43 shows a possible view of the structure once it is rotated. 5.4 Negative Test Case WHIPSTG Missing Information This test case will demonstrate how WHIPSTG behaves when the user interacts with
WHIPSTG tab. In particular, this test case will cover what happens when the user drags widgets into the middle are and attempts to save the tutorial. Also, it will cover what happens when there are no widgets in the middle area and the user attempts to save the tutorial.
Step 1: Perform Step 1 and Step 2 in Section 5.1.
Step 2: Drag a true false question widget, drag a multiple choice question widget, drag a GLmol widget, drag a GLmol highlight amino acids widget, and drag a GLmol highlight sequence widget into the middle area.
82
Figure 44 Negative Test Case WHIPSTG Missing Widget Info all Widgets Step 2 Confirmation: The browser should look like Figure 44. The middle area has to contain one instance of every widget, a total of six widgets.
Step 3: Click on Save File.
83
Figure 45 Negative Test Case WHIPSTG Missing Widget Info Error Messages Step 3 Confirmation: Figure 45 above shows that instead of saving the file to the computer, a pop up alert appears along with red text next to the input fields. The pop up alert says: “Please add items to the ‘Add your items here’ area or correct ‘Required’ errors.” In this case, it means to fix the “Required” errors before saving. The “Required” errors are displayed next to the input fields of every widget. The user has to fill out the information to fix the errors.
Step 4: Click on the reset button to delete all the six widgets added previously. Step 5: Click on Save File.
84
Figure 46 Negative Test Case WHIPSTG No Widgets Error Message Step 4 and 5 Confirmation: The browser should look like Figure 46 above. The file did not save because there are no items in the middle area. Instead a pop up alert showed up with a message: “Please add items to the ‘Add your items here’ area or correct ‘Required’ errors.” In this case, it appeared because there are no items in the middle area.
5.5 Negative Test Case GLmol Highlight Amino acids PDB ID 1111 This test case will demonstrate how WHIPSTG behaves when entering an invalid PDB
Id in the GLmol Highlight Amino Acids widget in the WHIPSTG Tab, and how GLmol handles that invalid PDB id.
Step 1: Perform Step 1 and Step 2 in Section 5.1.
Step 2: Drag a GLmol Highlight Amino Acids widget and enter PDB Id ‘1111’ into PDBID input field. 85
Step 3: Click on save file to save a tutorial with a GLmol Highlight Amino Acids widget with protein 1111.
Figure 47 Negative Test Case GLmol Highlight Amino Acids Save File Step 2 and 3: The browser should look like Figure 47. In this figure, we can see that WHIPSTG saved a file even though “1111” is invalid.
Step 4: Open file.html to see how GLmol processed the invalid input.
86
Figure 48 Negative Test Case GLmol Highlight Amino Acids Widget Error Message
Step 4 Confirmation: The GLmol Highlighting Amino Acids Widget should look like Figure 48. GLmol does not recognize the PDB Id ‘1111’. So, it displays a message saying: Loading structure from server… It may take a while. If you believe something went wrong, please make sure PDB ID is correct. Please also make sure that WebGL is enabled in your browser. Internet Explorer: sorry. IE doesn’t support WebGL. Firefox (version 4 or later): try force enable WebGL. Chrome: try force enable WebGL. Safari: have to enable WebGL manually.
The message is very self-explanatory. If this is the first time someone is running WebGL in her browser, she might be tempted to force enable WebGL in her browser. On the other hand, if she already knows that her browser runs WebGL, she might want to check that the PDB ID is correct. This demonstrates how GLmol behaves when handling invalid data. Since it is a GLmol feature, the same behavior applies when using the other two GLmol widgets.
87
6. CONCLUSION AND FUTURE WORK
This project has successfully achieved to create a teaching tool to generate an interactive website tutorial that will help in teaching and learning about protein structures.
The generator tool reduces the time to create an interactive website so that biology or biochemistry professors teach lessons about protein structures. The tutorial interactivity will help students be more engaged and more experimental in learning about proteins.
Even though the website interface provides good functionality and examples, there are several aspects in which it could be improved.
One feature that can be supported in the future is drag and drop capabilities in a touch device. The library used for this purpose, jQuery UI, responds to mouse events. Thus, it limits the drag and drop functionality to only desktops or laptops. There is a plug-in,
Touch Punch, that translates mouse events into touch events but it is not very effective. On the other hand, “The jQuery Foundation” are working on resolving this issue and they plan to add this functionality at the end of 2014. This feature can be taken into account only if the generator tool might want to be used in mobile devices.
Another possible feature that may be added is responsive web design. Responsive web design aims to provide an optimal view experience across many devices. A website that implements this design applies several rules according to the screen resolution of the website to target more devices. For example, with a responsive design a webpage applies different CSS style sheets according to the screen size during the event of resizing the window.
Another improvement is to make the tutorial more interactive so that the students have a greater experience while learning. The true false question and the multiple-choice
88 widgets have a low level of interactivity that could be improved significantly. For the scope of this project, our main goal was to create a web interface that generated a tutorial website that students could use. For this reason, interactivity has been kept at a basic level for the tutorial.
Subsequently, it would be useful that the generated tutorial could be sent to the user’s e-mail address instead of saving the file to the computer. This could come in handy if students are assigned to create a tutorial in class using the school’s computers and they would like a copy of their tutorial. They could access the tutorial from their personal computer, tablet or mobile device at home.
Also, the text widget uses a jQuery TE text editor. The textarea in this widget exceeds the height of the text widget if the user enters a long text. This problem could be possibly resolved by making the text area scrollable or making the widgtes resizable.
Lastly, other widgets could be added to integrate other types of questions into the tutorial website. HTML5 provides drag and drop capabilities. So, it would be useful to integrate a type of question to match a concept with its definition by dragging and dropping.
7. REFERENCES 1. "Aptana Studio 3." Aptana. http://aptana.com/products/studio3 (accessed October 10, 2013). 2. "Best Screen Size & Screen Resolution to Design Websites | Is There A Standard Size? What Is The Most Common Dimension?." Hobo. http://www.hobo- web.co.uk/best-screen-size/ (accessed April 13, 2014). 3. Castaño-Muñoz, Jonatan, Josep M. Duart, and Teresa Sancho-Vinuesa. "The Internet in face-to-face higher education: Can interactive learning improve academic achievement?." British Journal of Educational Technology 45, no. 1 (2014): 149-159. 4. "CSS Tutorial." CSS Tutorial. http://www.w3schools.com/css/default.asp (accessed October 10, 2013). 5. "Documentation." Welcome to the Worldwide Protein Data Bank.
89
http://www.wwpdb.org/docs.html (accessed November 14, 2013). 6. "GLmol - Molecular Viewer on WebGL/Javascript." GLmol - Molecular Viewer on WebGL/Javascript. http://webglmol.sourceforge.jp/index-en.html (accessed May 3, 2014). 7. "HTML5 Introduction." HTML5 Introduction. http://www.w3schools.com/html/html5_intro.asp (accessed May 2, 2014). 8. "JavaScript Tutorial." JavaScript Tutorial. http://www.w3schools.com/js/ (accessed May 3, 2014). 9. "Jmol: an open-source Java viewer for chemical structures in 3D." Jmol: an open- source Java viewer for chemical structures in 3D. http://www.jmol.org/ (accessed May 3, 2014). 10. "jQuery." jQuery. http://jquery.com/ (accessed May 2, 2014). 11. "jQuery Tutorial." jQuery Tutorial. http://www.w3schools.com/jquery/default.asp (accessed October 10, 2013). 12. "jQuery UI." jQuery UI. http://jqueryui.com/ (accessed May 3, 2014). 13. "mrdoob/three.js." GitHub. https://github.com/mrdoob/three.js/ (accessed May 3, 2014). 14. Pan, Yi. Algorithmic and artificial intelligence methods for protein bioinformatics. Hoboken, N.J.: J. Wiley & Sons, 2013. 15. Panzenböck , Mathias . "Hackworthy." : Save/download data generated in JavaScript. http://hackworthy.blogspot.com/2012/05/savedownload-data-generated-in.html (accessed May 5, 2014). 16. "PDB identification code." - Proteopedia, life in 3D. http://proteopedia.org/wiki/index.php/PDB_identification_code (accessed May 3, 2014). 17. Roberts, Matt. "Stygian Vision - Random thoughts from a random guy." Creating a jQuery Sortable Trash Bin to Remove Items. http://stygianvision.net/updates/jquery- sortable-remove-item/ (accessed April 22, 2014). 18. "Style Your jQuery-UI Tabs - Web Development is Easy!." Style Your jQuery-UI Tabs - Web Development is Easy!. http://www.webdeveasy.com/style-your-jquery-ui- tabs/ (accessed May 3, 2014). 19. "The Khronos Group - a non-profit industry consortium to develop, publish and promote open standard, royalty-free media authoring and acceleration standards for desktop and handheld devices, combined with conformance qualification programs for platform and." WebGL. http://www.khronos.org/webgl/ (accessed May 3, 2014). 20. "Tired of hunting." website dimensions. http://www.websitedimensions.com/ (accessed May 3, 2014). 21. "Understanding PDB Data: Looking at Structures." RCSB PDB-101. http://www.rcsb.org/pdb/101/static101.do?p=education_discussion/Looking-at- Structures/intro.html (accessed May 3, 2014). 22. "What is Biochemistry?." Home Page. https://www.mcgill.ca/biochemistry/about- us/information/biochemistry (accessed May 3, 2014). 23. "What is jQuery TE?." jQuery Text Editor. http://jqueryte.com/ (accessed May 3, 2014). 24. "WebGL." Mozilla Developer Network. https://developer.mozilla.org/en- US/docs/Web/WebGL (accessed May 3, 2014).
90
25. "WebGL." RealTime Rendering. http://www.realtimerendering.com/blog/tag/webgl 26. "WebGL Specification." WebGL Specification. https://www.khronos.org/registry/webgl/specs/1.0/ (accessed May 3, 2014). 27. Wikimedia Foundation. "Data URI Scheme." Wikipedia. http://en.wikipedia.org/wiki/Data_URI_scheme#JavaScript (accessed May 3, 2014). 28. Wikimedia Foundation. "WebGL." Wikipedia. http://en.wikipedia.org/wiki/WebGL (accessed May 3, 2014).
91
APPENDICES
1. whipst.html This appendix contains the code for file “whipst.html,” which is responsible for providing a web interface to this project.
1 2 3
4Generating Interactive Protein Structure Tutorial Using WebGL and HTML5
21- 24
- 25 Welcome 26 27
- 28 WHIPSTG 29 30
- 31 Help 32 33
- 34 Simple 35 36
- 37 Left 38
- 40 Right 41 42
- 43 GLHAA 44 45
- 46 GLHS 47 48
92
39
51 INTRODUCTION
52 Biochemistry is the study of living organisms and of molecular basis for the transformation that occur
53 in living cells. Much of Biochemistry deals with large structures such as proteins. Protein molecules
54 are long polymers typically containing several thousand of atoms, composed of a uniform repetitive
55 backbone with a particular sidechain attached to each residue. One problem that arises in learning about
56 proteins is the hardship to visualize the little details of structures of such magnitude. This is where
57 Bioinformatics – the application of computer science that utilizes software to solve problems in
58 visualization – comes in. Using a visualization tool to display a protein in 3D helps protein elements
59 such as amino acids to stand out and be identified quickly. WebGL and HTML5 Interactive Protein Structure
60 Tutorial or WHIPSTG aims to facilitate the learning of protein structures by creating a website tutorial
61 that allows the user to interact with a protein visualization in 3D, true false questions, multiple-choice
62 questions, and to display text to the tutorial. WHIPSTG uses GLmol – a 3D molecular viewer based on WebGL
63 and JavaScript – that allows the user to manipulate the 3D protein. For the scope of this project, GLmol
64 has been slightly modified to include functionality for highlighting amino acids, highlighting a part of
65 a protein sequence and for embedding multiple GLmol instances into a webpage. 66
68
- 78
- 79 80 81
-
93
82 83
84 - 85 86 87
- 88 89 90
- 91 92 93
- 94 95 96
- 103
- Add your items here 104
112
113
114 115
What is WHIPSTG?
123 125 WHIPSTG is a tool that allows the user to create a tutorial for students that are learning about
126 protein structures.The tutorial is a webpage that displays the content provided by the user. The
127 tutorial has interactive widgets that allows for manipulation of 3D protein structures, answering
128 of true false questions, and also answering to multiple- choice questions.
94
129
130What are the WHIPSTG Components?
132The screen is divided in three parts: the left area, the middle area, and the right area. In the left
134 area there are six widgets:
135
- 136
- True False Question 137
- Multiple Choice Questions 138
- GLmol 139
- Glmol Highlight Amino Acids 140
- Glmol Highlight Sequence 141
- Text 142
144 enter a title to name the tutorial to be created The right side has an area where widgets entered erroneously
145 will be dropped and deleted. It also has a Template area to choose a template. There are also two buttons at the
146 bottom right of the page: one is to reset the middle area contents and the other one to save the file. 147 148
What information is required by widgets?
150152
- 153
- True False Question 154
- 155
- Question - A true false question is a statement that is either true or false. 156
- Correct Answer - This is the correct answer of the question. For example, true. 157
- Explanation Correct - This is a message to be displayed when the person using the tutorial selects 158 the correct answer. For example,
the user might want to encourage the person using the tutorial with 159 a message like: “Great job! Keep
up the good work!” 160 - Explanation Incorrect - This is a message to be displayed when the person using the tutorial selects 161 the incorrect answer. In this case,
the user might want to encourage the person using the tutorial to 162 keep studying. For example, the user might use a message
like: “Not quite right! Please review Chapter 163 2, Section 3 of our textbook!” 164 165
167
- 169
- Multiple Choice Question 170
- 171
- Question - A multiple-choice question is a type of question that provides a question and four possible
95
172 answers in which only one answer is correct.
173 - A - This is the first answer choice. 174
- Explanation - This is an explanation for the A answer. If answer A is correct or incorrect, what 175 message does the user want to give to the person using the tutorial? Consider a positive or 176 negative message. 177
- B - This is the second answer choice. Write it in the input field provided. 178
- Explanation - This is an explanation for the B answer. If answer B is correct or incorrect, what 179 message does the user want to give to the person using the tutorial? Consider a positive or negative 180 message. 181
- C - This is the third answer choice. Write it in the input field provided. 182
- Explanation - This is an explanation for the C answer. If answer C is correct or incorrect, what 183 message does the user want to give to the person using the tutorial? Consider a positive or negative 184 message. 185
- D - This is the fourth answer choice. Write it in the input field provided. 186
- Explanation - This is an explanation for the D answer. If answer D is correct or incorrect, what 187 message does the user want to give to the person using the tutorial? Consider a positive or negative 188 message. 189
- Correct Value - This is the correct value of the question. 190
192 - Question - A multiple-choice question is a type of question that provides a question and four possible
- 194
- GLmol 195
- 196
- PDB Id - This is the id of the protein structure that will be displayed on the tutorial. 197
199
- 201
- GLmol Highlight Amino Acids 202
- 203
- PDB Id - This is the id of the protein structure will be displayed on the tutorial. 204
206
- 208
- GLmol Highlight Sequence 209
- 210
- PDB Id - This is the id of the protein structure will be displayed on the tutorial. 211
96
212
213
- 215
- Text 216
- 217
- This is some text that the user wants to display in the tutorial, for example, text describing a 218 protein structure or a set of
instructions to perform during the tutorial. 219
221 - This is some text that the user wants to display in the tutorial, for example, text describing a 218 protein structure or a set of
What is a tutorial?
225A tutorial is a website created by WHIPSTG. The tutorial contains several interactive widgets.
227How to create a tutorial?
229231 Click on a widget from the left area and drag it into the middle area. The widget will change to ask for information. 232 Fill out all the information as needed. The widgets can be sorted. Once you are satisfied with the contents you chose, 233 click on save file. You should see a file in your downloads folder. 234 235
236How to delete an unnecessary widget?
238To delete a widget, drag it from the middle area and drop it into the trash area.
240How to delete all widgets?
242To delete all widgets in the middle area, click on the reset button.
244How do the templates look?
246The Simple, Left and Right Tabs on this web page display websites that use the Simple, Left and Right templates respectively.
248What do I do if the tutorial I created does not work?
250 252 First of all, I suggest that you check that all the files are read from the hosting site.
253 The files needed for the website tutorial to run are:
254
- 255
- simple.css 256
- left.css
- right.css 258
- tabs.css 259
- Three49custom.js 260
- Query-1.7.min.js 261
- GLmol.js 262
- widgetFunctionality.js 263
- jquery-ui-1.8.9.js 264
97
257
267 You can find them by adding the file name after css/ For example, to see the simple.css file
268 you can write http://montes.co.nf/css/simple.css
269 270 If for any reason, you still have problems, you can reach me at [email protected] 271 272
2. file.html This appendix contains the code for the file “file.html.” This html file defines the interactive widgets and includes the files needed for its proper execution. This file is the output of the system presented on this paper.
1 2 3
43. whipst.js This appendix shows contents of the file “whipst.js,” which handles the interactivity of the web interface. This file is responsible for the dragging and sorting capabilitites in the middle area, for generating the widgets contents by calling the appropriate writing function, and for saving the file to the computer.
1 /* 2 * Programmer: Elizabeth Montes 3 * Year: 2013- 2014 4 */ 5 //When the document loads have everything initialized 6 $(function(){ 7 var idName = ""; 8 9 //get the id of the draggable 10 $("li").mousedown(function(){ 11 idName = this.id; 12 }); 13 14 var counter = 0; 15 16 // This function makes the widgets (they have the class boxes) draggable 17 $(".boxes").draggable({ 18 appendTo: "body", 19 cursor: "crosshair", 20 cursorAt: { top: 56, left: 56 }, 21 helper: "clone", 22 revert: "invalid", 23 connectToSortable: ".sortableList",
103
24 stop: function(event,ui){ 25 counter++; 26 } 27 }); 28 29 //This function makes sortList sortable. 30 $("#sortList").sortable({ 31 tolerance: 'pointer', 32 items: "li:not(.placeholder),li:not(.notSortable)", 33 dropOnEmpty: true, 34 connectWith: '.trash', 35 appendTo: "#sortList", 36 sort: function(event, ui){ 37 $(this).removeClass("ui-state-default"); 38 }, 39 beforeStop: function(event, ui){ 40 newItem = ui.item; 41 }, 42 receive: function(event, ui){ 43 current = idName + counter; 44 if($(this).find(".placeholder").length > 0){ 45 promptInformation($(newItem), current); 46 $(this).find(".placeholder").remove(); 47 }else{ 48 promptInformation($(newItem), current); 49 } 50 } 51 }); 52 53 //Sortable to hold the trash 54 $(".trash").sortable({ 55 items: "li:not(.notTrash)", 56 receive: function(event, ui){ 57 $(".trash").each(function(){ 58 $(this).find('li').each(function(){ 59 $(this).css("display","none"); 60 }); 61 }); 62 } 63 }); 64 65 /* 66 * This function prompts the user for information according to the selected widget. 67 * Parameters: 68 * elem - item that will be passed from receive to stop event in $("#sortList").sortable() 69 * current - current id. This is a unique id that avoids conflict between widgets ids 70 * */ 71 function promptInformation(elem, current){ 72 73 switch(current){ 74 case "trueFalseQuestion"+counter: 75 elem.addClass("tempclass");
104
76 elem.html('
  ;' + 77 ' ' + 78 '' + 79 '
' + 80 ' ' + 81 '
' + 85 ' ' + 86 '' + 87 '
' + 88 '' + 89 '' + 90 '
'); 91 elem.css({width:"600px",height: '120px'}); 92 $(".tempclass").attr("id","trueFalseQuestion"+counter); 93 $("#trueFalseQuestion"+counter).removeClass("tempclass"); 94 if(elem) 95 break; 96 case "multipleChoiceQuestion"+counter: 97 elem.addClass("tempclass"); 98 elem.append('
' + 99 '' + 100 '
' + 101 '' + 103 '' + 104 '
' + 105 '' + 106 '' + 107 '
' + 108 '' + 110 '' + 111 '
' + 112 '' + 113 '' + 114 '
' + 115 '
105
116 ' ' + 117 '' + 118 '
' + 119 '' + 120 '' + 121 '
' + 122 '' + 124 '' + 125 '
' + 126 '' + 127 '' + 128 '
' + 129 '' + 130 ''); 136 $(".tempclass").attr("id","multipleChoiceQuestion"+counter); 137 $("#multipleChoiceQuestion"+counter).removeClass("tempclass"); 138 elem.css({width:"600px",height:"260px"}); 139 break; 140 case "glmolwidget1_"+counter: 141 elem.addClass("tempclass"); 142 elem.append('
' + 144 '' + 145 '
'); 146 elem.css({width:"600px", height:"40px"}); 147 $(".tempclass").attr("id","glmolwidget1_"+counter); 148 $("#glmolwidget1_"+counter).removeClass("tempclass"); 149 break; 150 case "glmolwidget2_"+counter: 151 elem.addClass("tempclass"); 152 elem.append('
' + 154 '' + 155 ''); 156 elem.css({width:"600px", height:"40px"}); 157 $(".tempclass").attr("id","glmolwidget2_"+counter); 158 $("#glmolwidget2_"+counter).removeClass("tempclass"); 159 break; 160 case "glmolwidget3_"+counter: 161 elem.addClass("tempclass");
106
162 elem.append('
' + 164 '' + 165 ''); 166 elem.css({width:"600px", height:"40px"}); 167 $(".tempclass").attr("id","glmolwidget3_"+counter); 168 $("#glmolwidget3_"+counter).removeClass("tempclass"); 169 break; 170 case "paragraphText"+counter: 171 elem.addClass("tempclass"); 172 elem.append('' + 173 ''); 174 elem.css({width:"600px", height:"200px"}); 175 $("#txtInfo"+counter).jqte(); //create the jqte text area 176 177 $(".tempclass").attr("id","paragraphText"+counter); 178 $("#paragraphText"+counter).removeClass("tempclass"); 179 console.log($(this)); 180 break; 181 } 182 } 183 }); 184 185 //This functions clears sortableList 186 function reset(){ 187 $(".sortableList").empty(); 188 } 189 190 //This functions saves the file tutorial to computer 191 function save(){ 192 193 var flag = false; 194 var len, pos, num; 195 var objects = new Array(); 196 var str_header = ""; 197 var str_left = ""; 198 var str_footer = ""; 199 var str_right = ""; 200 var str_tab_list = ""; 201 var str = ""; 202 var simple_str = ""; 203 var titlePage = $("#pageTitle").val(); 204 var nameTemplate = $('input[name="template"]:checked').val(); 205 206 if(nameTemplate == "left" || nameTemplate == "right"){ 207 str_right += ""; 209 str_header += writeHeader(titlePage, nameTemplate); 210 } 211 else { 212 simple_str += writeHeader(titlePage, nameTemplate); 213 }
107
214 if(($(".sortableList").length >= 1) && ($(".sortableList").find(".placeholder").length == 0)){ 215 $(".sortableList").each(function(){ 216 $(this).find('li').each(function(){ 217 var currentId = $(this).attr('id'); 218 219 if(currentId.search("multipleChoiceQuestion") != -1){ 220 221 len = currentId.length; 222 num = currentId.slice(22, len); 223 console.log(mcqValid(num)); 224 if(mcqValid(num)){ 225 str_right += writeMultipleChoice(num); 226 simple_str += writeMultipleChoice(num); 227 } 228 flag = mcqValid(num); 229 } 230 else if(currentId.search("trueFalseQuestion") != -1){ 231 232 len = currentId.length; 233 num = currentId.slice(17, len); 234 if(tfValid(num)){ 235 str_right += writeTrueFalse(num); 236 simple_str += writeTrueFalse(num); 237 } 238 flag = tfValid(num); 239 } 240 else if(currentId.search("glmolwidget1_") != -1){ 241 242 len = currentId.length; 243 num = currentId.slice(13, len); 244 if(gl1Valid(num)){ 245 246 var pdbid = $("#pdbid1_"+num).val(); 247 if(nameTemplate == "left" || nameTemplate == "right"){ 248 str_tab_list += '
108
264 if(nameTemplate == "left" || nameTemplate == "right"){ 265 str_tab_list += '
109
313 str_footer += writeFooter(objects, nameTemplate); 314 str = str_header + str_tab_list + str_left + str_right + str_footer; 315 }else{ 316 simple_str += writeFooter(objects, nameTemplate); 317 str = simple_str; 318 } 319 320 if(flag){ 321 if(titlePage.length == 0){ 322 $("#buttonMsg").html("Look for file in Downloads folder."); 323 downloadFile("file.html", str); 324 }else{ 325 titlePage = titlePage.replace(/\s/g, ''); //Remove space in file 326 $("#buttonMsg").html("Look for file in Downloads folder."); 327 downloadFile(titlePage+".html", str); 328 } 329 } 330 else { 331 alert("Please add items to the 'Add your items here' area \n or correct 'Required errors'"); 332 } 333 return flag; 334 } 335 /* VALIDATION FUNCTIONS */ 336 function required(name, num){ 337 if(!$("#"+ name + num).val().length){ 338 $("#"+ name + "msg" + num).html("Required"); 339 }else{ 340 $("#"+ name + "msg" + num).html(" "); 341 } 342 } 343 344 function clearmcmsg(num){ 345 $("#mcqmsg"+num).html(" "); 346 $("#mcamsg"+num).html(" "); 347 $("#mcaexpmsg"+num).html(" "); 348 $("#mcbmsg"+num).html(" "); 349 $("#mcbexpmsg"+num).html(" "); 350 $("#mccmsg"+num).html(" "); 351 $("#mccexpmsg"+num).html(" "); 352 $("#mcdmsg"+num).html(" "); 353 $("#mcdmsg"+num).html(" "); 354 $("#mcdexpmsg"+num).html(" "); 355 $("#mccvmsg"+num).html(" "); 356 } 357 358 function mcqValid(num){ 359 360 if (!$("#mcq"+num).val().length || !$("#mca"+num).val().length || !$("#mcaexp"+num).val().length 361 || !$("#mcb"+num).val().length || !$("#mcbexp"+num).val().length || !$("#mcc"+num).val().length 362 || !$("#mccexp"+num).val().length || !$("#mcd"+num).val().length || !$("#mcdexp"+num).val().length){ 363 364 required("mcq", num);
110
365 required("mca", num); 366 required("mcaexp", num); 367 required("mcb",num); 368 required("mcbexp", num); 369 required("mcc",num); 370 required("mccexp", num); 371 required("mcd",num); 372 required("mcdexp", num); 373 required("mccv",num); 374 return false; 375 } 376 //at this point everything is true, clear required messages 377 clearmcmsg(num); 378 return true; 379 } 380 381 function tfValid(num){ 382 if(!$("#tfexpc"+num).val().length || !$("#tfq"+num).val().length || !$("#tfexpi"+num).val().length 383 || !$("#tfcv"+num).val().length) 384 { 385 required("tfq",num); 386 required("tfexpc",num); 387 required("tfexpi",num); 388 required("tfcv", num); 389 390 return false; 391 } 392 //at this point everything is true, clear required messages 393 $("#tfqmsg"+num).html(" "); 394 $("#tfexpcmsg"+num).html(" "); 395 $("#tfexpimsg"+num).html(" "); 396 $("#tfcvmsg"+num).html(" "); 397 return true; 398 } 399 400 function gl1Valid(num){ 401 if(!$("#pdbid1_"+num).val().length){ 402 $("#pdbid1msg_"+num).html("Required"); 403 return false; 404 }else{ 405 if(!$("#pdbid1_"+num).val().match(/^[1-9][A-Za-z0-9]{3}$/)){ 406 $("#pdbid1msg_"+num).html("Wrong PDB Id"); 407 return false; 408 } 409 } 410 $("#pdbid1msg_"+num).html(" "); 411 return true; 412 } 413 414 function gl2Valid(num){ 415 if(!$("#pdbid2_"+num).val().length){ 416 $("#pdbid2msg_"+num).html("Required"); 417 return false; 418 } else{ 111
419 if(!$("#pdbid2_"+num).val().match(/^[1-9][A-Za-z0-9]{3}$/)){ 420 $("#pdbid2msg_"+num).html("Wrong PDB Id"); 421 return false; 422 } 423 } 424 $("#pdbid2msg_"+num).html(" "); 425 return true; 426 } 427 428 function gl3Valid(num){ 429 if(!$("#pdbid3_"+num).val().length){ 430 $("#pdbid3msg_"+num).html("Required"); 431 return false; 432 } else{ 433 if(!$("#pdbid3_"+num).val().match(/^[1-9][A-Za-z0-9]{3}$/)){ 434 $("#pdbid3msg_"+num).html("Wrong PDB Id"); 435 return false; 436 } 437 } 438 $("#pdbid3msg_"+num).html(" "); 439 return true; 440 } 441 442 function txtValid(num){ 443 if(!$("#txtInfo"+num).val().length){ 444 $("#txtInfomsg"+num).html("Required"); 445 return false; 446 } 447 $("#txtInfomsg"+num).html(" "); 448 return true; 449 } 450 451 /* FUNCTIONS THAT RETURN STRING WITH TUTORIAL HTML CODE */ 452 function writeHeader(title, name){ 453 var str = ''; 454 str += '\n\n
'; 455 str += '