wiki:VsparqlGUI_Examples
Last modified 7 years ago Last modified on 11/09/10 09:32:13

VSPARQL GUI Examples

The vSPARQL GUI is a Flex application for creating vSPARQL view definitions. The GUI allows view definitions to be created in a dataflow-style. Individual subqueries in the view definition can be executed and their results inspected to determine if they are correct.

This page contains three step-by-step examples demonstrating how to use the vSPARQL GUI to create and debug view definitions.

Tour of vSPARQL GUI

At the top of the screen, there is a purple block containing an "Add Prefix" button. vSPARQL queries allow users to specify prefixes to reduce the amount of text needed to specify a URI. Currently defined prefixes are listed in the righthand side of this box.

The blocks on the leftmost side of the screen are the component blocks that can be used to create a view definition. Clicking on one of these blocks will result in an instance of the blocks being placed in the main development window. The blocks available are: data source, SELECT query, CONSTRUCT subquery, recursive subquery, DESCRIBE query, and ASK query.

In general, clicking on a block makes it possible to move or resize the block. Double clicking causes the blocks black lines to become bold; users may then click within the block on editable elements (e.g. textbox, button).

To connect the output of one block to the input of another block, double click on a block, click and hold on the "Add Output Target" button, then drag the cursor to the target block. A black line will be drawn while the mouse is being dragged.

When selecting items in a pull-down list, you can use <shift> and <control> to select multiple items.

To delete a block, double click and then press <delete>.

Example 1: Direct Parts of Liver

http://www.cs.washington.edu/homes/mar/liverPartsSelect.png

1) Load the vSPARQL GUI http://axon.biostr.washington.edu:8080/VSparQL_Service/GUI/vsparql_oh_degrafa.html in a web browser.

2) Click on the red "data source" block on the left. An instance of the data source block will appear in the development region. Double-click on the red block to select it (black lines will become bold). Click on the textbox and enter "http://sig.biostr.washington.edu/fma3.0".

This creates a data source for the FMA3.0 that can be used in the view definition.

3) Click on the orange "SELECT Query" block on the left; this adds an instance to the development region. Click on the orange block to move it below the red data source.

4) Double-click on the red data source to select it. Click and hold the "Add Data source Target" button, and drag the mouse to the orange SELECT block and release the mouse button; this will draw a black line between the two blocks.

This adds the FMA3.0 as an input graph to the SELECT query. The FROM/FROM NAMED/FROM NAMEDV pull-down lists should now have the FMA3.0 listed as a source.

5) Double-click on the orange SELECT block. Use the arrows to scroll through the source available to the "FROM" field. Click on the FMA3.0 to select it as an input source. The selection should be highlighted in blue. You can use the <shift> and <control> keys to select more than one item in a pull-down list.

This ensures that the WHERE clause will be applied to the FMA3.0.

6) Click in the WHERE clause textbox and type:

fma:Liver ?p ?parts .
FILTER((?p=fma:regional_part)||(?p=fma:constitutional_part))

This indicates that you want to match all regional and constitutional parts of the liver.

7) Click on the SELECT textbox and type:

?parts

This indicates that the bindings for variable ?parts should be projected by the SELECT statement.

8) Click on the "Query" button. This will cause a pop-up window to appear that contains the entire vSPARQL query string. Double-click to select the window and then click on "Close" to remove the window.

9) Click on the "Query Results" button. This will cause a pop-up window to appear that contains the result of executing the vSPARQL query string. Double-click to select the window and then click on "Close."

Example 2: Recursive Parts of Liver

http://www.cs.washington.edu/homes/mar/liverPartsRecursive.png

1) Load the vSPARQL GUI http://axon.biostr.washington.edu:8080/VSparQL_Service/GUI/vsparql_oh_degrafa.html in a web browser.

2) Click on the red "data source" block on the left. An instance of the data source block will appear in the development region. Double-click on the red block to select it (black lines will become bold). Click on the textbox and enter "http://sig.biostr.washington.edu/fma3.0".

This creates a data source for the FMA3.0 that can be used in the view definition.

