chado_linker__relationship.inc 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  1. <?php
  2. class chado_linker__relationship extends TripalField {
  3. /**
  4. * @see TripalField::field_info()
  5. */
  6. function field_info() {
  7. return array(
  8. 'label' => t('Relationships'),
  9. 'description' => t('Relationships between records.'),
  10. 'default_widget' => 'chado_linker__relationship_widget',
  11. 'default_formatter' => 'chado_linker__relationship_formatter',
  12. 'settings' => array(),
  13. 'storage' => array(
  14. 'type' => 'field_chado_storage',
  15. 'module' => 'tripal_chado',
  16. 'active' => TRUE
  17. ),
  18. );
  19. }
  20. /**
  21. * @see TripalField::attach_info()
  22. */
  23. function attach_info($entity_type, $bundle, $target) {
  24. $field_info = array();
  25. $table_name = $target['data_table'];
  26. $type_table = $target['type_table'];
  27. $type_field = $target['field'];
  28. $cv_id = $target['cv_id'];
  29. $cvterm_id = $target['cvterm_id'];
  30. // If the linker table does not exists then we don't want to add attach.
  31. $rel_table = $table_name . '_relationship';
  32. if (!chado_table_exists($rel_table)) {
  33. return $field_info;
  34. }
  35. $schema = chado_get_schema($rel_table);
  36. $pkey = $schema['primary key'][0];
  37. // Initialize the field array.
  38. $field_info = array(
  39. 'field_name' => $table_name . '_relationship',
  40. 'field_type' => 'chado_linker__relationship',
  41. 'widget_type' => 'chado_linker__relationship_widget',
  42. 'widget_settings' => array('display_label' => 1),
  43. 'description' => 'A generic field for displaying relationships between data types',
  44. 'label' => 'Relationships',
  45. 'is_required' => 0,
  46. 'cardinality' => FIELD_CARDINALITY_UNLIMITED,
  47. 'storage' => 'field_chado_storage',
  48. 'field_settings' => array(
  49. 'chado_table' => $rel_table,
  50. 'chado_column' => $pkey,
  51. 'base_table' => $table_name,
  52. 'semantic_web' => 'SBO:0000374',
  53. ),
  54. );
  55. return $field_info;
  56. }
  57. /**
  58. * @see TripalField::widget_info()
  59. */
  60. function widget_info() {
  61. return array(
  62. 'label' => t('Relationship Settings'),
  63. 'field types' => array('chado_linker__relationship')
  64. );
  65. }
  66. /**
  67. * @see TripalField::formatter_info()
  68. */
  69. function formatter_info() {
  70. return array(
  71. 'label' => t('Relationships'),
  72. 'field types' => array('chado_linker__relationship'),
  73. 'settings' => array(
  74. ),
  75. );
  76. }
  77. /**
  78. * @see TripalField::formatter_view()
  79. */
  80. function formatter_view(&$element, $entity_type, $entity,
  81. $field, $instance, $langcode, $items, $display) {
  82. // Get the settings
  83. $settings = $display['settings'];
  84. $rows = array();
  85. $headers = array('Subject' ,'Type', 'Object');
  86. $headers = array('Relationship');
  87. foreach ($items as $delta => $item) {
  88. if (!$item['value']) {
  89. continue;
  90. }
  91. $subject_name = $item['value']['subject']['name'];
  92. $subject_type = $item['value']['subject']['type'];
  93. $object_name = $item['value']['object']['name'];
  94. $object_type = $item['value']['object']['type'];
  95. $phrase = $item['value']['phrase'];
  96. // Handle some special cases.
  97. // For mRNA objects we don't want to show the CDS, exons, 5' UTR, etc.
  98. // we want to show the parent gene and the protein.
  99. if ($object_type == 'mRNA' and ($subject_type != 'polypeptide')) {
  100. continue;
  101. }
  102. if ($subject_type == 'mRNA' and ($object_type != 'gene')) {
  103. continue;
  104. }
  105. $phrase = preg_replace("/$subject_type/", "<b>$subject_type</b>", $phrase);
  106. $phrase = preg_replace("/$object_type/", "<b>$object_type</b>", $phrase);
  107. if (array_key_exists('entity_id', $item['value']['object'])) {
  108. $object_entity_id = $item['value']['object']['entity_id'];
  109. if ($object_entity_id != $entity->id) {
  110. $link = l($object_name, 'bio_data/' . $object_entity_id);
  111. $phrase = preg_replace("/$object_name/", $link, $phrase);
  112. }
  113. }
  114. if (array_key_exists('entity_id', $item['value']['subject'])) {
  115. $subject_entity_id = $item['value']['subject']['entity_id'];
  116. if ($subject_entity_id != $entity->id) {
  117. $link = l($subject_name, 'bio_data/' . $subject_entity_id);
  118. $phrase = preg_replace("/$subject_name/", $link, $phrase);
  119. }
  120. }
  121. $rows[] = array($phrase);
  122. }
  123. // the $table array contains the headers and rows array as well as other
  124. // options for controlling the display of the table. Additional
  125. // documentation can be found here:
  126. // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
  127. $table = array(
  128. 'header' => $headers,
  129. 'rows' => $rows,
  130. 'attributes' => array(
  131. 'id' => 'chado-linker--relationship-table',
  132. 'class' => 'tripal-data-table'
  133. ),
  134. 'sticky' => FALSE,
  135. 'caption' => '',
  136. 'colgroups' => array(),
  137. 'empty' => 'There are no relationships',
  138. );
  139. // once we have our table array structure defined, we call Drupal's theme_table()
  140. // function to generate the table.
  141. $element[$delta] = array(
  142. '#type' => 'markup',
  143. '#markup' => theme_table($table),
  144. );
  145. }
  146. /**
  147. * @see TripalField::widget_form()
  148. */
  149. function widget_form(&$widget, $form, $form_state, $field, $instance,
  150. $langcode, $items, $delta, $element) {
  151. $field_name = $field['field_name'];
  152. $field_type = $field['type'];
  153. $field_table = $field['settings']['chado_table'];
  154. $field_column = $field['settings']['chado_column'];
  155. // Get the FK column that links to the base table.
  156. $chado_table = $field['settings']['chado_table'];
  157. $base_table = $field['settings']['base_table'];
  158. $schema = chado_get_schema($chado_table);
  159. $pkey = $schema['primary key'][0];
  160. $fkeys = array_values($schema['foreign keys'][$base_table]['columns']);
  161. $fkey = $fkeys[0];
  162. // Get the field defaults.
  163. $record_id = '';
  164. $fkey_value = $element['#entity']->chado_record_id;
  165. $subject_id = '';
  166. $subject_uniquename = '';
  167. $type_id = '';
  168. $type = '';
  169. $object_id = '';
  170. $object_uniquename = '';
  171. $value = '';
  172. $rank = '';
  173. // If the field already has a value then it will come through the $items
  174. // array. This happens when editing an existing record.
  175. if (array_key_exists($delta, $items)) {
  176. $record_id = $items[$delta][$field_table . '__' . $pkey];
  177. $subject_id = $items[$delta][$field_table . '__subject_id'];
  178. $subject_uniquename = $items[$delta][$field_table . '__subject_id--uniquename'];
  179. $type_id = $items[$delta][$field_table . '__type_id'];
  180. $type = $items[$delta][$field_table . '__type_id--name'];
  181. $object_id = $items[$delta][$field_table . '__object_id'];
  182. $object_uniquename = $items[$delta][$field_table . '__object_id--uniquename'];
  183. $value = $items[$delta][$field_table . '__value'];
  184. $rank = $items[$delta][$field_table . '__rank'];
  185. }
  186. // Check $form_state['values'] to see if an AJAX call set the values.
  187. if (array_key_exists('values', $form_state) and array_key_exists($delta, $form_state['values'])) {
  188. $record_id = tripal_chado_get_field_form_values($field_name, $form_state, $delta, $field_table . '__' . $pkey);
  189. $subject_id = tripal_chado_get_field_form_values($field_name, $form_state, $delta, $field_table . '__subject_id');
  190. $subject_uniquename = tripal_chado_get_field_form_values($field_name, $form_state, $delta, $field_table . '__subject_id--uniquename');
  191. $type_id = tripal_chado_get_field_form_values($field_name, $form_state, $delta, $field_table . '__type_id');
  192. $type = tripal_chado_get_field_form_values($field_name, $form_state, $delta, $field_table . '__type_id--name');
  193. $object_id = tripal_chado_get_field_form_values($field_name, $form_state, $delta, $field_table . '__object_id');
  194. $object_uniquename = tripal_chado_get_field_form_values($field_name, $form_state, $delta, $field_table . '__object_id--uniquename');
  195. $value = tripal_chado_get_field_form_values($field_name, $form_state, $delta, $field_table . '__value');
  196. $rank = tripal_chado_get_field_form_values($field_name, $form_state, $delta, $field_table . '__rank');
  197. }
  198. $widget['#table_name'] = $chado_table;
  199. $widget['#fkey_field'] = $fkey;
  200. // $widget['#element_validate'] = array('chado_linker__relationship_validate');
  201. // $widget['#theme'] = 'chado_linker__relationship_widget';
  202. $widget['#prefix'] = "<span id='$chado_table-$delta'>";
  203. $widget['#suffix'] = "</span>";
  204. $widget['value'] = array(
  205. '#type' => 'value',
  206. '#value' => array_key_exists($delta, $items) ? $items[$delta]['value'] : '',
  207. );
  208. $widget[$field_table . '__' . $pkey] = array(
  209. '#type' => 'value',
  210. '#default_value' => $record_id,
  211. );
  212. $widget[$field_table . '__subject_id'] = array(
  213. '#type' => 'value',
  214. '#default_value' => $subject_id,
  215. );
  216. $widget[$field_table . '__type_id'] = array(
  217. '#type' => 'value',
  218. '#default_value' => $type_id,
  219. );
  220. $widget[$field_table . '__object_id'] = array(
  221. '#type' => 'value',
  222. '#default_value' => $object_id,
  223. );
  224. if (array_key_exists('value', $schema['fields'])) {
  225. $widget[$field_table . '__value'] = array(
  226. '#type' => 'value',
  227. '#default_value' => $value,
  228. );
  229. }
  230. if (array_key_exists('rank', $schema['fields'])) {
  231. $widget[$field_table . '__rank'] = array(
  232. '#type' => 'value',
  233. '#default_value' => $rank,
  234. );
  235. }
  236. $widget[$field_table . '__subject_id--uniquename'] = array(
  237. '#type' => 'textfield',
  238. '#title' => t('Subject Uniquename'),
  239. '#default_value' => $subject_uniquename,
  240. '#required' => $element['#required'],
  241. '#maxlength' => array_key_exists('length', $schema['fields']['subject_id']) ? $schema['fields']['subject_id']['length'] : 255,
  242. '#size' => 15,
  243. );
  244. $options = array($type);
  245. $widget[$field_table . '__cvterm_id--name'] = array(
  246. '#type' => 'select',
  247. '#title' => t('Type'),
  248. '#options' => $options,
  249. '#required' => $element['#required'],
  250. '#default_value' => $type,
  251. '#ajax' => array(
  252. 'callback' => "chado_linker__relationship_widget_form_ajax_callback",
  253. 'wrapper' => "$field_name-relationship--cvterm-id-$delta",
  254. 'effect' => 'fade',
  255. 'method' => 'replace'
  256. ),
  257. );
  258. $widget[$field_table . '__object_id--uniquename'] = array(
  259. '#type' => 'textfield',
  260. '#title' => t('Object Uniquename'),
  261. '#default_value' => $object_uniquename,
  262. '#required' => $element['#required'],
  263. '#maxlength' => array_key_exists('length', $schema['fields']['object_id']) ? $schema['fields']['object_id']['length'] : 255,
  264. '#size' => 15,
  265. );
  266. }
  267. /**
  268. * @see TripalField::load()
  269. */
  270. function load($field, $entity, $details) {
  271. $settings = $field['settings'];
  272. $record = $details['record'];
  273. $field_name = $field['field_name'];
  274. $field_type = $field['type'];
  275. $field_table = $field['settings']['chado_table'];
  276. $field_column = $field['settings']['chado_column'];
  277. $base_table = $field['settings']['base_table'];
  278. // Get the PKey for this table
  279. $schema = chado_get_schema($field_table);
  280. $pkey = $schema['primary key'][0];
  281. // Get the Pkeys for the subject and object tables
  282. $subject_fkey_table = '';
  283. $object_fkey_table = '';
  284. $fkeys = $schema['foreign keys'];
  285. foreach ($fkeys as $fktable => $details) {
  286. foreach ($details['columns'] as $fkey_lcolumn => $fkey_rcolumn) {
  287. if ($fkey_lcolumn == 'subject_id') {
  288. $subject_fkey_table = $fktable;
  289. }
  290. if ($fkey_lcolumn == 'object_id') {
  291. $object_fkey_table = $fktable;
  292. }
  293. }
  294. }
  295. $subject_schema = chado_get_schema($subject_fkey_table);
  296. $object_schema = chado_get_schema($object_fkey_table);
  297. $subject_pkey = $subject_schema['primary key'][0];
  298. $object_pkey = $object_schema['primary key'][0];
  299. // Get the FK that links to the base record.
  300. $schema = chado_get_schema($field_table);
  301. $fkey_lcolumn = key($schema['foreign keys'][$base_table]['columns']);
  302. $fkey_rcolumn = $schema['foreign keys'][$base_table]['columns'][$fkey_lcolumn];
  303. // Set some defaults for the empty record.
  304. $entity->{$field_name}['und'][0] = array(
  305. 'value' => array(),
  306. $field_table . '__' . $pkey => '',
  307. $field_table . '__subject_id' => '',
  308. $field_table . '__object_id' => '',
  309. $field_table . '__type_id' => TRUE,
  310. );
  311. if (array_key_exists('value', $schema['fields'])) {
  312. $entity->{$field_name}['und'][0][$field_table . '__value'] = '';
  313. }
  314. if (array_key_exists('rank', $schema['fields'])) {
  315. $entity->{$field_name}['und'][0][$field_table . '__rank'] = '';
  316. }
  317. if (!$record) {
  318. return;
  319. }
  320. // Expand the object to include the relationships.
  321. $options = array(
  322. 'return_array' => 1,
  323. // we don't want to fully recurse we only need information about the
  324. // relationship type and the object and subject
  325. 'include_fk' => array(
  326. 'type_id' => 1,
  327. 'object_id' => array(
  328. 'type_id' => 1,
  329. ),
  330. 'subject_id' => array(
  331. 'type_id' => 1,
  332. ),
  333. ),
  334. );
  335. $rel_table = $base_table . '_relationship';
  336. $schema = chado_get_schema($rel_table);
  337. if (array_key_exists('rank', $schema['fields'])) {
  338. $options['order_by'] = array('rank' => 'ASC');
  339. }
  340. $record = chado_expand_var($record, 'table', $rel_table, $options);
  341. if (!$record->$rel_table) {
  342. return;
  343. }
  344. $srelationships = $record->$rel_table->subject_id;
  345. $orelationships = $record->$rel_table->object_id;
  346. $i = 0;
  347. if ($orelationships) {
  348. foreach ($orelationships as $relationship) {
  349. $rel_acc = $relationship->type_id->dbxref_id->db_id->name . ':' . $relationship->type_id->dbxref_id->accession;
  350. $rel_type = $relationship->type_id->name;
  351. $verb = $this->get_rel_verb($rel_type);
  352. $subject_name = $relationship->subject_id->name;
  353. $subject_type = $relationship->subject_id->type_id->name;
  354. $object_name = $relationship->object_id->name;
  355. $object_type = $relationship->object_id->type_id->name;
  356. $entity->{$field_name}['und'][$i]['value'] = array(
  357. '@type' => $rel_acc,
  358. 'subject' => array(
  359. '@type' => $relationship->subject_id->type_id->dbxref_id->db_id->name .
  360. ':' . $relationship->subject_id->type_id->dbxref_id->accession,
  361. 'type' => $subject_type,
  362. 'name' => $subject_name,
  363. ),
  364. 'type' => $relationship->type_id->name,
  365. 'object' => array(
  366. '@type' => $relationship->object_id->type_id->dbxref_id->db_id->name .
  367. ':' . $relationship->object_id->type_id->dbxref_id->accession,
  368. // TODO the entity_id should not be here.... wherre to put it.
  369. 'entity_id' => $entity->id,
  370. 'entity_type' => 'TripalEntity',
  371. 'type' => $object_type,
  372. 'name' => $object_name,
  373. )
  374. );
  375. if (property_exists($relationship->subject_id, 'uniquename')) {
  376. $subject_name = $relationship->subject_id->uniquename;
  377. $entity->{$field_name}['und'][$i]['value']['subject']['name'] = $subject_name;
  378. }
  379. if (property_exists($relationship->object_id, 'uniquename')) {
  380. $object_name = $relationship->object_id->uniquename;
  381. $entity->{$field_name}['und'][$i]['value']['object']['name'] = $object_name;
  382. }
  383. if (property_exists($relationship->subject_id, 'entity_id')) {
  384. $entity_id = $relationship->subject_id->entity_id;
  385. $entity->{$field_name}['und'][$i]['value']['subject']['entity_id'] = $entity_id;
  386. $entity->{$field_name}['und'][$i]['value']['subject']['entity_type'] = 'TripalEntity';
  387. }
  388. $rel_type_clean = lcfirst(preg_replace('/_/', ' ', $rel_type));
  389. $entity->{$field_name}['und'][$i]['value']['phrase'] = 'The ' . $subject_type . ', ' .
  390. $subject_name . ', ' . $verb . ' ' . $rel_type_clean . ' this ' .
  391. $object_type . '.';
  392. $entity->{$field_name}['und'][$i][$field_table . '__' . $pkey] = $relationship->$pkey;
  393. $entity->{$field_name}['und'][$i][$field_table . '__subject_id'] = $relationship->subject_id->$subject_pkey;
  394. $entity->{$field_name}['und'][$i][$field_table . '__subject_id--uniquename'] = $relationship->subject_id->uniquename;
  395. $entity->{$field_name}['und'][$i][$field_table . '__type_id'] = $relationship->type_id->cvterm_id;
  396. $entity->{$field_name}['und'][$i][$field_table . '__type_id--name'] = $relationship->type_id->name;
  397. $entity->{$field_name}['und'][$i][$field_table . '__object_id'] = $relationship->object_id->$object_pkey;
  398. $entity->{$field_name}['und'][$i][$field_table . '__object_id--uniquename'] = $relationship->object_id->uniquename;
  399. if (array_key_exists('value', $schema['fields'])) {
  400. $entity->{$field_name}['und'][$i][$field_table . '__value'] = $relationship->value;
  401. }
  402. if (array_key_exists('rank', $schema['fields'])) {
  403. $entity->{$field_name}['und'][$i][$field_table . '__rank'] = $relationship->rank;
  404. }
  405. $i++;
  406. }
  407. }
  408. if ($srelationships) {
  409. foreach ($srelationships as $relationship) {
  410. $rel_acc = $relationship->type_id->dbxref_id->db_id->name . ':' . $relationship->type_id->dbxref_id->accession;
  411. $rel_type = $relationship->type_id->name;
  412. $verb = $this->get_rel_verb($rel_type);
  413. $subject_name = $relationship->subject_id->name;
  414. $subject_type = $relationship->subject_id->type_id->name;
  415. $object_name = $relationship->object_id->name;
  416. $object_type = $relationship->object_id->type_id->name;
  417. $entity->{$field_name}['und'][$i]['value'] = array(
  418. '@type' => $rel_acc,
  419. 'subject' => array(
  420. '@type' => $relationship->subject_id->type_id->dbxref_id->db_id->name .
  421. ':' . $relationship->subject_id->type_id->dbxref_id->accession,
  422. 'type' => $subject_type,
  423. 'name' => $subject_name,
  424. 'entity_id' => $entity->id,
  425. 'entity_type' => 'TripalEntity',
  426. ),
  427. 'type' => $relationship->type_id->name,
  428. 'object' => array(
  429. '@type' => $relationship->object_id->type_id->dbxref_id->db_id->name .
  430. ':' . $relationship->object_id->type_id->dbxref_id->accession,
  431. 'type' => $object_type,
  432. 'name' => $object_name,
  433. )
  434. );
  435. if (property_exists($relationship->subject_id, 'uniquename')) {
  436. $subject_name = $relationship->subject_id->uniquename;
  437. $entity->{$field_name}['und'][$i]['value']['subject']['name'] = $subject_name;
  438. }
  439. if (property_exists($relationship->object_id, 'uniquename')) {
  440. $object_name = $relationship->object_id->uniquename;
  441. $entity->{$field_name}['und'][$i]['value']['object']['name'] = $object_name;
  442. }
  443. if (property_exists($relationship->object_id, 'entity_id')) {
  444. $entity_id = $relationship->object_id->entity_id;
  445. $entity->{$field_name}['und'][$i]['value']['object']['entity_id'] = $entity_id;
  446. $entity->{$field_name}['und'][$i]['value']['object']['entity_type'] = 'TripalEntity';
  447. }
  448. $rel_type_clean = lcfirst(preg_replace('/_/', ' ', $rel_type));
  449. $entity->{$field_name}['und'][$i]['value']['phrase'] = 'This ' .
  450. $subject_type . ' ' . $verb . ' ' . $rel_type_clean . ' the ' .
  451. $object_type . ', ' . $object_name . '.';
  452. $entity->{$field_name}['und'][$i][$field_table . '__' . $pkey] = $relationship->$pkey;
  453. $entity->{$field_name}['und'][$i][$field_table . '__subject_id'] = $relationship->subject_id->$subject_pkey;
  454. $entity->{$field_name}['und'][$i][$field_table . '__subject_id--uniquename'] = $relationship->subject_id->uniquename;
  455. $entity->{$field_name}['und'][$i][$field_table . '__type_id'] = $relationship->type_id->cvterm_id;
  456. $entity->{$field_name}['und'][$i][$field_table . '__type_id--name'] = $relationship->type_id->name;
  457. $entity->{$field_name}['und'][$i][$field_table . '__object_id'] = $relationship->object_id->$object_pkey;
  458. $entity->{$field_name}['und'][$i][$field_table . '__object_id--uniquename'] = $relationship->object_id->uniquename;
  459. if (array_key_exists('value', $schema['fields'])) {
  460. $entity->{$field_name}['und'][$i][$field_table . '__value'] = $relationship->value;
  461. }
  462. if (array_key_exists('rank', $schema['fields'])) {
  463. $entity->{$field_name}['und'][$i][$field_table . '__rank'] = $relationship->rank;
  464. }
  465. $i++;
  466. }
  467. }
  468. }
  469. /**
  470. * A helper function to define English verbs for relationship types.
  471. *
  472. * @param $rel_type
  473. * The vocabulary term name for the relationship.
  474. *
  475. * @return
  476. * The verb to use when creating a sentence of the relationship.
  477. */
  478. private function get_rel_verb($rel_type) {
  479. $rel_type_clean = lcfirst(preg_replace('/_/', ' ', $rel_type));
  480. $verb = $rel_type_clean;
  481. switch ($rel_type_clean) {
  482. case 'integral part of':
  483. case 'instance of':
  484. $verb = 'is an';
  485. break;
  486. case 'proper part of':
  487. case 'transformation of':
  488. case 'genome of':
  489. case 'part of':
  490. $verb = 'is a';
  491. case 'position of':
  492. case 'sequence of':
  493. case 'variant of':
  494. $verb = 'is a';
  495. break;
  496. case 'derives from':
  497. case 'connects on':
  498. case 'contains':
  499. case 'finishes':
  500. case 'guides':
  501. case 'has origin':
  502. case 'has part':
  503. case 'has quality':
  504. case 'is consecutive sequence of':
  505. case 'maximally overlaps':
  506. case 'overlaps':
  507. case 'starts':
  508. break;
  509. default:
  510. $verb = 'is';
  511. }
  512. return $verb;
  513. }
  514. }