Re: [Gmod-tripal-devel] [Gmod-tripal] Populating linking table

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: [Gmod-tripal-devel] [Gmod-tripal] Populating linking table

Stephen Ficklin-2
Hi Hrishikesh,

It looks like we are missing some information in the tripal_example.chado_node.inc file that gives this information.   If you take a look in the same file in the feature module you'll see the function chado_feature_insert() and at the bottom of that function is where the entry is added to the linking table.  Here's the snippet of code from that function:

  // Make sure the entry for this feature doesn't already exist in the
  // chado_feature table if it doesn't exist then we want to add it.
  $check_org_id = chado_get_id_from_nid('feature', $node->nid);
  if (!$check_org_id) {
    $record = new stdClass();
    $record->nid = $node->nid;
    $record->vid = $node->vid;
    $record->feature_id = $feature_id;
    drupal_write_record('chado_feature', $record);
  }


However, it sounds as though you may be duplicating effort.  The feature module should already provide gene pages for you and if you want to customize the way those gene pages look you just need to edit the existing template files.  Have you tried that route and can't get it to do what you are needing?

Stephen

On 11/3/2014 12:27 PM, Hrishikesh A. Lokhande wrote:
Hello all,

I am working on implementing a gene module and using the example module and api’s from tripal.info for my reference. 

My module is partly functional, I am having issues with the chado_node_sync_form function. The following is what I have implemented. 



function triapl_gene_menu(){
   $items=array();
   .
   .
   .
   .
    $items['admin/tripal/chado/tripal_gene/sync'] = array(
    'title' => ' Sync',
    'description' => 'Create pages on this site for genes stored in Chado',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('chado_node_sync_form', 'tripal_gene', 'chado_gene'),
    'access arguments' => array('administer tripal gene'),
    'type' => MENU_LOCAL_TASK,
    'weight' => 2
  );
  .
  .
  .
  .
  return $items;


}


function tripal_gene_node_info() {
  return array(
    'chado_gene' => array(
      'name'        => t('Gene'),
      'base'        => 'chado_gene',
      'description' => t('A gene from the Chado database'),
      'has_title'   => TRUE,
      'locked'      => TRUE,
      'chado_node_api' => array(
        'base_table' => 'gene',
        'hook_prefix' => 'chado_gene',
        'record_type_title' => array(
          'singular' => t('Gene'),
          'plural' => t('Genes')
        ),
        'sync_filters' => array(
          'type_id' => FALSE,
          'organism_id' => FALSE
        ),
      ),
    ),
  );
}

The sync works from the UI but doesn’t populate the chado_gene table, I can see entries in the node table for chado_gene. 

Is there any other function that I need to implement (like hook_insert) to populate chado_gene?

Thanks 


Hrishikesh A. Lokhande
Bioinformatics Analyst
National Center for Genome Resources 



------------------------------------------------------------------------------


_______________________________________________
Gmod-tripal mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-tripal


------------------------------------------------------------------------------

_______________________________________________
Gmod-tripal-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-tripal-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Gmod-tripal-devel] [Gmod-tripal] Populating linking table

Stephen Ficklin-2
Hi Hrishikesh,

Hope you don't mind.  I'm moving this over to the tripal devel list...   Currently, the insert happens at the node type level.  The module defines the node type, and creates the linking table in it's install file.  So, we made it also be responsible for populating the linker table as well during the hook_insert().  But, you are correct in your thinking that the chado_node_sync_form API should be smart enough to be able to make the link on it's own.   It's something to think on... I've added an issue for this on the Tripal project page: 

https://www.drupal.org/node/2368419

But, for now, you'll have to make the association in the hook_insert() as the other modules do.  Oh, and we do have an example of that code in the example module. I missed it when I first went looking for it. 

Also, I think you may be able to create your own module, and add new templates without disturbing the feature module and without creating a new node type. Which should save you some programming effort.  If you want to give a bit more information about what new content you are trying to support I'd be happy to offer suggestions. 

Thanks,
Stephen

On 11/3/2014 1:48 PM, Hrishikesh A. Lokhande wrote:
Hello Steohen,

Thanks for the reply. I was under the impression that chado_node_sync_form does the insert. 

Yes, I am aware that feature does include gene information, we are trying to add new templates and additional information, without disturbing the feature module.


On Nov 3, 2014, at 11:43 AM, Stephen Ficklin <[hidden email]> wrote:

Hi Hrishikesh,

It looks like we are missing some information in the tripal_example.chado_node.inc file that gives this information.   If you take a look in the same file in the feature module you'll see the function chado_feature_insert() and at the bottom of that function is where the entry is added to the linking table.  Here's the snippet of code from that function:

  // Make sure the entry for this feature doesn't already exist in the
  // chado_feature table if it doesn't exist then we want to add it.
  $check_org_id = chado_get_id_from_nid('feature', $node->nid);
  if (!$check_org_id) {
    $record = new stdClass();
    $record->nid = $node->nid;
    $record->vid = $node->vid;
    $record->feature_id = $feature_id;
    drupal_write_record('chado_feature', $record);
  }


However, it sounds as though you may be duplicating effort.  The feature module should already provide gene pages for you and if you want to customize the way those gene pages look you just need to edit the existing template files.  Have you tried that route and can't get it to do what you are needing?

Stephen

On 11/3/2014 12:27 PM, Hrishikesh A. Lokhande wrote:
Hello all,

I am working on implementing a gene module and using the example module and api’s from tripal.info for my reference. 

My module is partly functional, I am having issues with the chado_node_sync_form function. The following is what I have implemented. 



function triapl_gene_menu(){
   $items=array();
   .
   .
   .
   .
    $items['admin/tripal/chado/tripal_gene/sync'] = array(
    'title' => ' Sync',
    'description' => 'Create pages on this site for genes stored in Chado',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('chado_node_sync_form', 'tripal_gene', 'chado_gene'),
    'access arguments' => array('administer tripal gene'),
    'type' => MENU_LOCAL_TASK,
    'weight' => 2
  );
  .
  .
  .
  .
  return $items;


}


function tripal_gene_node_info() {
  return array(
    'chado_gene' => array(
      'name'        => t('Gene'),
      'base'        => 'chado_gene',
      'description' => t('A gene from the Chado database'),
      'has_title'   => TRUE,
      'locked'      => TRUE,
      'chado_node_api' => array(
        'base_table' => 'gene',
        'hook_prefix' => 'chado_gene',
        'record_type_title' => array(
          'singular' => t('Gene'),
          'plural' => t('Genes')
        ),
        'sync_filters' => array(
          'type_id' => FALSE,
          'organism_id' => FALSE
        ),
      ),
    ),
  );
}

The sync works from the UI but doesn’t populate the chado_gene table, I can see entries in the node table for chado_gene. 

Is there any other function that I need to implement (like hook_insert) to populate chado_gene?

Thanks 


Hrishikesh A. Lokhande
Bioinformatics Analyst
National Center for Genome Resources 



------------------------------------------------------------------------------


_______________________________________________
Gmod-tripal mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-tripal


Hrishikesh A. Lokhande
Bioinformatics Analyst
National Center for Genome Resources 



------------------------------------------------------------------------------

_______________________________________________
Gmod-tripal-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-tripal-devel