tripal_chado.module.DEPRECATED.api.inc 57 KB

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