3) Click on the green "Recursive query" block on the left. An instance of the recursive subquery block will appear in the development region. Click on the green block and move it below the red data source block.

4) Double-click on the red data source block to select it. Click and hold the "Add Data Source Target" button, drag the mouse to the green block, and release. A black line will be drawn while the mouse is being dragged.

This adds the FMA3.0 as an input graph to the recursive subquery. The FROM/FROM NAMED/FROM NAMEDV pull-down lists should now have the FMA3.0 listed as a source.

5) Double-click on the green block to select it. Recursive subqueries require at least a single base case and a single recursive case. The recursive subqueries are evaluated in the following way: First evaluate the base case to put data in the results graph. Next, repeatedly evaluate the recursive case using the data in the results graph; iterate until no new data is added to the results graph.

6) In the base case, use the arrows to scroll through the source available to the "FROM" field. Click on the FMA3.0 to select it as an input source. The selection should be highlighted in blue.

This ensures that the WHERE clause will be applied to the FMA3.0.

7) In the base case, click in the WHERE textbox and type:

fma:Liver ?p ?parts .
FILTER((?p=fma:regional_part)||(?p=fma:constitutional_part))

This indicates that you want to match all regional and constitutional parts of the liver.

8) In the base case, click in the CONSTRUCT textbox and type:

fma:Liver ?p ?parts

This ensures that the regional and constitutional parts of the liver are added to our result graph.

8) In the recursive case, use the arrows to scroll through the source available to the "FROM" field. Click on the FMA3.0 to select it as an input source. The selection should be highlighted in blue.

This ensures that the WHERE clause will be applied to the FMA3.0.

9) In the recursive case, use the arrows to scroll through the source available to the "FROM NAMED" field. Click on "recursive" to select it as a named input source. The selection should be highlighted in blue.

This ensures that you can use <recursive> as a named graph in the WHERE clause.

NOTE: If you look at the bottom of this green recursive block, you'll see a textbox named "Sub Query Name" with the value "recursive" filled in. This is the name of the result of the recursive query; if you change this, then you'll need to change every reference to it within the query (i.e. FROM pull-down lists and WHERE clause).

10) Click in the WHERE textbox and type:

GRAPH <recursive> { ?a ?b ?c }
?c ?p ?parts .
FILTER((?p=fma:regional_part)||(?p=fma:constitutional_part))

This indicates that we want to find all regional and constitutional parts of the object ?c. ?c will be bound to all regional and constitutional parts found on previous iterations.

11) Click in the CONSTRUCT textbox and type

?c ?p ?parts

This indicates that newly found regional and constitutional parts should be added to our result set.

12) Click on the "Query" button. This will cause a pop-up window to appear that contains the entire vSPARQL query string. Double-click to select the window and then click on "Close" to remove the window.

13) Click on the "Query Output" button. This will cause a pop-up window to appear that contains the result of executing the vSPARQL query string.

The window contains two tabs: "RDF/XML" and "?x ?y ?z." Both windows display the results of executing the query, just in different formats. Double-click on the window and then click on the tabs to view the two different formats.

Example 3: Orientation and Recursive Parts of Liver

http://www.cs.washington.edu/homes/mar/overallPicture.png

1) Load the vSPARQL GUI http://axon.biostr.washington.edu:8080/VSparQL_Service/GUI/vsparql_oh_degrafa.html in a web browser.

2) Perform all of the actions in Example 2 to create a recursive subquery that extracts the subgraph containing all of the regional and constitutional parts of the liver.

3) Double-click on the green recursive subquery block to select it. Click in the "Sub Query Name" textbox and type "rec_parts."

This changes the name of the result graph produced by the recursive subquery from "recursive" to "rec_parts." Go to the FROM NAMEDV pull-down list and select "rec_parts." Replace "<recursive>" with "<rec_parts>" in the WHERE textbox.

4) Click on the yellow "CONSTRUCT query" block on the left. An instance of the CONSTRUCT subquery block will appear in the development region. Click on the yellow block and move it below the red data source block and to the right of the green recursive subquery block.

