1angular 2 .module('goForm') 3 .component('goForm', { 4 controller: function ($routeParams, $filter, $location, evidenceCodes, sendToView, pubMedData, allGoTerms, locusTag2QID) { 5 var ctrl = this; 6 7 ctrl.$onInit = function () { 8 ctrl.currentTaxid = $routeParams.taxid; 9 ctrl.currentLocusTag = $routeParams.locusTag; 10 locusTag2QID.getLocusTag2QID(ctrl.currentLocusTag, ctrl.currentTaxid).then(function (data) { 11 12 ctrl.geneQID = $filter('parseQID')(data.data.results.bindings[0].gene.value); 13 ctrl.proteinQID = $filter('parseQID')(data.data.results.bindings[0].protein.value); 14 15 var goClassMap = { 16 'mf_button': { 17 name: 'Molecular Function', 18 QID: 'Q14860489' 19 }, 20 'cc_button': { 21 name: 'Cellular Component', 22 QID: 'Q5058355' 23 }, 24 'bp_button': { 25 name: 'Biological Process', 26 QID: 'Q2996394' 27 } 28 }; 29 30 ctrl.goFormModel = { 31 evi: null, 32 pub: null, 33 go: null, 34 proteinQID: ctrl.proteinQID, 35 goClass: goClassMap[ctrl.goclass].QID 36 }; 37 38 39 //controls for navigating form 40 ctrl.pageCount = 0; 41 ctrl.nextClick = function () { 42 ctrl.pageCount += 1; 43 }; 44 ctrl.backClick = function () { 45 ctrl.pageCount -= 1; 46 }; 47 48 //data collection for form query sets 49 evidenceCodes.getevidenceCodes(function (data) { 50 ctrl.evidence = data; 51 }); 52 53 ctrl.selectGoTerm = function ($item, $model, $label) { 54 ctrl.goFormModel.go = $item; 55 ctrl.goValue = '' 56 }; 57 58 ctrl.selectPub = function ($item, $model, $label) { 59 ctrl.goFormModel.pub = $item; 60 ctrl.pubValue = '' 61 }; 62 63 64 ctrl.getGoTermsAll = function (val) { 65 ctrl.goTermLoading = true; 66 return allGoTerms.getGoTermsAll(val, goClassMap[ctrl.goclass].QID).then( 67 function (data) { 68 return data.data.results.bindings.map(function (item) { 69 return item; 70 }); 71 }).finally(function () { 72 ctrl.goTermLoading = false; 73 } 74 ); 75 }; 76 ctrl.getPMID = function (val) { 77 return pubMedData.getPMID(val).then( 78 function (data) { 79 80 var resultData = [data.data.result[val]]; 81 return resultData.map(function (item) { 82 return item; 83 }); 84 } 85 ); 86 }; 87 88 89 //form validation, must be true to allow submission 90 ctrl.validateFields = function () { 91 if (ctrl.goFormModel.evi && ctrl.goFormModel.pub && ctrl.goFormModel.go) { 92 return true 93 } 94 }; 95 96 //send form data to server to edit wikidata 97 ctrl.sendData = function (formData) { 98 ctrl.loading = true; 99 100 var url_suf = $location.path() + '/wd_go_edit'; 101 console.log(url_suf); 102 sendToView.sendToView(url_suf, formData).then(function (data) { 103 if (data.data.write_success === true) { 104 alert("Successfully Annotated! Well Done! The annotation will appear here in a few minutes."); 105 ctrl.resetForm(); 106 } 107 else { 108 alert("Something went wrong. Give it another shot!") 109 } 110 }).finally(function () { 111 ctrl.loading = false;
112 }); 113 114 }; 115 ctrl.resetForm = function () { 116 ctrl.pageCount = 0; 117 ctrl.goFormModel.evi = null; 118 ctrl.goFormModel.pub = null; 119 ctrl.goFormModel.go = null; 120 }; 121 122 123 }); 124 }; 125 126 }, 127 templateUrl: '/static/wiki/js/angular_templates/guided-go-form.html', 128 bindings: { 129 goclass: '<', 130 gene: '<' 131 } 132 133 }); 134 135 136 137
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.