123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782 |
- <?php
- require_once "parseInterpro.inc";
- function tripal_analysis_interpro_init(){
-
- drupal_add_css(drupal_get_path('theme', 'tripal').'/css/tripal_analysis_interpro.css');
- drupal_add_js( drupal_get_path('theme', 'tripal').'/js/tripal_analysis_interpro.js');
- }
- function tripal_analysis_interpro_node_info() {
- $nodes = array();
- $nodes['chado_analysis_interpro'] = array(
- 'name' => t('Analysis: Interpro'),
- 'module' => 'chado_analysis_interpro',
- 'description' => t('An interpro analysis from the chado database'),
- 'has_title' => FALSE,
- 'title_label' => t('Analysis: Interpro'),
- 'has_body' => FALSE,
- 'body_label' => t('Interpro Analysis Description'),
- 'locked' => TRUE
- );
- return $nodes;
- }
- function chado_analysis_interpro_form ($node){
-
- $form = chado_analysis_form($node);
- $analysis = $node->analysis;
- $interprofile = $analysis->tripal_analysis_interpro->interprofile;
- $interproparameters = $analysis->tripal_analysis_interpro->interproparameters;
- $parsego = $analysis->tripal_analysis_interpro->parsego;
- $parseHTML = $analysis->tripal_analysis_interpro->parseHTML;
- $query_re = $analysis->tripal_analysis_interpro->query_re;
- $query_type = $analysis->tripal_analysis_interpro->query_type;
- $query_uniquename = $analysis->tripal_analysis_interpro->query_uniquename;
- $moreSettings ['interpro'] = 'Interpro Settings';
- $form['interpro'] = array(
- '#title' => t('Interpro Settings'),
- '#type' => 'fieldset',
- '#description' => t('Specific Settings for Interpro Analysis.'),
- '#collapsible' => TRUE,
- '#attributes' => array('id' => 'interpro-extra-settings'),
- '#weight' => 11
- );
- $form['interpro']['interprofile'] = array(
- '#title' => t('InterProScan XML File/Directory: (if you input a directory without the tailing slash, all xml files in the directory will be loaded)'),
- '#type' => 'textfield',
- '#description' => t('Please provide the full path to the XML output file generated by InterProScan or a directory containing multiple XML files.'),
- '#default_value' => $interprofile,
- );
- $form['interpro']['interprojob'] = array(
- '#type' => 'checkbox',
- '#title' => t('Submit a job to parse the InterProScan XML file(s)'),
- '#description' => t('Note: features associated with the interpro results must '.
- 'exist in chado before parsing the file. Otherwise, interpro '.
- 'results that cannot be linked to a feature will not '.
- 'be imported. The feature name must be unique'),
- '#default_value' => $interprojob,
- '#attributes' => array(
- 'onclick' => 'return isSubmittingJob(this)'
- )
- );
- $form['interpro']['parseHTML'] = array(
- '#type' => 'checkbox',
- '#title' => t('The input file is in HTML format (deprecated, only provided for backwards compatibility)'),
- '#description' => t('Check the box to use the HTML parser.'),
- '#default_value' => $parseHTML
- );
- $form['interpro']['parsego'] = array(
- '#type' => 'checkbox',
- '#title' => t('Load GO terms to the database'),
- '#description' => t('Check the box to load GO terms to chado database'),
- '#default_value' => $parsego
- );
- $form['interpro']['interproparameters'] = array(
- '#title' => t('Parameters'),
- '#type' => 'textfield',
- '#description' => t('The parameters used when running the InterProScan analysis.'),
- '#default_value' => $interproparameters,
- );
- $form['interpro']['query_re'] = array(
- '#title' => t('Query Name RE'),
- '#type' => 'textfield',
- '#description' => t('Enter the regular expression that will extract the '.
- 'feature name from the query line in the interpro results. This option is '.
- 'is only required when the query does not identically match a feature '.
- 'in the database. By default, the parser will try to match results to '.
- 'a feature in Chado using the feature name. Select the check box below'.
- 'to match against the unique name if needed.'),
- '#default_value' => $query_re,
- );
- $form['interpro']['query_uniquename'] = array(
- '#title' => t('Use Unique Name'),
- '#type' => 'checkbox',
- '#description' => t('Select this checboxk if the query name in the results file '.
- 'matches the unique name of the feature. '),
- '#default_value' => $query_uniquename,
- );
- $form['interpro']['query_type'] = array(
- '#title' => t('Query Type'),
- '#type' => 'textfield',
- '#description' => t('Please enter the Sequence Ontology term (e.g. contig, polypeptide, mRNA) that describes '.
- 'the query sequences in the interproscan XML results file(s). This is only necessary if two '.
- 'or more sequences have the same name.'),
- '#default_value' => $query_type,
- );
- return $form;
- }
- function chado_analysis_interpro_validate($node, &$form){
-
- tripal_analysis_validate($node, $form);
- }
- function chado_analysis_interpro_load($node){
-
- $additions = chado_analysis_load($node);
-
- $analysis = $additions->analysis;
- $analysis_id = $analysis->analysis_id;
- $intepro_settings = tripal_analysis_get_property($analysis->analysis_id,'analysis_interpro_settings');
- $interprofile = tripal_analysis_get_property($analysis->analysis_id,'analysis_interpro_interprofile');
- $interproparameters= tripal_analysis_get_property($analysis->analysis_id,'analysis_interpro_interproparameters');
- $parsego = tripal_analysis_get_property($analysis->analysis_id,'analysis_interpro_parsego');
- $parseHTML = tripal_analysis_get_property($analysis->analysis_id,'analysis_interpro_parseHTML');
- $query_re = tripal_analysis_get_property($analysis->analysis_id,'analysis_interpro_query_re');
- $query_type = tripal_analysis_get_property($analysis->analysis_id,'analysis_interpro_query_type');
- $query_uniquename = tripal_analysis_get_property($analysis->analysis_id,'analysis_interpro_query_uniquename');
- $analysis->tripal_analysis_interpro->interprofile = $interprofile->value;
- $analysis->tripal_analysis_interpro->interproparameters= $interproparameters->value;
- $analysis->tripal_analysis_interpro->parsego = $parsego->value;
- $analysis->tripal_analysis_interpro->parseHTML = $parseHTML->value;
- $analysis->tripal_analysis_interpro->query_re = $query_re->value;
- $analysis->tripal_analysis_interpro->query_type = $query_type->value;
- $analysis->tripal_analysis_interpro->query_uniquename = $query_uniquename->value;
-
-
- if(count($interpro_settings)>0){
- $prop_values = explode ("|", $interpro_settings->value);
- $analysis->tripal_analysis_interpro->interprofile = $prop_values[0];
- $analysis->tripal_analysis_interpro->interproparameters = $prop_values[1];
- }
- return $additions;
- }
- function chado_analysis_interpro_insert($node){
-
- chado_analysis_insert($node);
-
- tripal_analysis_insert_property($node->analysis_id,'analysis_type','tripal_analysis_interpro');
-
- tripal_analysis_insert_property($node->analysis_id,'analysis_interpro_interprofile',$node->interprofile);
- tripal_analysis_insert_property($node->analysis_id,'analysis_interpro_interproparameters',$node->interproparameters);
- tripal_analysis_insert_property($node->analysis_id,'analysis_interpro_parsego',$node->parsego);
- tripal_analysis_insert_property($node->analysis_id,'analysis_interpro_parseHTML',$node->parseHTML);
- tripal_analysis_insert_property($node->analysis_id,'analysis_interpro_query_re',$node->query_re);
- tripal_analysis_insert_property($node->analysis_id,'analysis_interpro_query_type',$node->query_type);
- tripal_analysis_insert_property($node->analysis_id,'analysis_interpro_query_uniquename',$node->query_uniquename);
-
-
- chado_analysis_interpro_submit_job($node);
- }
- function chado_analysis_interpro_update($node){
-
- chado_analysis_update($node);
-
- tripal_analysis_update_property($node->analysis_id,'analysis_type','tripal_analysis_interpro',1);
-
- tripal_analysis_update_property($node->analysis_id,'analysis_interpro_interprofile',$node->interprofile,1);
- tripal_analysis_update_property($node->analysis_id,'analysis_interpro_interproparameters',$node->interproparameters,1);
- tripal_analysis_update_property($node->analysis_id,'analysis_interpro_parsego',$node->parsego,1);
- tripal_analysis_update_property($node->analysis_id,'analysis_interpro_parseHTML',$node->parseHTML,1);
- tripal_analysis_update_property($node->analysis_id,'analysis_interpro_query_re',$node->query_re,1);
- tripal_analysis_update_property($node->analysis_id,'analysis_interpro_query_type',$node->query_type,1);
- tripal_analysis_update_property($node->analysis_id,'analysis_interpro_query_uniquename',$node->query_uniquename,1);
-
- $old = tripal_analysis_get_property($node->analysis_id,'analysis_interpro_settings');
- if(count($old) > 0){
- tripal_analysis_delete_property($node->analysis_id,'analysis_interpro_settings');
- }
-
-
- chado_analysis_interpro_submit_job($node);
- }
- function chado_analysis_interpro_delete($node){
- chado_analysis_delete($node);
- }
- function chado_analysis_interpro_submit_job($node){
- global $user;
-
- if($node->interprojob) {
- $job_args[0] = $node->analysis_id;
- $job_args[1] = $node->interprofile;
- if ($node->parsego) {
- $job_args[2] = 1;
- } else {
- $job_args[2] = 0;
- }
- if (is_readable($node->interprofile)) {
- $fname = preg_replace("/.*\/(.*)/", "$1", $node->interprofile);
- if($node->parseHTML){
- tripal_add_job("Parse HTML interpro: $fname",'tripal_analysis_interpro',
- 'tripal_analysis_interpro_parseHTMLFile', $job_args, $user->uid);
- } else {
- $job_args[3] = $node->query_re;
- $job_args[4] = $node->query_type;
- $job_args[5] = $node->query_uniquename;;
- tripal_add_job("Parse XML interpro: $fname",'tripal_analysis_interpro',
- 'tripal_analysis_interpro_parseXMLFile', $job_args, $user->uid);
- }
- } else {
- drupal_set_message("Can not open interpro output file. Job not scheduled.");
- }
- }
-
-
- if ($node->interprokeywordjob) {
- $analysis_id = chado_get_id_for_node('analysis', $node);
- $job_args[0] = $analysis_id;
- tripal_add_job("Extract keywords for search: $node->analysisname",'tripal_analysis_interpro',
- 'tripal_analysis_interpro_extract_keywords', $job_args, $user->uid);
- }
- }
- function chado_analysis_interpro_view ($node, $teaser = FALSE, $page = FALSE) {
-
- if (!$teaser) {
- $node = node_prepare($node, $teaser);
-
-
- $time = $node->timeexecuted;
- if(is_array($time)){
- $month = $time['month'];
- $day = $time['day'];
- $year = $time['year'];
- $timestamp = $year.'-'.$month.'-'.$day;
- $node->timeexecuted = $timestamp;
- }
-
-
- if (preg_match("/.*\|.*/",$node->interprofile)) {
- $prop_values = explode("|", $node->interprofile);
- $node->interprofile = $prop_values[0];
- $node->interproparameters = $prop_values[1];
- }
- }
- return $node;
- }
- function tripal_analysis_interpro_block($op = 'list', $delta = 0, $edit=array()){
- switch($op) {
- case 'list':
- $blocks['ipr_base']['info'] = t('Analysis: Interpro Details');
- $blocks['ipr_base']['cache'] = BLOCK_NO_CACHE;
- $blocks['featureipr']['info'] = t('Tripal Feature Interpro Results');
- $blocks['featureipr']['cache'] = BLOCK_NO_CACHE;
-
- return $blocks;
- case 'view':
- if(user_access('access chado_analysis_interpro content') and arg(0) == 'node' and is_numeric(arg(1))) {
- $nid = arg(1);
- $node = node_load($nid);
-
- $block = array();
- switch($delta){
- case 'ipr_base':
- $block['subject'] = t('Interpro Details');
- $block['content'] = theme('tripal_analysis_interpro_base',$node);
- break;
- case 'featureipr':
- $block['subject'] = t('Interpro Results');
- $block['content'] = theme('tripal_feature_interpro_results',$node);
- break;
-
- default :
- }
- return $block;
- }
- }
- }
- function tripal_analysis_interpro_nodeapi(&$node, $op, $teaser, $page) {
- switch ($op) {
- case 'view':
-
- $types_to_show = variable_get('tripal_analysis_interpro_setting',
- array('chado_feature'));
-
- if (!in_array($node->type, $types_to_show, TRUE)) {
- break;
- }
-
- if (!$teaser && $node->feature->feature_id) {
- if($node->build_mode == NODE_BUILD_SEARCH_INDEX){
- $node->content['tripal_analysis_interpro_index_version'] = array(
- '#value' => theme('parse_EBI_Interpro_XML_index_version',$node),
- '#weight' => 7,
- );
- } else {
-
- $node->content['tripal_feature_interpro_results'] = array(
- '#value' => theme('tripal_feature_interpro_results', $node),
- '#weight' => 7
- );
- }
- }
- }
- }
- function tripal_analysis_interpro_theme () {
- return array(
- 'parse_EBI_Interpro_XML_index_version' => array (
- 'arguments' => array('node'),
- ),
- 'tripal_feature_interpro_results' => array (
- 'arguments' => array('node'=> null),
- 'template' => 'tripal_feature_interpro_results',
- ),
- 'tripal_analysis_interpro_base' => array (
- 'arguments' => array('node'=> null),
- 'template' => 'tripal_analysis_interpro_base',
- )
- );
- }
- function tripal_analysis_interpro_preprocess_tripal_feature_interpro_results(&$variables){
- $feature = $variables['node']->feature;
-
-
- $feature->tripal_analysis_interpro->results->html = tripal_get_interpro_HTML_results($feature->feature_id);
- $feature->tripal_analysis_interpro->results->xml = tripal_get_interpro_XML_results($feature->feature_id);
- }
- function theme_parse_EBI_Interpro_XML_index_version ($node) {
- $feature = $node->feature;
- $content = tripal_get_interpro_results_index_version($feature->feature_id);
- return $content;
- }
- function tripal_get_interpro_XML_results($feature_id){
-
-
-
-
- $select = array(
- 'analysisfeature_id' => array(
- 'feature_id' => $feature_id,
- ),
- 'type_id' => array(
- 'name' => 'analysis_interpro_xmloutput_hit',
- 'cv_id' => array(
- 'name' => 'tripal'
- ),
- ),
- );
- $afeatureprops = tripal_core_chado_select('analysisfeatureprop',array('*'),$select);
-
- $results = array ();
- if($afeatureprops){
- foreach ($afeatureprops as $index => $afeatureprop) {
-
- $analysisfeature_arr = tripal_core_chado_select('analysisfeature',array('analysis_id'),
- array('analysisfeature_id' => $afeatureprop->analysisfeature_id));
- $analysisfeature = $analysisfeature_arr[0];
-
- $analysis = tripal_core_generate_chado_var('analysis',
- array('analysis_id' => $analysisfeature->analysis_id));
- $analysis_id = $analysis->analysis_id;
-
- $interpro_xml = $afeatureprop->value;
- $orf = tripal_analysis_interpro_get_result_object($interpro_xml,$feature_id);
- $results[$analysis->analysis_id]['protein_ORFs'][] = $orf;
- $results[$analysis->analysis_id]['analysis'] = $analysis;
-
- if(!is_array($results[$analysis->analysis_id]['allterms'])){
- $results[$analysis->analysis_id]['allterms'] = array();
- }
- if(!is_array($results[$analysis->analysis_id]['goterms'])){
- $results[$analysis->analysis_id]['goterms'] = array();
- }
- $results[$analysis->analysis_id]['allterms'] = array_merge($results[$analysis->analysis_id]['allterms'],$orf['iprterms']);
- $results[$analysis->analysis_id]['goterms'] = array_merge($results[$analysis->analysis_id]['goterms'],$orf['goterms']);
- $i++;
- }
- }
- return $results;
- }
- function tripal_get_interpro_HTML_results($feature_id){
-
-
- $previous_db = tripal_db_set_active('chado');
- $sql = "SELECT CVT.cvterm_id FROM {cvterm} CVT
- INNER JOIN cv ON cv.cv_id = CVT.cv_id
- WHERE CVT.name = 'analysis_interpro_output_hit'
- AND CV.name = 'tripal'";
- $type_id = db_result(db_query($sql));
-
-
- $sql = "SELECT A.analysis_id AS aid
- FROM {analysis} A
- INNER JOIN analysisfeature AF ON A.analysis_id = AF.analysis_id
- INNER JOIN analysisfeatureprop AFP ON AF.analysisfeature_id = AFP.analysisfeature_id
- WHERE feature_id = %d
- AND AFP.type_id = %d
- AND AFP.value NOT like '%No hits reported.%'
- AND AFP.value NOT like '%parent%'
- AND AFP.value NOT like '%children%'
- GROUP BY A.analysis_id
- ";
- $hasResult = db_result(db_query($sql, $feature_id, $type_id));
- $result = db_query($sql, $feature_id, $type_id);
-
- if ($hasResult) {
- $content .= "<table class=\"tripal_interpro_results_table\">
- <tr><td>";
- while ($ana = db_fetch_object($result)) {
-
- $sql = "SELECT name, to_char(timeexecuted, 'MM-DD-YYYY') AS time
- FROM {analysis}
- WHERE analysis_id = %d";
- $ana_details = db_fetch_object(db_query($sql, $ana->aid));
-
- tripal_db_set_active($previous_db);
- $ana_nid = db_result(db_query("SELECT nid FROM {chado_analysis} WHERE analysis_id = %d", $ana->aid));
- $ana_url = url("node/".$ana_nid);
- $previous_db = tripal_db_set_active('chado');
-
-
- $content .= "<strong>Analysis Date:</strong> $ana_details->time
- (<a href=$ana_url>$ana_details->name</a>)";
-
-
- $sql = "SELECT AFP.value AS afpvalue
- FROM {analysisfeatureprop} AFP
- INNER JOIN analysisfeature AF on AF.analysisfeature_id = AFP.analysisfeature_id
- WHERE AF.analysis_id = %d
- AND AF.feature_id = %d
- AND AFP.type_id = %d
- AND AFP.value NOT like '%No hits reported.%'
- AND AFP.value NOT like '%parent%'
- AND AFP.value NOT like '%children%'
- ";
- $interpro_results = db_query($sql, $ana->aid, $feature_id, $type_id);
- while ($afp = db_fetch_object($interpro_results)) {
- $content .= $afp->afpvalue;
- }
- }
- $content .= '</td></tr></table>';
- }
-
- tripal_db_set_active($previous_db);
- return $content;
- }
- function tripal_get_interpro_results_index_version($feature_id){
-
-
- $previous_db = tripal_db_set_active('chado');
- $sql = "SELECT CVT.cvterm_id FROM {cvterm} CVT ".
- "INNER JOIN cv ON cv.cv_id = CVT.cv_id ".
- "WHERE CVT.name = 'analysis_interpro_output_hit' ".
- "AND CV.name = 'tripal'";
- $type_id = db_result(db_query($sql));
-
- $sql = "SELECT AFP.value AS afpvalue FROM {analysisfeatureprop} AFP ".
- "INNER JOIN analysisfeature AF ON AF.analysisfeature_id = AFP.analysisfeature_id ".
- "INNER JOIN analysisprop AP ON AP.analysis_id = AF.analysis_id ".
- "WHERE feature_id = %d ".
- "AND AFP.type_id = %d ";
- $result = db_query($sql, $feature_id, $type_id);
- tripal_db_set_active($previous_db);
- if (db_result($result)) {
-
- while ($analysisfeatureprop = db_fetch_object($result)) {
- $content .= $analysisfeatureprop->afpvalue;
- }
- }
- return $content;
- }
- function tripal_analysis_interpro_get_settings() {
-
- $options = node_get_types('names');
-
- $allowedoptions ['chado_feature'] = "Show Interpro results on feature pages";
- $form['description'] = array(
- '#type' => 'item',
- '#value' => t("Some chado features were analyzed using InterProScan. This option allows user to display the interpro analysis results. Please read user manual for storage and display of interpro files. Check the box to enable the analysis results. Uncheck to disable it."),
- '#weight' => 0,
- );
- $form['tripal_analysis_interpro_setting'] = array(
- '#type' => 'checkboxes',
- '#options' => $allowedoptions,
- '#default_value' => variable_get('tripal_analysis_interpro_setting',
- array('chado_feature')),
- );
- $settings->form = $form;
- $settings->title = "Tripal Interpro";
- return $settings;
- }
- function tripal_analysis_interpro_perm(){
- return array(
- 'access chado_analysis_interpro content',
- 'create chado_analysis_interpro content',
- 'delete chado_analysis_interpro content',
- 'edit chado_analysis_interpro content',
- );
- }
- function chado_analysis_interpro_access($op, $node, $account){
- if ($op == 'create') {
- if(!user_access('create chado_analysis_interpro content', $account)){
- return FALSE;
- }
- }
- if ($op == 'update') {
- if (!user_access('edit chado_analysis_interpro content', $account)) {
- return FALSE;
- }
- }
- if ($op == 'delete') {
- if (!user_access('delete chado_analysis_interpro content', $account)) {
- return FALSE;
- }
- }
- if ($op == 'view') {
- if(!user_access('access chado_analysis_interpro content', $account)){
- return FALSE;
- }
- }
- return NULL;
- }
- function tripal_analysis_interpro_job_describe_args($callback,$args){
- $new_args = array();
- if($callback == 'tripal_analysis_interpro_parseXMLFile'){
-
- if($args[0]){
- $analysis = tripal_core_chado_select('analysis',array('name'),array('analysis_id' => $args[0]));
- }
- $new_args['Analysis'] = $analysis[0]->name;
- $new_args['File or Directory Name'] = $args[1];
- if($args[2]){
- $new_args['Parse GO terms'] = 'Yes';
- } else {
- $new_args['Parse GO terms'] = 'No';
- }
- $new_args['Query name regular expression'] = $args[3];
- $new_args['Query type'] = $args[4];
- if($args[5] == 1){
- $new_args['Feature identifier'] = 'feature unique name';
- } else {
- $new_args['Feature identifier'] = 'feature name';
- }
- }
- return $new_args;
- }
- function tripal_analysis_interpro_extract_keywords ($analysis_id) {
-
-
- print "Remove keywords previously stored...\n";
- $output_type_id = tripal_get_cvterm_id('analysis_interpro_output_hit');
- $sql = "SELECT distinct AFP.analysisfeature_id FROM {analysisfeatureprop} AFP
- INNER JOIN {analysisfeature} AF ON AF.analysisfeature_id = AFP.analysisfeature_id
- WHERE type_id = $output_type_id
- AND AF.analysis_id = $analysis_id";
- $results_remove = chado_query($sql);
- $keyword_type_id = tripal_get_cvterm_id('analysis_interpro_output_keywords');
- while ($record = db_fetch_object($results_remove)) {
- $af_id = $record->analysisfeature_id;
- $sql = "DELETE FROM {analysisfeatureprop} WHERE analysisfeature_id =$af_id AND type_id = $keyword_type_id";
- chado_query($sql);
- }
-
- print "Extracting keywords...\n";
- $sql = "SELECT AFP.analysisfeature_id, AFP.value FROM {analysisfeatureprop} AFP
- INNER JOIN {analysisfeature} AF ON AF.analysisfeature_id = AFP.analysisfeature_id
- WHERE type_id = $output_type_id
- AND AF.analysis_id = $analysis_id
- AND value NOT like '%No hits reported.%'
- AND value NOT like '%parent%'
- AND value NOT like '%children%'";
- $results = chado_query($sql);
-
- $search = array (
- "'SEQUENCE:.*'",
- "'CRC64:.*'",
- "'LENGTH:.*'",
- "'unintegrated'",
- "'noIPR'",
- "'<td>seg</td>'",
- "'<b>InterPro<br/>'",
- "'<br/>Domain|Family\n'",
- "'<td>no description</td>'",
- "'<[/!]*?[^<>]*?>'si",
- "'\n'",
- );
- $replace = array (
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- " ",
- " ",
- );
- while ($record = db_fetch_object($results)) {
- $af_id = $record->analysisfeature_id;
- $value = $record->value;
-
- $sql = "SELECT value FROM {analysisfeatureprop} WHERE analysisfeature_id =$af_id AND type_id = $keyword_type_id";
- $keywords = db_result(chado_query($sql));
-
-
- $text = preg_replace($search, $replace, $value);
- $new_keywords = trim(ereg_replace(' +', ' ', $text));
-
-
- if ($keywords) {
- $new_keywords = "$keywords $new_keywords";
- $sql = "UPDATE {analysisfeatureprop} SET value = '$new_keywords' WHERE analysisfeature_id =$af_id AND type_id = $keyword_type_id ";
- } else {
-
- $sql = "INSERT INTO {analysisfeatureprop} (analysisfeature_id, type_id, value, rank) VALUES ($af_id, $keyword_type_id, '$new_keywords', 0)";
- }
- chado_query($sql);
- }
-
- print "Finished.\n";
-
- }
|