Technical Manual

User Manual:

Open the PDF directly: View PDF PDF.
Page Count: 6

Technical Manual
Carbon Semantics
”https://github.com/CarboSem”
Department of Computer Science, University of L’Aquila
June 9, 2017
Abstract
CarboSem is a webapp interface for the DIANA project (Data science analysis
to determine the Influence of multiple conjoint mirnAs on caNcer diseAse).
developed with jquery, d3.js, python and the bottle micro-framework.
0.1 File Roles
The webapp comprises of 2 main files, one ”carbosem.py” acts as a mini-
mal server, the other ”carbosem.js” acts as a data visualizer.
.
carbosem . py
j s
carbosem . j s
0.1.1 carbosem.py
The main server-side script that handles client requests, fetches files from the
server to be loaded to the client, and relays submitted data from the client to
the 3rd party server-side scripts. It is mainly a skeleton script with routing
subroutines.
One certain routing subroutine that the 3rd party developers should be made
aware of is the one that receives data from the client to be queried:
@route ( ’ / graph )
d e f grap h ( ) :
# TODO
r e t u r n True
In the TODO section should go the interface to the scripts that handle
queries.
1
0.1.2 carbosem.js
The main client-side script that handles data manipulation on the returned
JSON file and visualization of said data, it is responsible for the drawing and
handling of the graph canvas, the checkbox area and the ledger area.
We will go in detail over some of the code segments which those who wish to
use this script should pay attention to.
We start off with client events, which include calling the submission rou-
tine and the drawing routine on client submission of a string to be queried:
/
c a l l i n g f u n c t i o n s a c c o r d i n g t o DOM b i n d i n g s
/
(”# s e a r c h ) . s ub mi t ( submitQue ry ) ;
(”# s e a r c h ) . s ub mi t ( drawGraph ) ;
( window ) . r e s i z e ( drawGraph ) ;
return ;
From here we examine the submission routine, as every submission brings
a new set of relations, we tend to reset the checkbox area (which when an
element of which is active it denotes an active relationship on the screen):
f u n c t i o n submitQuery ( ) {
/
r e s e t t i n g the checkbox a r e a
/
checkbox . s t a t e s = [ ] ;
checkbox . v a l s = [ ] ;
checkbox . c o l o r s = [ ] ;
/
TODO
v ar qu ery = (”# s e a r c h ) . f i n d ( ” i np u t [ name=s e a r c h ] ) . v a l ( ) ;
. g e t (/ graph ? mir=” + encodeURIComponent ( query ) ) ;
/
}
It is also important to note that 3rd party developers take good care in ar-
ticulating the routing request from the submission routine to the ”graph()”
routine on the server side.
2
Moving on to the drawing routine, we notice that every time we call this
routine the ledger is reset, because this routine is called regardless of any
server submissions sometimes, depending on client change of the checkbox
area, which in turn has the ledger require adjustment according to the new
node types on display and according to the checkbox states.
/
r e s e t t i n g the le d g e r ar ea
/
l e d g e r . e le me nt s = [ ] ;
l e d g e r . c o l o r s = [ ] ;
d3 . j s o n ( ”/ getJSON ” , f u n c t i o n ( e r r o r , graph ) {
i f ( e r r o r ) {
a l e r t ( Error , no JSON f i l e found ! ” ) ;
return ;
}
/
c l e a n i n g up p r e v i o u s l y r en de red c hec kb ox es and l e d g e r e le me nts
/
d3 . s e l e c t A l l ( d i v #addedCheckbox ”) . remove ( ) ;
d3 . s e l e c t A l l ( d i v #addedLedger ” ) . remove ( ) ;
Also at this stage, the JSON file is reloaded and drawn from according to
the checkbox states, and both the ledger and the checkbox areas are removed
from screen for re-rendering to reflect new or less elements in the ledger area
and the new chosen states of the checkbox area.
As for choosing the colors, we opted in for using the schemeCategory
functions already packaged with d3 to construct our source color arrays, and
we chose different schemes for the checkbox area and the ledger area:
/
d e f i n i n g c o l o r a r ra ys
/
va r l i n k C o l o r = d3 . s c a l e O r d i n a l ( d3 . sch eme Ca teg or y10 ) ;
va r nod eCo lo r = d3 . s c a l e O r d i n a l ( d3 . schem eC ate gor y2 0 ) ;
Whenever we get the result of a query, we construct our target color arrays
depending on node/link types and the source color arrays.
3
For example, when we submit a query for the first time, as soon as we
get the JSON file we scan through it looking for different types of links to
populate our checkbox area accordingly, we store information about the link
type, its state: whether it’s active or inactive, and we derive its targeted
color according to its index from the source color array:
var p us hSt at e = c heckbox . v a l s . indexOf ( graph . nod es [ i ] . t a r g e t s [ j ] . ty pe ) ;
i f ( pus h S tat e == 1) {
checkbox . v a l s . push ( graph . nodes [ i ] . t a r g e t s [ j ] . type ) ;
ch ec kb ox . s t a t e s . push ( t r u e ) ;
che ckb ox . c o l o r s . push ( l i n k C o l o r ( c he ckb ox . s t a t e s . l e n g th 1 ) ) ;
}
If one wants fixed colors for certain nodes or links, one can choose a function
with ”if” statements to choose certain colors for certain node/link types.
One other way is getting rid of the target color arrays and depending solely
on one set of color arrays, but that requires using another method to choose
the proper color index for a type, which is embedding this information inside
the JSON file for each link/node type.
One final thing we ought to mention is the recalling of the drawing routine
on checkbox changes by the client, that is done using the following:
addedCheckbox . on ( ” c han ge , f u n c t i o n ( ) {
f o r ( va r i = 0 ; i <c he ck box . s t a t e s . l e n g t h ; i ++) {
checkbox . s t a t e s [ i ] = addedBoxes [ i ] . pr op er ty ( ch ecked ) ;
checkbox . c o l o r s [ i ] = checkbox . s t a t e s [ i ] ? l i n k C o lo r ( i ) : #
FFFFFF” ;
}
drawGraph ( ) ;
return ;
}) ;
We notice that before the recall of the drawing routine, the checkboxes are
checked for changes and if so, color and state arrays are changed accordingly
to be re-rendered on routine recall.
4

Navigation menu