tripal_chado.module.DEPRECATED.api.inc 58 KB

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