tripal_chado.module.DEPRECATED.api.inc 58 KB

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