2 // AJAX-based ontology browser
4 // Lukas Mueller and Naama Menda
6 // Sol Genomics Network (http://sgn.cornell.edu/ )
11 JSAN
.use('MochiKit.DOM');
12 JSAN
.use('MochiKit.Visual');
13 JSAN
.use('MochiKit.Logging');
14 JSAN
.use('MochiKit.Async');
15 JSAN
.use('Prototype');
16 JSAN
.use('CXGN.Effects');
18 //JSAN.use('CXGN.Onto');
19 JSAN
.use('CXGN.Onto.Browser');
20 //JSAN.use('CXGN.Phenome.Tools');
23 CXGN = function () {};
24 CXGN
.Onto = function () {};
26 CXGN
.Onto
.Browser = function () {
28 this.nodelist
= new Array();
30 //this.workingMessage(false);
31 //document.write('<p id="ontology_browser"> </p>');
32 //var dom = MochiKit.DOM.getElement('ontology_browser');
33 //MochiKit.Logging.log('DOM: '+dom);
34 //this.setDOMElement(dom);
36 //MochiKit.Logging.log('In browser constructor.');
40 CXGN
.Onto
.Browser
.prototype = {
42 fetchTestRoots: function() {
43 //MochiKit.Logging.log('creating root node.');
44 this.rootnode
= new Node(this);
45 this.rootnode
.setName('ROOT');
46 this.rootnode
.openNode();
48 for (var i
=0; i
<5; i
++) {
49 //MochiKit.Logging.log('adding child node '+i);
50 var n
= new Node(this);
52 var nodeName
= 'node';
59 //MochiKit.Logging.log('p2 is now ' + p2.getName());
61 this.rootnode
.addChild(n
);
66 //MochiKit.Logging.log('adding second level child nodes...');
76 resetBrowser: function() {
78 //this.setSearchTerm();
79 //this.setSearchValue();
80 document
.getElementById("ontology_browser_input").value
='';
81 document
.getElementById("ontology_term_input").value
='';
82 //this.setSearchResults(); //this works
84 this.initializeBrowser();
89 setUpBrowser: function() {
90 document
.write('<div id="ontology_browser_input" > </div><div id="working"></div> '); // the element for the go id parentage search
91 document
.write('<div id="ontology_term_input" ></div>'); // the element for the search
92 document
.write('<input id="hide_link" type="button" value="show results" display="none" onClick="MochiKit.Visual.toggle(\'search_results\', \'blind\'); o.toggleSearchResultsVisible(); o.setSearchButtonText(); "><br />');
94 document
.write('<div id="search_results" ></div>');
95 document
.write('<div id="ontology_browser" style="font-size:12px; line-height:10px; font-face:arial,helvetica" > </div>'); // the element for the browser
101 initializeBrowser: function() {
103 this.setSearchTerm('');
104 this.setSearchValue('');
105 this.setSearchResults('');
107 this.hideSearchButton();
108 this.setSearchResponseCount(0);
112 fetchRoots: function() {
113 //MochiKit.Logging.log('THis in fetchRoots: ' + this);
115 new Ajax
.Request("/chado/ajax_ontology_browser.pl", {
116 parameters
: { action
: 'roots' },
119 alert('An error occurred! The database may currently be unavailable. Please check back later.');
121 onSuccess: function(request
) {
123 //MochiKit.Logging.log('COMPLETE!');
125 var responseText
= request
.responseText
;
127 //MochiKit.Logging.log('RESPONSETEXT = ' + responseText);
129 //MochiKit.Logging.log('This = ' + this);
131 o
.rootnode
= new Node(o
);
133 //MochiKit.Logging.log('Created root node. Yay!');
134 o
.rootnode
.setName('');
135 o
.rootnode
.setAccession('root');
136 o
.rootnode
.openNode();
138 o
.rootnode
.setHasChildren(true);
139 //MochiKit.Logging.log('root: ' + o.rootnode + ' ---- ' + o.rootnode.name);
141 //MochiKit.Logging.log('fetching roots...');
143 var t
= responseText
.split('#');
145 //MochiKit.Logging.log('Children count ' + t.length + '<br />');
147 for (var i
=0; i
<t
.length
; i
++) {
148 var j
= t
[i
].split('*');
149 // MochiKit.Logging.log(i + '. Child: ID: '+ j[0] + ' Name: ' + j[1] + ' <br />');
152 //MochiKit.Logging.log('Processing '+j[0]);
155 var childNode
= new Node(o
);
157 o
.rootnode
.addChild(childNode
);
158 childNode
.setAccession(j
[0]);
159 //childNode.setHilite(true);
160 childNode
.closeNode();
162 childNode
.setName(j
[1]);
163 childNode
.setCVtermID(j
[2]);
164 childNode
.setRelType(j
[4]);
165 //MochiKit.Logging.log('hasChildren = '+j[2]);
167 childNode
.setHasChildren(true);
170 childNode
.setHasChildren(false);
173 //MochiKit.Logging.log('Root node name: '+o.rootnode.getName()+'<br />');
174 //MochiKit.Logging.log('Child accession: '+childNode.getAccession()+'<br />');
181 workingMessage: function(status
) {
182 MochiKit
.Logging
.log('the working message = ' , status
);
183 var w
= document
.getElementById('working');
186 // MochiKit.Logging.log('status is true! ' , status);
187 w
.style
.visibility
='visible';
190 w
.style
.visibility
='hidden';
194 renderSearchById: function() {
195 //this.workingMessage(false);
196 //MochiKit.Logging.log('the value of ontology_browser_input is ...', (document.getElementById('ontology_browser_input')).value);
198 var s
= '<form name="search_id_form" style="margin-bottom:0" onSubmit="javascript:o.showParentage(this.ontology_browser_input.value); return false;" >';
199 s
+= '<div id="search_by_id" style="width:700" style="margin-bottom:0" >';
200 s
+= '<table summary="" cellpadding="5" cellspacing="0" ><tr><td align="center">';
201 s
+= 'Ontology id <input id="ontology_browser_input" name="ontology_browser_input_name" type="text" size="12" style="margin-bottom:0" /><input id="ontology_browser_submit" type="submit" style="margin-bottom:0" />';
202 s
+= ' | <input id="reset_hiliting" type="button" value="clear hiliting" onClick="javascript:o.clearHiliting()" style="margin-bottom:0" /> | <input id="reset_tree" type="button" value="reset" onClick="javascript:o.resetBrowser()" style="margin-bottom:0" />';
203 s
+= '</td><td align="right" width="*" ></td></tr></table>';
206 var e
= document
.getElementById('ontology_browser_input');
207 //MochiKit.Logging.log('the value of ontology_browser_input is ...',document.getElementById('ontology_browser_input').value);
209 document
.getElementById('ontology_browser_input').value
=(o
.getSearchTerm());
210 this.workingMessage(false);
213 renderSearchByName: function() {
214 //this.workingMessage(false);
215 var s
= '<form style="margin-bottom:0" name="SearchByNameForm" onsubmit="javascript:o.getOntologies(this.cv_select.value, this.ontology_term_input.value); return false;" >';
216 s
+= '<div id="search_by_name" style="margin-bottom:0" >';
217 //s += '<form name="search_name_form" style="margin-bottom:0" >';
218 s
+= '<table summary="" cellpadding="5" cellspacing="0"><tr><td align="center" >';
219 s
+= 'Ontology term <input id="ontology_term_input" name="ontology_term_input_name" type="text" size="30" />';
220 s
+= '<select id="cv_select" >';
221 s
+= '<option value="GO" ' + o
.isSelected("GO") +'>GO (gene ontology)</option>';
222 s
+= '<option value="PO" ' + o
.isSelected("PO") +'>PO (plant ontology)</option>';
223 s
+= '<option value="SP" ' + o
.isSelected("SP") +'>SP (Solanaceae phenotypes)</option>';
224 s
+= '<option value="PATO" ' + o
.isSelected("PATO") +'>PATO (Phenotype and trait)</option>';
225 s
+= '<option value="SO" ' + o
.isSelected("SO") +'>SO (Sequence ontology)</option>';
228 s
+= '<input id="term_search" type="submit" value="Search" />';
229 s
+= '</td></tr></table>';
230 s
+= '</div></form>';
232 var e
= document
.getElementById('ontology_term_input');
234 document
.getElementById('ontology_term_input').value
=(o
.getSearchValue());
242 if (o
.searchResults
) {
243 //s +='<input id="hide_link" type="button" value="'+o.getSearchButtonText()+'" onClick="MochiKit.Visual.toggle(\'search_results\', \'blind\'); o.toggleSearchResultsVisible(); o.setSearchButtonText(); "><br />';
244 document
.getElementById("hide_link").style
.display
="inline";
248 o
.setSearchButtonText();
250 document
.getElementById("search_results").innerHTML
=this.getSearchResults();
251 // s +='<div id="search_results" >' + this.getSearchResults() + '</div>';
253 //s += '<div style="font-size:9pt; line-height:10px; font-face:arial,helvetica" >';
255 s
= s
+ this.renderLevel(s
, this.rootnode
, 0);
256 var e
= document
.getElementById('ontology_browser');
264 renderLevel: function (s
, node
, level
, last
) {
265 //MochiKit.Logging.log('renderLevel: ' + node.getName() + ', '+level);
269 if ((node
== undefined) || (node
.isHidden())) {
270 //MochiKit.Logging.log('undefined or hidden node!');
274 //MochiKit.Logging.log('level '+level);
275 //for (var l=0; l<level; l++) {
276 // MochiKit.Logging.log('.');
280 for (var i
=0; i
<level
-1; i
++) {
281 t
+= '<img src="/documents/img/tree_bar.png" border="0" />';
284 if (node
.hasChildren()) {
285 var key
= node
.getNodeKey();
286 if (node
.getOpenNode()) {
288 t
+= '<a href="javascript:o.closeNode('+key
+')"><img src="/documents/img/tree_exp.png" border="0" /></a>';
294 t
+= '<a href="javascript:o.openNode('+key
+')"><img src="/documents/img/tree_col_end.png" border="0" /></a>';
298 t
+= '<b><a href="javascript:o.openNode('+key
+')"><img src="/documents/img/tree_col.png" border="0" /></a></b>';
304 t
+= '<img src="/documents/img/tree_end.png" border="0" />';
307 t
+= '<img src="/documents/img/tree_bar_con.png" border="0" />';
312 t
+= node
.renderNode(level
);
316 if (node
.getOpenNode()) {
318 var c
= node
.children
;
320 //MochiKit.Logging.log('now processing node '+node.name + ', with '+c.length+' children nodes');
322 var cs
= new Array();
323 for(var i
=0; i
<c
.length
; i
++) {
324 last
= (i
==c
.length
-1);
325 //MochiKit.Logging.log('<p>', c[i].accession, '</p>');
326 t
= t
+ this.renderLevel(t
, c
[i
], level
, last
);
334 //MochiKit.Logging.log('renderLevel end');
337 addNode: function(node
) {
338 //MochiKit.Logging.log('addNode: adding node ' + node.getName());
339 var key
= this.newNodeKey();
340 node
.setNodeKey(key
);
341 //MochiKit.Logging.log('generated node key '+key);
342 this.nodelist
[key
]=node
;
345 getNode: function(key
) {
346 return this.nodelist
[key
];
350 closeNode: function(key
) {
351 var n
= this.getNode(key
);
356 openNode: function(key
) {
357 //MochiKit.Logging.log('opening node ' + key);
358 this.workingMessage(true);
359 var n
= this.getNode(key
);
361 var c
= n
.getChildren();
362 for (var i
=0; i
<c
.length
; i
++) {
366 this.workingMessage(false);
369 hideNode: function(key
) {
370 var n
= this.getNode(key
);
375 unHideNode: function(key
) {
376 this.getNode().unHide();
380 findNode: function(node
) {
383 newNodeKey: function() {
388 resetNodeKey: function() {
392 showParentage: function(accession
) {
393 MochiKit
.Logging
.log('the accession is :', accession
);
394 this.setSearchTerm(accession
);
395 if (accession
.length
< 5) {
396 alert('The search text must be longer than 4 characters');
399 this.workingMessage(true);
400 var pL
= this.getParentsList(accession
);
402 MochiKit
.Logging
.log('Retrieved parents '+pL
.join(' '));
404 var c
= this.rootnode
.getChildren();
405 for (var i
=0; i
<c
.length
; i
++) {
406 this.recursiveParentage(c
[i
], pL
, accession
);
409 this.workingMessage(false);
412 //this is called when a search term is clicked from the search results list.
413 //we explicitly hide the search results.
414 searchTermParentage: function(accession
) {
415 o
.hideSearchResults();
416 o
.showParentage(accession
);
419 getSearchTerm: function() {
420 return this.searchTerm
;
423 setSearchTerm: function(searchTerm
) {
424 this.searchTerm
= searchTerm
;
426 getSearchValue: function() {
427 return this.searchValue
;
430 setSearchValue: function(searchValue
) {
431 this.searchValue
= searchValue
;
434 recursiveParentage: function(currentNode
, parentsList
, accession
) {
436 if (currentNode
.getAccession() == accession
) {
437 //MochiKit.Logging.log('unHiding '+currentNode.getAccession() + ' ' + accession);
438 currentNode
.unHide();
439 currentNode
.setHilite(true);
443 //MochiKit.Logging.log('node is ' + currentNode.getAccession() + ' accession= ' , accession);
444 if (this.hasMatch(parentsList
, currentNode
.getAccession())) { // indexOf does not seem to be implemented widely.
445 //MochiKit.Logging.log('Opening node '+ currentNode.getName());
446 currentNode
.openNode();
447 currentNode
.unHide();
450 //MochiKit.Logging.log('Current node '+currentNode.getAccession()+' does not match parent list ' + parentsList.join(' '));
454 var c
= currentNode
.getChildren();
455 for (var i
=0; i
<c
.length
; i
++) {
456 this.recursiveParentage(c
[i
], parentsList
, accession
);
461 //check if a list contains a certain member
462 hasMatch: function(list
, value
) {
463 for (var i
=0; i
<list
.length
; i
++) {
464 if (list
[i
] == value
) {
471 //clears all hiliting in the tree.
472 clearHiliting: function() {
473 this.recursiveHiliteClearing(this.rootnode
);
477 recursiveHiliteClearing: function(node
) {
478 node
.setHilite(false);
479 var c
= node
.getChildren();
480 for (var i
=0; i
<c
.length
; i
++) {
481 this.recursiveHiliteClearing(c
[i
]);
485 getParentsList: function(accession
) {
486 //MochiKit.Logging.log('Fetching children for node '+this.getName());
488 var parentsList
= new Array();
491 new Ajax
.Request('/chado/ajax_ontology_browser.pl', {
492 parameters
: { node
: accession
, action
: 'parents' },
495 alert('An error occurred! The database may currently be unavailable. Please check back later.');
498 onSuccess: function(request
) {
500 var responseText
= request
.responseText
;
502 var t
= responseText
.split('#');
504 //MochiKit.Logging.log('Children count ' + t.length);
506 for (var i
=0; i
<=t
.length
; i
++) {
507 var j
= t
[i
].split('*');
508 //MochiKit.Logging.log(i + '. Parent: ID: '+ j[0] + ' Name: ' + j[1], '' );
510 //MochiKit.Logging.log('Processing '+j[0]);
511 parentsList
.push(j
[0]);
513 //MochiKit.Logging.log('Child accession: '+childNode.getAccession());
517 //MochiKit.Logging.log('Rendering again...');
518 //parentNode.browser.render();
526 //Make an ajax response that finds all the ontology terms with names/definitions/synonyms/accessions like the current value of the ontology input
527 getOntologies: function(db_name
, search_string
) {
528 this.workingMessage(true);
529 // var search_string= document.getElementById('ontology_term_input').value;
530 // var db_name = document.getElementById('cv_select').value;
531 o
.setSelected(db_name
);
532 if(search_string
.length
<4){
533 alert('The search text must be longer than 4 characters');
536 new Ajax
.Request('/chado/ajax_ontology_browser.pl', {
537 parameters
: {action
: 'match', term_name
: search_string
, db_name
: db_name
},
540 alert('An error occurred! The database may currently be unavailable. Please check back later.');
543 onSuccess: function(request
) {
544 var matchNodes
= new Array();
545 var responseText
= request
.responseText
;
547 var responseArray
= responseText
.split('|');
551 o
.setSearchResponseCount(responseArray
.length
);
552 MochiKit
.Logging
.log('Matched '+responseArray
.length
+' terms');
553 for (var i
=0; i
<responseArray
.length
; i
++) {
554 var ontologyObject
= responseArray
[i
].split('--');
555 var searchResults
= responseArray
[i
].split('*');
556 MochiKit
.Logging
.log('getOntologies found term ', ontologyObject
[1] );
557 MochiKit
.Logging
.log('search term ', search_string
);
558 matchNodes
.push(ontologyObject
[0]); ///
559 s
+='<a href=javascript:o.searchTermParentage(\''+ontologyObject
[1]+'\')>'+searchResults
[1]+'</a><br />';
561 // MochiKit.Logging.log('the search results:' , s) ;
562 MochiKit
.Logging
.log('the search string:' , search_string
) ;
564 if (s
=== '') { s
= '(no terms found) '; }
565 o
.setSearchResults('<div class="topicbox">Search term: <b>'+search_string
+'</b></div><div class="topicdescbox">'+s
+'</div>');
566 o
.showSearchResults();
567 o
.setSearchValue(search_string
);
573 this.workingMessage(false);
577 getSearchResults: function() {
578 return this.searchResults
|| '';
581 setSearchResults: function(searchResults
) {
582 //MochiKit.Logging.log('searh results= ',searchResults);
583 this.searchResults
= searchResults
;
586 //showSearchResults, hideSearchResults
588 //hides the result section of the search but keeps the
589 //the un/hide toggle button visible
591 showSearchResults: function() {
592 this.showResults
= true;
593 this.showSearchButton();
594 this.setSearchButtonText();
595 document
.getElementById('search_results').style
.display
='inline';
598 hideSearchResults: function() {
599 this.showResults
= false;
600 this.setSearchButtonText();
601 document
.getElementById('search_results').style
.display
='none';
604 //accessor setSearchResponseCount, getSearchResponseCount
605 //property defines how many items were found in the search
606 //used to display that number in the un/hide toggle button
607 setSearchResponseCount: function(c
) {
608 this.searchCount
= c
;
611 getSearchResponseCount: function() {
612 return this.searchCount
|| 0;
615 toggleSearchResultsVisible: function() {
616 if (this.isSearchResultsVisible() === true) { this.hideSearchResults(); }
618 this.showSearchResults();
622 isSearchResultsVisible: function() {
623 return this.showResults
;
627 hideSearchButton: function() {
628 document
.getElementById("hide_link").style
.display
="none";
631 showSearchButton: function() {
632 document
.getElementById("hide_link").style
.display
="inline";
639 setSearchButtonText: function() {
641 if (this.getSearchResponseCount() === 0) {
642 this.hideSearchButton();
645 this.showSearchButton();
649 if (this.isSearchResultsVisible()) {
650 this.searchButtonText
= 'hide ' + this.getSearchResponseCount() + ' results';
653 this.searchButtonText
= 'show '+this.getSearchResponseCount()+ ' results';
657 if (document
.getElementById('hide_link')) {
658 document
.getElementById('hide_link').value
=this.searchButtonText
;
660 return this.searchButtonText
;
663 getSelected: function() {
664 return this.selected
|| '';
667 setSelected: function(selected
) {
668 this.selected
= selected
;
671 isSelected: function(db_name
) {
672 var selected_db_name
=o
.getSelected();
673 if (selected_db_name
== db_name
) {
675 }else { return '' ; }
679 // the following function is deprecated.
681 fetchMatches: function (searchText
) {
683 //MochiKit.Logging.log('Fetching children for node '+this.getName());
685 new Ajax
.Request('/chado/ajax_ontology_browser.pl', {
686 parameters
: { node
: searchText
, action
: 'match' },
689 alert('An error occurred! The database may currently be unavailable. Please check back later.');
692 onSuccess: function(request
) {
694 //MochiKit.Logging.log('HELLO WORLD!');
695 var matchNodes
= new Array();
696 var responseText
= request
.responseText
;
698 var t
= responseText
.split('#');
700 // t.pop(); //remove last element from the array
702 //MochiKit.Logging.log('Matched '+t.length+' nodes');
703 for (var i
=0; i
<t
.length
; i
++) {
704 var j
= t
[i
].split('*');
706 //MochiKit.Logging.log('matching node: '+ j[0]);
707 matchNodes
.push(j
[0]); ///
716 setLinkToTextField: function(linkToTextField
) {
717 this.linkToTextField
=linkToTextField
;
720 setShowSelectTermButtons: function(showLinks
) {
721 this.showLinks
= showLinks
;
724 getShowSelectTermButtons: function() {
725 return this.showLinks
;
728 copySelectedToTextField: function(node
) {
729 var copyToElement
= document
.getElementById(node
.linkToTextField
);
730 if (copyToElement
!= undefined) {
731 copyToElement
.setValue(node
.getName());
736 // submitFormWithEnter: function(myfield,e) {
738 // if (window.event) keycode = window.event.keyCode;
739 // else if (e) keycode = e.which;
742 // if (keycode == 13)
744 // myfield.form.submit();
755 Node = function(browser
) {
756 //MochiKit.Logging.log('Node constructor...');
757 this.children
= new Array();
758 this.parents
= new Array();
759 this.browser
= browser
;
760 //MochiKit.Logging.log('adding node to the browser...');
762 this.browser
.addNode(this);
763 //MochiKit.Logging.log('done...');
766 //MochiKit.Logging.log('Node constructor: Created node.');
771 setName: function(name
) {
775 getName: function() {
779 setAccession: function(accession
) {
780 this.accession
=accession
;
783 getAccession: function() {
784 return this.accession
;
787 setCVtermID: function(cvtermid
) {
788 this.cvtermid
=cvtermid
;
791 getCVtermID: function() {
792 return this.cvtermid
;
795 setNodeKey: function(key
) {
799 getNodeKey: function() {
803 setBrowser: function(browser
) {
804 this.browser
= browser
;
807 getBrowser: function() {
811 setOpenNode: function(status
) {
812 this.nodeOpen
= status
;
815 getOpenNode: function() {
816 return this.nodeOpen
;
818 setRelType: function(reltype
) {
819 this.reltype
=reltype
;
822 getRelType: function() {
825 openNode: function() {
826 this.setOpenNode(true);
827 if (this.hasChildren() && !this.getChildrenFetched()) {
828 this.fetchChildren(this);
829 this.setChildrenFetched(true);
833 closeNode: function() {
834 this.setOpenNode(false);
845 isHidden: function() {
849 setChildrenFetched: function(fetched
) {
850 this.childrenFetched
=fetched
;
853 getChildrenFetched: function() {
854 return this.childrenFetched
;
857 setParentsFetched: function(fetched
) {
858 this.parentsFetched
= fetched
;
861 getParentsFetched: function() {
862 return this.parentsFetched
;
865 addChild: function (child
) {
866 //MochiKit.Logging.log('Adding child '+child.name + ' to '+ this.name);
869 this.children
.push(c
);
870 child
.parents
.push(p
);
873 getChildren: function () {
874 return this.children
;
877 setParents: function(p
) {
881 getParents: function() {
885 setHasChildren: function(childrenFlag
) {
886 this.childrenFlag
= childrenFlag
;
889 hasChildren: function() {
890 //MochiKit.Logging.log('Number of children for node '+this.getName()+' is ' +this.children.length);
891 //if (this.children.length > 0) {
897 return this.childrenFlag
;
900 addParent: function (parent
) {
902 this.parents
.push(p
);
905 getParents: function () {
906 if (!this.getParentsFetched()) {
907 var p
= this.fetchParents
;
913 renderNode: function (level
) {
914 //MochiKit.Logging.log('Rendering node '+this.getName());
916 // if (this.getOpenNode()) {
921 var hiliteStyle
= 'background-color:white';
922 if (this.isHilited()) {
923 hiliteStyle
= 'background-color:yellow';
926 // add a button to select this node and fill it into a textfield
927 // as provided by linkToTextField
929 // if (this.getBrowser().linkToTextField==true) {
930 if (this.getBrowser().getShowSelectTermButtons()) {
931 link
= '<a href="javascript:o.copySelectedToTextField(this)"><img src="/documents/img/select.png" border="0" /></a>';
934 var relType
=this.getRelType() || '';
935 return relType
+ ' <span style="'+hiliteStyle
+'"><a href="/chado/cvterm.pl?action=view&cvterm_id='+this.getCVtermID()+'">'+this.getAccession() + '</a> ' + this.getName() + ' ' + link
+'</span><br />';
938 setHilite: function(h
) {
943 isHilited: function() {
947 fetchChildren: function () {
949 //MochiKit.Logging.log('Fetching children for node '+this.getName());
951 var parentNode
= this;
952 new Ajax
.Request('/chado/ajax_ontology_browser.pl', {
953 parameters
: { node
: parentNode
.getAccession(), action
: 'children' },
956 alert('An error occurred! The database may currently be unavailable. Please check back later.');
959 onSuccess: function(request
) {
962 //MochiKit.Logging.log('HELLO WORLD!');
964 var responseText
= request
.responseText
;
966 var t
= responseText
.split('#');
968 //MochiKit.Logging.log('Children count ' + t.length + '<br />');
970 for (var i
=0; i
<t
.length
; i
++) {
971 var j
= t
[i
].split('*');
972 //MochiKit.Logging.log(i + '. Child: ID: '+ j[0] + ' Name: ' + j[1] + ' <br />');
974 //MochiKit.Logging.log('Processing '+j[0]);
976 var childNode
= new Node(o
);
978 childNode
.setAccession(j
[0]);
979 childNode
.closeNode();
981 childNode
.setName(j
[1]);
982 childNode
.setCVtermID(j
[2]);
983 childNode
.setRelType(j
[4]);
984 //MochiKit.Logging.log('hasChildren = '+j[2]);
986 childNode
.setHasChildren(true);
989 childNode
.setHasChildren(false);
992 parentNode
.addChild(childNode
);
994 //MochiKit.Logging.log('Child accession: '+childNode.getAccession()+'<br />');
997 //MochiKit.Logging.log('Rendering again...');
998 parentNode
.browser
.render();
1005 fetchParents: function() {
1006 //MochiKit.Logging.log('Fetching children for node '+this.getName());
1008 var childNode
= this;
1010 new Ajax
.Request("/chado/ajax_ontology_browser.pl", {
1011 parameters
: { node
: childNode
.getAccession(), action
: 'parents' },
1012 asynchronous
: false,
1013 onSuccess: function(request
) {
1015 //MochiKit.Logging.log('HELLO WORLD!');
1017 var responseText
= request
.responseText
;
1019 var t
= responseText
.split('#');
1021 //MochiKit.Logging.log('Children count ' + t.length + '<br />');
1023 for (var i
=0; i
<t
.length
; i
++) {
1024 var j
= t
[i
].split('*');
1025 //MochiKit.Logging.log(i + '. Child: ID: '+ j[0] + ' Name: ' + j[1] + ' <br />');
1027 //MochiKit.Logging.log('Processing '+j[0]);
1028 var parent
= new Node(o
);
1030 parent
.setAccession(j
[0]);
1033 parent
.setName(j
[1]);
1034 parent
.setCVtermID(j
[2]);
1035 parent
.setRelType(j
[4]);
1036 //MochiKit.Logging.log('hasChildren = '+j[1]);
1038 parent
.setHasChildren(true);
1041 parent
.setHasChildren(false);
1044 parentList
.push(parent
);
1046 //MochiKit.Logging.log('Child accession: '+childNode.getAccession()+'<br />');
1049 //MochiKit.Logging.log('Rendering again...');
1050 //parentNode.browser.render();