tripal_chado.module.DEPRECATED.api.inc 62 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637
  1. <?php
  2. /**
  3. * @file
  4. *
  5. * These api functions are deprecated, if your site is currently using them
  6. * please update your code with the newer tripal_chado functions.
  7. */
  8. /**
  9. * @defgroup tripal_chado_module_DEPRECATED_api
  10. * @ingroup tripal_chado_api
  11. * @{
  12. * Deprecated legacy api code.
  13. * @}
  14. */
  15. /**tripal_analysis_api*/
  16. /**
  17. * Retrieves a chado analysis variable.
  18. *
  19. * @param $itentifier
  20. * an array with the key stating what the identifier is. Supported keys
  21. * (only on of the following unique keys is required):
  22. * - analysis_id: the chado analysis.analysis_id primary key.
  23. * - nid: the drupal node.nid primary key.
  24. * There are also some specially handled keys. They are:
  25. * - property: An array/object describing the property to select records for.
  26. * It should at least have either a type_name (if unique across cvs) or
  27. * type_id. Other supported keys include: cv_id/cv_name (of the type),
  28. * value and rank.
  29. * @param $options
  30. * An array of options. Supported keys include:
  31. * - Any keys supported by chado_generate_var(). See that function
  32. * definition for additional details.
  33. *
  34. * NOTE: the $identifier parameter can really be any array similar to $values
  35. * passed into chado_select_record(). It should fully specify the stock record
  36. * to be returned.
  37. *
  38. * @return
  39. * the analysis node matching the passed in identifier
  40. *
  41. * @ingroup tripal_chado_module_DEPRECATED_api
  42. */
  43. function tripal_get_analysis($identifier, $options) {
  44. chado_get_analysis($identifier, $options);
  45. }
  46. /**
  47. * Returns a list of analyses that are currently synced with Drupal to use in
  48. * select lists.
  49. *
  50. * @param $syncd_only
  51. * Whether or not to return all chado analyses or just those sync'd with
  52. * drupal. Defaults to TRUE (only sync'd analyses).
  53. * @return
  54. * An array of analyses sync'd with Drupal where each value is the analysis
  55. * scientific name and the keys are analysis_id's.
  56. *
  57. * @ingroup tripal_chado_module_DEPRECATED_api
  58. */
  59. function tripal_get_analysis_select_options($syncd_only = true) {
  60. chado_get_analysis_select_options($syncd_only);
  61. }
  62. /**tripal_contact_api*/
  63. /**
  64. * Adds a contact to the Chado contact table.
  65. *
  66. * @param $values
  67. * An array of values to be inserted. Valid keys include:
  68. * - name: The name of the contact.
  69. * - description: Text describing the contact.
  70. * - type_name: The type of contact. Must be a term in the tripal_contact
  71. * vocabulary.
  72. * - properties: An associative array containing a list of key value pairs for
  73. * the properites. The key's must be valid terms in the tripal_contact
  74. * vocabulary (e.g. Affiliation, Address, etc).
  75. *
  76. * @return
  77. * On success, an array is returned containing the fields of the contact
  78. * record including the newly added contact_id. On failure, FALSE is
  79. * returned.
  80. *
  81. * @ingroup tripal_chado_module_DEPRECATED_api
  82. */
  83. function tripal_insert_contact($values) {
  84. chado_insert_contact($values);
  85. }
  86. /**
  87. * This function is intended to be used in autocomplete forms for contacts.
  88. *
  89. * @param $text
  90. * The string to search for.
  91. *
  92. * @return
  93. * A json array of terms that begin with the provided string.
  94. *
  95. * @ingroup tripal_chado_module_DEPRECATED_api
  96. */
  97. function tripal_autocomplete_contact($text) {
  98. chado_autocomplete_contact($text);
  99. }
  100. /**tripal_chado_cv_api*/
  101. /**
  102. * Retrieves a chado controlled vocabulary variable
  103. *
  104. * @param $identifier
  105. * An array with the key stating what the identifier is. Supported keys (only
  106. * on of the following unique keys is required):
  107. * - cv_id: the chado cv.cv_id primary key.
  108. * - name: the chado cv.name field (assume unique).
  109. * @param $options
  110. * An array of options. Supported keys include:
  111. * - Any keys supported by chado_generate_var(). See that function
  112. * definition fot additional details.
  113. *
  114. * NOTE: the $identifier parameter can really be any array similar to $values
  115. * passed into chado_select_record(). It should fully specify the cv record to
  116. * be returned.
  117. *
  118. * @return
  119. * If unique values were passed in as an identifier then an object describing
  120. * the cv will be returned (will be a chado variable from
  121. * chado_generate_var()). Otherwise, FALSE will be returned.
  122. *
  123. * @ingroup tripal_chado_module_DEPRECATED_api
  124. */
  125. function tripal_get_cv($identifiers, $options = array()) {
  126. chado_get_cv($identifiers, $options);
  127. }
  128. /**
  129. * Create an options array to be used in a form element which provides a
  130. * list of all chado cvs.
  131. *
  132. * @return
  133. * An array(cv_id => name) for each cv in the chado cv table.
  134. *
  135. * @ingroup tripal_chado_module_DEPRECATED_api
  136. */
  137. function tripal_get_cv_select_options() {
  138. chado_get_cv_select_options();
  139. }
  140. /**
  141. * Retrieves a chado controlled vocabulary term variable.
  142. *
  143. * @param $identifier
  144. * An array apropriate for use with the chado_generate_var for uniquely
  145. * identifying a cvterm record. Alternativley, there are also some specially
  146. * handled keys. They are:
  147. * - id: an ID for the term of the for [dbname]:[accession], where [dbname]
  148. * is the short name of the vocabulary and accession is the unique ID.
  149. * - cv_id: an integer indicating the cv_id or an array with 'name' => the
  150. * name of the cv.
  151. * - synonym: an array with 'name' => the name of the synonym of the cvterm
  152. * you want returned; 'cv_id' => the cv_id of the synonym; 'cv_name' =>
  153. * the name of the cv of the synonym.
  154. * - property: An array/object describing the property to select records
  155. * for. It should at least have either a type_name (if unique across cvs)
  156. * or type_id. Other supported keys include: cv_id/cv_name (of the type),
  157. * value and rank.
  158. * @param $options
  159. * An array of options. Supported keys include:
  160. * - Any keys supported by chado_generate_var(). See that function
  161. * definition for additional details.
  162. *
  163. * NOTE: the $identifier parameter can really be any array similar to $values
  164. * passed into chado_select_record(). It should fully specify the cvterm
  165. * record to be returned.
  166. *
  167. * @return
  168. * If unique values were passed in as an identifier then an object describing
  169. * the cvterm will be returned (will be a chado variable from
  170. * chado_generate_var()). Otherwise, FALSE will be returned.
  171. *
  172. * @ingroup tripal_chado_module_DEPRECATED_api
  173. */
  174. function tripal_get_cvterm($identifiers, $options = array()) {
  175. chado_get_cvterm($identifiers, $options);
  176. }
  177. /**
  178. * Create an options array to be used in a form element
  179. * which provides a list of all chado cvterms.
  180. *
  181. * @param $cv_id
  182. * The chado cv_id; only cvterms with the supplied cv_id will be returnedl.
  183. * @param $rel_type
  184. * Set to TRUE if the terms returned should only be relationship types in
  185. * the vocabulary. This is useful for creating drop-downs of terms
  186. * used for relationship linker tables.
  187. *
  188. * @return
  189. * An associative array with the cvterm_id's as keys. The first
  190. * element in the array has a key of '0' and a value of 'Select a Type'.
  191. *
  192. * @ingroup tripal_chado_module_DEPRECATED_api
  193. */
  194. function tripal_get_cvterm_select_options($cv_id, $rel_type = false) {
  195. chado_get_cvterm_select_options($cv_id, $rel_type);
  196. }
  197. /**
  198. * Duplicate of fill_cvtermpath() stored procedure in Chado.
  199. *
  200. * Identifies all of the root terms of the controlled vocabulary. These
  201. * root terms are then processed by calling the
  202. * chado_update_cvtermpath_root_loop() function on each one.
  203. *
  204. * @param $cvid
  205. * The controlled vocabulary ID from the cv table of Chado (i.e. cv.cv_id).
  206. * @param $job_id
  207. *
  208. * @ingroup tripal_chado_module_DEPRECATED_api
  209. */
  210. function tripal_update_cvtermpath($cv_id, $job_id = null) {
  211. chado_update_cvtermpath($cv_id, $job_id);
  212. }
  213. /**
  214. * Duplicate of _fill_cvtermpath4root() stored procedure in Chado.
  215. *
  216. * This function process a "branch" of the ontology. Initially, the
  217. * "root" starts at the top of the tree. But, as the cvtermpath is populated
  218. * the "root" becomes terms deeper in the tree.
  219. *
  220. * @param $rootid
  221. * The term ID from the cvterm table of Chado (i.e. cvterm.cvterm_id).
  222. * @param $cvid
  223. * The controlled vocabulary ID from the cv table of Chado (i.e. cv.cv_id).
  224. *
  225. * @ingroup tripal_chado_module_DEPRECATED_api
  226. */
  227. function tripal_update_cvtermpath_root_loop($rootid, $cvid, &$roots) {
  228. chado_update_cvtermpath_root_loop($rootid, $cvid, $roots);
  229. }
  230. /**
  231. *
  232. * @param $origin
  233. * The root terms cvterm_id.
  234. * @param $child_id
  235. * The cvterm_id of the current child term. The child term is a descendent
  236. * of the origin.
  237. * @param $cv_id
  238. * The controlled vocabulary ID from the cv table of Chado (i.e. cv.cv_id).
  239. * @param $type_id
  240. * The relationship type between the origin term and the child.
  241. * @param $depth
  242. * The depth of the recursion.
  243. * @param $increment_of_depth.
  244. * An integer tailing the number of children that have been walked down.
  245. * @param $tree_path.
  246. * The array of every term between the current child and the origin. Each
  247. * element in the array is an associative array with the keys:
  248. * -build_id: an string identifier for the child that combines the origin,
  249. * child cvterm_id,cv_id, and the type_id.
  250. * -depth: the depth that a child was inserted into the cvtermpath table.
  251. * @param $possible_loop
  252. * A boolean flag.
  253. * @param $matched_row
  254. * An array of rows that are currently in the cvtermpath table that match the
  255. * build_id of the current term trying to be written to the table
  256. * @param $possible_start_of_ loop
  257. * The array of the possible loop item between the current child and the
  258. * origin. Each element in the array is an associative array with the keys:
  259. * - cvid : $cv_id
  260. * - subject_id:
  261. * - child_id : $child_id,
  262. * - type_id : $type_id,
  263. * - depth : $depth,
  264. * @param $no_loop_skip_test
  265. * A boolean used when the possible loop has been ruled out as a loop.
  266. *
  267. *
  268. * @ingroup tripal_chado_module_DEPRECATED_api
  269. */
  270. function tripal_update_cvtermpath_loop($origin, $child_id, $cv_id, $type_id,
  271. $depth, $increment_of_depth, $tree_path, $possible_loop, $matched_rows,
  272. $possible_start_of_loop, $no_loop_skip_test) {
  273. chado_update_cvtermpath_loop($origin, $child_id, $cv_id, $type_id, $depth,
  274. $increment_of_depth, $tree_path, $possible_loop, $matched_rows,
  275. $possible_start_of_loop, $no_loop_skip_test);
  276. }
  277. /**
  278. *
  279. * @param $origin
  280. * The root terms cvterm_id.
  281. * @param $child_id
  282. * The cvterm_id of the current child term. The child term is a descendent
  283. * of the origin.
  284. * @param $cv_id
  285. * The controlled vocabulary ID from the cv table of Chado (i.e. cv.cv_id).
  286. * @param $type_id
  287. * The relationship type between the origin term and the child.
  288. * @param $depth
  289. * The depth of the recursion.
  290. * @param $increment_of_depth.
  291. * An integer.
  292. * @param $tree_path.
  293. * The array of every term between the current child and the origin. Each
  294. * element in the array is an associative array with the keys:
  295. * -build_id: an string identifier for the child that combines the origin,
  296. * child cvterm_id,cv_id, and the type_id.
  297. * -depth: the depth that a child was inserted into the cvtermpath table.
  298. * @param $possible_loop
  299. * A boolean flag.
  300. * @param $matched_row
  301. * An array of rows that are currently in the cvtermpath table that match the
  302. * build_id of the current term trying to be written to the table
  303. * @param $possible_start_of_ loop
  304. * The array of the possible loop item between the current child and the origin.
  305. * Each element in the array is an associative array with the keys:
  306. * - cvid : $cv_id
  307. * - subject_id:
  308. * - child_id : $child_id,
  309. * - type_id : $type_id,
  310. * - depth : $depth,
  311. * @param $no_loop_skip_test
  312. * A boolean used when the possible loop has been ruled out as a loop.
  313. * @return multitype: Either a number that represents the row count of existing
  314. * rows that already match these specification or a Boolean false.
  315. *
  316. * @ingroup tripal_chado_module_DEPRECATED_api
  317. */
  318. function tripal_update_cvtermpath_loop_increment($origin, $child_id, $cv_id,
  319. $type_id, $depth, $increment_of_depth, $tree_path, $possible_loop, $matched_rows,
  320. &$possible_start_of_loop, $no_loop_skip_test) {
  321. chado_update_cvtermpath_loop_increment($origin, $child_id, $cv_id, $type_id,
  322. $depth, $increment_of_depth, $tree_path, $possible_loop, $matched_rows,
  323. $possible_start_of_loop, $no_loop_skip_test);
  324. }
  325. /**
  326. * Adds a controlled vocabulary to the CV table of Chado.
  327. *
  328. * @param $name
  329. * The name of the controlled vocabulary. These are typically all lower case
  330. * with no special characters other than an undrescore (for spaces).
  331. * @param $comment
  332. * A description or definition of the vocabulary.
  333. *
  334. * @return
  335. * An object populated with fields from the newly added database.
  336. *
  337. * @ingroup tripal_chado_module_DEPRECATED_api
  338. */
  339. function tripal_insert_cv($name, $definition) {
  340. chado_insert_cv($name, $definition);
  341. }
  342. /**
  343. * Add's a controlled vocabulary term to Chado.
  344. *
  345. * This function will add a cvterm record (and a dbxref record if appropriate
  346. * values are provided). If the parent vocabulary does not exist then
  347. * that also is added to the cv table. If the cvterm is a relationship term
  348. * then the 'is_relationship' value should be set. All
  349. * terms must also have a corresponding database. This is specified in the
  350. * term's ID just before the colon (e.g. GO:003824). If the database does not
  351. * exist in the DB table then it will be added automatically. The accession
  352. * (the value just after the colon in the term's ID) will be added to the
  353. * dbxref table. If the CVterm already exists and $update is set (default)
  354. * then the cvterm is updated. If the CVTerm already exists and $update is
  355. * not set, then no changes are made and the CVTerm object is returned.
  356. *
  357. * @param $term
  358. * An associative array with the following keys:
  359. * - id: the term accession. must be of the form <DB>:<ACCESSION>, where
  360. * <DB> is the name of the database to which the cvterm belongs and the
  361. * <ACCESSION> is the term's accession number in the database.
  362. * - name: the name of the term. usually meant to be human-readable.
  363. * - is_obsolete: is present and set to 1 if the term is defunct.
  364. * - definition: the definition of the term.
  365. * - cv_name: The CV name to which the term belongs. If this arugment is
  366. * null or not provided then the function tries to find a record in the
  367. * CV table with the same name provided in the $term[namespace]. If
  368. * this field is provided then it overrides what the value in
  369. * $term[namespace].
  370. * - is_relationship: If this term is a relationship term then this value
  371. * should be 1.
  372. * - db_name: In some cases the database name will not be part of the
  373. * $term['id'] and it needs to be explicitly set. Use this argument
  374. * only if the database name cannot be specififed in the term ID
  375. * (e.g. <DB>:<ACCESSION>).
  376. * @param $options
  377. * An associative array with the following keys:
  378. * - update_existing: By default this is TRUE. If the term exists it is
  379. * automatically updated.
  380. *
  381. * @return
  382. * A cvterm object
  383. *
  384. * @ingroup tripal_chado_module_DEPRECATED_api
  385. */
  386. function tripal_insert_cvterm($term, $options = array()) {
  387. chado_insert_cvterm($term, $options);
  388. }
  389. /**
  390. * TODO: deprecate this function
  391. *
  392. * Avoid using this function as it will be deprecated in future releases.
  393. *
  394. * This function allows other modules to programatically
  395. * submit an ontology for loading into Chado.
  396. *
  397. * This function will add a job to the Jobs subsystem for parsing the ontology.
  398. * You can either pass a known OBO ID to the function or the URL
  399. * or full path the the ontology file. If a URL or file name is
  400. * passed then the $obo_name argument must also be provided. If
  401. * this is the first time the ontology has been provided to Tripal
  402. * then it will be added to the database and will be assigned a
  403. * unique OBO ID.
  404. *
  405. * @param $obo_id
  406. * If the ontology is already loaded into the Tripal tables then
  407. * use this argument to specify the unique ID for the ontology
  408. * that will be loaded.
  409. * @param $obo_name
  410. * If the OBO has not been added before then use this argument
  411. * to specify the human readable name of the ontology.
  412. * @param $obo_url
  413. * If the OBO to be loaded is located on a remote server then
  414. * use this argument to provide the URL.
  415. * @param $obo_file
  416. * If the OBO is housed on the local file system of the server then
  417. * use this argument to specify the full path.
  418. *
  419. * @return
  420. * returns the job_id of the submitted job or FALSE if the job was not added
  421. *
  422. * @ingroup tripal_chado_module_DEPRECATED_api
  423. */
  424. function tripal_submit_obo_job($obo) {
  425. chado_submit_obo_job($obo);
  426. }
  427. /**
  428. * Add the OBO to the tripal_cv_obo table in the Drupal database.
  429. *
  430. * If the OBO name already exists in the table then the path is updated.
  431. *
  432. * @param $name
  433. * The human readable name of this ontology.
  434. * @param $path
  435. * The file path or URL of the ontology.
  436. *
  437. * @return
  438. * Returns the ontology ID.
  439. *
  440. * @ingroup tripal_chado_module_DEPRECATED_api
  441. */
  442. function tripal_insert_obo($name, $path) {
  443. chado_insert_obo($name, $path);
  444. }
  445. /**
  446. * Retrieves an OBO record.
  447. *
  448. * @param $values
  449. * An associate array with the following allowed keys: obo_id, name.
  450. *
  451. * @return
  452. * An instance of an OBO record object.
  453. *
  454. * @ingroup tripal_chado_module_DEPRECATED_api
  455. */
  456. function tripal_get_obo($values) {
  457. chado_get_obo($values);
  458. }
  459. /**
  460. * This function is intended to be used in autocomplete forms.
  461. *
  462. * This function searches for a matching controlled vobulary name.
  463. *
  464. * @param $string
  465. * The string to search for.
  466. *
  467. * @return
  468. * A json array of terms that begin with the provided string.
  469. *
  470. * @ingroup tripal_chado_module_DEPRECATED_api
  471. */
  472. function tripal_autocomplete_cv($string = '') {
  473. chado_autocomplete_cv($string);
  474. }
  475. /**
  476. * This function is intended to be used in autocomplete forms
  477. * for searching for CV terms that begin with the provided string.
  478. *
  479. * @param $cv_id
  480. * The CV ID in which to search for the term.
  481. * @param $string
  482. * The string to search for.
  483. *
  484. * @return
  485. * A json array of terms that begin with the provided string.
  486. *
  487. * @ingroup tripal_chado_module_DEPRECATED_api
  488. */
  489. function tripal_autocomplete_cvterm($cv_id, $string = '') {
  490. chado_autocomplete_cvterm($cv_id, $string);
  491. }
  492. /**
  493. * Add a record to a cvterm linking table (ie: feature_cvterm).
  494. *
  495. * @param $basetable
  496. * The base table to which the cvterm should be linked/associated. Thus to
  497. * associate a cvterm to a feature the basetable=feature and cvterm_id is
  498. * added to the feature_cvterm table.
  499. * @param $record_id
  500. * The primary key of the basetable to associate the cvterm with. This should
  501. * be in integer.
  502. * @param $cvterm
  503. * An associative array describing the cvterm. Valid keys include:
  504. * - name: the name for the cvterm,
  505. * - cv_name: the name of the cv the cvterm belongs to.
  506. * - cv_id: the primary key of the cv the cvterm belongs to.
  507. * @param $options
  508. * An associative array of options. Valid keys include:
  509. * - insert_cvterm: Insert the cvterm if it doesn't already exist. FALSE is
  510. * the default.
  511. *
  512. * @ingroup tripal_chado_module_DEPRECATED_api
  513. */
  514. function tripal_associate_cvterm($basetable, $record_id, $cvterm, $options = array()) {
  515. chado_associate_cvterm($basetable, $record_id, $cvterm, $options);
  516. }
  517. /**tripal_chado_database_api*/
  518. /**
  519. * Retrieves a chado db variable.
  520. *
  521. * Example Usage:
  522. * @code
  523. * $select_values = array(
  524. * 'name' => 'SOFP'
  525. * );
  526. * $db_object = tripal_get_db($select_values);
  527. * @endcode
  528. * The above code selects the SOFP db and returns the following object:
  529. * @code
  530. * $db_object = stdClass Object (
  531. * [db_id] => 49
  532. * [name] => SOFP
  533. * [description] =>
  534. * [urlprefix] =>
  535. * [url] =>
  536. * );
  537. * @endcode
  538. *
  539. * @param $identifier
  540. * An array with the key stating what the identifier is. Supported keys (only
  541. * on of the following unique keys is required):
  542. * - db_id: the chado db.db_id primary key.
  543. * - name: the chado db.name field (assume unique).
  544. * @param $options
  545. * An array of options. Supported keys include:
  546. * - Any keys supported by chado_generate_var(). See that function
  547. * definition for additional details.
  548. *
  549. * NOTE: the $identifier parameter can really be any array similar to $values
  550. * passed into chado_select_record(). It should fully specify the db record to
  551. * be returned.
  552. *
  553. * @return
  554. * If unique values were passed in as an identifier then an object describing
  555. * the cv will be returned (will be a chado variable from
  556. * chado_generate_var()). Otherwise, an array of objects will be returned.
  557. *
  558. * @ingroup tripal_chado_module_DEPRECATED_api
  559. */
  560. function tripal_get_db($identifiers, $options = array()) {
  561. chado_get_db($identifiers, $options);
  562. }
  563. /**
  564. * Create an options array to be used in a form element
  565. * which provides a list of all chado dbs.
  566. *
  567. * @return
  568. * An array(db_id => name) for each db in the chado db table.
  569. *
  570. * @ingroup tripal_chado_module_DEPRECATED_api
  571. */
  572. function tripal_get_db_select_options() {
  573. chado_get_db_select_options();
  574. }
  575. /**
  576. * Retrieves a chado database reference variable.
  577. *
  578. * Example Usage:
  579. * @code
  580. * $identifiers = array(
  581. * 'accession' => 'synonym',
  582. * 'db_id' => array(
  583. * 'name' => 'SOFP'
  584. * )
  585. * );
  586. * $dbxref_object = tripal_get_dbxref($identifiers);
  587. * @endcode
  588. * The above code selects the synonym database reference and returns the
  589. * following object:
  590. * @code
  591. * $dbxref_object = stdClass Object (
  592. * [dbxref_id] => 2581
  593. * [accession] => synonym
  594. * [description] =>
  595. * [version] =>
  596. * [db_db_id] => 49
  597. * [db_name] => SOFP
  598. * [db_description] =>
  599. * [db_urlprefix] =>
  600. * [db_url] =>
  601. * );
  602. * @endcode
  603. *
  604. * @param $identifier
  605. * An array apropriate for use with the chado_generate_var for uniquely
  606. * identifying a dbxref record. Alternatively, there are also some specially
  607. * handled keys. They are:
  608. * - property: An array/object describing the property to select records for.
  609. * It should at least have either a type_name (if unique across cvs) or
  610. * type_id. Other supported keys include: cv_id/cv_name (of the type),
  611. * value and rank.
  612. * @param $options
  613. * An array of options. Supported keys include:
  614. * - Any keys supported by chado_generate_var(). See that function
  615. * definition for additional details.
  616. *
  617. * NOTE: the $identifier parameter can really be any array similar to $values
  618. * passed into chado_select_record(). It should fully specify the dbxref record
  619. * to be returned.
  620. *
  621. * @return
  622. * If unique values were passed in as an identifier then an object describing
  623. * the dbxref will be returned (will be a chado variable from
  624. * chado_generate_var()). Otherwise, FALSE will be returned.
  625. *
  626. * @ingroup tripal_chado_module_DEPRECATED_api
  627. */
  628. function tripal_get_dbxref($identifiers, $options = array()) {
  629. chado_get_dbxref($identifiers, $options);
  630. }
  631. /**
  632. * Generates a URL for the controlled vocabulary term.
  633. *
  634. * If the URL and URL prefix are provided for the database record of a cvterm
  635. * then a URL can be created for the term. By default, the db.name and
  636. * dbxref.accession are concatenated and appended to the end of the db.urlprefix.
  637. * But Tripal supports the use of {db} and {accession} tokens when if present
  638. * in the db.urlprefix string will be replaced with the db.name and
  639. * dbxref.accession respectively.
  640. *
  641. * @param $dbxref
  642. * A dbxref object as created by the chado_generate_var() function.
  643. *
  644. * @return
  645. * A string containing the URL.
  646. *
  647. * @ingroup tripal_chado_module_DEPRECATED_api
  648. */
  649. function tripal_get_dbxref_url($dbxref) {
  650. chado_get_dbxref_url($dbxref);
  651. }
  652. /**
  653. * Adds a new database to the Chado DB table and returns the DB object.
  654. *
  655. * @param $values
  656. * An associative array of the values of the db (those to be inserted):
  657. * - name: The name of the database. This name is usually used as the prefix
  658. * for CV term accessions.
  659. * - description: (Optional) A description of the database. By default no
  660. * description is required.
  661. * - url: (Optional) The URL for the database.
  662. * - urlprefix: (Optional) The URL that is to be used as a prefix when
  663. * constructing a link to a database term.
  664. * @param $options
  665. * Optional. An associative array of options that can include:
  666. * - update_existing: Set this to '1' to force an update of the database if it
  667. * already exists. The default is to not update. If the database exists
  668. * then nothing is added.
  669. *
  670. * @return
  671. * An object populated with fields from the newly added database. If the
  672. * database already exists it returns the values in the current entry.
  673. *
  674. * @ingroup tripal_chado_module_DEPRECATED_api
  675. */
  676. function tripal_insert_db($values, $options = array()) {
  677. chado_insert_db($values, $options);
  678. }
  679. /**
  680. * Add a database reference.
  681. *
  682. * @param $values
  683. * An associative array of the values to be inserted including:
  684. * - db_id: the database_id of the database the reference is from.
  685. * - accession: the accession.
  686. * - version: (Optional) The version of the database reference.
  687. * - description: (Optional) A description of the database reference.
  688. *
  689. * @return
  690. * The newly inserted dbxref as an object, similar to that returned by
  691. * the chado_select_record() function.
  692. *
  693. * @ingroup tripal_chado_module_DEPRECATED_api
  694. */
  695. function tripal_insert_dbxref($values) {
  696. chado_insert_dbxref($values);
  697. }
  698. /**
  699. * Add a record to a database reference linking table (ie: feature_dbxref).
  700. *
  701. * @param $basetable
  702. * The base table for which the dbxref should be associated. Thus to associate
  703. * a dbxref with a feature the basetable=feature and dbxref_id is added to the
  704. * feature_dbxref table.
  705. * @param $record_id
  706. * The primary key of the basetable to associate the dbxref with. This should
  707. * be in integer.
  708. * @param $dbxref
  709. * An associative array describing the dbxref. Valid keys include:
  710. * 'accession' => the accession for the dbxref, 'db_name' => the name of the
  711. * database the dbxref belongs to.
  712. * 'db_id' => the primary key of the database the dbxref belongs to.
  713. * @param $options
  714. * An associative array of options. Valid keys include:
  715. * - insert_dbxref: Insert the dbxref if it doesn't already exist. TRUE is
  716. * the default.
  717. *
  718. * @ingroup tripal_chado_module_DEPRECATED_api
  719. */
  720. function tripal_associate_dbxref($basetable, $record_id, $dbxref, $options = array()) {
  721. chado_associate_dbxref($basetable, $record_id, $dbxref, $options);
  722. }
  723. /**
  724. * This function is intended to be used in autocomplete forms
  725. * for searching for accession that begin with the provided string.
  726. *
  727. * @param $db_id
  728. * The DB ID in which to search for the term.
  729. * @param $string
  730. * The string to search for.
  731. *
  732. * @return
  733. * A json array of terms that begin with the provided string.
  734. *
  735. * @ingroup tripal_chado_module_DEPRECATED_api
  736. */
  737. function tripal_autocomplete_dbxref($db_id, $string = '') {
  738. chado_autocomplete_dbxref($db_id, $string);
  739. }
  740. /**tripal_feature_api*/
  741. /**
  742. * Used for autocomplete in forms for identifying for publications.
  743. *
  744. * @param $field
  745. * The field in the publication to search on.
  746. * @param $string
  747. * The string to search for.
  748. *
  749. * @return
  750. * A json array of terms that begin with the provided string.
  751. *
  752. * @ingroup tripal_chado_module_DEPRECATED_api
  753. */
  754. function tripal_autocomplete_feature($string = '') {
  755. chado_autocomplete_feature($string);
  756. }
  757. /**
  758. * Performs a reverse compliment of a nucleotide sequence.
  759. *
  760. * @param $sequence
  761. * The nucelotide sequence.
  762. *
  763. * @return
  764. * an upper-case reverse complemented sequence.
  765. *
  766. * @ingroup tripal_chado_module_DEPRECATED_api
  767. */
  768. function tripal_reverse_compliment_sequence($sequence) {
  769. chado_reverse_compliment_sequence($sequence);
  770. }
  771. /**
  772. * Retrieves the sequences for a given feature.
  773. *
  774. * If a feature has multiple alignments or multiple relationships then
  775. * multiple sequences will be returned.
  776. *
  777. * @param $feature
  778. * An associative array describing the feature. Valid keys include:
  779. * - feature_id: The feature_id of the feature for which the sequence will
  780. * be retrieved.
  781. * - name: The feature name. This will appear on the FASTA definition line.
  782. * - parent_id: (optional) only retrieve a sequence if 'derive_from_parent'
  783. * is true and the parent matches this ID.
  784. * - featureloc_id: (optional) only retrieve a sequence if
  785. * 'derive_from_parent' is true and the alignment is defined with this
  786. * featureloc_id.
  787. * @param $options
  788. * An associative array of options. Valid keys include:
  789. * - width: Indicate the number of bases to use per line. A new line will
  790. * be added after the specified number of bases on each line.
  791. * - is_html: Set to '1' if the sequence is meant to be displayed on a web
  792. * page. This will cause a <br> tag to separate lines of the FASTA sequence.
  793. * - derive_from_parent: Set to '1' if the sequence should be obtained from
  794. * the parent to which this feature is aligned.
  795. * - aggregate: Set to '1' if the sequence should only contain sub features,
  796. * excluding intro sub feature sequence. For example, set this option to
  797. * obtain just the coding sequence of an mRNA.
  798. * - upstream: An integer specifing the number of upstream bases to include
  799. * in the output.
  800. * - downstream: An integer specifying the number of downstream bases to
  801. * include in the output.
  802. * - sub_feature_types: Only include sub features (or child features) of
  803. * the types provided in the array.
  804. * - relationship_type: If a relationship name is provided (e.g. sequence_of)
  805. * then any sequences that are in relationships of this type with matched
  806. * sequences are also included.
  807. * - relationship_part: If a relationship is provided in the preceeding
  808. * argument then the rel_part must be either 'object' or 'subject' to
  809. * indicate which side of the relationship the matched features belong.
  810. *
  811. * @return
  812. * an array of matching sequence in the following keys for each sequence:
  813. * - types: an array of feature types that were used to derive
  814. * the sequence (e.g. from an aggregated sequence)
  815. * - upstream: the number of upstream bases included in the sequence
  816. * - downstream: the number of downstream bases included in the
  817. * sequence
  818. * - defline: the definintion line used to create a FASTA sequence
  819. * - residues: the residues
  820. * - featureloc_id: the featureloc_id if the sequences is from an
  821. * alignment
  822. *
  823. * @ingroup tripal_chado_module_DEPRECATED_api
  824. */
  825. function tripal_get_feature_sequences($feature, $options) {
  826. chado_get_feature_sequences($feature, $options);
  827. }
  828. /**
  829. * Retrieves the bulk sequences for a given feature.
  830. *
  831. * @param $options
  832. * An associative array of options for selecting a feature. Valid keys include:
  833. * - org_commonname: The common name of the organism for which sequences
  834. * should be retrieved
  835. * - genus: The genus of the organism for which sequences should be retrieved
  836. * - species: The species of the organism for which sequences should be
  837. * retrieved
  838. * - analysis_name: The name of an analysis to which sequences belong. Only
  839. * those that are associated with the analysis will be retrieved.
  840. * - type: The type of feature (a sequence ontology term).
  841. * - feature_name: the name of the feature. Can be an array of feature names.
  842. * - feature_uname: the uniquename of the feature. Can be an array of
  843. * feature unique names.
  844. * - upstream: An integer specifing the number of upstream bases to include
  845. * in the output
  846. * - downstream: An integer specifying the number of downstream bases to
  847. * include in the output.
  848. * - derive_from_parent: Set to '1' if the sequence should be obtained from
  849. * the parent to which this feature is aligned.
  850. * - aggregate: Set to '1' if the sequence should only contain sub features,
  851. * excluding intro sub feature sequence. For example, set this option to
  852. * obtain just the coding sequence of an mRNA.
  853. * - sub_feature_types: Only include sub features (or child features) of
  854. * the types provided in the array
  855. * - relationship_type: If a relationship name is provided (e.g. sequence_of)
  856. * then any sequences that are in relationships of this type with matched
  857. * sequences are also included
  858. * - relationship_part: If a relationship is provided in the preceeding
  859. * argument then the rel_part must be either 'object' or 'subject' to
  860. * indicate which side of the relationship the matched features belong
  861. * - width: Indicate the number of bases to use per line. A new line will
  862. * be added after the specified number of bases on each line.
  863. * - is_html: Set to '1' if the sequence is meant to be displayed on a
  864. * web page. This will cause a <br> tag to separate lines of the FASTA
  865. * sequence.
  866. * @return
  867. * Returns an array of sequences. The sequences will be in an array with the
  868. * following keys for each sequence:
  869. * 'types' => an array of feature types that were used to derive
  870. * the sequence (e.g. from an aggregated sequence)
  871. * 'upstream' => the number of upstream bases in the sequence
  872. * 'downstream' => the number of downstream bases in the sequence
  873. * 'defline' => the definintion line used to create a FASTA sequence
  874. * 'residues' => the residues
  875. * 'featureloc_id' => the featureloc_id if from an alignment
  876. *
  877. * @ingroup tripal_chado_module_DEPRECATED_api
  878. */
  879. function tripal_get_bulk_feature_sequences($options) {
  880. chado_get_bulk_feature_sequences($options);
  881. }
  882. /**
  883. * Returns a definition line that can be used in a FASTA file.
  884. *
  885. * @param $feature
  886. * A single feature object containing all the fields from the chado.feature
  887. * table. Best case is to provide an object generated by the
  888. * chado_generate_var() function.
  889. * @param $notes
  890. * Optional: additional notes to be added to the definition line.
  891. * @param $featureloc
  892. * Optional: a single featureloc object generated using chado_generate_var
  893. * that contains a record from the chado.featureloc table. Provide this if the
  894. * sequence was obtained by using the alignment rather than from the
  895. * feature.residues column.
  896. * @param $type
  897. * Optional: the type of sequence. By default the feature type is used.
  898. * @param $length
  899. * Optional: the length of the sequence.
  900. *
  901. * @return
  902. * A string of the format: uniquename|name|type|feature_id
  903. * or if an alignment: srcfeature_name:fmin..fmax[+-]; alignment of
  904. * uniquename|name|type|feature_id.
  905. *
  906. * @ingroup tripal_chado_module_DEPRECATED_api
  907. */
  908. function tripal_get_fasta_defline($feature, $notes = '', $featureloc = null, $type = '', $length = 0) {
  909. chado_get_fasta_defline($feature, $notes, $featureloc, $type, $length);
  910. }
  911. /**
  912. * Returns a string representing a feature location in an alignment.
  913. *
  914. * @param $featureloc
  915. * A single featureloc object generated using chado_generate_var that
  916. * contains a record from the chado.featureloc table.
  917. *
  918. * @return
  919. * A string of the format: uniquename:featurelocmin..featurelocmax.strand
  920. *
  921. * @ingroup tripal_chado_module_DEPRECATED_api
  922. */
  923. function tripal_get_location_string($featureloc) {
  924. chado_get_location_string($featureloc);
  925. }
  926. /**
  927. * Retrieves a chado organism variable.
  928. *
  929. * @param $identifier
  930. * An array with the key stating what the identifier is. Supported keys (only
  931. * on of the following unique keys is required):
  932. * - organism_id: the chado organism.organism_id primary key.
  933. * - genus & species: the chado organism.genus field & organism.species field.
  934. * There are also some specially handled keys. They are:
  935. * - property: An array/object describing the property to select records for.
  936. * It should at least have either a type_name (if unique across cvs) or
  937. * type_id. Other supported keys include: cv_id/cv_name (of the type),
  938. * value and rank.
  939. * @param $options
  940. * An array of options. Supported keys include:
  941. * - Any keys supported by chado_generate_var(). See that function
  942. * definition for additional details.
  943. *
  944. * NOTE: the $identifier parameter can really be any array similar to $values
  945. * passed into chado_select_record(). It should fully specify the organism
  946. * record to be returned.
  947. *
  948. * @return
  949. * If unique values were passed in as an identifier then an object describing
  950. * the organism will be returned (will be a chado variable from
  951. * chado_generate_var()). Otherwise, FALSE will be returned.
  952. *
  953. * @ingroup tripal_chado_module_DEPRECATED_api
  954. */
  955. function tripal_get_organism($identifiers, $options = array()) {
  956. chado_get_organism($identifiers, $options);
  957. }
  958. /**
  959. * Returns the full scientific name of an organism.
  960. *
  961. * @param $organism
  962. * An organism object.
  963. * @return
  964. * The full scientific name of the organism.
  965. *
  966. * @ingroup tripal_chado_module_DEPRECATED_api
  967. */
  968. function tripal_get_organism_scientific_name($organism) {
  969. chado_get_organism_scientific_name($organism);
  970. }
  971. /**
  972. * Returns a list of organisms that are currently synced with Drupal to use in
  973. * select lists.
  974. *
  975. * @param $syncd_only
  976. * Whether or not to return all chado organisms or just those sync'd with
  977. * drupal. Defaults to TRUE (only sync'd organisms).
  978. * @return
  979. * An array of organisms sync'd with Drupal where each value is the organism
  980. * scientific name and the keys are organism_id's.
  981. *
  982. * @ingroup tripal_chado_module_DEPRECATED_api
  983. */
  984. function tripal_get_organism_select_options($syncd_only = true) {
  985. chado_get_organism_select_options($syncd_only);
  986. }
  987. /**
  988. * Return the path for the organism image.
  989. *
  990. * @param $organism
  991. * An organism table record.
  992. *
  993. * @return
  994. * If the type parameter is 'url' (the default) then the fully qualified
  995. * url to the image is returend. If no image is present then NULL is returned.
  996. *
  997. * @ingroup tripal_chado_module_DEPRECATED_api
  998. */
  999. function tripal_get_organism_image_url($organism) {
  1000. chado_get_organism_image_url($organism);
  1001. }
  1002. /**
  1003. * This function is intended to be used in autocomplete forms
  1004. * for searching for organisms that begin with the provided string.
  1005. *
  1006. * @param $text
  1007. * The string to search for.
  1008. *
  1009. * @return
  1010. * A json array of terms that begin with the provided string.
  1011. *
  1012. * @ingroup tripal_chado_module_DEPRECATED_api
  1013. */
  1014. function tripal_autocomplete_organism($text) {
  1015. chado_autocomplete_organism($text);
  1016. }
  1017. /**
  1018. * A handy function to abbreviate the infraspecific rank.
  1019. *
  1020. * @param $rank
  1021. * The rank below species.
  1022. * @return
  1023. * The proper abbreviation for the rank.
  1024. *
  1025. * @ingroup tripal_chado_module_DEPRECATED_api
  1026. */
  1027. function tripal_abbreviate_infraspecific_rank($rank) {
  1028. chado_abbreviate_infraspecific_rank($rank);
  1029. }
  1030. /** tripal_phylotree_api */
  1031. /**
  1032. * Validates an $options array for insert or update of a phylotree record.
  1033. *
  1034. * If validation passes then any values that needed validation lookups
  1035. * (such as the dbxref, analysis, leaf_type, etc) will have their approriate
  1036. * primary_keys added to the $options array, and missing default values
  1037. * will also be added.
  1038. *
  1039. * @param $val_type
  1040. * The type of validation. Can be either 'insert' or 'update'.
  1041. * @param $options
  1042. * An array of key/value pairs containing any of the valid keys for
  1043. * either the tripal_insert_phylotree() or tripal_update_phylotree()
  1044. * functions.
  1045. * @param $errors
  1046. * An empty array where validation error messages will be set. The keys
  1047. * of the array will be name of the field from the options array and the
  1048. * value is the error message.
  1049. * @param $warnings
  1050. * An empty array where validation warning messagges will be set. The
  1051. * warnings should not stop an insert or an update but should be provided
  1052. * to the user as information by a drupal_set_message() if appropriate. The
  1053. * keys of the array will be name of the field from the options array and the
  1054. * value is the error message.
  1055. * @return
  1056. * If validation failes then FALSE is returned. Any options that do not pass
  1057. * validation checks will be added in the $errors array with the key being
  1058. * the option and the value being the error message. If validation
  1059. * is successful then TRUE is returned.
  1060. *
  1061. * @ingroup tripal_chado_module_DEPRECATED_api
  1062. */
  1063. function tripal_validate_phylotree($val_type, &$options, &$errors, &$warnings) {
  1064. chado_validate_phylotree($val_type, $options, $errors, $warnings);
  1065. }
  1066. /**
  1067. * Inserts a phylotree record into Chado.
  1068. *
  1069. * This function validates the options passed prior to insertion of the record,
  1070. * and if validation passes then any values in the options array that needed
  1071. * validation lookups (such as the dbxref, analysis, leaf_type, etc) will have
  1072. * their approriate primary key values added to the options array.
  1073. *
  1074. * @param $options
  1075. * An array of key value pairs with the following keys required:
  1076. * 'name': The name of the tree. This will be displayed to users.
  1077. * 'description: A description about the tree
  1078. * 'anlaysis_id: The ID of the analysis to which this phylotree should be
  1079. * associated.
  1080. * 'analysis': If the analysis_id key is not used then the analysis name
  1081. * may be provided to identify the analysis to which the tree
  1082. * should be associated.
  1083. * 'leaf_type': A sequence ontology term or the word 'organism'. If the
  1084. * type is 'organism' then this tree represents a
  1085. * taxonomic tree. The default, if not specified, is the
  1086. * term 'polypeptide'.
  1087. * 'tree_file': The path of the file containing the phylogenetic tree to
  1088. * import or a Drupal managed_file numeric ID.
  1089. * 'format': The file format. Currently only 'newick is supported'.
  1090. *
  1091. * Optional keys:
  1092. * 'dbxref': A database cross-reference of the form DB:ACCESSION.
  1093. * Where DB is the database name, which is already present
  1094. * in Chado, and ACCESSION is the unique identifier for
  1095. * this tree in the remote database.
  1096. * 'name_re': If the leaf type is NOT 'taxonomy', then the value of
  1097. * this field can be a regular expression to pull out
  1098. * the name of the feature from the node label in the
  1099. * intput tree. If no value is provided the entire label is
  1100. * used.
  1101. * 'match': Set to 'uniquename' if the leaf nodes should be matched
  1102. * with the feature uniquename.
  1103. * 'load_now': If set, the tree will be loaded immediately if a tree_file
  1104. * is provided. Otherwise, the tree will be loaded via
  1105. * a Tripal jobs call.
  1106. * 'no_load': If set the tree file will not be loaded.
  1107. * @param $errors
  1108. * An empty array where validation error messages will be set. The keys
  1109. * of the array will be name of the field from the options array and the
  1110. * value is the error message.
  1111. * @param $warnings
  1112. * An empty array where validation warning messagges will be set. The
  1113. * warnings should not stop an insert or an update but should be provided
  1114. * to the user as information by a drupal_set_message() if appropriate. The
  1115. * keys of the array will be name of the field from the options array and the
  1116. * value is the error message.
  1117. * @return
  1118. * TRUE for success and FALSE for failure.
  1119. *
  1120. * @ingroup tripal_chado_module_DEPRECATED_api
  1121. */
  1122. function tripal_insert_phylotree(&$options, &$errors, &$warnings) {
  1123. chado_insert_phylotree($options, $errors, $warnings);
  1124. }
  1125. /**
  1126. * Updates a phylotree record into Chado.
  1127. *
  1128. * This function validates the options passed prior to update of the record
  1129. * and if validation passes then any values in the options array that needed
  1130. * validation lookups (such as the dbxref, analysis, leaf_type, etc) will have
  1131. * their approriate primary key values added to the options array. A Drupal
  1132. * File object will be added to the options array for the tree file if one
  1133. * is provided.
  1134. *
  1135. *
  1136. * @param $phylotree_id
  1137. * The ID of the phylotree to update.
  1138. * @param $options
  1139. * An array of key value pairs with the following optional keys:
  1140. * 'name': The name of the tree. This will be displayed to users.
  1141. * 'description: A description about the tree
  1142. * 'anlaysis_id: The ID of the analysis to which this phylotree should be
  1143. * associated.
  1144. * 'analysis': If the analysis_id key is not used then the analysis name
  1145. * may be provided to identify the analysis to which the tree
  1146. * should be associated.
  1147. * 'leaf_type': A sequence ontology term or the word 'organism'. If the
  1148. * type is 'organism' then this tree represents a
  1149. * taxonomic tree. The default, if not specified, is the
  1150. * term 'polypeptide'.
  1151. * 'tree_file': The path of the file containing the phylogenetic tree to
  1152. * import or a Drupal managed_file numeric ID.
  1153. * 'format': The file format. Currently only 'newick is supported'
  1154. * 'dbxref': A database cross-reference of the form DB:ACCESSION.
  1155. * Where DB is the database name, which is already present
  1156. * in Chado, and ACCESSION is the unique identifier for
  1157. * this tree in the remote database.
  1158. * 'name_re': If the leaf type is NOT 'taxonomy', then the value of
  1159. * this field can be a regular expression to pull out
  1160. * the name of the feature from the node label in the
  1161. * intput tree. If no value is provided the entire label is
  1162. * used.
  1163. * 'match': Set to 'uniquename' if the leaf nodes should be matched
  1164. * with the feature uniquename.
  1165. * 'load_now': If set, the tree will be loaded immediately if a tree_file
  1166. * is provided. Otherwise, the tree will be loaded via
  1167. * a Tripal jobs call.
  1168. *
  1169. * @ingroup tripal_chado_module_DEPRECATED_api
  1170. */
  1171. function tripal_update_phylotree($phylotree_id, &$options) {
  1172. chado_update_phylotree($phylotree_id, $options);
  1173. }
  1174. /**
  1175. * Deletes a phylotree record from Chado.
  1176. *
  1177. * @param $phylotree_id
  1178. *
  1179. * @return
  1180. * TRUE on success, FALSE on failure.
  1181. *
  1182. * @ingroup tripal_chado_module_DEPRECATED_api
  1183. */
  1184. function tripal_delete_phylotree($phylotree_id) {
  1185. chado_delete_phylotree($phylotree_id);
  1186. }
  1187. /**
  1188. * Iterates through the tree and sets the left and right indicies.
  1189. *
  1190. * @param $tree
  1191. * The tree array.
  1192. * @param $index
  1193. * This parameters is not used when the function is first called. It
  1194. * is used for recursive calls.
  1195. *
  1196. * @ingroup tripal_chado_module_DEPRECATED_api
  1197. */
  1198. function tripal_assign_phylogeny_tree_indices(&$tree, &$index = 1) {
  1199. chado_assign_phylogeny_tree_indices($tree, $index);
  1200. }
  1201. /**
  1202. * Iterates through the tree array and creates phylonodes in Chado.
  1203. *
  1204. * The function iterates through the tree in a top-down approach adding
  1205. * parent internal nodes prior to leaf nodes. Each node of the tree should have
  1206. * the following fields:
  1207. *
  1208. * -name: The name (or label) for this node.
  1209. * -depth: The depth of the node in the tree.
  1210. * -is_root: Set to 1 if this node is a root node.
  1211. * -is_leaf: Set to 1 if this node is a leaf node.
  1212. * -is_internal: Set to 1 if this node is an internal node.
  1213. * -left_index: The index of the node to the left in the tree.
  1214. * -right_index: The index of the node to the right in the tree.
  1215. * -branch_set: An array containing a list of nodes of that are children
  1216. * of the node.
  1217. * -parent: The name of the parent node.
  1218. * -organism_id: The organism_id for associtating the node with an organism.
  1219. * -properties: An array of key/value pairs where the key is the cvterm_id
  1220. * and the value is the property value. These properties
  1221. * will be assocaited with the phylonode.
  1222. *
  1223. * Prior to importing the tree the indicies can be set by using the
  1224. * chado_assign_phylogeny_tree_indices() function.
  1225. *
  1226. * @param $tree
  1227. * The tree array.
  1228. * @param $phylotree.
  1229. * The phylotree object (from Chado).
  1230. * @param $options
  1231. * The options provide some direction for how the tree is imported. The
  1232. * following keys can be used:
  1233. * -taxonomy: Set to 1 if this tree is a taxonomic tree. Set to 0
  1234. * otherwise.
  1235. * -leaf_type: Set to the leaf type name. If this is a non-taxonomic tree
  1236. * that is associated with features, then this should be the
  1237. * Sequence Ontology term for the feature (e.g. polypeptide).
  1238. * If this is a taxonomic tree then this option is not needed.
  1239. * -match: Set to either 'name' or 'uniquename'. This is used for
  1240. * matching the feature name or uniquename with the node name.
  1241. * This is not needed for taxonomic trees.
  1242. * -match_re: Set to a regular that can be used for matching the node
  1243. * name with the feature name if the node name is not
  1244. * identical to the feature name.
  1245. * @param $vocab
  1246. * Optional. An array containing a set of key/value pairs that maps node
  1247. * types to CV terms. The keys must be 'root', 'internal' or 'leaf'. If
  1248. * no vocab is provded then the terms provided by the tripal_phylogeny
  1249. * CV will be used.
  1250. * @param $parent
  1251. * This argument is not needed when the funtion is first called. This
  1252. * function is recursive and this argument is used on recursive calls.
  1253. *
  1254. * @ingroup tripal_chado_module_DEPRECATED_api
  1255. */
  1256. function tripal_phylogeny_import_tree(&$tree, $phylotree, $options, $vocab = array(), $parent = null) {
  1257. chado_phylogeny_import_tree($tree, $phylotree, $options, $vocab, $parent);
  1258. }
  1259. /**
  1260. * Get the vocabulary terms used to describe nodes in the tree.
  1261. *
  1262. * @return
  1263. * Array of vocab info or FALSE on failure.
  1264. *
  1265. * @ingroup tripal_chado_module_DEPRECATED_api
  1266. */
  1267. function tripal_phylogeny_get_node_types_vocab() {
  1268. chado_phylogeny_get_node_types_vocab();
  1269. }
  1270. /**
  1271. * Imports a tree file.
  1272. *
  1273. * This function is used as a wrapper for loading a phylogenetic tree using
  1274. * any number of file loaders.
  1275. *
  1276. * @param $file_name
  1277. * The name of the file containing the phylogenetic tree to import.
  1278. * @param $format
  1279. * The format of the file. Currently only the 'newick' file format is
  1280. * supported.
  1281. * @param $options
  1282. * Options if the phylotree record already exists:
  1283. * 'phylotree_id': The imported nodes will be associated with this tree.
  1284. * 'leaf_type': A sequence ontology term or the word 'organism'. If the
  1285. * type is 'organism' then this tree represents a
  1286. * taxonomic tree. The default, if not specified, is the
  1287. * term 'polypeptide'.
  1288. * 'name_re': If the leaf type is NOT 'taxonomy', then the value of
  1289. * this field can be a regular expression to pull out
  1290. * the name of the feature from the node label in the
  1291. * intput tree. If no value is provided the entire label is
  1292. * used.
  1293. * 'match': Set to 'uniquename' if the leaf nodes should be matched
  1294. * with the feature uniquename.
  1295. *
  1296. * @ingroup tripal_chado_module_DEPRECATED_api
  1297. */
  1298. function tripal_phylogeny_import_tree_file($file_name, $format, $options = array(), $job_id = null) {
  1299. chado_phylogeny_import_tree_file($file_name, $format, $options, $job_id);
  1300. }
  1301. /** tripal_pub_api */
  1302. /**
  1303. * Retrieves a chado publication array.
  1304. *
  1305. * @param $identifier
  1306. * An array used to uniquely identify a publication. This array has the same
  1307. * format as that used by the chado_generate_var(). The following keys can be
  1308. * useful for uniquely identifying a publication as they should be unique:
  1309. * - pub_id: the chado pub.pub_id primary key.
  1310. * - nid: the drupal nid of the publication.
  1311. * - uniquename: A value to matach with the pub.uniquename field.
  1312. * There are also some specially handled keys. They are:
  1313. * - property: An array describing the property to select records for. It
  1314. * should at least have either a 'type_name' key (if unique across cvs) or
  1315. * 'type_id' key. Other supported keys include: 'cv_id', 'cv_name'
  1316. * (of the type), 'value' and 'rank'
  1317. * - dbxref: The database cross reference accession. It should be in the
  1318. * form DB:ACCESSION, where DB is the database name and ACCESSION is the
  1319. * unique publication identifier (e.g. PMID:4382934)
  1320. * - dbxref_id: The dbxref.dbxref_id of the publication.
  1321. * @param $options
  1322. * An array of options. Supported keys include:
  1323. * - Any keys supported by chado_generate_var(). See that function
  1324. * definition for additional details.
  1325. *
  1326. * NOTE: the $identifier parameter can really be any array similar to $values
  1327. * passed into chado_select_record(). It should fully specify the pub record to
  1328. * be returned.
  1329. *
  1330. * @return
  1331. * If a singe publication is retreived using the identifiers, then a
  1332. * publication array will be returned. The array is of the same format
  1333. * returned by the chado_generate_var() function. Otherwise, FALSE will be
  1334. * returned.
  1335. *
  1336. * @ingroup tripal_chado_module_DEPRECATED_api
  1337. */
  1338. function tripal_get_publication($identifiers, $options = array()) {
  1339. chado_get_publication($identifiers, $options);
  1340. }
  1341. /**
  1342. * The publication table of Chado only has a unique constraint for the
  1343. * uniquename of the publiation, but in reality a publication can be considered
  1344. * unique by a combination of the title, publication type, published year and
  1345. * series name (e.g. journal name or conference name). The site administrator
  1346. * can configure how publications are determined to be unique. This function
  1347. * uses the configuration specified by the administrator to look for publications
  1348. * that match the details specified by the $pub_details argument
  1349. * and indicates if one ore more publications match the criteria.
  1350. *
  1351. * @param $pub_details
  1352. * An associative array with details about the publications. The expected keys
  1353. * are:
  1354. * 'Title': The title of the publication.
  1355. * 'Year': The published year of the publication.
  1356. * 'Publication Type': An array of publication types. A publication can
  1357. * have more than one type.
  1358. * 'Series Name': The series name of the publication.
  1359. * 'Journal Name': An alternative to 'Series Name'.
  1360. * 'Conference Name': An alternative to 'Series Name'.
  1361. * 'Citation': The publication citation (this is the value saved
  1362. * in the pub.uniquename field and must be unique).
  1363. *
  1364. * If this key is present it will also be checked
  1365. * 'Publication Dbxref': A database cross reference of the form DB:ACCESSION
  1366. * where DB is the name of the database and ACCESSION
  1367. * is the unique identifier (e.g PMID:3483139).
  1368. *
  1369. * @return
  1370. * An array containing the pub_id's of matching publications. Returns an
  1371. * empty array if no pubs match.
  1372. *
  1373. * @ingroup tripal_chado_module_DEPRECATED_api
  1374. */
  1375. function tripal_publication_exists($pub_details) {
  1376. chado_publication_exists($pub_details);
  1377. }
  1378. /**
  1379. * Used for autocomplete in forms for identifying for publications.
  1380. *
  1381. * @param $field
  1382. * The field in the publication to search on.
  1383. * @param $string
  1384. * The string to search for.
  1385. *
  1386. * @return
  1387. * A json array of terms that begin with the provided string.
  1388. *
  1389. * @ingroup tripal_chado_module_DEPRECATED_api
  1390. */
  1391. function tripal_autocomplete_pub($string = '') {
  1392. chado_autocomplete_pub($string);
  1393. }
  1394. /**
  1395. * Imports a singe publication specified by a remote database cross reference.
  1396. *
  1397. * @param $pub_dbxref
  1398. * The unique database ID for the record to update. This value must
  1399. * be of the format DB_NAME:ACCESSION where DB_NAME is the name of the
  1400. * database (e.g. PMID or AGL) and the ACCESSION is the unique identifier
  1401. * for the record in the database.
  1402. * @param $do_contact
  1403. * Set to TRUE if authors should automatically have a contact record added
  1404. * to Chado.
  1405. * @param $do_update
  1406. * If set to TRUE then the publication will be updated if it already exists
  1407. * in the database.
  1408. *
  1409. * @ingroup tripal_chado_module_DEPRECATED_api
  1410. */
  1411. function tripal_import_pub_by_dbxref($pub_dbxref, $do_contact = false, $do_update = true) {
  1412. chado_import_pub_by_dbxref($pub_dbxref, $do_contact, $do_update);
  1413. }
  1414. /**
  1415. * Imports all publications for all active import setups.
  1416. *
  1417. * @param $report_email
  1418. * A list of email address, separated by commas, that should be notified
  1419. * once importing has completed.
  1420. * @param $do_update
  1421. * If set to TRUE then publications that already exist in the Chado database
  1422. * will be updated, whereas if FALSE only new publications will be added.
  1423. *
  1424. * @ingroup tripal_chado_module_DEPRECATED_api
  1425. */
  1426. function tripal_execute_active_pub_importers($report_email = false, $do_update = false) {
  1427. chado_execute_active_pub_importers($report_email, $do_update);
  1428. }
  1429. /**
  1430. * Updates publication records.
  1431. *
  1432. * Updates publication records that currently exist in the Chado pub table
  1433. * with the most recent data in the remote database.
  1434. *
  1435. * @param $do_contact
  1436. * Set to TRUE if authors should automatically have a contact record added
  1437. * to Chado. Contacts are added using the name provided by the remote
  1438. * database.
  1439. * @param $dbxref
  1440. * The unique database ID for the record to update. This value must
  1441. * be of the format DB_NAME:ACCESSION where DB_NAME is the name of the
  1442. * database (e.g. PMID or AGL) and the ACCESSION is the unique identifier
  1443. * for the record in the database.
  1444. * @param $db
  1445. * The name of the remote database to update. If this value is provided and
  1446. * no dbxref then all of the publications currently in the Chado database
  1447. * for this remote database will be updated.
  1448. *
  1449. * @ingroup tripal_chado_module_DEPRECATED_api
  1450. */
  1451. function tripal_reimport_publications($do_contact = false, $dbxref = null, $db = null) {
  1452. chado_reimport_publications($do_contact, $dbxref, $db);
  1453. }
  1454. /**
  1455. * Launch the Tripal job to generate citations.
  1456. *
  1457. * This function will recreate citations for all publications currently
  1458. * loaded into Tripal. This is useful to create a consistent format for
  1459. * all citations.
  1460. *
  1461. * @param $options
  1462. * Options pertaining to what publications to generate citations for.
  1463. * One of the following must be present:
  1464. * - all: Create and replace citation for all pubs.
  1465. * - new: Create citation for pubs that don't already have one.
  1466. *
  1467. * @ingroup tripal_chado_module_DEPRECATED_api
  1468. */
  1469. function tripal_pub_create_citations($options) {
  1470. chado_pub_create_citations($options);
  1471. }
  1472. /**
  1473. * This function generates citations for publications. It requires
  1474. * an array structure with keys being the terms in the Tripal
  1475. * publication ontology. This function is intended to be used
  1476. * for any function that needs to generate a citation.
  1477. *
  1478. * @param $pub
  1479. * An array structure containing publication details where the keys
  1480. * are the publication ontology term names and values are the
  1481. * corresponding details. The pub array can contain the following
  1482. * keys with corresponding values:
  1483. * - Publication Type: an array of publication types. a publication can
  1484. * have more than one type.
  1485. * - Authors: a string containing all of the authors of a publication.
  1486. * - Journal Name: a string containing the journal name.
  1487. * - Journal Abbreviation: a string containing the journal name abbreviation.
  1488. * - Series Name: a string containing the series (e.g. conference
  1489. * proceedings) name.
  1490. * - Series Abbreviation: a string containing the series name abbreviation
  1491. * - Volume: the serives volume number.
  1492. * - Issue: the series issue number.
  1493. * - Pages: the page numbers for the publication.
  1494. * - Publication Date: A date in the format "Year Month Day".
  1495. *
  1496. * @return
  1497. * A text string containing the citation.
  1498. *
  1499. * @ingroup tripal_chado_module_DEPRECATED_api
  1500. */
  1501. function tripal_pub_create_citation($pub) {
  1502. chado_pub_create_citation($pub);
  1503. }
  1504. /**
  1505. * Retrieves the minimal information to uniquely describe any publication.
  1506. *
  1507. * The returned array is an associative array where the keys are
  1508. * the controlled vocabulary terms in the form [vocab]:[accession].
  1509. *
  1510. * @param $pub
  1511. * A publication object as created by chado_generate_var().
  1512. *
  1513. * @return
  1514. * An array with the following keys: 'Citation', 'Abstract', 'Authors',
  1515. * 'URL'. All keys are term names in the Tripal Publication Ontology :TPUB.
  1516. *
  1517. * @ingroup tripal_chado_module_DEPRECATED_api
  1518. */
  1519. function tripal_get_minimal_pub_info($pub) {
  1520. chado_get_minimal_pub_info($pub);
  1521. }
  1522. /** tripal_stock_api */
  1523. /**
  1524. * Retrieves a chado stock variable
  1525. *
  1526. * @param $identifier
  1527. * An array with the key stating what the identifier is. Supported keys (only
  1528. * one of the following unique keys is required):
  1529. * - stock_id: the chado stock.stock_id primary key
  1530. * - nid: the drupal nid of the stock
  1531. * There are also some specially handled keys. They are:
  1532. * - property: An array/object describing the property to select records for.
  1533. * It should at least have either a type_name (if unique across cvs) or
  1534. * type_id. Other supported keys include: cv_id/cv_name (of the type),
  1535. * value and rank
  1536. * @param $options
  1537. * An array of options. Supported keys include:
  1538. * - Any keys supported by chado_generate_var(). See that function
  1539. * definition for additional details.
  1540. *
  1541. * NOTE: the $identifier parameter can really be any array similar to $values
  1542. * passed into chado_select_record(). It should fully specify the stock record
  1543. * to be returned.
  1544. *
  1545. * @return
  1546. * If unique values were passed in as an identifier then an object describing
  1547. * the stock will be returned (will be a chado variable from
  1548. * chado_generate_var()). Otherwise, FALSE will be returned.
  1549. *
  1550. * @ingroup tripal_chado_module_DEPRECATED_api
  1551. */
  1552. function tripal_get_stock($identifiers, $options = array()) {
  1553. chado_get_stock($identifiers, $options);
  1554. }
  1555. /**
  1556. * Retrieves a chado stock variable.
  1557. *
  1558. * @param $identifier
  1559. * An array with the key stating what the identifier is. Supported keys
  1560. * include any field in the stock table. See the chado_select_record() $values
  1561. * parameter for additional details including an example.
  1562. * @param $options
  1563. * An array of options. Supported keys include:
  1564. * - Any keys supported by chado_generate_var(). See that function
  1565. * definition for additional details.
  1566. *
  1567. * @return
  1568. * An array of stock objects matching the criteria.
  1569. *
  1570. * @ingroup tripal_chado_module_DEPRECATED_api
  1571. */
  1572. function tripal_get_multiple_stocks($identifiers, $options = array()) {
  1573. chado_get_multiple_stocks($identifiers, $options);
  1574. }