tripal_chado.semweb.inc 58 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670
  1. <?php
  2. /**
  3. * Adds defaults to the chado_semweb table.
  4. */
  5. function tripal_chado_populate_chado_semweb_table() {
  6. // Insert commonly used ontologies into the tables.
  7. $ontologies = array(
  8. // array('Relationship Ontology', 'http://purl.obolibrary.org/obo/ro.obo'),
  9. array('Relationship Ontology (legacy)', '{tripal_chado}/files/legacy_ro.obo'),
  10. array('Sequence Ontology', 'http://purl.obolibrary.org/obo/so.obo'),
  11. array('Gene Ontology', 'http://purl.obolibrary.org/obo/go.obo'),
  12. // array('Cell Ontology', 'https://raw.githubusercontent.com/obophenotype/cell-ontology/master/cl.obo'),
  13. // array('Plant Structure Ontology', 'http://palea.cgrb.oregonstate.edu/viewsvn/Poc/trunk/ontology/OBO_format/po_anatomy.obo?view=co'),
  14. // array('Plant Growth and Development Stages Ontology', 'http://palea.cgrb.oregonstate.edu/viewsvn/Poc/trunk/ontology/OBO_format/po_temporal.obo?view=co')
  15. );
  16. foreach ($ontologies as $o) {
  17. db_query("INSERT INTO {tripal_cv_obo} (name,path) VALUES (:name, :path)", array(':name' => $o[0], ':path' => $o[1]));
  18. }
  19. // Add in all tables and fields into the chado_semweb table.
  20. $chado_tables = chado_get_table_names(TRUE);
  21. foreach ($chado_tables as $chado_table) {
  22. tripal_add_chado_semweb_table($chado_table);
  23. }
  24. // TODO: should this code be in the tripal_chado module? Some of these terms
  25. // are used solely by web services (e.g. rdfs:label) and are not used to
  26. // map chado terms to vocabularies.
  27. // Perhaps we should have an API for working with terms where these can be
  28. // inserted.
  29. // Now set defaults!
  30. tripal_chado_populate_vocab_EDAM();
  31. tripal_chado_populate_vocab_ERO();
  32. tripal_chado_populate_vocab_FOAF();
  33. tripal_chado_populate_vocab_IAO();
  34. tripal_chado_populate_vocab_LOCAL();
  35. tripal_chado_populate_vocab_NCBITAXON();
  36. tripal_chado_populate_vocab_OBI();
  37. tripal_chado_populate_vocab_OGI();
  38. tripal_chado_populate_vocab_RDFS();
  39. tripal_chado_populate_vocab_SBO();
  40. tripal_chado_populate_vocab_SCHEMA();
  41. tripal_chado_populate_vocab_SIO();
  42. tripal_chado_populate_vocab_SO();
  43. tripal_chado_populate_vocab_SWO();
  44. tripal_chado_populate_vocab_TAXRANK();
  45. tripal_chado_populate_vocab_TPUB();
  46. tripal_chado_populate_vocab_UO();
  47. // Add TAXRANK vocabulary for full import.
  48. $obo_id = tripal_insert_obo('Taxonomic Rank', 'http://purl.obolibrary.org/obo/taxrank.obo');
  49. $cv = chado_select_record('cv', array('name'), array('name' => 'taxonomic_rank'));
  50. if (count($cv) == 0 and $obo_id) {
  51. tripal_chado_load_obo_v1_2_id($obo_id);
  52. }
  53. //tripal_submit_obo_job(array('obo_id' => $obo_id));
  54. // Add Tripal Contact vocabulary for full import.
  55. $obo_path = '{tripal_chado}/files/tcontact.obo';
  56. $obo_id = tripal_insert_obo('Tripal Contacts', $obo_path);
  57. $cv = chado_select_record('cv', array('name'), array('name' => 'tripal_contact'));
  58. if (count($cv) == 0 and $obo) {
  59. tripal_chado_load_obo_v1_2_id($obo_id);
  60. }
  61. //tripal_submit_obo_job(array('obo_id' => $obo_id));
  62. // Add Tripal Publication vocabulary for full import.
  63. $obo_path = '{tripal_chado}/files/tpub.obo';
  64. $obo_id = tripal_insert_obo('Tripal Publication', $obo_path);
  65. $cv = chado_select_record('cv', array('name'), array('name' => 'tripal_pub'));
  66. if (count($cv) == 0 and $obo) {
  67. tripal_chado_load_obo_v1_2_id($obo_id);
  68. }
  69. // Load the sequence ontology if it isn't already loaded
  70. $cv = chado_select_record('cv', array('name'), array('name' => 'sequence'));
  71. $obo = tripal_get_obo(array('obo_name' => 'Sequence Ontology'));
  72. if (count($cv) == 0 and $obo) {
  73. print "Installing the Sequence Ontology... This may take a while...\n";
  74. tripal_chado_load_obo_v1_2_id($obo->obo_id);
  75. }
  76. // Add the Chado ontology CV.
  77. //$obo_path = '{tripal_chado}/files/cv_property.obo';
  78. //$obo_id = tripal_insert_obo('Chado CV Properties', $obo_path);
  79. //tripal_chado_load_obo_v1_2_id($obo_id);
  80. //tripal_submit_obo_job(array('obo_id' => $obo_id));
  81. // $obo_path = '{tripal_feature}/files/feature_property.obo';
  82. // $obo_id = tripal_insert_obo('Chado Feature Properties', $obo_path);
  83. // tripal_chado_load_obo_v1_2_id($obo_id);
  84. //// tripal_submit_obo_job(array('obo_id' => $obo_id));
  85. }
  86. /**
  87. * Adds the friend of a friend database and terms.
  88. */
  89. function tripal_chado_populate_vocab_FOAF() {
  90. tripal_insert_cv('foaf','Friend of a Friend');
  91. tripal_insert_db(array(
  92. 'name' => 'foaf',
  93. 'description' => 'Friend of a Friend',
  94. 'url' => 'http://www.foaf-project.org/',
  95. 'urlprefix' => 'http://xmlns.com/foaf/spec/#',
  96. ));
  97. tripal_insert_cv('foaf','Friend of a Friend. A dictionary of people-related terms that can be used in structured data).');
  98. }
  99. /**
  100. * Adds the RDFS database and terms.
  101. */
  102. function tripal_chado_populate_vocab_RDFS() {
  103. tripal_insert_db(array(
  104. 'name' => 'rdfs',
  105. 'description' => 'Resource Description Framework Schema',
  106. 'url' => 'https://www.w3.org/TR/rdf-schema/',
  107. 'urlprefix' => 'https://www.w3.org/TR/rdf-schema/#ch_',
  108. ));
  109. tripal_insert_cv('rdfs','Resource Description Framework Schema');
  110. $name = tripal_insert_cvterm(array(
  111. 'id' => 'rdfs:type',
  112. 'name' => 'type',
  113. 'cv_name' => 'rdfs',
  114. 'definition' => 'The type of resource.',
  115. ));
  116. $name = tripal_insert_cvterm(array(
  117. 'id' => 'rdfs:label',
  118. 'name' => 'label',
  119. 'cv_name' => 'rdfs',
  120. 'definition' => 'A human-readable version of a resource\'s name.',
  121. ));
  122. }
  123. /**
  124. * Adds the Schema.org database and terms.
  125. */
  126. function tripal_chado_populate_vocab_SCHEMA() {
  127. tripal_insert_db(array(
  128. 'name' => 'schema',
  129. 'description' => 'Schema.org.',
  130. 'url' => 'https://schema.org/',
  131. 'urlprefix' => 'https://schema.org/{accession}',
  132. ));
  133. tripal_insert_cv('schema','Schema.org. Schema.org is sponsored by Google, Microsoft, Yahoo and Yandex. The vocabularies are developed by an open community process.');
  134. $term = tripal_insert_cvterm(array(
  135. 'id' => 'schema:name',
  136. 'name' => 'name',
  137. 'cv_name' => 'schema',
  138. 'definition' => 'The name of the item.',
  139. ));
  140. tripal_associate_chado_semweb_term(NULL, 'name', $term);
  141. $term = tripal_insert_cvterm(array(
  142. 'id' => 'schema:alternateName',
  143. 'name' => 'alternateName',
  144. 'cv_name' => 'schema',
  145. 'definition' => 'An alias for the item.',
  146. ));
  147. $term = tripal_insert_cvterm(array(
  148. 'id' => 'schema:comment',
  149. 'name' => 'comment',
  150. 'cv_name' => 'schema',
  151. 'definition' => 'Comments, typically from users.',
  152. ));
  153. tripal_associate_chado_semweb_term(NULL, 'comment', $term);
  154. $term = tripal_insert_cvterm(array(
  155. 'id' => 'schema:description',
  156. 'name' => 'description',
  157. 'cv_name' => 'schema',
  158. 'definition' => 'A description of the item.',
  159. ));
  160. tripal_associate_chado_semweb_term(NULL, 'description', $term);
  161. tripal_associate_chado_semweb_term('organism', 'comment', $term);
  162. $term = tripal_insert_cvterm(array(
  163. 'id' => 'schema:publication',
  164. 'name' => 'publication',
  165. 'cv_name' => 'schema',
  166. 'definition' => 'A publication event associated with the item.',
  167. ));
  168. tripal_associate_chado_semweb_term(NULL, 'pub_id', $term);
  169. $term = tripal_insert_cvterm(array(
  170. 'id' => 'schema:url',
  171. 'name' => 'url',
  172. 'cv_name' => 'schema',
  173. 'definition' => 'URL of the item.',
  174. ));
  175. tripal_associate_chado_semweb_term('db', 'URL', $term);
  176. }
  177. /**
  178. * Adds the SemanticScience database and terms.
  179. */
  180. function tripal_chado_populate_vocab_SIO() {
  181. tripal_insert_db(array(
  182. 'name' => 'SIO',
  183. 'description' => 'Semanticscience Integrated Ontology.',
  184. 'url' => 'http://sio.semanticscience.org/',
  185. 'urlprefix' => 'http://semanticscience.org/resource/{db}_{accession}',
  186. ));
  187. tripal_insert_cv('SIO',' The Semanticscience Integrated Ontology (SIO) provides a simple, integrated ontology of types and relations for rich description of objects, processes and their attributes.');
  188. $term = tripal_insert_cvterm(array(
  189. 'id' => 'SIO:000493',
  190. 'name' => 'clause',
  191. 'cv_name' => 'SIO',
  192. 'definition' => 'A clause consists of a subject and a predicate.',
  193. ));
  194. }
  195. /**
  196. * Adds the EDAM database and terms.
  197. */
  198. function tripal_chado_populate_vocab_EDAM() {
  199. tripal_insert_db(array(
  200. 'name' => 'data',
  201. 'description' => 'Bioinformatics operations, data types, formats, identifiers and topics.',
  202. 'url' => 'http://edamontology.org/page',
  203. 'urlprefix' => 'http://edamontology.org/{db}_{accession}',
  204. ));
  205. tripal_insert_db(array(
  206. 'name' => 'EDAM',
  207. 'description' => 'Bioinformatics operations, data types, formats, identifiers and topics.',
  208. 'url' => 'http://edamontology.org/page',
  209. 'urlprefix' => 'http://edamontology.org/{db}_{accession}',
  210. ));
  211. tripal_insert_cv('data','Bioinformatics operations, data types, formats, identifiers and topics.');
  212. $term = tripal_insert_cvterm(array(
  213. 'id' => 'data:1249',
  214. 'name' => 'Sequence length',
  215. 'cv_name' => 'EDAM',
  216. 'definition' => 'The size (length) of a sequence, subsequence or region in a sequence, or range(s) of lengths.',
  217. ));
  218. tripal_associate_chado_semweb_term('feature', 'seqlen', $term);
  219. $term = tripal_insert_cvterm(array(
  220. 'id' => 'data:2190',
  221. 'name' => 'Sequence checksum',
  222. 'cv_name' => 'EDAM',
  223. 'definition' => 'A fixed-size datum calculated (by using a hash function) for a molecular sequence, typically for purposes of error detection or indexing.',
  224. ));
  225. tripal_associate_chado_semweb_term('feature', 'md5checksum', $term);
  226. $term = tripal_insert_cvterm(array(
  227. 'id' => 'data:2091',
  228. 'name' => 'Accession',
  229. 'cv_name' => 'EDAM',
  230. 'definition' => 'A persistent (stable) and unique identifier, typically identifying an object (entry) from a database.',
  231. ));
  232. tripal_associate_chado_semweb_term(NULL, 'dbxref_id', $term);
  233. $term = tripal_insert_cvterm(array(
  234. 'id' => 'data:2044',
  235. 'name' => 'Sequence',
  236. 'cv_name' => 'EDAM',
  237. 'definition' => 'One or more molecular sequences, possibly with associated annotation..',
  238. ));
  239. tripal_associate_chado_semweb_term('feature', 'residues', $term);
  240. $term = tripal_insert_cvterm(array(
  241. 'id' => 'data:0842',
  242. 'name' => 'Identifier',
  243. 'cv_name' => 'EDAM',
  244. 'definition' => 'A text token, number or something else which identifies an entity, but which may not be persistent (stable) or unique (the same identifier may identify multiple things).',
  245. ));
  246. tripal_associate_chado_semweb_term(NULL, 'uniquename', $term);
  247. $term = tripal_insert_cvterm(array(
  248. 'id' => 'data:2968',
  249. 'name' => 'Image',
  250. 'cv_name' => 'EDAM',
  251. 'definition' => 'Biological or biomedical data has been rendered into an image, typically for display on screen.',
  252. ));
  253. tripal_associate_chado_semweb_term(NULL, 'eimage_id', $term);
  254. $term = tripal_insert_cvterm(array(
  255. 'id' => 'data:1274',
  256. 'name' => 'Map',
  257. 'cv_name' => 'EDAM',
  258. 'definition' => 'A map of (typically one) DNA sequence annotated with positional or non-positional features.',
  259. ));
  260. tripal_associate_chado_semweb_term(NULL, 'eimage_id', $term);
  261. $term = tripal_insert_cvterm(array(
  262. 'id' => 'data:1278',
  263. 'name' => 'Genetic map',
  264. 'cv_name' => 'EDAM',
  265. 'definition' => 'A map showing the relative positions of genetic markers in a nucleic acid sequence, based on estimation of non-physical distance such as recombination frequencies.',
  266. ));
  267. tripal_associate_chado_semweb_term('featuremap', 'featuremap_id', $term);
  268. $term = tripal_insert_cvterm(array(
  269. 'id' => 'data:1280',
  270. 'name' => 'Physical map',
  271. 'cv_name' => 'EDAM',
  272. 'definition' => 'A map of DNA (linear or circular) annotated with physical features or landmarks such as restriction sites, cloned DNA fragments, genes or genetic markers, along with the physical distances between them. Distance in a physical map is measured in base pairs. A physical map might be ordered relative to a reference map (typically a genetic map) in the process of genome sequencing.',
  273. ));
  274. tripal_associate_chado_semweb_term('featuremap', 'featuremap_id', $term);
  275. $term = tripal_insert_cvterm(array(
  276. 'id' => 'data:2012',
  277. 'name' => 'Sequence coordinates',
  278. 'cv_name' => 'EDAM',
  279. 'definition' => 'A position in a map (for example a genetic map), either a single position (point) or a region / interval.',
  280. ));
  281. $term = tripal_insert_cvterm(array(
  282. 'id' => 'data:1056',
  283. 'name' => 'Databse name',
  284. 'cv_name' => 'EDAM',
  285. 'definition' => 'The name of a biological or bioinformatics database.',
  286. ));
  287. tripal_associate_chado_semweb_term('db', 'name', $term);
  288. }
  289. /**
  290. * Adds the Eagle-i Resource Ontology database and terms.
  291. */
  292. function tripal_chado_populate_vocab_ERO() {
  293. tripal_insert_db(array(
  294. 'name' => 'ERO',
  295. 'description' => 'The Eagle-I Research Resource Ontology',
  296. 'url' => 'http://purl.bioontology.org/ontology/ERO',
  297. 'urlprefix' => 'http://purl.bioontology.org/ontology/ERO/{db}:{accession}',
  298. ));
  299. tripal_insert_cv('ero','The Eagle-I Research Resource Ontology models research resources such instruments. protocols, reagents, animal models and biospecimens. It has been developed in the context of the eagle-i project (http://eagle-i.net/).');
  300. $term = tripal_insert_cvterm(array(
  301. 'id' => 'ERO:0001716',
  302. 'name' => 'database',
  303. 'cv_name' => 'ero',
  304. 'definition' => 'A database is an organized collection of data, today typically in digital form.',
  305. ));
  306. }
  307. /**
  308. * Adds the Information Artifact Ontology database and terms.
  309. */
  310. function tripal_chado_populate_vocab_OBI() {
  311. tripal_insert_db(array(
  312. 'name' => 'OBI',
  313. 'description' => 'The Ontology for Biomedical Investigation.',
  314. 'url' => 'http://obi-ontology.org/page/Main_Page',
  315. 'urlprefix' => 'http://purl.obolibrary.org/obo/{db}_{accession}',
  316. ));
  317. tripal_insert_cv('obi','Ontology for Biomedical Investigation. The Ontology for Biomedical Investigations (OBI) is build in a collaborative, international effort and will serve as a resource for annotating biomedical investigations, including the study design, protocols and instrumentation used, the data generated and the types of analysis performed on the data. This ontology arose from the Functional Genomics Investigation Ontology (FuGO) and will contain both terms that are common to all biomedical investigations, including functional genomics investigations and those that are more domain specific.');
  318. $term = tripal_insert_cvterm(array(
  319. 'id' => 'OBI:0100026',
  320. 'name' => 'organism',
  321. 'cv_name' => 'obi',
  322. 'definition' => 'A material entity that is an individual living system, such as animal, plant, bacteria or virus, that is capable of replicating or reproducing, growth and maintenance in the right environment. An organism may be unicellular or made up, like humans, of many billions of cells divided into specialized tissues and organs.',
  323. ));
  324. tripal_associate_chado_semweb_term(NULL, 'organism_id', $term);
  325. }
  326. /**
  327. * Adds the Ontology for genetic interval database and terms.
  328. */
  329. function tripal_chado_populate_vocab_OGI() {
  330. tripal_insert_db(array(
  331. 'name' => 'OGI',
  332. 'description' => 'Ontology for genetic interval.',
  333. 'url' => 'http://purl.bioontology.org/ontology/OGI',
  334. 'urlprefix' => 'http://purl.obolibrary.org/obo/{db}_{accession}',
  335. ));
  336. tripal_insert_cv('obi','Ontology for Biomedical Investigation. The Ontology for Biomedical Investigations (OBI) is build in a collaborative, international effort and will serve as a resource for annotating biomedical investigations, including the study design, protocols and instrumentation used, the data generated and the types of analysis performed on the data. This ontology arose from the Functional Genomics Investigation Ontology (FuGO) and will contain both terms that are common to all biomedical investigations, including functional genomics investigations and those that are more domain specific.');
  337. $term = tripal_insert_cvterm(array(
  338. 'id' => 'OGI:0000021',
  339. 'name' => 'location on map',
  340. 'cv_name' => 'ogi',
  341. 'definition' => '',
  342. ));
  343. tripal_associate_chado_semweb_term(NULL, 'organism_id', $term);
  344. }
  345. /**
  346. * Adds the Information Artifact Ontology database and terms.
  347. */
  348. function tripal_chado_populate_vocab_IAO() {
  349. tripal_insert_db(array(
  350. 'name' => 'IAO',
  351. 'description' => 'The Information Artifact Ontology (IAO).',
  352. 'url' => 'https://github.com/information-artifact-ontology/IAO/',
  353. 'urlprefix' => 'http://purl.obolibrary.org/obo/IAO_',
  354. ));
  355. tripal_insert_cv('IAO','Information Artifact Ontology is a new ' .
  356. 'ontology of information entities, originally driven by work by the ' .
  357. 'OBI digital entity and realizable information entity branch.');
  358. $term = tripal_insert_cvterm(array(
  359. 'id' => 'IAO:0000115',
  360. 'name' => 'definition',
  361. 'cv_name' => 'iao',
  362. 'definition' => 'The official OBI definition, explaining the meaning of ' .
  363. 'a class or property. Shall be Aristotelian, formalized and normalized. ' .
  364. 'Can be augmented with colloquial definitions.',
  365. ));
  366. tripal_associate_chado_semweb_term(NULL, 'definition', $term);
  367. $term = tripal_insert_cvterm(array(
  368. 'id' => 'IAO:0000129',
  369. 'name' => 'version number',
  370. 'cv_name' => 'IAO',
  371. 'definition' => 'A version number is an ' .
  372. 'information content entity which is a sequence of characters ' .
  373. 'borne by part of each of a class of manufactured products or its ' .
  374. 'packaging and indicates its order within a set of other products ' .
  375. 'having the same name.',
  376. ));
  377. tripal_associate_chado_semweb_term('analysis', 'programversion', $term);
  378. $term = tripal_insert_cvterm(array(
  379. 'id' => 'IAO:0000064',
  380. 'name' => 'algorithm',
  381. 'cv_name' => 'IAO',
  382. 'definition' => 'An algorithm is a set of instructions for performing a paticular calculation.',
  383. ));
  384. tripal_associate_chado_semweb_term('analysis', 'algorithm', $term);
  385. }
  386. /**
  387. * Adds terms to the 'local' database.
  388. *
  389. * These are terms where an appropriate match could not be found in any other
  390. * ontology.
  391. */
  392. function tripal_chado_populate_vocab_LOCAL() {
  393. tripal_insert_db(array(
  394. 'name' => 'local',
  395. 'description' => 'Terms created for this site.',
  396. 'url' => '/cv/lookup',
  397. 'urlprefix' => '/cv/lookup/{db}/{accession}',
  398. ));
  399. // ----------------
  400. // Add the various CV's that fall under the local DB.
  401. // ----------------
  402. tripal_insert_cv(
  403. 'local',
  404. 'Locally created terms.'
  405. );
  406. tripal_insert_cv(
  407. 'organism_property',
  408. 'A local vocabulary that contains locally defined properties for organisms'
  409. );
  410. tripal_insert_cv(
  411. 'tripal_phylogeny',
  412. 'Terms used by the Tripal phylotree module for phylogenetic and taxonomic trees.'
  413. );
  414. tripal_insert_cv(
  415. 'synonym_type',
  416. 'A local vocabulary that contains synonym types (e.g. exact, broad, narrow, related).'
  417. );
  418. // Add cv for relationship types
  419. tripal_insert_cv(
  420. 'feature_relationship',
  421. 'A local vocabulary that contains types of relationships between features.'
  422. );
  423. // The feature_property CV may already exists. It comes with Chado, but
  424. // we need to add it just in case it doesn't get added before the feature
  425. // module is installed. But as of Tripal v3.0 the Chado version of this
  426. // vocabulary is no longer loaded by default.
  427. tripal_insert_cv(
  428. 'feature_property',
  429. 'A local vocabulary that contains properties for genomic features'
  430. );
  431. // Add the cv for contact properties. This is a default vocabulary in the event
  432. // that a user does not want to use the tripal_contact vocabulary
  433. tripal_insert_cv(
  434. 'contact_property',
  435. 'A local vocabulary that contains properties for contacts. This can be used if the tripal_contact vocabulary (which is default for contacts in Tripal) is not desired.'
  436. );
  437. // add the cv for the contact type. This is a default vocabulary in the event
  438. // that a user does not want to use the tripal_contact vocabulary
  439. tripal_insert_cv(
  440. 'contact_type',
  441. 'A local vocabulary that contains types of contacts. This can be used if the tripal_contact vocabulary (which is default for contacts in Tripal) is not desired.'
  442. );
  443. // Add the cv for the tripal_contact vocabulary which is loaded via the OBO
  444. tripal_insert_cv(
  445. 'tripal_contact',
  446. 'A local vocabulary that contains a heirarchical set of terms for describing a contact. It is intended to be used as the default vocabularies in Tripal for contact types and contact properties.'
  447. );
  448. // add the cv for contact relationships
  449. tripal_insert_cv(
  450. 'contact_relationship',
  451. 'A local vocabulary that contains types of relationships between contacts.'
  452. );
  453. tripal_insert_cv(
  454. 'featuremap_units',
  455. 'A local vocabulary that contains map unit types for the unittype_id column of the featuremap table.'
  456. );
  457. tripal_insert_cv(
  458. 'featurepos_property',
  459. 'A local vocabulary that contains terms map properties.'
  460. );
  461. tripal_insert_cv(
  462. 'featuremap_property',
  463. 'A local vocabulary that contains positional types for the feature positions'
  464. );
  465. tripal_insert_cv(
  466. 'library_property',
  467. 'A local vocabulary that contains properties for libraries.'
  468. );
  469. tripal_insert_cv(
  470. 'library_type',
  471. 'A local vocabulary that contains terms for types of libraries (e.g. BAC, cDNA, FOSMID, etc).'
  472. );
  473. // Add the cv for project properties
  474. tripal_insert_cv(
  475. 'project_property',
  476. 'A local vocabulary that contains properties for projects'
  477. );
  478. // Add cv for relationship types
  479. tripal_insert_cv(
  480. 'project_relationship',
  481. 'A local vocabulary that contains Types of relationships between projects.'
  482. );
  483. // Add the cv for pub properties
  484. tripal_insert_cv(
  485. 'tripal_pub',
  486. 'A local vocabulary that contains a heirarchical set of terms for describing a publication. It is intended to be used as the default vocabularies in Tripal for publication types and contact properties.'
  487. );
  488. // Add the cv for pub types
  489. tripal_insert_cv(
  490. 'pub_type',
  491. 'A local vocabulary that contains types of publications. This can be used if the tripal_pub vocabulary (which is default for publications in Tripal) is not desired.'
  492. );
  493. // Add the cv for pub properties
  494. tripal_insert_cv(
  495. 'pub_property',
  496. 'A local vocabulary that contains properties for publications. This can be used if the tripal_pub vocabulary (which is default for publications in Tripal) is not desired.'
  497. );
  498. // Add cv for relationship types
  499. tripal_insert_cv(
  500. 'pub_relationship',
  501. 'A local vocabulary that contains types of relationships between publications.'
  502. );
  503. // Add cv for relationship types
  504. tripal_insert_cv(
  505. 'stock_relationship',
  506. 'A local vocabulary that contains types of relationships between stocks.'
  507. );
  508. tripal_insert_cv(
  509. 'stock_property',
  510. 'A local vocabulary that contains properties for stocks.'
  511. );
  512. tripal_insert_cv(
  513. 'stock_type',
  514. 'A local vocabulary that contains a list of types for stocks.'
  515. );
  516. tripal_insert_cv(
  517. 'tripal_analysis',
  518. 'A local vocabulary that contains terms used for analyses.'
  519. );
  520. //-----------------------------
  521. // Misc Terms
  522. //-----------------------------
  523. $term = tripal_insert_cvterm(array(
  524. 'id' => 'local:property',
  525. 'name' => 'property',
  526. 'cv_name' => 'local',
  527. 'definition' => 'A generic term indicating that represents an attribute, quality or characteristic of something.',
  528. ));
  529. //-----------------------------
  530. // Terms for base table fields
  531. //-----------------------------
  532. $term = tripal_insert_cvterm(array(
  533. 'id' => 'local:timelastmodified',
  534. 'name' => 'time_last_modified',
  535. 'cv_name' => 'local',
  536. 'definition' => 'The time at which the record was last modified.',
  537. ));
  538. tripal_associate_chado_semweb_term(NULL, 'timelastmodified', $term);
  539. $term = tripal_insert_cvterm(array(
  540. 'id' => 'local:timeaccessioned',
  541. 'name' => 'time_accessioned',
  542. 'cv_name' => 'local',
  543. 'definition' => 'The time at which the record was first added.',
  544. ));
  545. tripal_associate_chado_semweb_term(NULL, 'timeaccessioned', $term);
  546. $term = tripal_insert_cvterm(array(
  547. 'id' => 'local:timeexecuted',
  548. 'name' => 'time_executed',
  549. 'cv_name' => 'local',
  550. 'definition' => 'The time when the task was executed.',
  551. ));
  552. tripal_associate_chado_semweb_term(NULL, 'timeexecuted', $term);
  553. $term = tripal_insert_cvterm(array(
  554. 'id' => 'local:infraspecific_type',
  555. 'name' => 'infraspecific_type',
  556. 'definition' => 'The connector type (e.g. subspecies, varietas, forma, etc.) for the infraspecific name',
  557. 'cv_name' => 'local',
  558. ));
  559. tripal_associate_chado_semweb_term('organism', 'type_id', $term);
  560. $term = tripal_insert_cvterm(array(
  561. 'id' => 'local:abbreviation',
  562. 'name' => 'abbreviation',
  563. 'cv_name' => 'local',
  564. 'definition' => 'A shortened name (or abbreviation) for the item.'
  565. ));
  566. tripal_associate_chado_semweb_term('organism', 'abbreviation', $term);
  567. $term = tripal_insert_cvterm(array(
  568. 'id' => 'local:expression',
  569. 'name' => 'expression',
  570. 'definition' => 'Curated expression data',
  571. 'cv_name' => 'local',
  572. ));
  573. $term = tripal_insert_cvterm(array(
  574. 'id' => 'local:is_analysis',
  575. 'name' => 'is_analysis',
  576. 'definition' => 'Indicates if this feature was predicted computationally using another feature.',
  577. 'cv_name' => 'local',
  578. ));
  579. tripal_associate_chado_semweb_term('feature', 'is_analysis', $term);
  580. $term = tripal_insert_cvterm(array(
  581. 'id' => 'local:is_obsolete',
  582. 'name' => 'is_obsolete',
  583. 'definition' => 'Indicates if this record is obsolete.',
  584. 'cv_name' => 'local',
  585. ));
  586. tripal_associate_chado_semweb_term(NULL, 'is_obsolete', $term);
  587. //-----------------------------
  588. // Relationship Terms
  589. //-----------------------------
  590. $term = tripal_insert_cvterm(array(
  591. 'id' => 'local:relationship_subject',
  592. 'name' => 'clause subject',
  593. 'definition' => 'The subject of a relationship clause.',
  594. 'cv_name' => 'local',
  595. ));
  596. tripal_associate_chado_semweb_term(NULL, 'subject_id', $term);
  597. tripal_associate_chado_semweb_term(NULL, 'subject_reagent_id', $term);
  598. tripal_associate_chado_semweb_term(NULL, 'subject_project_id', $term);
  599. $term = tripal_insert_cvterm(array(
  600. 'id' => 'local:relationship_object',
  601. 'name' => 'clause predicate',
  602. 'definition' => 'The object of a relationship clause.',
  603. 'cv_name' => 'local',
  604. ));
  605. tripal_associate_chado_semweb_term(NULL, 'object_id', $term);
  606. tripal_associate_chado_semweb_term(NULL, 'object_reagent_id', $term);
  607. tripal_associate_chado_semweb_term(NULL, 'object_project_id', $term);
  608. $term = tripal_insert_cvterm(array(
  609. 'id' => 'local:relationship_type',
  610. 'name' => 'relationship type',
  611. 'definition' => 'The relationship type.',
  612. 'cv_name' => 'local',
  613. ));
  614. tripal_associate_chado_semweb_term('acquisition_relationship', 'type_id', $term);
  615. tripal_associate_chado_semweb_term('biomaterial_relationship', 'type_id', $term);
  616. tripal_associate_chado_semweb_term('cell_line_relationship', 'type_id', $term);
  617. tripal_associate_chado_semweb_term('contact_relationship', 'type_id', $term);
  618. tripal_associate_chado_semweb_term('element_relationship', 'type_id', $term);
  619. tripal_associate_chado_semweb_term('elementresult_relationship', 'type_id', $term);
  620. tripal_associate_chado_semweb_term('feature_relationship', 'type_id', $term);
  621. tripal_associate_chado_semweb_term('nd_reagent_relationship', 'type_id', $term);
  622. tripal_associate_chado_semweb_term('phylonode_relationship', 'type_id', $term);
  623. tripal_associate_chado_semweb_term('project_relationship', 'type_id', $term);
  624. tripal_associate_chado_semweb_term('pub_relationship', 'type_id', $term);
  625. tripal_associate_chado_semweb_term('quantification_relationship', 'type_id', $term);
  626. tripal_associate_chado_semweb_term('stock_relationship', 'type_id', $term);
  627. //-----------------------------
  628. // NCBI Organism Property Terms
  629. //-----------------------------
  630. // TODO: these probably have real terms we can use.
  631. $term = tripal_insert_cvterm(array(
  632. 'id' => 'locak:rank',
  633. 'name' => 'rank',
  634. 'definition' => 'A taxonmic rank',
  635. 'cv_name' => 'local',
  636. ));
  637. $terms = array(
  638. 'lineage',
  639. 'genetic_code',
  640. 'genetic_code_name',
  641. 'mitochondrial_genetic_code',
  642. 'mitochondrial_genetic_code_name',
  643. 'division',
  644. 'genbank_common_name',
  645. 'synonym',
  646. 'other_name',
  647. 'equivalent_name',
  648. 'anamorph'
  649. );
  650. $options = array('update_existing' => TRUE);
  651. foreach ($terms as $term) {
  652. $value = array(
  653. 'name' => $term,
  654. 'definition' => '',
  655. 'cv_name' => 'organism_property',
  656. 'is_relationship' => 0,
  657. 'db_name' => 'local'
  658. );
  659. tripal_insert_cvterm($value, $options);
  660. }
  661. //---------------------
  662. // Phylogeny Tree Terms
  663. //---------------------
  664. // Add the terms used to identify nodes in the tree.
  665. tripal_insert_cvterm(
  666. array(
  667. 'name' => 'phylo_leaf',
  668. 'definition' => 'A leaf node in a phylogenetic tree.',
  669. 'cv_name' => 'tripal_phylogeny',
  670. 'is_relationship' => 0,
  671. 'db_name' => 'local'
  672. ),
  673. array('update_existing' => TRUE)
  674. );
  675. // Add the terms used to identify nodes in the tree.
  676. tripal_insert_cvterm(array(
  677. 'name' => 'phylo_root',
  678. 'definition' => 'The root node of a phylogenetic tree.',
  679. 'cv_name' => 'tripal_phylogeny',
  680. 'is_relationship' => 0,
  681. 'db_name' => 'local'
  682. ));
  683. // Add the terms used to identify nodes in the tree.
  684. tripal_insert_cvterm(array(
  685. 'name' => 'phylo_interior',
  686. 'definition' => 'An interior node in a phylogenetic tree.',
  687. 'cv_name' => 'tripal_phylogeny',
  688. 'is_relationship' => 0,
  689. 'db_name' => 'local'
  690. ));
  691. // Add the terms used to identify nodes in the tree.
  692. tripal_insert_cvterm(array(
  693. 'name' => 'taxonomy',
  694. 'definition' => 'A term used to indicate if a phylotree is a taxonomic tree',
  695. 'cv_name' => 'tripal_phylogeny',
  696. 'is_relationship' => 0,
  697. 'db_name' => 'local'
  698. ));
  699. //---------------------
  700. // Synonym Types Terms
  701. //---------------------
  702. tripal_insert_cvterm(array(
  703. 'name' => 'exact',
  704. 'definition' => 'An exact equivalent; interchangeable with the term name.',
  705. 'cv_name' => 'synonym_type',
  706. 'db_name' => 'local',
  707. ), array('force_db_change' => TRUE));
  708. tripal_insert_cvterm(array(
  709. 'name' => 'broad',
  710. 'definition' => 'The synonym is broader than the name.',
  711. 'cv_name' => 'synonym_type',
  712. 'db_name' => 'local',
  713. ), array('force_db_change' => TRUE));
  714. tripal_insert_cvterm(array(
  715. 'name' => 'narrow',
  716. 'definition' => 'The synonym is narrower or more precise than the name.',
  717. 'cv_name' => 'synonym_type',
  718. 'db_name' => 'local',
  719. ), array('force_db_change' => TRUE));
  720. tripal_insert_cvterm(array(
  721. 'name' => 'related',
  722. 'definition' => 'The synonym is related in some way.',
  723. 'cv_name' => 'synonym_type',
  724. 'db_name' => 'local'
  725. ), array('force_db_change' => TRUE));
  726. //--------------
  727. // Project Terms
  728. //--------------
  729. // Insert cvterm 'Project Description' into cvterm table of chado
  730. // database. This CV term is used to keep track of the project
  731. // description in the projectprop table.
  732. tripal_insert_cvterm(array(
  733. 'name' => 'Project Description',
  734. 'definition' => 'Description of a project',
  735. 'cv_name' => 'project_property',
  736. 'db_name' => 'local'
  737. ), array('force_db_change' => TRUE));
  738. //--------------
  739. // Natural Diversity Terms
  740. //--------------
  741. // add cvterms for the nd_experiment_types
  742. tripal_insert_cvterm(array(
  743. 'name' => 'Genotyping',
  744. 'definition' => 'An experiment where genotypes of individuals are identified.',
  745. 'cv_name' => 'nd_experiment_types',
  746. 'db_name' => 'local'
  747. ), array('force_db_change' => TRUE));
  748. tripal_insert_cvterm(array(
  749. 'name' => 'Phenotyping',
  750. 'definition' => 'An experiment where phenotypes of individuals are identified.',
  751. 'cv_name' => 'nd_experiment_types',
  752. 'db_name' => 'local'
  753. ), array('force_db_change' => TRUE));
  754. tripal_insert_cvterm(array(
  755. 'name' => 'Location',
  756. 'definition' => 'The name of the location.',
  757. 'cv_name' => 'nd_geolocation_property',
  758. 'db_name' => 'local'
  759. ), array('force_db_change' => TRUE));
  760. //--------------
  761. // Library Terms
  762. //--------------
  763. // Insert cvterm 'library_description' into cvterm table of chado
  764. // database. This CV term is used to keep track of the library
  765. // description in the libraryprop table.
  766. tripal_insert_cvterm(array(
  767. 'id' => 'local:library_description',
  768. 'name' => 'Library Description',
  769. 'definition' => 'Description of a library',
  770. 'cv_name' => 'library_property',
  771. 'db_name' => 'local'
  772. ), array('force_db_change' => TRUE));
  773. // add cvterms for the map unit types
  774. tripal_insert_cvterm(array(
  775. 'id' => 'local:cdna_library',
  776. 'name' => 'cdna_library',
  777. 'definition' => 'cDNA library',
  778. 'cv_name' => 'library_type',
  779. 'db_name' => 'local'
  780. ), array('force_db_change' => TRUE));
  781. tripal_insert_cvterm(array(
  782. 'id' => 'local:bac_library',
  783. 'name' => 'bac_library',
  784. 'definition' => 'Bacterial Artifical Chromsome (BAC) library',
  785. 'cv_name' => 'library_type',
  786. 'db_name' => 'local'
  787. ), array('force_db_change' => TRUE));
  788. tripal_insert_cvterm(array(
  789. 'id' => 'local:fosmid_library',
  790. 'name' => 'fosmid_library',
  791. 'definition' => 'Fosmid library',
  792. 'cv_name' => 'library_type',
  793. 'db_name' => 'local'
  794. ), array('force_db_change' => TRUE));
  795. tripal_insert_cvterm(array(
  796. 'id' => 'local:cosmid_library',
  797. 'name' => 'cosmid_library',
  798. 'definition' => 'Cosmid library',
  799. 'cv_name' => 'library_type',
  800. 'db_name' => 'local'
  801. ), array('force_db_change' => TRUE));
  802. tripal_insert_cvterm(array(
  803. 'id' => 'local:yac_library',
  804. 'name' => 'yac_library',
  805. 'definition' => 'Yeast Artificial Chromosome (YAC) library',
  806. 'cv_name' => 'library_type',
  807. 'db_name' => 'local'
  808. ), array('force_db_change' => TRUE));
  809. tripal_insert_cvterm(array(
  810. 'id' => 'local:genomic_library',
  811. 'name' => 'genomic_library',
  812. 'definition' => 'Genomic Library',
  813. 'cv_name' => 'library_type',
  814. 'db_name' => 'local'
  815. ), array('force_db_change' => TRUE));
  816. //--------------
  817. // Feature Map
  818. //--------------
  819. // add cvterms for the map unit types
  820. tripal_insert_cvterm(array(
  821. 'name' => 'cM',
  822. 'definition' => 'Centimorgan units',
  823. 'cv_name' => 'featuremap_units',
  824. 'is_relationship' => 0,
  825. 'db_name' => 'local'
  826. ), array('force_db_change' => TRUE));
  827. tripal_insert_cvterm(array(
  828. 'name' => 'bp',
  829. 'definition' => 'Base pairs units',
  830. 'cv_name' => 'featuremap_units',
  831. 'is_relationship' => 0,
  832. 'db_name' => 'local'
  833. ), array('force_db_change' => TRUE));
  834. tripal_insert_cvterm(array(
  835. 'name' => 'bin_unit',
  836. 'definition' => 'The bin unit',
  837. 'cv_name' => 'featuremap_units',
  838. 'is_relationship' => 0,
  839. 'db_name' => 'local'
  840. ), array('force_db_change' => TRUE));
  841. tripal_insert_cvterm(array(
  842. 'name' => 'marker_order',
  843. 'definition' => 'Units simply to define marker order.',
  844. 'cv_name' => 'featuremap_units',
  845. 'is_relationship' => 0,
  846. 'db_name' => 'local'
  847. ), array('force_db_change' => TRUE));
  848. tripal_insert_cvterm(array(
  849. 'name' => 'undefined',
  850. 'definition' => 'A catch-all for an undefined unit type',
  851. 'cv_name' => 'featuremap_units',
  852. 'is_relationship' => 0,
  853. 'db_name' => 'local'
  854. ), array('force_db_change' => TRUE));
  855. // featurepos properties
  856. tripal_insert_cvterm(array(
  857. 'name' => 'start',
  858. 'definition' => 'The start coordinate for a map feature.',
  859. 'cv_name' => 'featurepos_property',
  860. 'is_relationship' => 0,
  861. 'db_name' => 'local'
  862. ), array('force_db_change' => TRUE));
  863. tripal_insert_cvterm(array(
  864. 'name' => 'stop',
  865. 'definition' => 'The end coordinate for a map feature',
  866. 'cv_name' => 'featurepos_property',
  867. 'is_relationship' => 0,
  868. 'db_name' => 'local'
  869. ), array('force_db_change' => TRUE));
  870. // add cvterms for map properties
  871. tripal_insert_cvterm(array(
  872. 'name' => 'Map Dbxref',
  873. 'definition' => 'A unique identifer for the map in a remote database. The '
  874. . 'format is a database abbreviation and a unique accession separated '
  875. . 'by a colon. (e.g. Gramene:tsh1996a)',
  876. 'cv_name' => 'featuremap_property',
  877. 'is_relationship' => 0,
  878. 'db_name' => 'local'
  879. ), array('force_db_change' => TRUE));
  880. tripal_insert_cvterm(array(
  881. 'name' => 'Map Type',
  882. 'definition' => 'The type of Map (e.g. QTL, Physical, etc.)',
  883. 'cv_name' => 'featuremap_property',
  884. 'is_relationship' => 0,
  885. 'db_name' => 'local'
  886. ), array('force_db_change' => TRUE));
  887. tripal_insert_cvterm(array(
  888. 'name' => 'Genome Group',
  889. 'definition' => '',
  890. 'cv_name' => 'featuremap_property',
  891. 'is_relationship' => 0,
  892. 'db_name' => 'local'
  893. ), array('force_db_change' => TRUE));
  894. tripal_insert_cvterm(array(
  895. 'name' => 'URL',
  896. 'definition' => 'A univeral resource locator (URL) reference where the '
  897. . 'publication can be found. For maps found online, this would be '
  898. . 'the web address for the map.',
  899. 'cv_name' => 'featuremap_property',
  900. 'is_relationship' => 0,
  901. 'db_name' => 'local'
  902. ), array('force_db_change' => TRUE));
  903. tripal_insert_cvterm(array(
  904. 'name' => 'Population Type',
  905. 'definition' => 'A brief description of the population type used to generate '
  906. . 'the map (e.g. RIL, F2, BC1, etc).',
  907. 'cv_name' => 'featuremap_property',
  908. 'is_relationship' => 0,
  909. 'db_name' => 'local'
  910. ), array('force_db_change' => TRUE));
  911. tripal_insert_cvterm(array(
  912. 'name' => 'Population Size',
  913. 'definition' => 'The size of the population used to construct the map.',
  914. 'cv_name' => 'featuremap_property',
  915. 'is_relationship' => 0,
  916. 'db_name' => 'local'
  917. ), array('force_db_change' => TRUE));
  918. tripal_insert_cvterm(array(
  919. 'name' => 'Methods',
  920. 'definition' => 'A brief description of the methods used to construct the map.',
  921. 'cv_name' => 'featuremap_property',
  922. 'is_relationship' => 0,
  923. 'db_name' => 'local'
  924. ), array('force_db_change' => TRUE));
  925. tripal_insert_cvterm(array(
  926. 'name' => 'Software',
  927. 'definition' => 'The software used to construct the map.',
  928. 'cv_name' => 'featuremap_property',
  929. 'is_relationship' => 0,
  930. 'db_name' => 'local'
  931. ), array('force_db_change' => TRUE));
  932. //--------------
  933. // Analysis Terms
  934. //--------------
  935. // add analysis_date. This is no longer used (as far as we can tell) but we don't
  936. // get rid of it in case it is used, so just keep it in the Tripal CV
  937. tripal_insert_cvterm(array(
  938. 'name' => 'analysis_date',
  939. 'definition' => 'The date that an analysis was performed.',
  940. 'cv_name' => 'tripal_analysis',
  941. 'is_relationship' => 0,
  942. 'db_name' => 'local'
  943. ), array('update_existing' => TRUE));
  944. // add analysis_short_name. This is no longer used (as far as we can tell) but we don't
  945. // get rid of it in case it is used, so just keep it in the Tripal CV
  946. tripal_insert_cvterm(array(
  947. 'name' => 'analysis_short_name',
  948. 'definition' => 'A computer legible (no spaces or special characters) '
  949. . 'abbreviation for the analysis.',
  950. 'cv_name' => 'tripal_analysis',
  951. 'is_relationship' => 0,
  952. 'db_name' => 'local'
  953. ), array('update_existing' => TRUE));
  954. // the 'analysis_property' vocabulary is for user definable properties wo we
  955. // will add an 'Analysis Type' to this vocubulary
  956. tripal_insert_cvterm(array(
  957. 'name' => 'Analysis Type',
  958. 'definition' => 'The type of analysis that was performed.',
  959. 'cv_name' => 'analysis_property',
  960. 'is_relationship' => 0,
  961. 'db_name' => 'local'
  962. ), array('update_existing' => TRUE));
  963. }
  964. /**
  965. * Adds the Systems Biology Ontology database and terms.
  966. */
  967. function tripal_chado_populate_vocab_SBO() {
  968. tripal_insert_db(array(
  969. 'name' => 'SBO',
  970. 'description' => 'Systems Biology.',
  971. 'url' => 'http://www.ebi.ac.uk/sbo/main/',
  972. 'urlprefix' => 'http://purl.obolibrary.org/obo/{db}_{accession}',
  973. ));
  974. tripal_insert_cv('sbo','Systems Biology. Terms commonly used in Systems Biology, and in particular in computational modeling.');
  975. $dbxref = tripal_insert_cvterm(array(
  976. 'id' => 'SBO:0000358',
  977. 'name' => 'phenotype',
  978. 'cv_name' => 'sbo',
  979. 'definition' => 'A biochemical network can generate phenotypes or affects biological processes. Such processes can take place at different levels and are independent of the biochemical network itself.',
  980. ));
  981. $dbxref = tripal_insert_cvterm(array(
  982. 'id' => 'SBO:0000554',
  983. 'name' => 'database cross reference',
  984. 'cv_name' => 'sbo',
  985. 'definition' => 'An annotation which directs one to information contained within a database.',
  986. ));
  987. $relationship = tripal_insert_cvterm(array(
  988. 'id' => 'SBO:0000374',
  989. 'name' => 'relationship',
  990. 'cv_name' => 'sbo',
  991. 'definition' => 'Connectedness between entities and/or interactions representing their relatedness or influence.',
  992. ));
  993. }
  994. /**
  995. * Adds the Sequence Ontology
  996. */
  997. function tripal_chado_populate_vocab_SO() {
  998. tripal_insert_db(array(
  999. 'name' => 'SO',
  1000. 'description' => 'Sequence Ontology',
  1001. 'url' => 'http://www.sequenceontology.org',
  1002. 'urlprefix' => 'http://www.sequenceontology.org/browser/current_svn/term/{db}:{accession}',
  1003. ));
  1004. tripal_insert_cv('sequence','The Sequence Ontology.');
  1005. }
  1006. /**
  1007. * Adds the Software Ontology database and terms.
  1008. */
  1009. function tripal_chado_populate_vocab_SWO() {
  1010. tripal_insert_db(array(
  1011. 'name' => 'SWO',
  1012. 'description' => 'Software Ontology',
  1013. 'url' => 'http://theswo.sourceforge.net/',
  1014. 'urlprefix' => '',
  1015. ));
  1016. tripal_insert_cv('swo','Software Ontology. An ontology representation of the NCBI organismal taxonomy.');
  1017. $term = tripal_insert_cvterm(array(
  1018. 'id' => 'SWO:0000001',
  1019. 'name' => 'software',
  1020. 'cv_name' => 'swo',
  1021. 'definition' => 'Computer software, or generally just software, is any ' .
  1022. 'set of machine-readable instructions (most often in the form of a ' .
  1023. 'computer program) that conform to a given syntax (sometimes ' .
  1024. 'referred to as a language) that is interpretable by a given ' .
  1025. 'processor and that directs a computer\'s processor to perform ' .
  1026. 'specific operations.',
  1027. ));
  1028. tripal_associate_chado_semweb_term('analysis', 'program', $term);
  1029. }
  1030. /**
  1031. * Adds the pub table mapping.
  1032. */
  1033. function tripal_chado_populate_vocab_TPUB() {
  1034. $term = tripal_get_cvterm(array('id' => 'TPUB:0000039'));
  1035. tripal_associate_chado_semweb_term('pub', 'title', $term);
  1036. $term = tripal_get_cvterm(array('id' => 'TPUB:0000243'));
  1037. tripal_associate_chado_semweb_term('pub', 'volumetitle', $term);
  1038. $term = tripal_get_cvterm(array('id' => 'TPUB:0000042'));
  1039. tripal_associate_chado_semweb_term('pub', 'volume', $term);
  1040. $term = tripal_get_cvterm(array('id' => 'TPUB:0000256'));
  1041. tripal_associate_chado_semweb_term('pub', 'series_name', $term);
  1042. $term = tripal_get_cvterm(array('id' => 'TPUB:0000043'));
  1043. tripal_associate_chado_semweb_term('pub', 'issue', $term);
  1044. $term = tripal_get_cvterm(array('id' => 'TPUB:0000059'));
  1045. tripal_associate_chado_semweb_term('pub', 'pyear', $term);
  1046. $term = tripal_get_cvterm(array('id' => 'TPUB:0000044'));
  1047. tripal_associate_chado_semweb_term('pub', 'pages', $term);
  1048. $term = tripal_get_cvterm(array('id' => 'TPUB:0000244'));
  1049. tripal_associate_chado_semweb_term('pub', 'publisher', $term);
  1050. $term = tripal_get_cvterm(array('id' => 'TPUB:0000245'));
  1051. tripal_associate_chado_semweb_term('pub', 'pubplace', $term);
  1052. }
  1053. /**
  1054. * Adds the Uni Ontology database, terms and mappings.
  1055. */
  1056. function tripal_chado_populate_vocab_UO() {
  1057. tripal_insert_db(array(
  1058. 'name' => 'UO',
  1059. 'description' => 'Units of Measurement Ontology',
  1060. 'url' => 'http://purl.obolibrary.org/obo/uo',
  1061. 'urlprefix' => 'http://purl.obolibrary.org/obo/TAXRANK_',
  1062. ));
  1063. tripal_insert_cv('uo','Units of Measurement Ontology');
  1064. $term = tripal_insert_cvterm(array(
  1065. 'id' => 'UO:0000000',
  1066. 'name' => 'unit',
  1067. 'cv_name' => 'uo',
  1068. 'description' => 'A unit of measurement is a standardized quantity of a physical quality.'
  1069. ));
  1070. tripal_associate_chado_semweb_term('featuremap', 'unittype_id', $term);
  1071. }
  1072. /**
  1073. * Adds the Taxonomic Rank Ontology database and terms.
  1074. */
  1075. function tripal_chado_populate_vocab_TAXRANK() {
  1076. tripal_insert_db(array(
  1077. 'name' => 'TAXRANK',
  1078. 'description' => 'Taxonomic rank vocabulary.',
  1079. 'url' => 'https://github.com/phenoscape/taxrank',
  1080. 'urlprefix' => 'http://purl.obolibrary.org/obo/TAXRANK_',
  1081. ));
  1082. tripal_insert_cv('taxrank','Taxonomic rank vocabulary. A vocabulary of taxonomic ranks (species, family, phylum, etc).');
  1083. $term = tripal_insert_cvterm(array(
  1084. 'id' => 'TAXRANK:0000005',
  1085. 'name' => 'genus',
  1086. 'cv_name' => 'taxonomic_rank',
  1087. 'description' => 'Taxonomic rank of Genus'
  1088. ));
  1089. tripal_associate_chado_semweb_term('organism', 'genus', $term);
  1090. $term = tripal_insert_cvterm(array(
  1091. 'id' => 'TAXRANK:0000006',
  1092. 'name' => 'species',
  1093. 'cv_name' => 'taxonomic_rank',
  1094. 'description' => 'Taxonomic rank of species.'
  1095. ));
  1096. tripal_associate_chado_semweb_term('organism', 'species', $term);
  1097. $term = tripal_insert_cvterm(array(
  1098. 'id' => 'TAXRANK:0000045',
  1099. 'name' => 'infraspecies',
  1100. 'cv_name' => 'taxonomic_rank',
  1101. 'description' => 'Taxonomic infraspecies name.'
  1102. ));
  1103. tripal_associate_chado_semweb_term('organism', 'infraspecific_name', $term);
  1104. }
  1105. /**
  1106. * Adds the NCBI Taxon vocabulary database and terms.
  1107. */
  1108. function tripal_chado_populate_vocab_NCBITAXON() {
  1109. tripal_insert_db(array(
  1110. 'name' => 'NCBITaxon',
  1111. 'description' => 'NCBI organismal classification.',
  1112. 'url' => 'http://www.berkeleybop.org/ontologies/ncbitaxon/',
  1113. 'urlprefix' => 'http://purl.obolibrary.org/obo/ncbitaxon#',
  1114. ));
  1115. tripal_insert_cv('ncbitaxon','NCBI organismal classification. An ontology representation of the NCBI organismal taxonomy.');
  1116. $term = tripal_insert_cvterm(array(
  1117. 'id' => 'NCBITaxon:common_name',
  1118. 'name' => 'common name',
  1119. 'cv_name' => 'ncbitaxon',
  1120. ));
  1121. tripal_associate_chado_semweb_term('organism', 'common_name', $term);
  1122. }
  1123. /**
  1124. * Adds defaults to the chado_semweb table.
  1125. */
  1126. function tripal_chado_semweb_form($form, &$form_state, $chado_table = NULL) {
  1127. if (array_key_exists('values', $form_state)) {
  1128. $chado_table = $form_state['values']['chado_table'];
  1129. }
  1130. $chado_tables = chado_get_table_names(TRUE);
  1131. $chado_tables = array_merge(array('Select a Chado Table'), $chado_tables);
  1132. // Make sure the table name exists. If not, reset it.
  1133. $chado_table = in_array($chado_table, $chado_tables) ? $chado_table: NULL;
  1134. $form['chado_table'] = array(
  1135. '#type' => 'select',
  1136. '#title' => 'Chado Table',
  1137. '#description' => t('Select a chado table to set web services terms used for its columns.'),
  1138. '#options' => $chado_tables,
  1139. '#default_value' => $chado_table,
  1140. '#ajax' => array(
  1141. 'callback' => "tripal_chado_semweb_form_ajax_callback",
  1142. 'wrapper' => "tripal-chado-semweb-form",
  1143. 'effect' => 'fade',
  1144. 'method' => 'replace'
  1145. ),
  1146. );
  1147. // If the user has selected a chado table, then we need to
  1148. // show the columns for setting terms.
  1149. if ($chado_table) {
  1150. $schema = chado_get_schema($chado_table);
  1151. $pk = $schema['primary key'][0];
  1152. // $cv_default = db_select('tripal_cv_defaults', 'tc')
  1153. // ->fields('tc', array('field_name'))
  1154. // ->condition('table_name', $chado_table)
  1155. // ->execute()
  1156. // ->fetchField();
  1157. $columns = $schema['fields'];
  1158. $headers = array(
  1159. 'Field Name',
  1160. 'Vocabulary',
  1161. array(
  1162. 'data' => 'Name',
  1163. 'nowrap' => TRUE,
  1164. ),
  1165. 'Term',
  1166. 'Term Description',
  1167. 'Action'
  1168. );
  1169. $rows = array();
  1170. foreach ($columns AS $column => $detail) {
  1171. // Do not show column if it's the primary key or default cv
  1172. if ($column != $pk && $column != $cv_default) {
  1173. $cvterm_id =
  1174. db_select('chado_semweb', 'cs')
  1175. ->fields('cs', array('cvterm_id'))
  1176. ->condition('chado_table', $chado_table)
  1177. ->condition('chado_column', $column)
  1178. ->execute()
  1179. ->fetchField();
  1180. $sw_voc = '';
  1181. $sw_term = '';
  1182. $sw_desc = '';
  1183. $sw_accession = '';
  1184. if($cvterm_id) {
  1185. $term = chado_generate_var('cvterm', array('cvterm_id' => $cvterm_id));
  1186. $sw_voc = $term->cv_id->name;
  1187. $sw_term = $term->name;
  1188. $sw_accession = l($term->dbxref_id->db_id->name . ':' . $term->dbxref_id->accession,
  1189. 'cv/lookup/' . $term->dbxref_id->db_id->name . '/' . $term->dbxref_id->accession,
  1190. array('attributes' => array('target' => '_blank')));
  1191. $sw_desc = $term->definition;
  1192. }
  1193. $rows[] = array(
  1194. $column,
  1195. $sw_voc,
  1196. $sw_term,
  1197. $sw_accession,
  1198. $sw_desc,
  1199. array(
  1200. 'data' => l('Edit', '/admin/tripal/storage/chado/semweb/edit/' . $chado_table . '/' . $column) . ' | ' .
  1201. l('Reset', '/admin/tripal/storage/chado/semweb/reset/' . $chado_table . '/' . $column),
  1202. 'nowrap' => TRUE,
  1203. ),
  1204. );
  1205. }
  1206. }
  1207. $output = theme('table', array(
  1208. 'header' => $headers,
  1209. 'rows' => $rows,
  1210. ));
  1211. $form['table'] = array(
  1212. '#markup' => $output
  1213. );
  1214. }
  1215. $form['#prefix'] = '<div id="tripal-chado-semweb-form">';
  1216. $form['#suffix'] = '</div>';
  1217. return $form;
  1218. }
  1219. /**
  1220. * Implements hook_form()
  1221. * Edit terms used by the semantic web
  1222. *
  1223. * @param $form
  1224. * @param $form_state
  1225. * @param $table
  1226. * @param $column
  1227. * @return $form
  1228. */
  1229. function tripal_chado_semweb_edit_form($form, &$form_state, $table = NULL, $column = NULL) {
  1230. $term_name = array_key_exists('values', $form_state) ? $form_state['values']['term_name'] : '';
  1231. $form['chado_table'] = array(
  1232. '#markup' => 'Term used for the <strong>' . t($column) . '</strong> column of the chado <strong>' . t($table) . '</strong> table:',
  1233. );
  1234. $form['table_name'] = array(
  1235. '#type' => 'value',
  1236. '#value' => $table
  1237. );
  1238. $form['column'] = array(
  1239. '#type' => 'value',
  1240. '#value' => $column
  1241. );
  1242. // If no term has been selected yet then provide the auto complete field.
  1243. $form['term_name'] = array(
  1244. '#title' => t('Term'),
  1245. '#type' => 'textfield',
  1246. '#description' => t("The content type must be the name of a term in
  1247. a controlled vocabulary and the controlled vocabulary should
  1248. already be loaded into Tripal. For example, to create a content
  1249. type for storing 'genes', use the 'gene' term from the
  1250. Sequence Ontology (SO)."),
  1251. '#required' => TRUE,
  1252. '#default_value' => $term_name,
  1253. '#autocomplete_path' => "admin/tripal/storage/chado/auto_name/cvterm/",
  1254. );
  1255. $form['select_button'] = array(
  1256. '#type' => 'button',
  1257. '#value' => t('Lookup Term'),
  1258. '#name' => 'select_cvterm',
  1259. '#ajax' => array(
  1260. 'callback' => "tripal_chado_semweb_form_ajax_callback",
  1261. 'wrapper' => "tripal-chado-semweb-edit-form",
  1262. 'effect' => 'fade',
  1263. 'method' => 'replace'
  1264. ),
  1265. );
  1266. if ($term_name) {
  1267. $form['terms_list'] = array(
  1268. '#type' => 'fieldset',
  1269. '#title' => t('Matching Terms'),
  1270. '#description' => t('Please select the term the best matches the
  1271. content type you want to create. If the same term exists in
  1272. multiple vocabularies you will see more than one option below.')
  1273. );
  1274. $match = array(
  1275. 'name' => $term_name,
  1276. );
  1277. $terms = chado_generate_var('cvterm', $match, array('return_array' => TRUE));
  1278. $terms = chado_expand_var($terms, 'field', 'cvterm.definition');
  1279. $num_terms = 0;
  1280. foreach ($terms as $term) {
  1281. // Save the user a click by setting the default value as 1 if there's
  1282. // only one matching term.
  1283. $default = FALSE;
  1284. $attrs = array();
  1285. if ($num_terms == 0 and count($terms) == 1) {
  1286. $default = TRUE;
  1287. $attrs = array('checked' => 'checked');
  1288. }
  1289. $form['terms_list']['term-' . $term->cvterm_id] = array(
  1290. '#type' => 'checkbox',
  1291. '#title' => $term->name,
  1292. '#default_value' => $default,
  1293. '#attributes' => $attrs,
  1294. '#description' => '<b>Vocabulary:</b> ' . $term->cv_id->name . ' (' . $term->dbxref_id->db_id->name . ') ' . $term->cv_id->definition .
  1295. '<br><b>Term: </b> ' . $term->dbxref_id->db_id->name . ':' . $term->dbxref_id->accession . '. ' .
  1296. '<br><b>Definition:</b> ' . $term->definition,
  1297. );
  1298. $num_terms++;
  1299. }
  1300. if ($num_terms == 0) {
  1301. $form['terms_list']['none'] = array(
  1302. '#type' => 'item',
  1303. '#markup' => '<i>' . t('There is no term that matches the entered text.') . '</i>'
  1304. );
  1305. }
  1306. // Add in the button for the cases of no terms or too many.
  1307. $form['submit_button'] = array(
  1308. '#type' => 'submit',
  1309. '#value' => t('Use this term'),
  1310. '#name' => 'use_cvterm'
  1311. );
  1312. }
  1313. $form['cancel_button'] = array(
  1314. '#type' => 'button',
  1315. '#value' => t('Cancel'),
  1316. '#name' => 'cancel_button',
  1317. '#limit_validation_errors' => array()
  1318. );
  1319. $form['#prefix'] = '<div id = "tripal-chado-semweb-edit-form">';
  1320. $form['#suffix'] = '</div>';
  1321. return $form;
  1322. }
  1323. /**
  1324. * Implements hook_form_validate()
  1325. *
  1326. * Validate function for editing the semantic web term
  1327. *
  1328. * @param unknown $form
  1329. * @param unknown $form_state
  1330. */
  1331. function tripal_chado_semweb_edit_form_validate($form, &$form_state) {
  1332. if (array_key_exists('clicked_button', $form_state)) {
  1333. if ($form_state['clicked_button']['#name'] =='use_cvterm') {
  1334. $cvterm_id = NULL;
  1335. // Make sure we have a cvterm selected
  1336. $num_selected = 0;
  1337. foreach ($form_state['values'] as $key => $value) {
  1338. $matches = array();
  1339. if (preg_match("/^term-(\d+)$/", $key, $matches) and
  1340. $form_state['values']['term-' . $matches[1]]) {
  1341. $cvterm_id = $matches[1];
  1342. $num_selected++;
  1343. }
  1344. }
  1345. if ($num_selected == 0) {
  1346. form_set_error('', 'Please select at least one term.');
  1347. }
  1348. else if ($num_selected > 1) {
  1349. form_set_error('term-' . $cvterm_id, 'Please select only one term from the list below.');
  1350. }
  1351. else {
  1352. $form_state['values']['#selected_cvterm_id'] = $cvterm_id;
  1353. }
  1354. }
  1355. else if ($form_state['clicked_button']['#name'] =='cancel_button') {
  1356. $table_name = $form_state['values']['table_name'];
  1357. drupal_goto('/admin/tripal/storage/chado/semweb/' . $table_name);
  1358. }
  1359. }
  1360. }
  1361. /**
  1362. * Implements hook_form_submit()
  1363. *
  1364. * Submit function for editing the semantic web term
  1365. *
  1366. * @param unknown $form
  1367. * @param unknown $form_state
  1368. */
  1369. function tripal_chado_semweb_edit_form_submit($form, &$form_state) {
  1370. if (array_key_exists('clicked_button', $form_state) && $form_state['clicked_button']['#name'] =='use_cvterm') {
  1371. $table_name = $form_state['values']['table_name'];
  1372. $column = $form_state['values']['column'];
  1373. $cvterm_id = $form_state['values']['#selected_cvterm_id'];
  1374. // Check if there is already a record
  1375. $record_id =
  1376. db_select('chado_semweb', 'cs')
  1377. ->fields('cs', array('chado_semweb_id'))
  1378. ->condition('chado_table', $table_name)
  1379. ->condition('chado_column', $column)
  1380. ->execute()
  1381. ->fetchField();
  1382. // If the record exists, update it
  1383. if ($record_id) {
  1384. db_update('chado_semweb')
  1385. ->fields(array(
  1386. 'cvterm_id' => $cvterm_id
  1387. ))
  1388. ->condition('chado_semweb_id', $record_id)
  1389. ->execute();
  1390. }
  1391. // Otherwise, insert a new record
  1392. else {
  1393. db_insert('chado_semweb')
  1394. ->fields(array(
  1395. 'chado_table' => $table_name,
  1396. 'chado_column' => $column,
  1397. 'cvterm_id' => $cvterm_id
  1398. ))
  1399. ->execute();
  1400. }
  1401. drupal_set_message('The term settings have been saved.');
  1402. drupal_goto('/admin/tripal/storage/chado/semweb/' . $table_name);
  1403. }
  1404. }
  1405. /**
  1406. * Implements hook_form()
  1407. * Reset term used by semantic web
  1408. *
  1409. * @param $form
  1410. * @param $form_state
  1411. * @param $table
  1412. * @param $column
  1413. * @return $form
  1414. */
  1415. function tripal_chado_semweb_reset_form($form, &$form_state, $table = NULL, $column = NULL) {
  1416. $term_name = array_key_exists('values', $form_state) ? $form_state['values']['term_name'] : '';
  1417. $form['chado_table'] = array(
  1418. '#markup' => 'Are you sure you want to remove the use of this term? ',
  1419. );
  1420. $form['table_name'] = array(
  1421. '#type' => 'value',
  1422. '#value' => $table
  1423. );
  1424. $form['column'] = array(
  1425. '#type' => 'value',
  1426. '#value' => $column
  1427. );
  1428. $form['submit_button'] = array(
  1429. '#type' => 'submit',
  1430. '#value' => t('Reset'),
  1431. '#name' => 'reset_term'
  1432. );
  1433. $form['cancel_button'] = array(
  1434. '#type' => 'button',
  1435. '#value' => t('Cancel'),
  1436. '#name' => 'cancel_button',
  1437. '#limit_validation_errors' => array()
  1438. );
  1439. return $form;
  1440. }
  1441. /**
  1442. * Implements hook_form_validate()
  1443. *
  1444. * Validate function for resetting the semantic web term
  1445. *
  1446. * @param unknown $form
  1447. * @param unknown $form_state
  1448. */
  1449. function tripal_chado_semweb_reset_form_validate($form, &$form_state) {
  1450. if (array_key_exists('clicked_button', $form_state)) {
  1451. if ($form_state['clicked_button']['#name'] =='use_cvterm') {
  1452. $cvterm_id = NULL;
  1453. // Make sure we have a cvterm selected
  1454. $num_selected = 0;
  1455. foreach ($form_state['values'] as $key => $value) {
  1456. $matches = array();
  1457. if (preg_match("/^term-(\d+)$/", $key, $matches) and
  1458. $form_state['values']['term-' . $matches[1]]) {
  1459. $cvterm_id = $matches[1];
  1460. $num_selected++;
  1461. }
  1462. }
  1463. if ($num_selected == 0) {
  1464. form_set_error('', 'Please select at least one term.');
  1465. }
  1466. else if ($num_selected > 1) {
  1467. form_set_error('term-' . $cvterm_id, 'Please select only one term from the list below.');
  1468. }
  1469. else {
  1470. $form_state['values']['#selected_cvterm_id'] = $cvterm_id;
  1471. }
  1472. }
  1473. else if ($form_state['clicked_button']['#name'] =='cancel_button') {
  1474. $table_name = $form_state['values']['table_name'];
  1475. drupal_goto('/admin/tripal/storage/chado/semweb/' . $table_name);
  1476. }
  1477. }
  1478. }
  1479. /**
  1480. * Implements hook_form_submit()
  1481. *
  1482. * Submit function for editing the semantic web term
  1483. *
  1484. * @param unknown $form
  1485. * @param unknown $form_state
  1486. */
  1487. function tripal_chado_semweb_reset_form_submit($form, &$form_state) {
  1488. if (array_key_exists('clicked_button', $form_state) && $form_state['clicked_button']['#name'] =='reset_term') {
  1489. $table_name = $form_state['values']['table_name'];
  1490. $column = $form_state['values']['column'];
  1491. // Check if there is already a record
  1492. $record_id =
  1493. db_select('chado_semweb', 'cs')
  1494. ->fields('cs', array('chado_semweb_id'))
  1495. ->condition('chado_table', $table_name)
  1496. ->condition('chado_column', $column)
  1497. ->execute()
  1498. ->fetchField();
  1499. // If the record exists, reset it
  1500. if ($record_id) {
  1501. db_update('chado_semweb')
  1502. ->fields(array(
  1503. 'cvterm_id' => NULL
  1504. ))
  1505. ->condition('chado_semweb_id', $record_id)
  1506. ->execute();
  1507. }
  1508. drupal_set_message('The term settings have been reset.');
  1509. drupal_goto('/admin/tripal/storage/chado/semweb/' . $table_name);
  1510. }
  1511. }
  1512. /**
  1513. *
  1514. */
  1515. function tripal_chado_semweb_form_ajax_callback($form, $form_state) {
  1516. return $form;
  1517. }