5) Double-click on the red data source block to select it. Click and hold the "Add Data Source Target" button, drag the mouse to the yellow block, and release. A black line will be drawn while the mouse is being dragged.

This adds the FMA3.0 as an input graph to the CONSTRUCT subquery. The FROM/FROM NAMED/FROM NAMEDV pull-down lists should now have the FMA3.0 listed as a source.

6) Double-click on the yellow block to select it. CONSTRUCT subqueries are used to create result graphs. Use the arrows to scroll through the source available to the "FROM" field. Click on the FMA3.0 to select it as an input source. The selection should be highlighted in blue.

This ensures that the WHERE clause will be applied to the FMA3.0.

7) In the base case, click in the WHERE textbox and type:

fma:Liver fma:orientation ?orient .
?orient ?b ?c .

This indicates that you want to match all of the orientation links from the liver and that you want all outgoing links from the orientation object.

8) Click in the CONSTRUCT textbox and type:

fma:Liver fma:orientation ?orient .
?orient ?b ?c .

This ensures that the liver's orientation information is extracted and placed in the result graph.

9) Click in the CONSTRUCT "Sub Query Name" textbox and type "orientation." This names the result graph of this subquery.

10) Click on a yellow CONSTRUCT query block on the left. Drag the new CONSTRUCT query block below the green recursive subquery block and the existing <orientation> yellow CONSTRUCT block.

11) Double-click on the new yellow CONSTRUCT query block. Click in the "Sub Query Name" textbox and enter "parts_and_orientation."

12) Double-click on the green <rec_parts> recursive subquery block. Click and hold the "Add Output Target" button, drag the mouse to the yellow <parts_and_orientation> CONSTRUCT block, and release.

13) Double-click on the yellow <orientation> CONSTRUCT block. Click and hold the "Add Output Target" button, drag the mouse to the yellow <parts_and_orientation> CONSTRUCT block, and release.

14) Double-click on the yellow <parts_and_orientation> CONSTRUCT block. Use the arrows to scroll through the source available to the "FROM NAMEDV" field. Select both the <rec_parts> and <orientation> input sources by holding the <shift> key while you perform the selection. The selections should be highlighted in blue.

This ensures that the WHERE clause will be able to use both <rec_parts> and <orientation> as named graphs.

15) Click in the <parts_and_orientation> subquery WHERE textbox and type:

{ GRAPH <rec_parts> { ?a ?b ?c } }
UNION
{ GRAPH <orientation> { ?x ?y ?z } }

This indicates that you want to match on all triples in both of the input graphs.

16) Click in the <parts_and_orientation> subquery CONSTRUCT textbox and type:

?a ?b ?c .
?x ?y ?z .

This puts all of the triples in the input graphs in the result graph.

17) Click on an orange SELECT query block on the left. Drag the new SELECT query block below the yellow <parts_and_orientation> subquery block.

18) Double-click on the yellow <parts_and_orientation> CONSTRUCT block. Click and hold the "Add Output Target" button, drag the mouse to the orange SELECT block, and release.

19) Double-click on the orange SELECT block. Use the arrows to scroll through the source available to the "FROM" field. Use the mouse to select the <parts_and_orientation> input source. The selections should be highlighted in blue.

This ensures that the WHERE clause will be applied to the <parts_and_orientation> input source.

20) Click in the orange SELECT query WHERE textbox and type:

?a fma:orientation ?b .
?b fma:related_object ?obj .
?b fma:laterality ?lat .

This pattern matches against the related objects that are used to provide orientation information for the liver; specifically we are matching to find their relative laterality.

21) Click in the orange SELECT query SELECT textbox and type:

?lat ?obj

This indicates that only the laterality and related objects should be projected from the <parts_and_orientation> graph.

22) Click on the "Query" button. This will cause a pop-up window to appear that contains the entire vSPARQL query string. Double-click to select the window and then click on "Close" to remove the window.

23) Click on the "Query Results" button. This will cause a pop-up window to appear that contains the result of executing the vSPARQL query string. This window contains the bindings for the projected variables.