tripal_chado.module.DEPRECATED.api.inc 62 KB

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