Procházet zdrojové kódy

Merged in 6.x-0.4-dev branch

Lacey Sanderson před 12 roky
rodič
revize
fa17f954bc
100 změnil soubory, kde provedl 1575 přidání a 10957 odebrání
  1. 339 0
      LICENSE.txt
  2. 0 121
      base/tripal_core/cvterms.php
  3. 0 439
      base/tripal_core/mviews.php
  4. 0 1
      base/tripal_db/views/handlers/views_handler_field_dbxref_accession_link.inc
  5. 0 353
      base/tripal_feature/tripal_feature-properties.inc
  6. 0 255
      base/tripal_feature/tripal_feature.api.inc
  7. 0 1
      base/tripal_feature/views/handlers/views_handler_field_readable_date.inc
  8. 0 1
      base/tripal_library/views/handlers/views_handler_field_readable_date.inc
  9. 0 924
      extensions/tripal_analysis_blast/includes/parse_blast_XML.inc
  10. 0 102
      extensions/tripal_analysis_blast/node-chado_analysis_blast.tpl.php
  11. 0 33
      extensions/tripal_analysis_blast/theme/css/tripal_analysis_blast.css
  12. 0 183
      extensions/tripal_analysis_blast/theme/js/tripal_analysis_blast.js
  13. 0 78
      extensions/tripal_analysis_blast/theme/tripal_analysis_blast/tripal_analysis_blast_base.tpl.php
  14. 0 123
      extensions/tripal_analysis_blast/theme/tripal_analysis_blast/tripal_analysis_blast_report.tpl.php
  15. 0 53
      extensions/tripal_analysis_blast/theme/tripal_analysis_blast/tripal_analysis_blast_teaser.tpl.php
  16. 0 115
      extensions/tripal_analysis_blast/theme/tripal_feature/tripal_feature_blast_results.tpl.php
  17. 0 9
      extensions/tripal_analysis_blast/tripal_analysis_blast.info
  18. 0 198
      extensions/tripal_analysis_blast/tripal_analysis_blast.install
  19. 0 909
      extensions/tripal_analysis_blast/tripal_analysis_blast.module
  20. 0 208
      extensions/tripal_analysis_blast/tripal_analysis_blast_htmlreport.inc
  21. 0 23
      extensions/tripal_analysis_go/go_path_counts
  22. 0 466
      extensions/tripal_analysis_go/includes/gaf_loader.inc
  23. 0 17
      extensions/tripal_analysis_go/theme/css/tripal_analysis_go.css
  24. 0 52
      extensions/tripal_analysis_go/theme/js/tripal_analysis_go.js
  25. 0 35
      extensions/tripal_analysis_go/theme/tripal_feature/tripal_feature_go_terms.tpl.php
  26. 0 35
      extensions/tripal_analysis_go/theme/tripal_organism/tripal_organism_go_summary.tpl.php
  27. 0 10
      extensions/tripal_analysis_go/tripal_analysis_go.info
  28. 0 133
      extensions/tripal_analysis_go/tripal_analysis_go.install
  29. 0 608
      extensions/tripal_analysis_go/tripal_analysis_go.module
  30. 0 584
      extensions/tripal_analysis_interpro/includes/parseInterpro.inc
  31. 0 100
      extensions/tripal_analysis_interpro/node-chado_analysis_interpro.tpl.php
  32. 0 44
      extensions/tripal_analysis_interpro/theme/css/tripal_analysis_interpro.css
  33. 0 29
      extensions/tripal_analysis_interpro/theme/js/tripal_analysis_interpro.js
  34. 0 56
      extensions/tripal_analysis_interpro/theme/tripal_analysis_interpro/tripal_analysis_interpro_base.tpl.php
  35. 0 53
      extensions/tripal_analysis_interpro/theme/tripal_analysis_interpro/tripal_analysis_interpro_teaser.tpl.php
  36. 0 121
      extensions/tripal_analysis_interpro/theme/tripal_feature/tripal_feature_interpro_results.tpl.php
  37. 0 10
      extensions/tripal_analysis_interpro/tripal_analysis_interpro.info
  38. 0 90
      extensions/tripal_analysis_interpro/tripal_analysis_interpro.install
  39. 0 795
      extensions/tripal_analysis_interpro/tripal_analysis_interpro.module
  40. 0 101
      extensions/tripal_analysis_kegg/node-chado_analysis_kegg.tpl.php
  41. 0 46
      extensions/tripal_analysis_kegg/theme/css/tripal_analysis_kegg.css
  42. binární
      extensions/tripal_analysis_kegg/theme/images/kegg.gif
  43. 0 162
      extensions/tripal_analysis_kegg/theme/js/tripal_analysis_kegg.js
  44. 0 53
      extensions/tripal_analysis_kegg/theme/tripal_analysis_kegg/tripal_analysis_kegg_base.tpl.php
  45. 0 11
      extensions/tripal_analysis_kegg/theme/tripal_analysis_kegg/tripal_analysis_kegg_report.tpl.php
  46. 0 53
      extensions/tripal_analysis_kegg/theme/tripal_analysis_kegg/tripal_analysis_kegg_teaser.tpl.php
  47. 0 46
      extensions/tripal_analysis_kegg/theme/tripal_feature/tripal_feature_kegg_terms.tpl.php
  48. 0 22
      extensions/tripal_analysis_kegg/theme/tripal_organism/tripal_organism_kegg_summary.tpl.php
  49. 0 10
      extensions/tripal_analysis_kegg/tripal_analysis_kegg.info
  50. 0 106
      extensions/tripal_analysis_kegg/tripal_analysis_kegg.install
  51. 0 1302
      extensions/tripal_analysis_kegg/tripal_analysis_kegg.module
  52. 0 103
      extensions/tripal_analysis_unigene/node-chado_analysis_unigene.tpl.php
  53. 0 16
      extensions/tripal_analysis_unigene/theme/css/tripal_analysis_unigene.css
  54. 0 86
      extensions/tripal_analysis_unigene/theme/tripal_analysis_unigene/tripal_analysis_unigene_base.tpl.php
  55. 0 53
      extensions/tripal_analysis_unigene/theme/tripal_analysis_unigene/tripal_analysis_unigene_teaser.tpl.php
  56. 0 61
      extensions/tripal_analysis_unigene/theme/tripal_feature/tripal_feature_unigenes.tpl.php
  57. 0 52
      extensions/tripal_analysis_unigene/theme/tripal_organism/tripal_organism_unigenes.tpl.php
  58. 0 9
      extensions/tripal_analysis_unigene/tripal_analysis_unigene.info
  59. 0 290
      extensions/tripal_analysis_unigene/tripal_analysis_unigene.install
  60. 0 922
      extensions/tripal_analysis_unigene/tripal_analysis_unigene.module
  61. 1 1
      extensions/tripal_search_unigene/tripal_search_unigene.install
  62. 7 4
      extensions/tripal_search_unigene/views_handler_filter_analysis_name.inc
  63. 0 34
      tripal_analysis/tripal_analysis.admin.inc
  64. 0 0
      tripal_analysis/tripal_analysis.api.inc
  65. 0 0
      tripal_analysis/tripal_analysis.info
  66. 7 7
      tripal_analysis/tripal_analysis.install
  67. 4 2
      tripal_analysis/tripal_analysis.module
  68. 0 0
      tripal_analysis/tripal_analysis.views.inc
  69. 0 0
      tripal_analysis/tripal_analysis_privacy.inc
  70. 0 0
      tripal_analysis/views/README
  71. 0 0
      tripal_analysis/views/analysis.views.inc
  72. 16 0
      tripal_analysis/views/chado_analysis.views.inc
  73. 0 0
      tripal_analysis/views/handlers/views_handler_field_computed_analysis_nid.inc
  74. 0 0
      tripal_analysis/views/misc_tables.views.inc
  75. 0 0
      tripal_analysis/views/template.node_join.views.inc
  76. 0 0
      tripal_analysis/views/template.table_defn.views.inc
  77. 0 0
      tripal_bulk_loader/tripal_bulk_loader.admin.inc
  78. 0 0
      tripal_bulk_loader/tripal_bulk_loader.constants.inc
  79. 0 0
      tripal_bulk_loader/tripal_bulk_loader.info
  80. 0 0
      tripal_bulk_loader/tripal_bulk_loader.install
  81. 8 1
      tripal_bulk_loader/tripal_bulk_loader.loader.inc
  82. 0 0
      tripal_bulk_loader/tripal_bulk_loader.module
  83. 0 0
      tripal_contact/tripal_contact.api.inc
  84. 0 0
      tripal_contact/tripal_contact.info
  85. 0 0
      tripal_contact/tripal_contact.module
  86. 0 0
      tripal_contact/tripal_contact.views.inc
  87. 0 0
      tripal_contact/views/README
  88. 0 0
      tripal_contact/views/template.node_join.views.inc
  89. 0 0
      tripal_contact/views/template.table_defn.views.inc
  90. 0 0
      tripal_core/chado_install.php
  91. 0 0
      tripal_core/default_schema.sql
  92. 0 0
      tripal_core/initialize.sql
  93. 2 1
      tripal_core/jobs.php
  94. 703 0
      tripal_core/mviews.php
  95. 236 27
      tripal_core/tripal_core.api.inc
  96. 159 0
      tripal_core/tripal_core.drush.inc
  97. 0 0
      tripal_core/tripal_core.info
  98. 69 4
      tripal_core/tripal_core.install
  99. 1 3
      tripal_core/tripal_core.module
  100. 23 2
      tripal_core/tripal_core.schema.api.inc

+ 339 - 0
LICENSE.txt

@@ -0,0 +1,339 @@
+                    GNU GENERAL PUBLIC LICENSE
+                       Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                            Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                    GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+                            NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+                     END OF TERMS AND CONDITIONS
+
+            How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License along
+    with this program; if not, write to the Free Software Foundation, Inc.,
+    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.

+ 0 - 121
base/tripal_core/cvterms.php

@@ -1,121 +0,0 @@
-<?php
-
-/** 
- * @defgroup tripal_core_cv_api Core Module CV API
- * @{
- * For working with controlled vocabularies see the Controlled Vocabulary
- * API.  However, there are cases where a CV does not exist. For example in
- * some cases a module may want to support adding of properties (such as to
- * for an analysis) to a record but an organized CV does not exist.  The 
- * progammer may create their own ontology and populate it, or they may use
- * the basic CV interface provided by Tripal.  Tripal provides a CV named
- * 'Tripal' and modules may add terms to this CV to support the functionality
- * of their modules.  
- * @}
- * @ingroup tripal_api
- */
-
-/**
- * Add a materialized view to the chado database to help speed data access.
- *
- * @param $name 
- *   The name of the term
- * @param $definition 
- *   The definition for the term
- * @param $cv_name 
- *   The name of the controlled vocabulary to which the term will be added.
- *   The default CV is 'tripal'.
- * @param $db_name 
- *   CV records also have a corresponding database reference.  This argument
- *   specifies the name of the database to which this term belongs. The default
- *   database name is 'tripal'.
- *
- * @ingroup tripal_core_cv_api
- */
-function tripal_add_cvterms ($name,$definition,$cv_name = 'tripal',$db_name='tripal'){
-   
-   
-   $previous_db = tripal_db_set_active('chado');  // use chado database
-   $cv = db_fetch_object(db_query("SELECT * FROM {cv} WHERE name = '$cv_name'"));
-   if (!$cv->cv_id) {
-      tripal_db_set_active($previous_db);
-      tripal_add_cv('tripal', 'Terms used by Tripal for modules to manage data such as that 
-                               stored in property tables like featureprop, analysisprop, etc');
-      tripal_db_set_active('chado');
-      $cv = db_fetch_object(db_query("SELECT * FROM {cv} WHERE name = '$cv_name'"));
-   }
-   $db = db_fetch_object(db_query("SELECT * FROM {db} WHERE name = '$db_name'"));
-	if (!$db->db_id) {
-	   tripal_db_set_active($previous_db);
-	   tripal_add_db('tripal', 'Used as a database placeholder for tripal defined objects such as tripal cvterms', '', '');
-	   tripal_db_set_active('chado');
-	   $db = db_fetch_object(db_query("SELECT * FROM {db} WHERE name = '$db_name'"));
-	}
-
-	// check to see if the dbxref already exists if not then add it
-	$sql = "SELECT * FROM {dbxref} WHERE db_id = $db->db_id and accession = '$name'";
-	$dbxref = db_fetch_object(db_query($sql));
-	if(!$dbxref){
-	   db_query("INSERT INTO {dbxref} (db_id,accession) VALUES ($db->db_id,'$name')");
-		$dbxref = db_fetch_object(db_query($sql));
-	}
-
-   
-   // now add the cvterm only if it doesn't already exist
-	$sql = "SELECT * FROM {cvterm} ".
-	       "WHERE cv_id = $cv->cv_id and dbxref_id = $dbxref->dbxref_id and name = '$name'";
-	$cvterm = db_fetch_object(db_query($sql));
-	if(!$cvterm){
-      $result = db_query("INSERT INTO {cvterm} (cv_id,name,definition,dbxref_id) ".
-                         "VALUES ($cv->cv_id,'$name','$definition',$dbxref->dbxref_id)");
-	}
-   tripal_db_set_active($previous_db);  // now use drupal database	
-	
-   if(!$result){
-     // TODO -- ERROR HANDLING
-   }
-}
-/**
- * Add a database to the Chado 'db' table.
- * NOTE: This function is deprecated and may not be used in future releases of Tripal
- *  
- * @ingroup tripal_core_cv_api
- */
-function tripal_add_db($db_name,$description,$urlprefix,$url){
-   $previous_db = tripal_db_set_active('chado');  // use chado database
-
-   // use this SQL statement to get the db_id for the database name
-   $id_sql = "SELECT db_id FROM {db} WHERE name = '%s'";
-
-   $db = db_fetch_object(db_query($id_sql,$db_name));
-
-   // if the database doesn't exist then let's add it.
-   if(!$db->db_id){
-      $sql = "
-         INSERT INTO {db} (name,description,urlprefix,url) VALUES 
-         ('%s','%s','%s','%s');
-      ";
-      db_query($sql,$db_name,$description,$urlprefix,$url);
-    
-      # now get the id for this new db entry
-      $db = db_fetch_object(db_query($id_sql,$db_name));
-   }
-   tripal_db_set_active($previous_db);  // now use drupal database	
-   return $db->db_id;
-}
-
-
-/**
- * Get cvterm_id for a tripal term by passing its name
- * NOTE: This function is deprecated and may not be used in future releases of Tripal
- *  
- * @ingroup tripal_core_cv_api
- */
-function tripal_get_cvterm_id ($cvterm){
-	$sql = "SELECT CVT.cvterm_id FROM {cvterm} CVT
-         	    INNER JOIN cv ON cv.cv_id = CVT.cv_id 
-            	 WHERE CVT.name = '$cvterm' 
-                AND CV.name = 'tripal'";
-	return db_result(chado_query($sql));
-}
-

+ 0 - 439
base/tripal_core/mviews.php

@@ -1,439 +0,0 @@
-<?php
-
-/** 
- * @defgroup tripal_mviews_api Core Module Materalized Views API
- * @{
- * Provides an application programming interface (API) to manage materialized views in Chado.
- * The Perl-based chado comes with an interface for managing materialzed views.  This
- * API provides an alternative Drupal-based method.  
- * @}
- * @ingroup tripal_api
- */
-
-/**
- * Add a materialized view to the chado database to help speed data access.
- *
- * @param $name 
- *   The name of the materialized view.
- * @param $modulename 
- *   The name of the module submitting the materialized view (e.g. 'tripal_library')
- * @param $mv_table 
- *   The name of the table to add to chado. This is the table that can be queried.
- * @param $mv_specs 
- *   The table definition 
- * @param $indexed 
- *   The columns that are to be indexed
- * @param $query 
- *   The SQL query that loads the materialized view with data
- * @param $special_index  
- *   function
- *
- * @ingroup tripal_mviews_api
- */
-function tripal_add_mview ($name,$modulename,$mv_table,$mv_specs,$indexed,$query,$special_index){
-
-   $record = new stdClass();
-   $record->name = $name;
-   $record->modulename = $modulename;
-   $record->mv_schema = 'DUMMY';
-   $record->mv_table = $mv_table;
-   $record->mv_specs = $mv_specs;
-   $record->indexed = $indexed;
-   $record->query = $query;
-   $record->special_index = $special_index;
-
-   // add the record to the tripal_mviews table and if successful
-   // create the new materialized view in the chado schema
-   if(drupal_write_record('tripal_mviews',$record)){
-
-      // drop the table from chado if it exists
-      $previous_db = tripal_db_set_active('chado');  // use chado database
-      if (db_table_exists($mv_table)) {
-         $sql = "DROP TABLE $mv_table";
-         db_query($sql);
-      }
-      tripal_db_set_active($previous_db);  // now use drupal database
-      
-      // now add the table for this view
-      $index = '';
-      if($indexed){
-         $index = ", CONSTRAINT ". $mv_table . "_index UNIQUE ($indexed) ";
-      }
-      $sql = "CREATE TABLE {$mv_table} ($mv_specs $index)"; 
-      $previous_db = tripal_db_set_active('chado');  // use chado database
-      $results = db_query($sql);
-      tripal_db_set_active($previous_db);  // now use drupal database
-      if($results){
-         drupal_set_message(t("View '$name' created"));
-      } else {
-         // if we failed to create the view in chado then
-         // remove the record from the tripal_jobs table
-         $sql = "DELETE FROM {tripal_mviews} ".
-                "WHERE mview_id = $record->mview_id";
-         db_query($sql);
-      }
-   }
-}
-/**
- * Retrieve the materialized view_id given the name
- *
- * @param $view_name
- *   The name of the materialized view
- *
- * @return
- *   The unique identifier for the given view
- *
- * @ingroup tripal_mviews_api
- */
-function tripal_mviews_get_mview_id ($view_name){
-
-   $sql = "SELECT * FROM {tripal_mviews} ".
-          "WHERE name = '%s'";
-   if(db_table_exists('tripal_mviews')){
-      $mview = db_fetch_object(db_query($sql,$view_name));
-	   if($mview){
-	      return $mview->mview_id;
-	   }
-   }
-   return 0;
-}
-/**
-*
-*
-* @ingroup tripal_core
-*/
-function tripal_mviews_action ($op,$mview_id,$redirect=0){
-   global $user;
-   $args = array("$mview_id");
-   
-   if(!$mview_id){
-      return '';
-   }
-
-   // get this mview details
-   $sql = "SELECT * FROM {tripal_mviews} WHERE mview_id = $mview_id ";
-   $mview = db_fetch_object(db_query($sql));
-   
-   // add a job or perform the action based on the given operation
-   if($op == 'update'){
-      tripal_add_job("Update materialized view '$mview->name'",'tripal_core',
-         'tripal_update_mview',$args,$user->uid);
-	}
-   if($op == 'delete'){
-	   // remove the mview from the tripal_mviews table
-	   $sql = "DELETE FROM {tripal_mviews} ".
-             "WHERE mview_id = $mview_id";
-      db_query($sql);
-		
-	   // drop the table from chado if it exists
-      $previous_db = tripal_db_set_active('chado');  // use chado database
-      if (db_table_exists($mview->mv_table)) {
-         $sql = "DROP TABLE $mview->mv_table";
-         db_query($sql);
-      }
-      tripal_db_set_active($previous_db);  // now use drupal database
-   }
-   if($redirect){
-      drupal_goto("admin/tripal/mviews");
-   }
-}
-/**
-* Update a Materialized View
-*
-* @param $mview_id
-*   The unique identifier for the materialized view to be updated
-*
-* @return
-*   True if successful, false otherwise
-*
-* @ingroup tripal_mviews_api
-*/
-function tripal_update_mview ($mview_id){
-   $sql = "SELECT * FROM {tripal_mviews} WHERE mview_id = %d ";
-   $mview = db_fetch_object(db_query($sql,$mview_id));
-   if($mview){
-      $previous_db = tripal_db_set_active('chado');  // use chado database
-	   $results = db_query("DELETE FROM {$mview->mv_table}");
-      $results = db_query("INSERT INTO $mview->mv_table ($mview->query)");
-      tripal_db_set_active($previous_db);  // now use drupal database
-      if($results){
-	      $record = new stdClass();
-         $record->mview_id = $mview_id;
-         $record->last_update = time();
-		   drupal_write_record('tripal_mviews',$record,'mview_id');
-		   return 1;
-      } else {
-	     // TODO -- error handling
-	     return 0;
-	  }
-   }
-}
-/**
-*
-*
-* @ingroup tripal_mviews_api
-*/
-function tripal_mview_report ($mview_id) {
-   // get this mview details
-   $sql = "SELECT * FROM {tripal_mviews} WHERE mview_id = $mview_id ";
-   $mview = db_fetch_object(db_query($sql));
-
-   // create a table with each row containig stats for
-   // an individual job in the results set.
-
-   $return_url = url("admin/tripal/mviews/");
-
-   $output .= "<p><a href=\"$return_url\">Return to table of materialized views.</a></p>";
-   $output .= "<br />";
-   $output .= "<p>Details for <b>$mview->name</b>:</p>";
-   $output .= "<br />";
-   $output .= "<table class=\"border-table\">";
-   if($mview->name){
-      $output .= "  <tr>".
-      "    <th>View Name</th>".
-      "    <td>$mview->name</td>".
-      "  </tr>";
-   }   
-   if($mview->modulename){
-      $output .= "  <tr>".
-      "    <th>Module Name</th>".
-      "    <td>$mview->modulename</td>".
-      "  </tr>";
-   }
-   if($mview->mv_table){
-      $output .= "  <tr>".
-      "    <th>Table Name</th>".
-      "    <td>$mview->mv_table</td>".
-      "  </tr>";
-   }   
-   if($mview->mv_specs){
-      $output .= "  <tr>".
-      "    <th>Table Field Definitions</th>".
-      "    <td>$mview->mv_specs</td>".
-      "  </tr>";
-   }   
-   if($mview->query){
-      $output .= "  <tr>".
-      "    <th>Query</th>".
-      "    <td><pre>$mview->query</pre></td>".
-      "  </tr>";
-   }   
-   if($mview->indexed){
-      $output .= "  <tr>".
-      "    <th>Indexed Fields</th>".
-      "    <td>$mview->indexed</td>".
-      "  </tr>";
-   }   
-   if($mview->special_index){
-      $output .= "  <tr>".
-      "    <th>Special Indexed Fields</th>".
-      "    <td>$mview->speical_index</td>".
-      "  </tr>";
-   }   
-   if($mview->last_update > 0){
-      $update = format_date($mview->last_update);
-   } else {
-      $update = 'Not yet populated';
-   }
-   $output .= "  <tr>".
-      "    <th>Last Update</th>".
-      "    <td>$update</td>".
-      "  </tr>";
-
-   // build the URLs using the url function so we can handle installations where
-   // clean URLs are or are not used
-   $update_url = url("admin/tripal/mviews/action/update/$mview->mview_id");
-   $delete_url = url("admin/tripal/mviews/action/delete/$mview->mview_id");
-   $edit_url = url("admin/tripal/mviews/edit/$mview->mview_id");
-
-   $output .= "<tr><th>Actions</th>".
-              "<td> <a href='$update_url'>Update</a>, ".
-              "     <a href='$edit_url'>Edit</a>, ".
-              "     <a href='$delete_url'>Delete</a></td></tr>";
-
-   $output .= "</table>";
-
-   return $output;
-}
-/**
-*
-*
-* @ingroup tripal_mviews_api
-*/
-function tripal_mviews_report () {
-
-   $header = array('','MView Name','Last Update','');
-   $rows = array();
-
-   $mviews = db_query("SELECT * FROM {tripal_mviews} ORDER BY name");  
-   while($mview = db_fetch_object($mviews)){
-      if($mview->last_update > 0){
-         $update = format_date($mview->last_update);
-      } else {
-         $update = 'Not yet populated';
-      }
-      $rows[] = array(
-         l('View',"admin/tripal/mviews/report/$mview->mview_id") ." | ".
-            l('Update',"admin/tripal/mviews/action/update/$mview->mview_id"),
-         $mview->name,
-         $update,
-         l('Delete',"admin/tripal/mviews/action/delete/$mview->mview_id"),
-      );
-   }
-   $rows[] = array(
-      'data' => array( 
-         array('data' => l('Create a new materialized view.',"admin/tripal/mviews/new"), 
-               'colspan' => 4),
-         )
-   );
-   return theme('table', $header, $rows);
-}
-/**
-*
-*
-* @ingroup tripal_core
-*/
-function tripal_mviews_form(&$form_state = NULL,$mview_id = NULL){
-
-   if(!$mview_id){
-      $action = 'Add';
-   } else {
-      $action = 'Update';
-   }
-
-   // get this requested view
-   if(strcmp($action,'Update')==0){
-      $sql = "SELECT * FROM {tripal_mviews} WHERE mview_id = $mview_id ";
-      $mview = db_fetch_object(db_query($sql));
-
-
-      # set the default values.  If there is a value set in the 
-      # form_state then let's use that, otherwise, we'll pull 
-      # the values from the database 
-      $default_name = $form_state['values']['name'];
-      $default_mv_table = $form_state['values']['mv_table'];
-      $default_mv_specs = $form_state['values']['mv_specs'];
-      $default_indexed = $form_state['values']['indexed'];
-      $default_mvquery = $form_state['values']['mvquery'];
-      $default_special_index = $form_state['values']['special_index'];
-      if(!$default_name){
-         $default_name = $mview->name;
-      }
-      if(!$default_mv_table){
-         $default_mv_table = $mview->mv_table;
-      }
-      if(!$default_mv_specs){
-         $default_mv_specs = $mview->mv_specs;
-      }
-      if(!$default_indexed){
-         $default_indexed = $mview->indexed;
-      }
-      if(!$default_mvquery){
-         $default_mvquery = $mview->query;
-      }
-      if(!$default_special_index){
-         $default_special_index = $mview->special_index;
-      }
-   }
-   // Build the form
-   $form['action'] = array(
-      '#type' => 'value',
-      '#value' => $action
-   );
-   $form['mview_id'] = array(
-      '#type' => 'value',
-      '#value' => $mview_id
-   );
-   $form['name']= array(
-      '#type'          => 'textfield',
-      '#title'         => t('View Name'),
-      '#description'   => t('Please enter the name for this materialized view.'),
-      '#required'      => TRUE,
-      '#default_value' => $default_name,
-      '#weight'        => 1
-   );
-
-   $form['mv_table']= array(
-      '#type'          => 'textfield',
-      '#title'         => t('Table Name'),
-      '#description'   => t('Please enter the Postgres table name that this view will generate in the database.  You can use the schema and table name for querying the view'),
-      '#required'      => TRUE,
-      '#default_value' => $default_mv_table,
-      '#weight'        => 3
-   );
-   $form['mv_specs']= array(
-      '#type'          => 'textarea',
-      '#title'         => t('Table Definition'),
-      '#description'   => t('Please enter the field definitions for this view. Each field should be separated by a comma or enter each field definition on each line.'),
-      '#required'      => TRUE,
-      '#default_value' => $default_mv_specs,
-      '#weight'        => 4
-   );
-   $form['indexed']= array(
-      '#type'          => 'textarea',
-      '#title'         => t('Indexed Fields'),
-      '#description'   => t('Please enter the field names (as provided in the table definition above) that will be indexed for this view.  Separate by a comma or enter each field on a new line.'),
-      '#required'      => FALSE,
-      '#default_value' => $default_indexed,
-      '#weight'        => 5
-   );
-   $form['mvquery']= array(
-      '#type'          => 'textarea',
-      '#title'         => t('Query'),
-      '#description'   => t('Please enter the SQL statement used to populate the table.'),
-      '#required'      => TRUE,
-      '#default_value' => $default_mvquery,
-      '#weight'        => 6
-   );
-/**
-   $form['special_index']= array(
-      '#type'          => 'textarea',
-      '#title'         => t('View Name'),
-      '#description'   => t('Please enter the name for this materialized view.'),
-      '#required'      => TRUE,
-      '#default_value' => $default_special_index,
-      '#weight'        => 7
-   );
-*/
-   $form['submit'] = array (
-     '#type'         => 'submit',
-     '#value'        => t($action),
-     '#weight'       => 8,
-     '#executes_submit_callback' => TRUE,
-   );
-
-   $form['#redirect'] = 'admin/tripal/mviews';
-   return $form;
-}
-/**
-*
-*
-* @ingroup tripal_core
-*/
-function tripal_mviews_form_submit($form, &$form_state){
-   
-   $action = $form_state['values']['action'];
-   $mview_id = $form_state['values']['mview_id'];
-   $name = $form_state['values']['name'];
-   $mv_table = $form_state['values']['mv_table'];
-   $mv_specs = $form_state['values']['mv_specs'];
-   $indexed = $form_state['values']['indexed'];
-   $query = $form_state['values']['mvquery'];
-   $special_index = $form_state['values']['special_index'];
-
-   if(strcmp($action,'Update')==0){
-      // updating the materialized view consits of deleting the old entry
-      // and readding.  This is necessary because a change to any of the fields
-      // other than the query changes the nature of table so it needs to be 
-      // rebuilt
-      tripal_mviews_action ('delete',$mview_id);
-      tripal_add_mview ($name, 'tripal_core',$mv_table, $mv_specs,$indexed,$query,$special_index);
-   }
-   else if(strcmp($action,'Add')==0){
-      tripal_add_mview ($name, 'tripal_core',$mv_table, $mv_specs,$indexed,$query,$special_index);
-   }
-   else {
-        drupal_set_message("No action performed.");
-   }
-   return '';
-}

+ 0 - 1
base/tripal_db/views/handlers/views_handler_field_dbxref_accession_link.inc

@@ -1 +0,0 @@
-../../../tripal_core/views/handlers/views_handler_field_dbxref_accession_link.inc

+ 0 - 353
base/tripal_feature/tripal_feature-properties.inc

@@ -1,353 +0,0 @@
-<?php
-
-/**
- *
- *
- * @ingroup tripal_feature
- */
-function tripal_feature_edit_ALL_properties_page($node) {
-  $output = '';
-
-  $properties = tripal_core_chado_select(
-    'featureprop', 
-    array('featureprop_id','type_id','value','rank'), 
-    array(
-      'feature_id' => $node->feature->feature_id
-    ),
-    array('order_by' => array('type_id' => 'ASC','rank'=>'ASC'))
-  );
-  $expand_add = (sizeof($properties)) ? FALSE : TRUE;
-  
-  $output .= drupal_get_form('tripal_feature_add_ONE_property_form', $node, $expand_add);
-  $output .= drupal_get_form('tripal_feature_edit_ALL_properties_form', $node, $properties);
-  $output .= drupal_get_form('tripal_feature_implement_back_to_feature_button', $node->nid);
-
-  return $output;
-}
-
-/**
- * 
- *
- * @ingroup tripal_feature
- */
-function tripal_feature_add_ONE_property_form($form_state, $node, $expand) {
-  $form = array();
-  $feature_id = $node->feature->feature_id;
-
-  $form['add_properties'] = array(
-    '#type' => 'fieldset',
-    '#title' => t('Add Property'),
-    '#collapsible' => TRUE,
-    '#collapsed' => ($expand) ? FALSE : TRUE,
-  ); 
-
-  $form['prop_nid'] = array(
-    '#type' => 'hidden',
-    '#value' => $node->nid
-  );
-	
-  $prop_type_options = array();
-  $results = tripal_core_chado_select('cvterm',array('cvterm_id','name'), array('cv_id' => array('name' => 'feature_property')));
-  foreach ($results as $r) {
-    $prop_type_options[$r->cvterm_id] = $r->name;
-  }
-  $form['add_properties']['prop_type_id'] = array(
-    '#type' => 'select',
-    '#title' => t('Type of Property'),
-    '#options' => $prop_type_options,
-  );
-
-  $form['add_properties']['prop_value'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Value'),
-  );
-
-  $form['add_properties']['prop_feature_id'] = array(
-    '#type' => 'value',
-    '#value' => $feature_id,
-    '#required' => TRUE
-  );
-
-  $form['add_properties']['submit-add'] = array(
-    '#type' => 'submit',         
-    '#value' => t('Add Property')
-  );
-
-  return $form;
-}
-
-/**
- * 
- *
- * @ingroup tripal_feature
- */
-function tripal_feature_add_ONE_property_form_validate($form, &$form_state) {
-
-  // Only Require if Adding Property
-  if ($form_state['clicked_button']['#value'] == t('Add Property') ) {
-
-		// Check that there is a feature
-		if ( $form_state['values']['prop_feature_id'] <= 0 ) {
-			form_set_error('prop_feature_id', 'There is no associated feature.');
-		}
-		
-    // Check that Selected a type
-    if ( $form_state['values']['prop_type_id'] == 0) {
-      form_set_error('prop_type_id', 'Please select a type of property.');
-    } else {
-      // Check that type is in chado
-      $previous_db = tripal_db_set_active('chado');
-      $num_rows = db_fetch_object(db_query("SELECT count(*) as count FROM cvterm WHERE cvterm_id=%d", $form_state['values']['prop_type_id']));
-      tripal_db_set_active($previous_db);
-      if ( $num_rows->count != 1) {
-        form_set_error('prop_type_id', "The type you selected is not valid. Please choose another one. (CODE:$num_rows)");
-      } // end of if more or less than 1 row
-    } // if no prop type
-
-
-
-  } // if add Property
-
-}
-
-/**
- * 
- *
- * @ingroup tripal_feature
- */
-function tripal_feature_add_ONE_property_form_submit($form, &$form_state) {
-	
-  // if there is a property add it (only won't be a property if clicked next step w/ no property)
-  if ($form_state['values']['prop_type_id'] != 0) {
-    //determine the rank for this property
-    $max_rank = get_max_chado_rank('featureprop', 
-       array('feature_id'=>array('type'=>'INT','value'=>$form_state['values']['prop_feature_id']), 
-       'type_id'=>array('type'=>'INT','value'=> $form_state['values']['prop_type_id']) ));
-    if ($max_rank == -1) { $rank = 0; 
-    } else { $rank = $max_rank+1; }
-    
-    $previous_db = tripal_db_set_active('chado');
-    db_query(
-      "INSERT INTO featureprop (feature_id, type_id, value, rank) VALUES (%d, %d, '%s', %d)",
-      $form_state['values']['prop_feature_id'],
-      $form_state['values']['prop_type_id'],
-      $form_state['values']['prop_value'],
-      $rank
-    );
-    tripal_db_set_active($previous_db);
-
-    drupal_set_message("Successfully Added Property");
-
-  } //end of if property to add
-}
-
-/**
- * Implements Hook_form()
- * Handles adding of Properties for features
- *
- * @ingroup tripal_feature
- */ 
-function tripal_feature_edit_ALL_properties_form($form_state, $node, $properties) {
-  $form = array();
-
-  $form['nid'] = array(
-    '#type' => 'hidden',
-    '#value' => $node->nid
-  );
-  
-  if (sizeof($properties)) {
-    
-    $prop_type_options = array();
-    $results = tripal_core_chado_select('cvterm',array('cvterm_id','name'), array('cv_id' => array('name' => 'feature_property')));
-    foreach ($results as $r) {
-      $prop_type_options[$r->cvterm_id] = $r->name;
-    }
-      
-    foreach ($properties as $i => $property) {
-    
-      $form["num-$i"] = array(
-       '#type' => 'fieldset',
-       '#value' => "Property $i"
-      );
-      
-      $form["num-$i"]["id-$i"] = array(
-       '#type' => 'hidden',
-       '#value' => $property->featureprop_id
-      );
-      
-      $default = array_search($property->type, $prop_type_options);  
-      $form["num-$i"]["type-$i"] = array(
-       '#type' => 'select',
-       //'#title' => t('Type of Property'),
-       '#options' => $prop_type_options,
-       '#default_value' => $property->type_id
-      );
-      
-      $form["num-$i"]["value-$i"] = array(
-       '#type' => 'textfield',
-       //'#title' => t('Value'),
-       '#default_value' => $property->value
-      );
-      
-      $form["num-$i"]["delete-$i"] = array(
-       '#type' => 'submit',
-       '#value' => t("Delete"),
-       '#name' => "delete-$i",
-      );
-    }//end of foreach property
-  
-    $form['num_properties'] = array(
-      '#type' => 'hidden',
-      '#value' => $i
-    );
-  
-    $form["submit-edits"] = array(
-      '#type' => 'submit',
-      '#value' => t('Update All Properties')
-    );
-  }
-  
-  return $form;
-}
-
-/**
- * 
- *
- * @ingroup tripal_feature
- */
-function tripal_feature_edit_ALL_properties_form_submit($form, &$form_state) {
-
-  if ($form_state['clicked_button']['#value'] == t('Update All Properties') ) {
-     //Update all
-     for ($i=1; $i<=$form_state['values']['num_properties']; $i++) {
-       tripal_feature_update_property($form_state['values']["id-$i"], $form_state['values']["type-$i"], $form_state['values']["value-$i"], $form_state['values']["preferred-$i"], $form_state['values']["nid"]);
-     }
-     drupal_set_message("Updated all Properties");
-     drupal_goto('node/'.$form_state['values']['nid']);
-  } elseif ( preg_match('/delete-(\d+)/', $form_state['clicked_button']['#name'], $matches) ) {
-     $i = $matches[1];
-     tripal_feature_delete_property($form_state['values']["id-$i"], $form_state['values']["type-$i"], $form_state['values']["value-$i"]);
-     drupal_set_message("Deleted Property");
-  } else {
-    drupal_set_message("Unrecognized Button Pressed",'error');
-  }
-
-  
-}
-
-/**
- * 
- *
- * @ingroup tripal_feature
- */
-function tripal_feature_update_property($featureprop_id, $cvterm_id, $value, $preferred, $nid) {
-
-	$previous_db = tripal_db_set_active('chado');
-	$old_obj = db_fetch_object(db_query("SELECT * FROM featureprop WHERE featureprop_id=%d",$featureprop_id));
-	tripal_db_set_active($previous_db);
-	
-	// if they changed the type need to check rank
-	//   (if there is another property of the same type then rank needs to be increased to prevent collisions)
-	if ($cvterm_id == $old_obj->type_id) {
-	  $previous_db = tripal_db_set_active('chado');
-  	db_query(
-    	"UPDATE featureprop SET type_id=%d, value='%s' WHERE featureprop_id=%d",
-    	$cvterm_id, 
-    	$value,
-    	$featureprop_id
-  	);
-  	tripal_db_set_active($previous_db);
-  } else {
-      //determine the rank for this property
-    $max_rank = get_max_chado_rank('featureprop', 
-       array('feature_id'=>array('type'=>'INT','value'=> $old_obj->feature_id), 
-    	 'type_id'=>array('type'=>'INT','value'=> $cvterm_id ) ));
-    if ($max_rank == -1) { $rank = 0; 
-    } else { $rank = $max_rank+1; }
-	  $previous_db = tripal_db_set_active('chado');
-  	db_query(
-    	"UPDATE featureprop SET type_id=%d, value='%s', rank=%d WHERE featureprop_id=%d",
-    	$cvterm_id, 
-    	$value,
-    	$rank,
-    	$featureprop_id
-  	);
-  	tripal_db_set_active($previous_db);  	
-  }
-                                                                                                                                                                                                                          
-    module_load_include('inc', 'node', 'node.pages');                                                                                                                                                                                
-    drupal_execute('chado_feature_node_form', $node_form_state, $node);  
-
-}
-
-/**
- * 
- *
- * @ingroup tripal_feature
- */
-function tripal_feature_delete_property($featureprop_id) {
-
-  $previous_db = tripal_db_set_active('chado');
-  db_query(
-    "DELETE FROM featureprop WHERE featureprop_id=%d",
-    $featureprop_id
-  );
-  tripal_db_set_active($previous_db);
-
-}
-
-/**
- * 
- *
- * @ingroup tripal_feature
- */
-function theme_tripal_feature_edit_ALL_properties_form ($form) {
-  $output = '';
-  
-  $output .= '<br><fieldset>';
-  $output .= '<legend>Edit Already Existing Properties<span class="form-optional" title="This field is optional">(optional)</span></legend>';
-  $output .= '<p>Below is a list of already existing properties for this feature, one property per line. The type refers to the type of '
-  	     .'property and the value is the value for that property. </p>';
-  $output .= '<table>';
-  $output .= '<tr><th>#</th><th>Type</th><th>Value</th><th></th></tr>';
-
-  for ($i=0; $i<=$form['num_properties']['#value']; $i++) {
-    if (isset($form["num-$i"])) {
-      $output .= '<tr><td>'.($i+1).'</td><td>'.drupal_render($form["num-$i"]["type-$i"]).'</td><td>'.drupal_render($form["num-$i"]["value-$i"]).'</td><td>'.drupal_render($form["num-$i"]["delete-$i"]).'</td></tr>';
-      unset($form["num-$i"]);
-    }
-  }
-
-  $output .= '</table><br>';
-  $output .= drupal_render($form);
-  $output .= '</fieldset>';
-
-  return $output;
-}
-
-/**
- * 
- *
- * @ingroup tripal_feature
- */
-function tripal_feature_list_properties_for_node($properties) {
-
-  if (!empty($properties)) {
-    $output = '<table>';
-    $output .= '<tr><th>Type</th><th>Value</th></tr>';
-
-
-    if (!empty($properties) ) {
-      foreach ($properties as $p) {
-        $output .= '<tr><td>'.$p->type.'</td><td>'.$p->value.'</td></tr>';
-      } // end of foreach property
-    }
-
-    $output .= '</table>';
-
-  } else {
-    $output = 'No properties exist for the current feature';
-  }
-
-  return $output;
-}

+ 0 - 255
base/tripal_feature/tripal_feature.api.inc

@@ -1,255 +0,0 @@
-<?php
- 
-/**
- * Implements hook_chado_feature_schema()
- * Purpose: To add descriptions and foreign keys to default table description
- * Note: This array will be merged with the array from all other implementations
- *
- * @return
- *    Array describing the feature table
- *
- * @ingroup tripal_schema_api
- */
-function tripal_feature_chado_feature_schema() {
-  $description = array();
-
-  // Default table description in tripal_core.schema.api.inc: tripal_core_chado_feature_schema()
-
-  $description['foreign keys']['organism'] = array(
-        'table' => 'organism',
-        'columns' => array(
-          'organism_id' => 'organism_id',
-        ),
-  );
-  
-  $description['foreign keys']['dbxref'] = array(
-        'table' => 'dbxref',
-        'columns' => array(
-          'dbxref_id' => 'dbxref_id',
-        ),
-  );
-  
-  $description['foreign keys']['cvterm'] = array(
-        'table' => 'cvterm',
-        'columns' => array(
-          'type_id' => 'cvterm_id',
-        ),
-  );
-  
-  $referring_tables = array('analysisfeature',
-    'element',
-    'feature_cvterm',
-    'feature_dbxref',
-    'feature_expression',
-    'feature_genotype',
-    'feature_phenotype',
-    'feature_pub',
-    'feature_relationship',
-    'feature_synonym',
-    'featureloc',
-    'featurepos',
-    'featureprop',
-    'featurerange',
-    'library_feature',
-    'phylonode',
-    'wwwuser_feature'
-  );
-  $description['referring_tables'] = $referring_tables;
-
-  return $description;
-}
-
-/**
- * Implements hook_chado_featureprop_schema()
- * Purpose: To add descriptions and foreign keys to default table description
- * Note: This array will be merged with the array from all other implementations
- *
- * @return
- *    Array describing the featureprop table
- *
- * @ingroup tripal_schema_api
- */
-function tripal_feature_chado_featureprop_schema() {
-  $description = array();
-
-  // Default table description in tripal_core.schema.api.inc: tripal_core_chado_featureprop_schema()
-
-  $description['foreign keys']['feature'] = array(
-        'table' => 'feature',
-        'columns' => array(
-          'feature_id' => 'feature_id',
-        ),
-  );
-  
-  $description['foreign keys']['cvterm'] = array(
-        'table' => 'cvterm',
-        'columns' => array(
-          'type_id' => 'cvterm_id',
-        ),
-  );
-  
-  $referring_tables = array('analysisfeature',
-    'featureprop_pub',
-  );
-  $description['referring_tables'] = $referring_tables;
-
-  return $description;
-}
-
-/**
- * Implements hook_chado_featureloc_schema()
- * Purpose: To add descriptions and foreign keys to default table description
- * Note: This array will be merged with the array from all other implementations
- *
- * @return
- *    Array describing the featureloc table
- *
- * @ingroup tripal_schema_api
- */
-function tripal_feature_chado_featureloc_schema() {
-  $description = array();
-
-  // Default table description in tripal_core.schema.api.inc: tripal_core_chado_featureloc_schema()
-
-  $description['foreign keys']['feature'] = array(
-        'table' => 'feature',
-        'columns' => array(
-          'feature_id' => 'feature_id',
-          'srcfeature_id' => 'feature_id'
-        ),
-  );
-  
-  $referring_tables = array('analysisfeature',
-    'featureloc_pub',
-  );
-  $description['referring_tables'] = $referring_tables;
-
-  return $description;
-}
-
-/**
- * Implements hook_chado_feature_dbxref_schema()
- * Purpose: To add descriptions and foreign keys to default table description
- * Note: This array will be merged with the array from all other implementations
- *
- * @return
- *    Array describing the feature_dbxref table
- *
- * @ingroup tripal_schema_api
- */
-function tripal_feature_chado_feature_dbxref_schema() {
-  $description = array();
-
-  // Default table description in tripal_core.schema.api.inc: tripal_core_chado_feature_dbxref_schema()
-
-  $description['foreign keys']['feature'] = array(
-        'table' => 'feature',
-        'columns' => array(
-          'feature_id' => 'feature_id',
-        ),
-  );
-
-  $description['foreign keys']['dbxref'] = array(
-        'table' => 'dbxref',
-        'columns' => array(
-          'dbxref_id' => 'dbxref_id',
-        ),
-  );
-
-  return $description;
-}
-/**
- * Implements hook_chado_feature_relationship_schema()
- * Purpose: To add descriptions and foreign keys to default table description
- * Note: This array will be merged with the array from all other implementations
- *
- * @return
- *    Array describing the feature_dbxref table
- *
- * @ingroup tripal_schema_api
- */
-function tripal_feature_chado_feature_relationship_schema() {
-  $description = array();
-
-  // Default table description in tripal_core.schema.api.inc: tripal_core_chado_feature_dbxref_schema()
-
-  $description['foreign keys']['feature'] = array(
-        'table' => 'feature',
-        'columns' => array(
-          'object_id' => 'feature_id',
-          'subject_id' => 'feature_id',
-        ),
-  );
-  $description['foreign keys']['cvterm'] = array(
-        'table' => 'cvterm',
-        'columns' => array(
-          'type_id' => 'cvterm_id',
-        ),
-  );
-  return $description;
-}
-/**
- * Implements hook_chado_feature_relationship_schema()
- * Purpose: To add descriptions and foreign keys to default table description
- * Note: This array will be merged with the array from all other implementations
- *
- * @return
- *    Array describing the feature_dbxref table
- *
- * @ingroup tripal_schema_api
- */
-function tripal_feature_chado_feature_cvterm_schema() {
-  $description = array();
-
-  // Default table description in tripal_core.schema.api.inc: tripal_core_chado_feature_dbxref_schema()
-
-  $description['foreign keys']['feature'] = array(
-        'table' => 'feature',
-        'columns' => array(
-          'feature_id' => 'feature_id',
-        ),
-  );
-  $description['foreign keys']['cvterm'] = array(
-        'table' => 'cvterm',
-        'columns' => array(
-          'type_id' => 'cvterm_id',
-        ),
-  );
-  $description['foreign keys']['pub'] = array(
-        'table' => 'pub',
-        'columns' => array(
-          'pub_id' => 'pub_id',
-        ),
-  );
-  return $description;
-}
-/**
-*
-* @ingroup tripal_schema_api
-*/
-function tripal_feature_chado_feature_synonym_schema() {
-  $description = array();
-
-  // Default table description in tripal_core.schema.api.inc: tripal_core_chado_feature_dbxref_schema()
-
-  $description['foreign keys']['feature'] = array(
-        'table' => 'feature',
-        'columns' => array(
-          'feature_id' => 'feature_id',
-        ),
-  );
-  $description['foreign keys']['synonym'] = array(
-        'table' => 'synonym',
-        'columns' => array(
-          'synonym_id' => 'synonym_id',
-        ),
-  );
-  $description['foreign keys']['pub'] = array(
-        'table' => 'pub',
-        'columns' => array(
-          'pub_id' => 'pub_id',
-        ),
-  );
-
-  return $description;
-}

+ 0 - 1
base/tripal_feature/views/handlers/views_handler_field_readable_date.inc

@@ -1 +0,0 @@
-../../../tripal_core/views/handlers/views_handler_field_readable_date.inc

+ 0 - 1
base/tripal_library/views/handlers/views_handler_field_readable_date.inc

@@ -1 +0,0 @@
-../../../tripal_core/views/handlers/views_handler_field_readable_date.inc

+ 0 - 924
extensions/tripal_analysis_blast/includes/parse_blast_XML.inc

@@ -1,924 +0,0 @@
-<?php
-
-/*******************************************************************************
- * Parse NCBI Blast results for indexing so that user can use blast results to
- * find corresponding features
- */
-function parse_NCBI_Blast_XML_index_version($xml_string,$db,$feature_id) {
-	// Get the parser using db_id
-	$sql = "SELECT * FROM {tripal_analysis_blast} WHERE db_id = %d";
-	$parser = db_fetch_object(db_query($sql, $db->db_id));
-	$db_name = $parser->displayname;
-	$is_genbank = $parser->genbank_style;
-	$regex_hit_id = $parser->regex_hit_id;
-	$regex_hit_def = $parser->regex_hit_def;
-	$regex_hit_accession = $parser->regex_hit_accession;
-
-	// set default if regular expressions have not been specified
-	if(!$regex_hit_id){
-		$regex_hit_id = '/^(.*?)\s.*$/';
-	} else {
-		$regex_hit_id = '/'.$regex_hit_id.'/';
-	}
-	if(!$regex_hit_def){
-		$regex_hit_def = '/^.*?\s(.*)$/';
-	} else {
-		$regex_hit_def = '/'.$regex_hit_def.'/';
-	}
-	if(!$regex_hit_accession){
-		$regex_hit_accession = '/^(.*?)\s.*$/';
-	} else {
-		$regex_hit_accession = '/'.$regex_hit_accession.'/';
-	}
-
-	$html_out .= "<h3>$db_name</h3>";
-
-	// Load the file.  This XML file should be an extract
-	// of the original XML file with only a single iteration.
-	// An iteration is essentially all the hits for a single
-	// query sequence.
-	$xml_output = simplexml_load_string($xml_string);
-	$iteration = '';
-	// new XML file parser has added the feature name within <Iteration_query-def> tags.
-	if ($xml_output->getName() == 'Iteration') {
-		foreach ($xml_output->children() as $xml_tag) {
-			if ($xml_tag->getName() == 'Iteration_query-def') {
-				// Here we show the feature name again to check if we pull the correct data
-				$html_out .= "Query: $xml_tag<br>";
-			} else if ($xml_tag->getName() == 'Iteration_hits') {
-				$iteration = $xml_tag;
-			}
-		}
-		// This is for the file parsed by the old parser
-	} else {
-		$iteration = $xml_output;
-	}
-
-	// now run through the blast hits/hsps of this iteration
-	// and generate the rows of the table
-	foreach($iteration->children() as $hits){
-		$best_evalue = 0;
-		foreach($hits->children() as $hit){
-			$best_evalue = 0;
-			$element_name = $hit->getName();
-			if($element_name == 'Hit_id'){
-				// if parsing "name, acc, desc" from three tags (1/3)
-				if ($is_genbank) {
-					$hit_name = $hit;
-				}
-			} else if($element_name == 'Hit_def'){
-				if($is_genbank){
-					$description = $hit;
-				} else {
-					$accession = preg_replace($regex_hit_accession,"$1",$hit);
-					$hit_name = preg_replace($regex_hit_id,"$1",$hit);
-					$description = preg_replace($regex_hit_def,"$1",$hit);
-				}
-			} else if($element_name == 'Hit_accession'){
-				// if parsing "name, acc, desc" from three tags (3/3)
-				if ($is_genbank){
-					$accession = $hit;
-				}
-				// now run through each HSP for this hit
-			}
-		}
-		$html_out .= "<p>$hit_name<br>";
-		$html_out .= "$accession<br>";
-		$html_out .= "<b>$description</b></br>";
-		$hsp_html_out = '';
-	}
-	return $html_out;
-}
-
-/*******************************************************************************
- * Parse Blast XML Output file into analysisfeatureprop table
- */
-function tripal_analysis_blast_parseXMLFile ($analysis_id, $blastdb, $blastfile, 
-   $no_parsed, $blastfile_ext, $query_re, $query_type, $query_uniquename,
-   $is_concat,$job_id,$is_concat) {
-
-	// Prepare log
-	$filename = preg_replace("/.*\/(.*)/", "$1", $blastfile);
-	$logfile = file_directory_path() . "/tripal/tripal_analysis_blast/load_$filename.log";
-        $logfile = tempnam(sys_get_temp_dir(),"tripal_analysis_blast_import");
-	$log = fopen($logfile, 'a'); // append parsing results to log file
-        if(!$log){
-           print "ERROR: cannot open log file: $logfile\n";
-           exit;
-        }
-
-	// If user input a file (e.g. blast.xml)
-	if (is_file($blastfile)) {
-      tripal_analysis_blast_parseXML($analysis_id, $blastdb, $blastfile, 
-         $no_parsed, $blastfile_ext, $query_re, $query_type, $query_uniquename,
-         $job_id,1,$log,$is_concat);
-	} 
-   // Otherwise, $blastfile is a directory. Iterate through all xml files in it
-   else {
-      if(!$blastfile_ext){
-         $blastfile_ext = 'xml';
-      }
-
-		$dir_handle = @opendir($blastfile) or die("Unable to open $blastfile");
-		$pattern = sql_regcase($blastfile . "/*.$blastfile_ext");
-		$total_files = count(glob($pattern));
-		print "$total_files file(s) to be parsed.\n";
-		
-		$interval = intval($total_files * 0.01);
-		$no_file = 0;
-			
-		// Parsing all files in the directory
-		while ($file = readdir($dir_handle)) {
-			if(preg_match("/^.*\.$blastfile_ext/i",$file)){
-
-            tripal_analysis_blast_parseXML($analysis_id, $blastdb, "$blastfile/$file", 
-              $no_parsed, $blastfile_ext, $query_re, $query_type, $query_uniquename,
-              $job_id,0,$log);
-
-			   // Set job status
-			   if ($no_file % $interval == 0) {
-			      $percentage = (int) (($no_file / $total_files) * 100);
-				   tripal_job_set_progress($job_id, $percentage);
-				   print $percentage."%\r";
-			   }				
-         }
-   	   $no_file ++;
-		}
-	}
-
-	print "Done.\nSuccessful and failed entries have been saved in the log file:\n $logfile\n";
-	fwrite($log, "\n");
-	fclose($log);
-	return;
-}
-/********************************************************************************
- * 
- */
-function tripal_analysis_blast_parseXML($analysis_id, $blastdb, $blastfile, 
-   $no_parsed, $blastfile_ext, $query_re, $query_type, $query_uniquename,
-  $job_id,$set_progress,$log,$is_concat){
-
-	// Parsing started
-	print "Parsing File:".$blastfile." ...\n";
-	fwrite($log, date("D M j G:i:s Y").". Loading $blastfile\n");
-	if ($no_parsed == 'all') {
-		print "Parsing all hits...\n";
-	} else {
-		print "Parsing top $no_parsed hits...\n";
-	}
-	
-	// Get cvterm_id for 'analysis_blast_output_iteration_hits' which is required
-	// for inserting into the analysisfeatureprop table
-	$previous_db = tripal_db_set_active('chado'); // use chado database
-	$sql = "SELECT CVT.cvterm_id ".
-          "FROM {cvterm} CVT ".
-          "   INNER JOIN {cv} ON cv.cv_id = CVT.cv_id ".
-          "WHERE CVT.name = 'analysis_blast_output_iteration_hits' ".
-          "   AND CV.name = 'tripal'";
-	$type_id = db_result(db_query($sql));
-
-	// Load the XML file.
-   if (!is_readable($blastfile)) {
-      exit("Could not open the XML file '$blastfile'.  Check that file exists and that permissions are correct.\n");
-   }
-   
-   // if the file is a set of concatenated files then we want to split it up
-   // and run each one individually
-   if($is_concat){
-
-      // generate a temporary file name
-      $temp = tempnam(sys_get_temp_dir(),'blast_');
-      print "Blast XML file is concatenated.  Breaking apart and parsing each individually: $temp\n";
-      $out_fh = fopen($temp,"w");
-
-      // run through the lines of the XML file
-      $in_fh = fopen($blastfile,"r");
-      while(!feof($in_fh)){
-         $line = fgets($in_fh);
-         $line = trim($line);
-         if(!$line){
-            continue;
-         }
-         fwrite($out_fh,"$line\n");
-         // if the line begins a set of blast output XML then parse the
-         // preceeding set.
-         if(preg_match("/<\/BlastOutput>/",$line)){
-            // close the temp file
-            fclose($out_fh);
-            // now parse this new temp file
-            tripal_analysis_blast_parseXML($analysis_id, $blastdb, $temp, 
-               $no_parsed, $blastfile_ext, $query_re, $query_type, $query_uniquename,
-               $job_id,$set_progress,$log,0);
-            // reopen the file for the next set of results
-            $out_fh = fopen($temp,"w");
-         }
-      }
-      fclose($in_fh);
-
-      return;
-   } 
-
-	$blastoutput = simplexml_load_file($blastfile);
-   if(!$blastoutput){
-      exit("Could not read the XML file '$blastfile'.  Check that the XML file is not corrupted.\n");
-   }
-	$no_iterations = 0;
-	foreach($blastoutput->children() as $tmp) {
-		if ($tmp->getName() == 'BlastOutput_iterations') {
-			foreach($tmp->children() as $itr) {
-				if ($itr->getName() == 'Iteration') {
-					$no_iterations ++;
-				}
-			}
-		}
-	}
-	print "$no_iterations iterations to be processed.\n";
-		
-	$interval = intval($no_iterations * 0.01);
-	$idx_iterations = 0;
-	foreach ($blastoutput->children() as $blastoutput_tags) {
-
-		if ($blastoutput_tags->getName() == 'BlastOutput_iterations') {
-			foreach($blastoutput_tags->children() as $iterations) {
-				if ($iterations->getName() == 'Iteration') {
-
-					// Set job status
-					$idx_iterations ++;
-					if ($set_progress and $idx_iterations % $interval == 0) {
-						$percentage = (int) (($idx_iterations / $no_iterations) * 100);
-						tripal_job_set_progress($job_id, $percentage);
-						print $percentage."%\r";
-					}
-					// now run through the blast hits/hsps of this iteration
-					// and generate the rows of the table
-					$feature_id = 0;
-					foreach($iterations->children() as $iteration_tags) {
-
-						// Match chado feature uniquename with <Iteration_query-def>
-						// and get the feature_id
-						$featurenaem_xml = '';
-						if($iteration_tags->getName() == 'Iteration_query-def'){
-
-							// If the Iteration_query-def in the format provided by the 
-                     // user's regular expression 
-							if ($query_re and preg_match("/$query_re/", $iteration_tags, $matches)) {
-								$feature = $matches[1];
-							} 
-                     // If not in above format then pull up to the first space
-                     else {
-								if (preg_match('/^(.*?)\s.*$/', $iteration_tags, $matches)) {
-   								$feature = $matches[1];
-                        } 
-                        // if no match up to the first space then just use the entire string
-                        else {
-                           $feature = $iteration_tags;
-                        }
-                     }   
-
-                     if(!$feature and $query_re){
-                        print "ERROR: cannot find feature for $iteration_tags using the regular expression: $query_re\n";
-                        exit;
-                     }
-
-                     // now find the feature in chado
-                     $select = array();
-                     if($query_uniquename){
-                        $select['uniquename'] = $feature;
-                     } else {
-                        $select['name'] = $feature;
-                     }
-                     if($query_type){
-                        $select['type_id'] = array(
-                          'cv_id' => array(
-                             'name' => 'sequence'
-                          ),
-                          'name' => $query_type,
-                        );
-                     }
-
-                     $feature_arr = tripal_core_chado_select('feature',array('feature_id'),$select);
-                     if(count($feature_arr) > 1){
-  							   fwrite($log, "Ambiguous: '$feature' matches more than one feature and is being skipped.\n");
-								continue;
-                     }
-                     if(count($feature_arr) == 0){
-								fwrite($log, "Failed: '$feature' cannot find a matching feature in the database.\n");
-                        continue;
-                     }
-                     $feature_id = $feature_arr[0]->feature_id;
-
-    						fwrite($log, "Matched: '$feature' => feature id:".$feature_id);
-							$featurename_xml = $iteration_tags->asXML();
-						} 
-                  // Insert Iteration_hits into analysisfeatureprop and analysisfeature tables
-                  else if($iteration_tags->getName() == 'Iteration_hits'){
-							if ($feature_id) {
-								// Make sure this iteration doesn't exist in analysisfeatureprop. If it does, update but not insert
-								$sql = "SELECT analysisfeatureprop_id FROM {analysisfeatureprop} AFP ".
-                               "INNER JOIN analysisfeature AF ON AF.analysisfeature_id = AFP.analysisfeature_id ".       
-                               "WHERE feature_id=%d ".
-                            "AND analysis_id=%d ".
-                            "AND type_id=%d ";
-
-								$result = db_query($sql, $feature_id, $analysis_id, $type_id);
-								$analysisfeatureprop = db_fetch_object($result);
-								$xml_content =  "<Iteration>\n".$featurename_xml."\n";
-								// parse all hits
-								if ($no_parsed == 'all') {
-									$xml_content .= $iteration_tags->asXML();
-								// parse only top hits
-								} else {
-									$counter = 0;
-									$xml_content .= "<Iteration_hits>\n";
-									foreach ($iteration_tags->children() As $hit) {
-										if ($counter < $no_parsed) {
-											$xml_content .= $hit->asXML();
-										} else {
-											break;
-										}
-										$counter ++;
-									}
-									$xml_content .= "</Iteration_hits>";
-								}
-								$xml_content .= "\n</Iteration>";
-
-								// If this Iteration_hits already exists, update it
-								if ($analysisfeatureprop) {
-
-									$sql = "UPDATE {analysisfeatureprop} ".
-                               "SET value = '%s' ".
-                               "WHERE analysisfeatureprop_id = %d ";
-										
-									db_query($sql, $xml_content, $analysisfeatureprop->analysisfeatureprop_id);
-									fwrite($log, " (Update)\n"); // write to log
-
-									// Otherwise, insert the Iteration_hits into analysisfeature and analysisfeatureprop tables
-								} else {
-									//------------------------------------------------------
-									// Insert into analysisfeature table
-									//------------------------------------------------------
-									$sql = "INSERT INTO {analysisfeature} (feature_id, analysis_id) ".
-                               "VALUES (%d, %d)";
-									db_query ($sql, $feature_id, $analysis_id);
-									// Get the newly inserted analysisfeature_id
-									$sql = "SELECT analysisfeature_id FROM {analysisfeature} WHERE feature_id = %d AND analysis_id = %d";
-									$analysisfeature_id = db_result(db_query($sql, $feature_id, $analysis_id));
-									//------------------------------------------------------
-									// Insert into analysisfeatureprop table
-									//------------------------------------------------------
-									$sql = "INSERT INTO {analysisfeatureprop} (analysisfeature_id, type_id, value, rank)".
-                               "VALUES (%d, %d, '%s', %d)";
-									db_query($sql, $analysisfeature_id, $type_id, $xml_content, '0');
-									fwrite($log, " (Insert)\n"); // write to log
-								}
-							}
-						}	
-					}
-				}
-			}
-		}
-	}
-	tripal_db_set_active ($previous_db); // Use drupal database
-}
-/********************************************************************************
- * 
- */
-function tripal_analysis_blast_get_result_object($xml_string,$db,$max,$feature_id, $analysis) {
-	$blast_object = new stdClass();
-
-	// Get the parser using db_id
-	$sql = "SELECT * FROM {tripal_analysis_blast} WHERE db_id = %d";
-	$parser = db_fetch_object(db_query($sql, $db->db_id));
-	$db_name = $parser->displayname;
-	$is_genbank = $parser->genbank_style;
-	$regex_hit_id = $parser->regex_hit_id;
-	$regex_hit_def = $parser->regex_hit_def;
-	$regex_hit_accession = $parser->regex_hit_accession;
-
-	// set default if regular expressions have not been specified
-	if(!$regex_hit_id){
-		$regex_hit_id = '/^(.*?)\s.*$/';
-	} else {
-		$regex_hit_id = '/'.$regex_hit_id.'/';
-	}
-	if(!$regex_hit_def){
-		$regex_hit_def = '/^.*?\s(.*)$/';
-	} else {
-		$regex_hit_def = '/'.$regex_hit_def.'/';
-	}
-	if(!$regex_hit_accession){
-		$regex_hit_accession = '/^(.*?)\s.*$/';
-	} else {
-		$regex_hit_accession = '/'.$regex_hit_accession.'/';
-	}
-
-	// Get analysis information
-	$blast_object->analysis = $analysis;
-	$db->displayname = $db_name;
-	$blast_object->db = $db;
-	if (!$db_name) {
-		$blast_object->title = $analysis->name;
-	} else {
-		$blast_object->title = $db_name;
-	}
-
-	// Find node id for the analysis
-	$ana_nid = db_result(db_query("SELECT nid FROM {chado_analysis} WHERE analysis_id = %d", $analysis->analysis_id));
-   $analysis->nid = $ana_nid;
-
-
-	// Load the file.  This XML file should be an extract
-	// of the original XML file with only a single iteration.
-	// An iteration is essentially all the hits for a single
-	// query sequence.
-	$xml_output = simplexml_load_string($xml_string);
-	$iteration = '';
-	// new XML file parser has added the feature name within <Iteration_query-def> tags.
-	if ($xml_output->getName() == 'Iteration') {
-		foreach ($xml_output->children() as $xml_tag) {
-			if ($xml_tag->getName() == 'Iteration_query-def') {
-				// Here we show the feature name again to check if we pull the correct data
-				$blast_object->xml_tag = $xml_tag;
-			} else if ($xml_tag->getName() == 'Iteration_hits') {
-				$iteration = $xml_tag;
-			}
-		}
-		// This is for the file parsed by the old parser
-	} else {
-		$iteration = $xml_output;
-	}
-
-	$number_hits = 0;
-	foreach($iteration->children() as $hits){
-		$number_hits ++;
-	}
-
-	// add the links for updating blast info using Ajax
-	$blast_object->max = $max;
-	$blast_object->number_hits = $number_hits;
-	$blast_object->feature_id = $feature_id;
-	
-	$hits_array = array();
-	$hit_count = 0;
-
-	foreach($iteration->children() as $hits){
-		$hsp_array = array();
-		$counter = 0;
-		foreach($hits->children() as $hit){
-			$best_evalue = 0;
-			$best_identity = 0;
-			$best_len = 0;
-			$element_name = $hit->getName();
-			if($element_name == 'Hit_id'){
-				// if parsing "name, acc, desc" from three tags (1/3)
-				if ($is_genbank) {
-					$hit_name = $hit;
-				}
-			} else if($element_name == 'Hit_def'){
-				if($is_genbank){
-					$description = $hit;
-				} else {
-					$accession = preg_replace($regex_hit_accession,"$1",$hit);
-					$hit_name = preg_replace($regex_hit_id,"$1",$hit);
-					$description = preg_replace($regex_hit_def,"$1",$hit);
-				}
-			} else if($element_name == 'Hit_accession'){
-				// if parsing "name, acc, desc" from three tags (3/3)
-				if ($is_genbank){
-					$accession = $hit;
-				}
-				// now run through each HSP for this hit
-			} else if($element_name == 'Hit_hsps'){		
-				foreach($hit->children() as $hsp){
-					foreach($hsp->children() as $hsp_info){
-						$element_name = $hsp_info->getName();
-						if($element_name == 'Hsp_num'){
-							$hsp_num = $hsp_info;
-						}
-						if($element_name == 'Hsp_bit-score'){
-							$hsp_bit_score = $hsp_info;
-						}
-						if($element_name == 'Hsp_score'){
-							$hsp_score = $hsp_info;
-						}
-						if($element_name == 'Hsp_evalue'){
-							$hsp_evalue = $hsp_info;
-							// use the first evalue for this set of HSPs
-							// as the best evalue. This get's shown as
-							// info for the overall match.
-							if(!$best_evalue){
-								$best_evalue = $hsp_evalue;
-							}
-						}
-						if($element_name == 'Hsp_query-from'){
-							$hsp_query_from = $hsp_info;
-						}
-						if($element_name == 'Hsp_query-to'){
-							$hsp_query_to = $hsp_info;
-						}
-						if($element_name == 'Hsp_hit-from'){
-							$hsp_hit_from = $hsp_info;
-						}
-						if($element_name == 'Hsp_hit-to'){
-							$hsp_hit_to = $hsp_info;
-						}
-						if($element_name == 'Hsp_query-frame'){
-							$hsp_query_frame = $hsp_info;
-						}
-						if($element_name == 'Hsp_identity'){
-							$hsp_identity = $hsp_info;
-							// use the first evalue for this set of HSPs
-							// as the best evalue. This get's shown as
-							// info for the overall match.
-							if(!$best_identity){
-								$best_identity = $hsp_identity;
-							}
-						}
-						if($element_name == 'Hsp_positive'){
-							$hsp_positive = $hsp_info;
-						}
-						if($element_name == 'Hsp_align-len'){
-							$hsp_align_len = $hsp_info;
-							// use the first evalue for this set of HSPs
-							// as the best evalue. This get's shown as
-							// info for the overall match.
-							if(!$best_len){
-								$best_len = $hsp_align_len;
-							}
-						}
-						if($element_name == 'Hsp_qseq'){
-							$hsp_qseq = $hsp_info;
-						}
-						if($element_name == 'Hsp_hseq'){
-							$hsp_hseq = $hsp_info;
-						}
-						if($element_name == 'Hsp_midline'){
-							$hsp_midline = $hsp_info;
-						}
-					}
-
-					$hsp_content = array();
-					$hsp_content['hsp_num'] = $hsp_num;
-					$hsp_content['bit_score'] = $hsp_bit_score;
-					$hsp_content['score'] = $hsp_score;
-					$hsp_content['evalue'] = $hsp_evalue;
-					$hsp_content['query_frame'] = $hsp_query_frame;
-					$hsp_content['qseq'] = $hsp_qseq;
-					$hsp_content['midline'] = $hsp_midline;
-					$hsp_content['hseq'] = $hsp_hseq;
-					$hsp_content['hit_from'] = $hsp_hit_from;
-					$hsp_content['hit_to'] = $hsp_hit_to;
-					$hsp_content['identity'] = $hsp_identity;
-					$hsp_content['align_len'] = $hsp_align_len;
-					$hsp_content['positive'] = $hsp_positive;
-					$hsp_content['query_from'] = $hsp_query_from;
-					$hsp_content['query_to'] = $hsp_query_to;
-					$hsp_array[$counter] = $hsp_content;
-					$counter ++;
-				}
-			}
-		}
-      $arrowr_url = url(drupal_get_path('theme', 'tripal')."/images/arrow_r.png");
-		$hits_array[$hit_count]['arrowr_url'] = $arrowr_url;
-		$hits_array[$hit_count]['accession'] = $accession;
-		$hits_array[$hit_count]['hit_name'] = $hit_name;
-		
-		if($accession && $db->urlprefix){
-			$hits_array[$hit_count]['hit_url'] = "$db->urlprefix$accession";
-		} else {
-			// Test if this is another feature in the database
-			$sql = "SELECT feature_id FROM {feature} WHERE uniquename = '%s'";
-			$previous_db = db_set_active('chado');
-			$hit_feature_id = db_result(db_query($sql, $hit_name));
-			db_set_active($previous_db);
-			// If it is, add link to that feature
-			if ($hit_feature_id) {
-				$hits_array[$hit_count]['hit_url'] = "ID$hit_feature_id";
-			}
-		}
-		
-		$hits_array[$hit_count]['best_evalue'] = $best_evalue;
-		
-		if (!empty($best_len)) {
-			$percent_identity = number_format($best_identity/$best_len*100, 2);
-			$hits_array[$hit_count]['percent_identity'] = $percent_identity;
-		}
-
-		$hits_array[$hit_count]['description'] = $description;
-		
-		// if there is at least one HSP
-		if (!empty($hsp_array[0]['query_frame'])) {
-		  $hits_array[$hit_count]['hsp'] = $hsp_array;
-		} else {
-		  $hits_array[$hit_count]['hsp'] = array();
-		}
-		
-		$hit_count ++;
-		
-		// if we've hit the maximum number of hits then return
-		if($max > 0 && $hit_count >= $max){
-			break;
-		}
-	}
-	$blast_object->hits_array = $hits_array;
-	return $blast_object;
-}
-
-/********************************************************************************
- * Parse the best hit to generate the best hit homology report 
- */
-function tripal_analysis_blast_parse_best_hit ($analysis_id) {
-
-	// Select all features for this blast analysis, and save them to the 'featureSet' array
-	$sql = "SELECT feature_id
-	             FROM {analysisfeature} AF  
-	             WHERE analysis_id = %d";
-	$previous_db = tripal_db_set_active('chado');
-	$result = db_query($sql, $analysis_id);
-	$featureSet = array ();
-	$counter = 0;
-	while ($feature = db_fetch_object($result)) {
-		$featureSet [$counter] = $feature->feature_id;
-		$counter ++;
-	}
-
-	// Get analysis information including 'Time', 'Name', and 'DB Settings'
-	$sql = "SELECT value, name, to_char(timeexecuted, 'MM-DD-YYYY') AS time
-                FROM {analysis}  A
-                INNER JOIN {analysisprop} AP ON  A.analysis_id = AP.analysis_id 
-                WHERE A.analysis_id = %d
-                AND type_id= (SELECT cvterm_id 
-                                           FROM {cvterm} 
-                                           WHERE name = 'analysis_blast_settings')";
-	$analysis = db_fetch_object(db_query($sql, $analysis_id));
-	
-	// Parse the blast settings
-	$blastsettings = explode("|", $analysis->value);
-	$db_id = $blastsettings [0];
-	
-	// Get the xml description parser using db_id
-	tripal_db_set_active($previous_db);
-	$sql = "SELECT * FROM {tripal_analysis_blast} WHERE db_id = %d";
-	$parser = db_fetch_object(db_query($sql, $db_id));
-
-	$db_name = $parser->displayname;
-	$is_genbank = $parser->genbank_style;
-	$regex_hit_id = $parser->regex_hit_id;
-	$regex_hit_def = $parser->regex_hit_def;
-	$regex_hit_accession = $parser->regex_hit_accession;
-
-	// set default description parser  if regular expressions have not been specified
-	if(!$regex_hit_id){
-		$regex_hit_id = '/^(.*?)\s.*$/';
-	} else {
-		$regex_hit_id = '/'.$regex_hit_id.'/';
-	}
-	if(!$regex_hit_def){
-		$regex_hit_def = '/^.*?\s(.*)$/';
-	} else {
-		$regex_hit_def = '/'.$regex_hit_def.'/';
-	}
-	if(!$regex_hit_accession){
-		$regex_hit_accession = '/^(.*?)\s.*$/';
-	} else {
-		$regex_hit_accession = '/'.$regex_hit_accession.'/';
-	}
-	
-   $interval = intval($counter * 0.01);
-	for ($i = 0; $i < $counter; $i ++) {
-		
-		if ($i !=0 && $i % $interval == 0) {
-			$percentage = (int) ($i / $counter * 100);
-			tripal_job_set_progress($job_id, $percentage);	
-			print $percentage."%\r";
-		}
-
-		$sql = "SELECT value
-		             FROM {analysisfeatureprop} AFP 
-		             INNER JOIN {analysisfeature} AF ON AFP.analysisfeature_id = AF.analysisfeature_id 
-		             WHERE analysis_id = %d 
-		             AND feature_id = %d
-		             AND type_id = (SELECT cvterm_id FROM cvterm WHERE name='analysis_blast_output_iteration_hits' AND cv_id = (SELECT cv_id FROM cv WHERE name='tripal'))";
-		$previous_db = tripal_db_set_active('chado');
-		$xml_output = simplexml_load_string(db_result(db_query($sql, $analysis_id, $featureSet[$i])));
-		
-		$iteration = '';
-		// new XML file parser has added the feature name within <Iteration_query-def> tags.
-		if ($xml_output->getName() == 'Iteration') {
-			$query = "";
-			foreach ($xml_output->children() as $xml_tag) {
-				if ($xml_tag->getName() == 'Iteration_query-def') {
-					// Here we show the feature name again to check if we pull the correct data
-					$query = $xml_tag;
-				} else if ($xml_tag->getName() == 'Iteration_hits') {
-					$iteration = $xml_tag;
-				}
-			}
-	   // This is for the file parsed by the old parser
-		} else {
-			$iteration = $xml_output;
-		}
-
-		$number_hits = 0;
-		foreach($iteration->children() as $hits){
-			$number_hits ++;
-		}
-
-		$query = explode(" ", $query) ;
-		$query = $query [0];
-		if ($number_hits == 0) {
-			continue;
-		} 
-
-		// now run through the blast hits/hsps of this iteration
-		// and generate the rows of the table
-
-		foreach($iteration->children() as $hits){
-			$hit_count++;
-			foreach($hits->children() as $hit){
-				$best_evalue = 0;
-				$best_identity = 0;
-				$best_len = 0;
-				$element_name = $hit->getName();
-				if($element_name == 'Hit_id'){
-					// if parsing "name, acc, desc" from three tags (1/3)
-					if ($is_genbank) {
-						$hit_name = $hit;
-					}
-				} else if($element_name == 'Hit_def'){
-					if($is_genbank){
-						$description = $hit;
-					} else {
-						$accession = preg_replace($regex_hit_accession,"$1",$hit);
-						$hit_name = preg_replace($regex_hit_id,"$1",$hit);
-						$description = preg_replace($regex_hit_def,"$1",$hit);
-					}
-				} else if($element_name == 'Hit_accession'){
-					// if parsing "name, acc, desc" from three tags (3/3)
-					if ($is_genbank){
-						$accession = $hit;
-					}
-					// now run through each HSP for this hit
-				} else if($element_name == 'Hit_hsps'){
-					foreach($hit->children() as $hsp){
-						foreach($hsp->children() as $hsp_info){
-							$element_name = $hsp_info->getName();
-							if($element_name == 'Hsp_num'){
-								$hsp_num = $hsp_info;
-							}
-							if($element_name == 'Hsp_bit-score'){
-								$hsp_bit_score = $hsp_info;
-							}
-							if($element_name == 'Hsp_score'){
-								$hsp_score = $hsp_info;
-							}
-							if($element_name == 'Hsp_evalue'){
-								$hsp_evalue = $hsp_info;
-								// use the first evalue for this set of HSPs
-								// as the best evalue. This get's shown as
-								// info for the overall match.
-								if(!$best_evalue){
-									$best_evalue = $hsp_evalue;
-								}
-							}
-							if($element_name == 'Hsp_query-from'){
-								$hsp_query_from = $hsp_info;
-							}
-							if($element_name == 'Hsp_query-to'){
-								$hsp_query_to = $hsp_info;
-							}
-							if($element_name == 'Hsp_hit-from'){
-								$hsp_hit_from = $hsp_info;
-							}
-							if($element_name == 'Hsp_hit-to'){
-								$hsp_hit_to = $hsp_info;
-							}
-							if($element_name == 'Hsp_query-frame'){
-								$hsp_query_frame = $hsp_info;
-							}
-							if($element_name == 'Hsp_identity'){
-								$hsp_identity = $hsp_info;
-								// use the first evalue for this set of HSPs
-								// as the best evalue. This get's shown as
-								// info for the overall match.
-								if(!$best_identity){
-									$best_identity = $hsp_identity;
-								}
-							}
-							if($element_name == 'Hsp_positive'){
-								$hsp_positive = $hsp_info;
-							}
-							if($element_name == 'Hsp_align-len'){
-								$hsp_align_len = $hsp_info;
-								// use the first evalue for this set of HSPs
-								// as the best evalue. This get's shown as
-								// info for the overall match.
-								if(!$best_len){
-									$best_len = $hsp_align_len;
-								}
-							}
-							if($element_name == 'Hsp_qseq'){
-								$hsp_qseq = $hsp_info;
-							}
-							if($element_name == 'Hsp_hseq'){
-								$hsp_hseq = $hsp_info;
-							}
-							if($element_name == 'Hsp_midline'){
-								$hsp_midline = $hsp_info;
-							}
-						}
-					}
-				}
-			}
-			
-			// Get analysisfeature_id
-			$sql = "SELECT analysisfeature_id FROM {analysisfeature} WHERE analysis_id = %d AND feature_id = %d";
-			$af_id = db_result(db_query($sql, $analysis_id, $featureSet[$i]));
-			
-			// Get type_id
-			$sql = "SELECT cvterm_id FROM {cvterm} WHERE name = '%s' AND cv_id = (SELECT cv_id FROM {cv} WHERE name = 'tripal')"; 
-			$type_id = db_result(db_query($sql, 'analysis_blast_besthit_query'));
-			
-			$sql_test ="SELECT analysisfeatureprop_id FROM {analysisfeatureprop} WHERE analysisfeature_id = $af_id AND type_id = %d";
-			$test_afpid = db_result(db_query($sql_test, $type_id));
-			
-			//Insert only if this blast query not exists. 
-			if (!$test_afpid) {
-				$afp_sql = "INSERT INTO {analysisfeatureprop} (analysisfeature_id, type_id, value, rank) VALUES (%d, %d, '%s', 0)";
-				
-				//$query;
-				db_query($afp_sql, $af_id, $type_id, $query);
-
-				//$hit_name;
-				$type_id = db_result(db_query($sql, 'analysis_blast_besthit_match'));
-				db_query($afp_sql, $af_id, $type_id, $hit_name);
-					
-				//$description;
-				$type_id = db_result(db_query($sql, 'analysis_blast_besthit_description'));
-				db_query($afp_sql, $af_id, $type_id, $description);
-					
-				//$best_evalue;
-				$type_id = db_result(db_query($sql, 'analysis_blast_besthit_evalue'));
-				$e_digit = explode("e-", $best_evalue);
-				if (count($e_digit) == 2) {
-					$evalue_shown = number_format($e_digit [0],1);
-					$best_evalue = $evalue_shown."e-".$e_digit[1];
-				} 
-				db_query($afp_sql, $af_id, $type_id, $best_evalue);
-					
-				//$best_identity;
-				$type_id = db_result(db_query($sql, 'analysis_blast_besthit_identity'));
-				$percent_identity = number_format($best_identity/$best_len*100, 1);
-				db_query($afp_sql, $af_id, $type_id, $percent_identity);
-					
-				//$best_len;
-				$type_id = db_result(db_query($sql, 'analysis_blast_besthit_length'));
-				db_query($afp_sql, $af_id, $type_id, $best_len);
-				
-			// Otherwise, update all instead
-			} else {
-				$afp_sql = "UPDATE {analysisfeatureprop} SET analysisfeature_id = %d, type_id = %d, value = '%s', rank = 0 WHERE analysisfeatureprop_id = %d";
-
-				//$query;
-				db_query($afp_sql, $af_id, $type_id, $query, $test_afpid);
-				
-				//$hit_name;
-				$type_id = db_result(db_query($sql, 'analysis_blast_besthit_match'));
-				$test_afpid = db_result(db_query($sql_test, $type_id));
-				db_query($afp_sql, $af_id, $type_id, $hit_name, $test_afpid);
-
-				//$description;
-				$type_id = db_result(db_query($sql, 'analysis_blast_besthit_description'));
-				$test_afpid = db_result(db_query($sql_test, $type_id));
-				db_query($afp_sql, $af_id, $type_id, $description, $test_afpid);
-					
-				//$best_evalue;
-				$type_id = db_result(db_query($sql, 'analysis_blast_besthit_evalue'));
-				$test_afpid = db_result(db_query($sql_test, $type_id));
-				$e_digit = explode("e-", $best_evalue);
-				if (count($e_digit) == 2) {
-					$evalue_shown = number_format($e_digit [0],1);
-					$best_evalue = $evalue_shown."e-".$e_digit[1];
-				} 
-				db_query($afp_sql, $af_id, $type_id, $best_evalue, $test_afpid);
-					
-				//$best_identity;
-				$type_id = db_result(db_query($sql, 'analysis_blast_besthit_identity'));
-				$test_afpid = db_result(db_query($sql_test, $type_id));
-				$percent_identity = number_format($best_identity/$best_len*100, 1);
-				db_query($afp_sql, $af_id, $type_id, $percent_identity, $test_afpid);
-					
-				//$best_len;
-				$type_id = db_result(db_query($sql, 'analysis_blast_besthit_length'));
-				$test_afpid = db_result(db_query($sql_test, $type_id));
-				db_query($afp_sql, $af_id, $type_id, $best_len, $test_afpid);
-				
-			}
-			tripal_db_set_active($previous_db);
-			
-			break;
-		}
-	}
-   print "100%\n";
-	return;
-}

+ 0 - 102
extensions/tripal_analysis_blast/node-chado_analysis_blast.tpl.php

@@ -1,102 +0,0 @@
-<?php
-// Purpose: This template provides the layout of the organism node (page)
-//   using the same templates used for the various feature content blocks.
-//
-// To Customize the Featture Node Page:
-//   - This Template: customize basic layout and which elements are included
-//   - Using Panels: Override the node page using Panels3 and place the blocks
-//       of content as you please. This method requires no programming. See
-//       the Tripal User Guide for more details
-//   - Block Templates: customize the content/layout of each block of stock 
-//       content. These templates are found in the tripal_stock subdirectory
-//
-// Variables Available:
-//   - $node: a standard object which contains all the fields associated with
-//       nodes including nid, type, title, taxonomy. It also includes stock
-//       specific fields such as stock_name, uniquename, stock_type, synonyms,
-//       properties, db_references, object_relationships, subject_relationships,
-//       organism, etc.
-//   NOTE: For a full listing of fields available in the node object the
-//       print_r $node line below or install the Drupal Devel module which 
-//       provides an extra tab at the top of the node page labelled Devel
-?>
-
-<?php
- //uncomment this line to see a full listing of the fields avail. to $node
- //print '<pre>'.print_r($variables,TRUE).'</pre>';
- //drupal_add_css('./tripal-node-templates.css');
-drupal_add_css(drupal_get_path('theme', 'tripal') . '/tripal-node-templates.css');
-//this makes tripal required as theme-------^  !!!
-                                          
-$node = $variables['node'];
-$organism = $variables['node']->organism;
-?>
-
-<?php if ($teaser) { 
-	include(drupal_get_path('module' , 'tripal_analysis_blast') . '/theme/tripal_analysis_blast/tripal_analysis_blast_teaser.tpl.php');
-} else { ?>
-
-<script type="text/javascript">
-if (Drupal.jsEnabled) {
-   $(document).ready(function() {
-      // hide all tripal info boxes at the start
-      $(".tripal-info-box").hide();
- 
-      // iterate through all of the info boxes and add their titles
-      // to the table of contents
-      $(".tripal-info-box-title").each(function(){
-        var parent = $(this).parent();
-        var id = $(parent).attr('id');
-        var title = $(this).text();
-        $('#tripal_analysis_blast_toc_list').append('<li><a href="#'+id+'" class="tripal_analysis_blast_toc_item">'+title+'</a></li>');
-      });
-
-      // when a title in the table of contents is clicked, then
-      // show the corresponding item in the details box
-      $(".tripal_analysis_blast_toc_item").click(function(){
-         $(".tripal-info-box").hide();
-         href = $(this).attr('href');
-         $(href).fadeIn('slow');
-         // we want to make sure our table of contents and the details
-         // box stay the same height
-         $("#tripal_analysis_blast_toc").height($(href).parent().height());
-         return false;
-      }); 
-
-      // we want the base details to show up when the page is first shown 
-      // unless the user specified a specific block
-      var block = window.location.href.match(/[\?|\&]block=(.+?)\&/)
-      if(block == null){
-         block = window.location.href.match(/[\?|\&]block=(.+)/)
-      }
-      if(block != null){
-         $("#tripal_analysis_blast-"+block[1]+"-box").show();
-      } else {
-         $("#tripal_analysis_blast-base-box").show();
-      }
-
-      $("#tripal_analysis_blast_toc").height($("#tripal_analysis_blast-base-box").parent().height());
-      
-   });
-}
-</script>
-
-
-<div id="tripal_analysis_blast_details" class="tripal_details">
-
-   <!-- Basic Details Theme -->
-   <?php include('theme/tripal_analysis_blast/tripal_analysis_blast_base.tpl.php');?>
-
-   <?php print $content ?>
-</div>
-
-<!-- Table of contents -->
-<div id="tripal_analysis_blast_toc" class="tripal_toc">
-   <div id="tripal_analysis_blast_toc_title" class="tripal_toc_title">Resources</i></div>
-   <span id="tripal_analysis_blast_toc_desc" class="tripal_toc_desc"></span>
-   <ul id="tripal_analysis_blast_toc_list" class="tripal_toc_list">
-
-   </ul>
-</div>
-
-<?php } ?>

+ 0 - 33
extensions/tripal_analysis_blast/theme/css/tripal_analysis_blast.css

@@ -1,33 +0,0 @@
-#tripal_analysis_blast-table {
-   width: 100%;
-	overflow:auto;
-}
-#tripal_analysis_blast-table td {
-  text-align: left;
-}
-#tripal_analysis_blast-table .tripal-table-even-row {
-   border-top: 0px solid #CCCCCC;
-   border-bottom: 0px solid #CCCCCC;
-}
-#tripal_analysis_blast-table .tripal-table-odd-row {
-   border-top: 0px solid #CCCCCC;
-   border-bottom: 0px solid #CCCCCC;
-}
-#tripal_analysis_blast-table .tripal_analysis_blast-result-first-row {
-   border-top: 1px solid #CCCCCC;
-}
-#tripal_analysis_blast-table .tripal_analysis_blast-result-last-row {
-   border-bottom: 1px solid #CCCCCC;
-}
-
-.tripal_analysis_blast-info-hsp-desc {
-	background-color: #FFFFFF;
-	border:0px solid #CCC5AE;
-	display:none;
-	overflow:auto;
-   width: 100%;
-}
-.tripal_analysis_blast-info-hsp-desc pre{
-	background-color: #FFFFFF;
-   border:none;
-}

+ 0 - 183
extensions/tripal_analysis_blast/theme/js/tripal_analysis_blast.js

@@ -1,183 +0,0 @@
-
-if (Drupal.jsEnabled) {
-   
-   $(document).ready(function(){
-	   // If Anlaysis admin page is shown, get the settings for selected database
-	   if ($("#edit-blastdb")[0]) {
-		   tripal_update_regex($("#edit-blastdb")[0]);
-		   tripal_set_genbank_style();
-	   }
-      // hide the alignment information on the blast results box
-      $(".tripal_analysis_blast-info-hsp-desc").hide();
-
-   });
-  
-   //------------------------------------------------------------
-   // Update the blast results based on the user selection
-   function tripal_update_blast(link,db_id){
-      tripal_startAjax();
-      $.ajax({
-         url: link.href,
-         dataType: 'json',
-         type: 'POST',
-         success: function(data){         
-            $("#blast_db_" + db_id).html(data.update);
-            $(".tripal_analysis_blast-info-hsp-desc").hide();
-            tripal_stopAjax();
-         }
-      });
-      return false;
-   }
-
-   //------------------------------------------------------------
-   // Update the blast results based on the user selection
-   function tripal_blast_toggle_alignment(analysis_id,hit_id){
-      var alignment_box = $("#tripal_analysis_blast-info-hsp-desc-"+analysis_id+"-"+hit_id);
-      var toggle_img = $("#tripal_analysis_blast-info-toggle-image-"+analysis_id+"-"+hit_id);
-	   var icon_url = toggle_img.attr("src");
-
-
-      if (alignment_box.is(':visible')) {
-         alignment_box.fadeOut('fast');
-	      var changed_icon_url = icon_url.replace(/arrow_d.png/,"arrow_r.png");
-	      toggle_img.attr("src", changed_icon_url);
-	   } else {
-         var width = alignment_box.parent().width();
-         alignment_box.css("width", width+'px');
-         alignment_box.fadeIn('slow');
-	      var icon_url = icon_url.replace(/arrow_r.png/,"arrow_d.png");
-	      toggle_img.attr("src", icon_url);
-	   }
-      return false;
-   }
-   
-   //------------------------------------------------------------
-   // Update regular expression for selected database
-   function tripal_update_regex(options){
-	   // Get the dbname from DOM
-	   var index = options.selectedIndex;
-	   var dbid = options[index].value;
-
-	   // Form the link for the following ajax call	   
-      var baseurl = tripal_get_base_url();
-      var link = baseurl + '/tripal_blast_regex/' + dbid;
-	   
-	   // Make ajax call to retrieve regular expressions
-	   $.ajax( {
-			url : link,
-			dataType : 'json',
-			type : 'POST',
-			success : tripal_set_parser,
-		});
-	}
-   
-   // Set parser for the admin page
-   function tripal_set_parser(data) {
-	   // Set title if it exists
-	   if (data.name) {
-			$("#edit-displayname").val(data.name);
-	   } else {
-			$("#edit-displayname").val("");
-	   }
-		
-	   // If genbank_style is TRUE, check the Genbank style box, clear all regular expressions, and disable
-	   // the text fields
-	   if (data.genbank_style == 1) {
-		   $("#edit-gb-style-parser").attr("checked", true);
-		   $("#edit-hit-id").val("");
-		   $("#edit-hit-def").val("");
-		   $("#edit-hit-accession").val("");
-		
-	   // Otherwise, uncheck the Genbank style box and set the regular expressions
-	   } else {
-			$("#edit-gb-style-parser").attr("checked", false);
-			if (data.reg1) {
-				$("#edit-hit-id").val(data.reg1);			
-			// Show default hit-id parser if it's not set
-			} else {
-				$("#edit-hit-id").val("^(.*?)\s.*$");
-			}
-			if (data.reg2) {
-				$("#edit-hit-def").val(data.reg2);
-			// Show default hit-def parser if it's not set
-			} else {
-				$("#edit-hit-def").val("^.*?\s(.*)$");
-			}
-			if (data.reg3) {
-				$("#edit-hit-accession").val(data.reg3);			
-			// Show default hit-accession parser if it's not set
-			} else {
-				$("#edit-hit-accession").val("^(.*?)\s.*$");
-			}
-		}
-		tripal_set_genbank_style();  
-   }
-   // ------------------------------------------------------------
-   // Use genbank style parser. Hide regular expression text feilds
-   function tripal_set_genbank_style (){
-	  // Disable regular expressions if genbank style parser is used (checked)
-	  if ($("#edit-gb-style-parser").is(":checked")) {
-		  $("#edit-hit-id-wrapper > label").css("color", "grey");
-		  $("#edit-hit-def-wrapper > label").css("color", "grey");
-		  $("#edit-hit-accession-wrapper > label").css("color", "grey");
-		  $("#edit-hit-id").attr('disabled', 'disabled');
-		  $("#edit-hit-def").attr('disabled', 'disabled');
-		  $("#edit-hit-accession").attr('disabled', 'disabled');
-	  } else {
-		  $("#edit-hit-id-wrapper > label").css("color", "black");
-		  $("#edit-hit-def-wrapper > label").css("color", "black");
-		  $("#edit-hit-accession-wrapper > label").css("color", "black");
-		  $("#edit-hit-id").removeAttr('disabled');
-		  $("#edit-hit-def").removeAttr('disabled');
-		  $("#edit-hit-accession").removeAttr('disabled');
-	  }
-   }
-   // -------------------------------------------------------------
-   // Function that toggles the blast droppable subbox content
-   function tripal_set_blast_subbox(db_id){
-	  
-	  $('.blast-hit-arrow-icon').hover(
-	     function() {
-	        $(this).css("cursor", "pointer");
-	     },
-	     function() {
-	        $(this).css("cursor", "pointer");
-	     }
-	  );
-     $('.blast-hit-arrow-icon').click(function() {
-	        
-     });
-   }
-   
-   	//------------------------------------------------------------
-	// Update the blast best hit report for selected page and sorting
-	function tripal_update_best_hit_report(obj, analysis_id, sort, descending, per_page){
-		var page = obj.selectedIndex + 1;
-		var baseurl = location.href.substring(0,location.href.lastIndexOf('/tripal_blast_report/'));
-		var link = baseurl + '/tripal_blast_report/' + analysis_id + "/" + page + "/" + sort + "/" + descending + "/" + per_page;
-
-		tripal_startAjax();
-		$.ajax({
-			url: link,
-			dataType: 'html',
-			type: 'POST',
-			success: function(data){
-				var d = document.createElement('div');
-				d.innerHTML = data;
-				var divs = d.getElementsByTagName("div");
-				for (var i = 0; i < divs.length; i ++) {
-					if (divs[i].getAttribute('id') == 'blast-hits-report') {	
-						var report_table = document.getElementById('blast-hits-report');
-						report_table.innerHTML = divs[i].innerHTML;
-						var table_breport = document.getElementById('tripal_blast_report_table');
-						var sel = document.getElementById('tripal_blast_report_page_selector');
-						sel.options[page - 1].selected = true;
-						tripal_stopAjax();
-					}
-				}
-			}
-		});
-		
-		return false;
-	}
-}

+ 0 - 78
extensions/tripal_analysis_blast/theme/tripal_analysis_blast/tripal_analysis_blast_base.tpl.php

@@ -1,78 +0,0 @@
-<?php
-$node = $variables['node'];
-$analysis = $variables['node']->analysis;
-
-// the description is a text field so we want to expand that
-$analysis = tripal_core_expand_chado_vars($analysis,'field','analysis.description');
-
-// get the blast data 
-$blast = $node->analysis->tripal_analysis_blast;
-
-//dpm($analysis);
-
-?>
-<div id="tripal_analysis_blast-base-box" class="tripal_analysis_blast-info-box tripal-info-box">
-  <div class="tripal_analysis_blast-info-box-title tripal-info-box-title">Blast Analysis Details</div>
-  <div class="tripal_analysis_blast-info-box-desc tripal-info-box-desc"></div>
-   <table id="tripal_analysis_blast-table-base" class="tripal_analysis_blast-table tripal-table tripal-table-vert">
-      <tr class="tripal_analysis_blast-table-odd-row tripal-table-even-row">
-        <th>Analysis Name</th>
-        <td><?php print $analysis->name; ?></td>
-      </tr>
-      <tr class="tripal_analysis_blast-table-odd-row tripal-table-odd-row">
-        <th nowrap>Software</th>
-        <td><?php 
-          print $analysis->program; 
-          if($analysis->programversion){
-             print " (" . $analysis->programversion . ")"; 
-          }
-          if($analysis->algorithm){
-             print ". " . $analysis->algorithm; 
-          }
-          ?>
-        </td>
-      </tr>
-      <tr class="tripal_analysis_blast-table-odd-row tripal-table-even-row">
-        <th nowrap>Source</th>
-        <td><?php 
-          if($analysis->sourceuri){
-             print "<a href=\"$analysis->sourceuri\">$analysis->sourcename</a>"; 
-          } else {
-             print $analysis->sourcename; 
-          }
-          if($analysis->sourceversion){
-             print " (" . $analysis->sourceversion . ")"; 
-          }
-          ?>
-          </td>
-      </tr>
-      <tr class="tripal_analysis_blast-table-odd-row tripal-table-odd-row">
-        <th nowrap>Date performed</th>
-        <td><?php print preg_replace("/^(\d+-\d+-\d+) .*/","$1",$analysis->timeexecuted); ?></td>
-      </tr>
-      <tr class="tripal_analysis_blast-table-odd-row tripal-table-even-row">
-        <th nowrap>Description</th>
-        <td><?php print $analysis->description; ?></td>
-      </tr> 
-      <tr class="tripal_analysis_blast-table-even-row tripal-table-odd-row">
-        <th nowrap>Database</th>
-        <td><?php print $blast->db->name ?></td>
-      </tr> 
-      <tr class="tripal_analysis_blast-table-even-row tripal-table-even-row">
-        <th nowrap>Blast Arguments</th>
-        <td><?php print $blast->blastparameters ?></td>
-      </tr>  
-      <tr class="tripal_analysis_blast-table-odd-row tripal-table-odd-row">
-        <th>Report</th>
-        <td>
-        	<?php 
-        		if ($analysis->blast_report) {					
-        			print "<a href=$analysis->blast_report>View the best hit report</a>";
-        		} else {
-        			print "not available";
-        		}
-        	?>
-        	</td>
-      </tr>       	                                
-   </table>   
-</div>

+ 0 - 123
extensions/tripal_analysis_blast/theme/tripal_analysis_blast/tripal_analysis_blast_report.tpl.php

@@ -1,123 +0,0 @@
-<?php
-$report  = $variables['report_object'];
-$hits = $report->hits;
-?>
-
-<style type="text/css">
-#tripal_blast_report_current_page {
-	float: right;
-	margin-bottom: 5px;
-	margin-right: 20px;
-}
-#tripal_blast_report_pager {
-	float: right;
-	margin-bottom: 10px;
-	margin-right: 20px;
-}
-#tripal_blast_report_per_page {
-	float: left;
-	margin-bottom: 10px;
-}
-</style>
-
-<div id="tripal_ajaxLoading" style="display:none">
-	<div id="loadingText">Loading...</div>
-	<img src="<?php print url(drupal_get_path('theme', 'tripal') . '/images/ajax-loader.gif') ?>">
-</div>
-
-<div id="blast-hits-report">
-	<strong>Analysis Date: </strong><?php print $report->time?> (<a href=<?php print $report->url ?>><?php print $report->name ?></a>)<br>
-	There are <strong><?php print $report->counter ?></strong> records. 
-	<div id=tripal_blast_report_current_page>page <strong><?php print $report->currentpage ?></strong> of <strong><?php print $report->no_page ?></strong>
-	</div>
-	
-	<table id="tripal_analysi_blast-report-table" class="tripal_analysis_blast-table tripal-table tripal-table-horz">
-		<tr class="tripal_analysis_blast-table-odd-row tripal-table-odd-row">
-			<th nowrap><?php if ($report->sort == 0) {print $report->symbol;} ?>
-				<a href=<?php print $report->byQuery ?>>Query</a>
-			</th>
-			<th nowrap><?php if ($report->sort == 1) {print $report->symbol;} ?>
-				<a href=<?php print $report->byMatchName ?>>Match Name</a>
-			</th>
-			<th nowrap><?php if ($report->sort == 2) {print $report->symbol;} ?>
-				<a href=<?php print $report->byDescription ?>>Description</a>
-			</th>
-			<th nowrap><?php if ($report->sort == 3) {print $report->symbol;} ?>
-				<a href=<?php print $report->byEvalue ?>>E-value</a>
-			</th>
-			<th nowrap><?php if ($report->sort == 4) {print $report->symbol;} ?>
-				<a href=<?php print $report->byIdentity ?>>%Identity</a>
-			</th>
-			<th nowrap><?php if ($report->sort == 5) {print $report->symbol;} ?>
-				<a href=<?php print $report->byLength ?>>Length</a>
-			</th>
-		</tr>
-		
-		<?php foreach($hits AS $hit) {?>
-		<tr class="<?php print $hit->class ?>">
-		                           <td nowrap><a href=<?php print $hit->q_url ?>><?php print $hit->query ?></a></td>
-		                           <td nowrap><a href=<?php print $hit->urlprefix.$hit->match ?> target=_blank><?php print $hit->match ?></td>
-		                           <td><?php print $hit->desc ?></td>
-		                           <td nowrap><?php print $hit->evalue ?></td>
-		                           <td nowrap><?php print $hit->identity ?></td>
-		                           <td nowrap><?php print $hit->length ?></td>
-		                         </tr>
-		<?php } ?>	
-			
-	</table>
-			<div id="tripal_blast_report_per_page">Show	
-				<?php 
-				$per_page = $report->per_page;
-				$path = $report->path;
-				if ($per_page == 10) {?>
-					<strong>10</strong> | 
-				<?php } else { 
-					$url_path = url($path."10");
-				?>	
-					<a href=<?php print $url_path ?>>10</a> | 
-				<?php } 
-				if ($per_page == 20) {
-				?>
-					<strong>20</strong> | 
-				<?php } else {
-					$url_path = url($path."20");
-				?>
-					<a href=<?php print $url_path ?>>20</a> | 
-				<?php } 
-				if ($per_page == 50) {
-				?>
-					<strong>50</strong> | 
-				<?php } else {
-					$url_path = url($path."50");
-				?>
-					<a href=<?php print $url_path ?>>50</a> | 
-				<?php }
-				if ($per_page == 100) {
-				?>
-					<strong>100</strong> | 
-				<?php } else {
-					$url_path = url($path."100");
-				?>
-					<a href=<?php print $url_path ?>>100</a> | 
-				<?php }
-				if ($per_page == 200) {
-				?>
-					<strong>200</strong> | 
-				<?php } else {
-					$url_path = url($path."200");
-				?>
-			   	<a href=<?php print $url_path ?>>200</a>
-				<?php } ?>
-				
-				records per page
-		</div>
-		<div id=tripal_blast_report_pager>page
-			<select id=tripal_blast_report_page_selector onChange="tripal_update_best_hit_report(this, <?php print $report->analysis_id ?>,<?php print $report->sort ?>, <?php print $report->descending ?>, <?php print $report->per_page ?>)">
-			<?php  for ($i = 1; $i <= $report->no_page; $i ++) { ?>
-				<option value=<?php print $i ?>><?php print $i ?></option>
-			<?php } ?>	                           
-			</select>
-		</div>
-</div>
-			
-	

+ 0 - 53
extensions/tripal_analysis_blast/theme/tripal_analysis_blast/tripal_analysis_blast_teaser.tpl.php

@@ -1,53 +0,0 @@
-<?php
-$node = $variables['node'];
-$analysis = $variables['node']->analysis;
-
-// the description is a text field so we want to expand that
-$analysis = tripal_core_expand_chado_vars($analysis,'field','analysis.description');
-
-
-?>
-<div id="tripal_analysis-base-box" class="tripal_analysis-info-box tripal-info-box">
-  <div class="tripal_analysis-info-box-title tripal-info-box-title">Details</div>
-   <table id="tripal_analysis-table-base" class="tripal_analysis-table tripal-table tripal-table-vert">
-      <tr class="tripal_analysis-table-odd-row tripal-table-even-row">
-        <th>Analysis Name</th>
-        <td><?php print $analysis->name; ?></td>
-      </tr>
-      <tr class="tripal_analysis-table-odd-row tripal-table-odd-row">
-        <th nowrap>Software</th>
-        <td><?php 
-          print $analysis->program; 
-          if($analysis->programversion){
-             print " (" . $analysis->programversion . ")"; 
-          }
-          if($analysis->algorithm){
-             print ". " . $analysis->algorithm; 
-          }
-          ?>
-        </td>
-      </tr>
-      <tr class="tripal_analysis-table-odd-row tripal-table-even-row">
-        <th nowrap>Source</th>
-        <td><?php 
-          if($analysis->sourceuri){
-             print "<a href=\"$analysis->sourceuri\">$analysis->sourcename</a>"; 
-          } else {
-             print $analysis->sourcename; 
-          }
-          if($analysis->sourceversion){
-             print " (" . $analysis->sourceversion . ")"; 
-          }
-          ?>
-          </td>
-      </tr>
-      <tr class="tripal_analysis-table-odd-row tripal-table-odd-row">
-        <th nowrap>Date performed</th>
-        <td><?php print preg_replace("/^(\d+-\d+-\d+) .*/","$1",$analysis->timeexecuted); ?></td>
-      </tr>
-      <tr class="tripal_analysis-table-odd-row tripal-table-even-row">
-        <th nowrap>Description</th>
-        <td><?php print $analysis->description; ?></td>
-      </tr>             	                                
-   </table>   
-</div>

+ 0 - 115
extensions/tripal_analysis_blast/theme/tripal_feature/tripal_feature_blast_results.tpl.php

@@ -1,115 +0,0 @@
-<?php
-$feature  = $variables['node']->feature;
-$blast_results_list = $feature->tripal_analysis_blast->blast_results_list;
-
-?>
-<div id="tripal_ajaxLoading" style="display:none">
-	<div id="loadingText">Loading...</div>
-	<img src="<?php print drupal_get_path('theme', 'tripal') . '/images/ajax-loader.gif';?>">
-</div>
-
-<?php 
-if(count($blast_results_list) > 0){
-   foreach ($blast_results_list as $blast_result) {
-	  $hits_array = $blast_result->hits_array;
-	  $db = $blast_result->db;
-     $analysis = $blast_result->analysis;
-?>
-<div id="blast_db_<?php print $db->db_id ?>">
-<div id="tripal_analysis_blast-results-<?php print "$db->db_id" ?>-box" class="tripal_analysis_blast-box tripal-info-box">
-	<div class="tripal-info-box-title tripal_analysis_blast-info-box-title"><?php if ($db->displayname) {print $db->displayname;} else {print $db->name . "Homologs";} ?></div>
-	<div class="tripal-info-box-desc tripal_analysis_blast-info-box-desc">
-	<strong>Analysis Date: </strong><?php print preg_replace("/^(\d+-\d+-\d+) .*/","$1",$analysis->timeexecuted) . " (<a href=".url("node/$analysis->nid").">$analysis->name</a>)"?><br>
-	<!--Query: <?php print "$blast_result->xml_tag"?><br>-->
-	
-	<?php 
-   if($blast_result->max != 10){    
-      $url = url("tripal_top_blast/$feature->feature_id/$db->db_id/10");
-		?><span><a onclick="return tripal_update_blast(this,<?php print $db->db_id?>)" href="<?php print $url ?>">Show Best 10 Hits</a></span><?php
-	} else { 
-		?><span>Best 10 Hits Shown</span><?php
-	} 
-	
-	if($blast_result->number_hits <= 10){ 
-	} 
-   else if ($blast_result->max != 25) { 
-  	   $url = url("tripal_top_blast/$feature->feature_id/$db->db_id/25"); 	
-		?><span> | <a onclick="return tripal_update_blast(this,<?php print"$db->db_id"?>)" href="<?php print $url ?>">Show Best 25 Hits</a></span><?php
-	}else {
-		?><span> | Best 25 Hits Shown</span><?php
-	} 
-	
-	if($blast_result->number_hits <= 25){
-	} 
-   else if ($blast_result->max != 0) {
-	   $url = url("tripal_top_blast/$feature->feature_id/$db->db_id/all"); 		
-		?><span> | <a onclick="return tripal_update_blast(this, <?php print $db->db_id ?>)" href="<?php print $url ?>">Show All Hits</a> </span><?php
-	} else {
-		?><span> | All Hits Shown</span><?php
-	} 
-   ?>
-	<br><br><span>Click a description for more details</span>
-   </div>
-	<table id="tripal_analysis_blast-table" class="tripal-table tripal-table-horz tripal_analysis_blast-table">
-		<tr>
-         <th>&nbsp;</th>
-			<th nowrap>Match Name</th>
-			<th nowrap>E value</th>
-			<th nowrap>Identity</th>
-			<th nowrap>Description</th>
-		</tr>
-		
-		<?php 
-      $i = 0; 
-      if(sizeof($hits_array)==0){?>
-        <tr>
-          <td colspan="5">    
-            <div class="tripal-no-results">There are no matches against <?php print $db->name?> for this <?php print $feature->type_id->name?>.</div> 
-          </td>
-        </tr><?php
-      }
-		foreach($hits_array AS $hit) { 
-         $class = 'tripal-table-odd-row tripal_analysis_blast-table-odd-row';
-         if($i % 2 == 0 ){
-            $class = 'tripal-table-even-row tripal_analysis_blast-table-even-row';
-         }?>
-         <tr class="<?php print $class ?> tripal_analysis_blast-result-first-row">
-            <td><?php print $i+1 ?>.</td>
-		      <?php if ($hit['hit_url']) { ?>
-			      <td><a href="<?php print $hit['hit_url']?>" target="_blank"><?php print $hit['hit_name']?></a></td>
-		      <?php } else {?>
-			      <td><?php print $hit['hit_name'] ?></td>
-		      <?php } ?>
-			   <td nowrap><?php print $hit['best_evalue']?></td>
-			   <td nowrap><?php  if (!empty($hit['percent_identity'])) { print $hit['percent_identity']; } ?></td>
-			   <td><?php print $hit['description']?></td>
-		   </tr>
-   
-		   <!-- If there is alignment information for at least one HSP -->
-		   <?php if (!empty($hit['hsp'][0]['query_frame'])) { ?>
-	      <tr class="<?php print $class ?>">
-		      <td colspan=5>
-			      <a class="blast-hit-arrow-icon" onclick="return tripal_blast_toggle_alignment(<?php print $analysis->analysis_id ?>,<?php print $i?>)"><img id="tripal_analysis_blast-info-toggle-image-<?php print $analysis->analysis_id ?>-<?php print $i?>" src=<?php print $hit['arrowr_url']?> align="top"> View Alignment</a>
-			      <div class="tripal_analysis_blast-info-hsp-title"></div>
-		      </td>
-	      </tr>
-	      <tr class="<?php print $class ?> tripal_analysis_blast-result-last-row">
-		      <td colspan=5>
-		      <?php 
-		      $hsps_array = $hit['hsp'];
-		      foreach ($hsps_array AS $hsp) { ?>
-			      <div class="tripal_analysis_blast-info-hsp-desc" id="tripal_analysis_blast-info-hsp-desc-<?php print $analysis->analysis_id ?>-<?php print $i?>">
-				      &nbsp;HSP <?php  print $hsp['hsp_num'] ?>
-				      <pre>Score: <?php print $hsp['bit_score'] ?> bits (<?php print $hsp['score'] ?>), Expect = <?php print $hsp['evalue'] ?><br>Identity = <?php print sprintf("%d/%d (%.2f%%)", $hsp['identity'], $hsp['align_len'], $hsp['identity']/$hsp['align_len']*100) ?>, Postives = <?php print sprintf("%d/%d (%.2f%%)", $hsp['positive'], $hsp['align_len'], $hsp['positive']/$hsp['align_len']*100)?>, Query Frame = <?php print $hsp['query_frame']?></a><br><br></a>Query: <?php print sprintf("%4d", $hsp['query_from'])?> <?php print $hsp['qseq'] ?> <?php print sprintf("%d", $hsp['query_to']); ?><br>            <?php print $hsp['midline'] ?><br>Sbjct: <?php print sprintf("%4d", $hsp['hit_from']) ?> <?php print $hsp['hseq']?> <?php print sprintf("%d",$hsp['hit_to']) ?></pre><br>
-			      </div>
-		      <?php } //end of foreach hsp ?>
-		      </td>
-	      </tr>		
-         <?php } //end of if there is query sequence for at least one hsp
-         $i++;  
-     } //end of foreach hit ?>
-	</table>
-</div>
-</div>
-  <?php } // end of foreach blast result ?>
-<?php } //end of if there are blast results ?>

+ 0 - 9
extensions/tripal_analysis_blast/tripal_analysis_blast.info

@@ -1,9 +0,0 @@
-; $Id:
-name = Tripal Blast
-description = An analysis sub-module for adding, editing, and displaying blast analysis results.
-core = 6.x
-project = tripal_analysis_blast
-package = Tripal Extensions 
-dependencies[] = tripal_core
-dependencies[] = tripal_feature
-dependencies[] = tripal_analysis

+ 0 - 198
extensions/tripal_analysis_blast/tripal_analysis_blast.install

@@ -1,198 +0,0 @@
-<?php
-//$Id:
-
-/*******************************************************************************
- * Implementation of hook_install().
- */
-function tripal_analysis_blast_install() {
-   // create the module's data directory
-   tripal_create_moddir('tripal_analysis_blast');
-
-   // We need to register to tripal_analysis module so it can provide a control
-   // for our blast result. Basically the registration is done by inserting
-   // modulename into the drupal {tripal_analysis} table AND inserting required
-   // information to the chado Analysis table. Also in tripal_analysis_blast.module,
-   // we need to define HOOK_get_settings() for the module to work properly.   
-   // Register the analysis type
-   tripal_analysis_register_child('tripal_analysis_blast');
-   
-   // Add cvterms
-   tripal_analysis_blast_add_cvterms();
-   
-   // Create a tripal_analysis_blast table to store parsers
-   drupal_install_schema('tripal_analysis_blast');
-   
-   // Create default parser for swissprot, DB:genbank, and go-seqdb
-   $sql_db = "SELECT db_id, name FROM {db} WHERE name like '%s'";
-   $sql_parser = "INSERT INTO {tripal_analysis_blast} ".
-                 "  (db_id, displayname, regex_hit_id, regex_hit_def, regex_hit_accession, genbank_style) ".
-                 "VALUES (%d, '%s', '%s', '%s', '%s', %d)";
-   
-   // Add swissprot parser
-   $previous_db = tripal_db_set_active ('chado');
-   $results = db_query($sql_db, "%swissprot%");
-   tripal_db_set_active($previous_db);
-   while ($db = db_fetch_object($results)) {
-      db_query($sql_parser, $db->db_id, 'ExPASy Swissprot', '^sp\|.*?\|(.*?)\s.*?$', '^sp\|.*?\|.*?\s(.*)$', 'sp\|(.*?)\|.*?\s.*?$', 0);
-   }
-   
-   // Add trembl parser
-   $previous_db = tripal_db_set_active ('chado');
-   $results = db_query($sql_db, "%trembl%");
-   tripal_db_set_active($previous_db);
-   while ($db = db_fetch_object($results)) {
-      db_query($sql_parser, $db->db_id, 'ExPASy TrEMBL', '^.*?\|(.*?)\s.*?$', '^.*?\|.*?\s(.*)$', '^(.*?)\|.*?\s.*?$', 0);
-   }
-   
-   // Add NCBI genbank parser
-   $previous_db = tripal_db_set_active ('chado');
-   $results = db_query($sql_db, "%genbank%");
-   tripal_db_set_active($previous_db);
-   while ($db = db_fetch_object($results)) {
-      db_query($sql_parser, $db->db_id, 'Genbank', '', '', '', 1);
-   }
-}
-
-/*******************************************************************************
- * Implementation of hook_uninstall().
- */
-function tripal_analysis_blast_uninstall() {
-   
-   // Delete all information associate with the module
-   // Drupal complains when the user tries to uninstall tripal_analysis 
-   // and tripal_analysis_blast at the same time. This is because Drupal drops
-   // the {tripal_analysis} table before we can delete anything from it. Thus,
-   // we perform a db_table_exists() check before the deletion
-   
-   //Delete the settings from {tripal_analysis} table
-   tripal_analysis_unregister_child('tripal_analysis_blast');
-
-   // Delete module's variables from variables table.
-   db_query("DELETE FROM {variable} WHERE name='%s'",
-            'tripal_analysis_blast_setting');
-            
-   // Delete a tripal_analysis_blast table
-   drupal_uninstall_schema('tripal_analysis_blast');
-}
-
-/*******************************************************************************
-* Implementation of hook_schema(). This table stores the parsers for blast xml
-* xml results.
-*/
-function tripal_analysis_blast_schema() {
-   $schema = array();
-   $schema['tripal_analysis_blast'] = array(
-      'fields' => array(
-         'db_id' => array(
-            'type' => 'int',
-            'unsigned' => TRUE,
-            'not null' => TRUE,
-            'default' => 0
-         ),
-         'displayname' => array(
-            'type' => 'varchar',
-            'length' => 100,
-            'not null' => TRUE,
-         ),
-         'regex_hit_id' => array(
-            'type' => 'varchar',
-            'length' => 30,
-         ),
-         'regex_hit_def' => array(
-            'type' => 'varchar',
-            'length' => 30,
-         ),
-         'regex_hit_accession' => array(
-            'type' => 'varchar',
-            'length' => 30,
-         ),
-         'genbank_style' => array(
-            'type' => 'int',
-            'unsigned' => TRUE,
-            'default' => 0
-         ),
-      ),
-      'indexes' => array(
-         'db_id' => array('db_id')
-      ),
-      'primary key' => array('db_id'),
-  );
-  return $schema;
-}
-
-/*******************************************************************************
- * Implementation of hook_requirements(). Make sure 'Tripal Core' and 'Tripal
- * Analysis' are enabled before installation
- */
-function tripal_analysis_blast_requirements($phase) {
-   $requirements = array();
-   if ($phase == 'install') {
-      if (!function_exists('tripal_create_moddir') || !function_exists('tripal_analysis_register_child')) {
-         $requirements ['tripal_analysis_blast'] = array(
-            'title' => "tripal_analysis_blast",
-            'value' => "error. Some required modules are just being installed. Please try again.",
-            'severity' => REQUIREMENT_ERROR,
-         );
-      }
-   }
-   return $requirements;
-}
-
-/*******************************************************************************
- * Provide update script for adding new cvterms
- */
-function tripal_analysis_blast_update_6000(){
-
-   // we have some new cvterms to add
-   tripal_analysis_blast_add_cvterms();
-
-   $ret = array(
-      '#finished' => 1,
-   );
-   
-   return $ret;
-}
-
-/*******************************************************************************
- * Function for adding cvterms
- */
-function tripal_analysis_blast_add_cvterms () {
-	
-   // Add the cvterms for the anlysisprop table
-   tripal_add_cvterms('analysis_blast_settings', 'Settings of a blast analysis, '.
-      'including db_id, output file, and run parameters separated by a bar |');
-   tripal_add_cvterms('analysis_blast_blastdb','The database used for blasting');
-   tripal_add_cvterms('analysis_blast_blastfile','The input file or directory that contains the XML blast output');
-   tripal_add_cvterms('analysis_blast_blastparameters','The parameters used when performing blast.');
-   tripal_add_cvterms('analysis_blast_no_parsed','Indicates if the input file should be parsed to map results to features');
-   tripal_add_cvterms('analysis_blast_query_re','The regular expression for finding the feature name in the query definition line of the blast results');
-   tripal_add_cvterms('analysis_blast_query_type','The feature type (e.g. mRNA, polypeptide) of the query input file. This type is used to identify the query feature when multiple features have the same name');
-   tripal_add_cvterms('analysis_blast_query_uniquename','Indicates if the matched name in the query definition line of the blast results is feature uniquename');
-   tripal_add_cvterms('analysis_blast_blastfile_ext','Indicates the extension of the blast files. This is required if the blastfile setting is a directory.');
-   tripal_add_cvterms('analysis_blast_is_concat','Indicates if the blast results XML file is a series of concatenated XML results.  Such is the case, for example, if Blast2GO was used to perform the analysis.');
-
-   // Add cvterm 'analysis_blast_output_iteration_hits' for inserting into featureprop table
-   tripal_add_cvterms('analysis_blast_output_iteration_hits', 'Hits of a blast '.
-      'output iteration. Each iteration corresponds to a chado feature, and is '.
-      'the content between <iteration> and </iteration> tags in the blast xml '.
-      'output file. This cvterm represents all hits in the iteration');
-   
-   tripal_add_cvterms('analysis_blast_besthit_query', 'query name of the best hit 
-   associated with a feature and a blast analysis ');
-
-   tripal_add_cvterms('analysis_blast_besthit_match', 'match name of the best hit 
-   associated with a feature and a blast analysis ');
-    
-   tripal_add_cvterms('analysis_blast_besthit_description', 'description of the best hit 
-   associated with a feature and a blast analysis ');
-   
-   tripal_add_cvterms('analysis_blast_besthit_evalue', 'evalue of the best hit 
-   associated with a feature and a blast analysis ');
-    
-   tripal_add_cvterms('analysis_blast_besthit_identity', 'identity (%) of the best hit 
-   associated with a feature and a blast analysis ');
-   
-   tripal_add_cvterms('analysis_blast_besthit_length', 'length of the best hit 
-   associated with a feature and a blast analysis ');
-   
-}

+ 0 - 909
extensions/tripal_analysis_blast/tripal_analysis_blast.module

@@ -1,909 +0,0 @@
-<?php
-
-require_once "includes/parse_blast_XML.inc";
-
-
-/*******************************************************************************
- * Tripal Blast Result lets users show/hide blast results associated
- * with a tripal feature
- ******************************************************************************/
-function tripal_analysis_blast_init(){
-	// Add javascript and style sheet
-	drupal_add_css(drupal_get_path('module', 'tripal_analysis_blast') .'/theme/css/tripal_analysis_blast.css', 'theme');
-	drupal_add_js(drupal_get_path('module', 'tripal_analysis_blast') .'/theme/js/tripal_analysis_blast.js');
-}
-
-/*******************************************************************************
- * tripal_analysis_blast_menu()
- * HOOK: Implementation of hook_menu()
- * Entry points and paths of the module
- */
-function tripal_analysis_blast_menu() {
-	// Show top 10/25/all blast results for ajax calls
-	$items['tripal_top_blast'] = array(
-      'path' => 'top_blast',
-      'title' => t('Blast Hits'),
-      'page callback' => 'tripal_get_feature_blast_results_ajax',
-      'page arguments' => array(1,2,3),
-      'access arguments' => array('access content'),
-      'type' => MENU_CALLBACK
-	);
-	// Show regular expressions for selected database in Blast admin page
-	$items['admin/tripal/tripal_analysis/tripal_blast_regex/%'] = array(
-      'title' => t('Blast Regex'),
-      'page callback' => 'tripal_get_blast_regex',
-      'page arguments' => array(4),
-      'access arguments' => array('administer site configuration'),
-      'type' => MENU_CALLBACK
-	);
-	$items['tripal_blast_report'] = array(
-      'title' => t('Homology Report'),
-      'page callback' => 'tripal_get_blast_report',
-      'page arguments' => array(1,2,3,4,5),
-      'access arguments' => array('access chado_analysis_blast content'),
-      'type' => MENU_CALLBACK,
-	   'file' => 'tripal_analysis_blast_htmlreport.inc'
-	);
-	
-	return $items;
-}
-/**
- *
- *
- * @ingroup tripal_analysis_blast
- */
-function tripal_analysis_blast_block($op = 'list', $delta = 0, $edit=array()){
-   switch($op) {
-      case 'list':
-         $blocks['blast_base']['info'] = t('Analysis: Blast Details');
-         $blocks['blast_base']['cache'] = BLOCK_NO_CACHE;
-
-
-         $blocks['featureblast']['info'] = t('Tripal Feature Blast Results');
-         $blocks['featureblast']['cache'] = BLOCK_NO_CACHE;
-
-         
-         return $blocks;
-
-
-      case 'view':
-         if(user_access('access chado_analysis_blast content') and arg(0) == 'node' and is_numeric(arg(1))) {
-            $nid = arg(1);
-            $node = node_load($nid);
- 
-            $block = array();
-            switch($delta){
-               case 'blast_base':
-                  $block['subject'] = t('Blast Details');
-                  $block['content'] = theme('tripal_analysis_blast_base',$node);
-                  break;
-               case 'featureblast':
-                  $block['subject'] = t('Homology');
-                  $block['content'] = theme('tripal_feature_blast_results',$node);
-                  break;  
-               default :
-            }
-
-            return $block;
-         }
-   }
-}
-
-/*******************************************************************************
- * tripal_analysis_blast_nodeapi()
- * HOOK: Implementation of hook_nodeapi()
- * Display blast results for allowed node types
- */
-function tripal_analysis_blast_nodeapi(&$node, $op, $teaser, $page) {
-
-	switch ($op) {
-		case 'view':
-
-         if($teaser){
-            return '';
-         }
-			// Find out which node types for showing the blast
-			$types_to_show = variable_get('tripal_analysis_blast_setting',
-			array('chado_feature'));
-
-			// Abort if this node is not one of the types we should show.
-			if (!in_array($node->type, $types_to_show, TRUE)) {
-				break;
-			}
-
-         if(strcmp($node->type,'chado_feature')==0){
-				if($node->build_mode == NODE_BUILD_SEARCH_INDEX){
-					$node->content['tripal_analysis_blast_index_version'] = array(
-                  '#value' => theme('tripal_analysis_blast_results_index_version',$node),
-                  '#weight' => 8,
-					);
-				} else {
-				   // Show blast result if not at teaser view
-				   $node->content['tripal_feature_blast_results'] = array(
-                  '#value' => theme('tripal_feature_blast_results', $node),
-                  '#weight' => 8
-				   );
-				}
-			}
-         break;
-	}
-}
-
-/**
- * Implements hook_theme_registry_alter().
- */
-
-function tripal_analysis_blast_theme_registry_alter(&$info) {
-  // Inject our module into the node theme registry as being an available theme
-  // path so that we can override the node template for our content type.
-  array_splice($info['node']['theme paths'], 1, 0, array(drupal_get_path('module', 'tripal_analysis_blast')));
-}
-
-
-
-/************************************************************************
- *  We need to let drupal know about our theme functions and their arguments.
- *  We create theme functions to allow users of the module to customize the
- *  look and feel of the output generated in this module
- */
-function tripal_analysis_blast_theme () {
-	$path = drupal_get_path('module', 'tripal_analysis_blast') . '/theme';
-	$theme = array(
-      'tripal_analysis_blast_results_index_version' => array (
-         'arguments' => array('node'),
-		),
-		'tripal_feature_blast_results' => array(
-			'template' => 'tripal_feature_blast_results',
-			'arguments' =>  array('node'=> null),
-			'path' => $path . '/tripal_feature',
-		),
-		'tripal_analysis_blast_report' => array(
-			'template' => 'tripal_analysis_blast_report',
-			'arguments' =>  array('report_object'=> null),
-			'path' => $path . '/tripal_analysis_blast',
-		),
-		'tripal_analysis_blast_base' => array(
-			'template' => 'tripal_analysis_blast_base',
-			'arguments' =>  array('report_object'=> null),
-			'path' => $path . '/tripal_analysis_blast',
-		)
-	);
-	return $theme;
-}
-/*******************************************************************************
- *  
- */
-function tripal_get_feature_blast_results_ajax($feature_id, $db_id, $max){
-   $sql = "SELECT nid FROM {chado_feature} WHERE feature_id = %d";
-   $nid = db_fetch_object(db_query($sql,$feature_id));
-   $node = node_load($nid->nid);
-
-   // add the additional variables that the theme needs to generate the output
-   $node->db_id = $db_id;
-   $node->max = $max;
-   // call the theme to rebuild the blast results
-   drupal_json(array('update' => theme('tripal_feature_blast_results',$node)));
-}
-/*******************************************************************************
- *  
- */
-function tripal_analysis_blast_preprocess_tripal_feature_blast_results(&$variables){
-   $feature = $variables['node']->feature;
-   $db_id = $variables['node']->db_id; // this value only gets set on an ajax call
-  
-   $max = 10;
-   if(isset($variables['node']->max)){
-      $max = $variables['node']->max;
-   }
-
-   $blast_results = tripal_get_feature_blast_results($feature->feature_id, $db_id, $max);
-   $feature->tripal_analysis_blast->blast_results_list = $blast_results;
-	 
-	 
-}
-/*******************************************************************************
- * Prepare blast result for the feature shown on the page
- */
-function theme_tripal_analysis_blast_results_index_version ($node) {
-	$feature = $node->feature;
-	$content = tripal_get_blast_results_index_version($feature->feature_id);
-	return $content;
-}
-
-/*******************************************************************************
- * tripal_get_feature_blast_results()
- * Get blast result from featureprop table for the feature
- */
-function tripal_get_feature_blast_results($feature_id, $db_id, $max){
-
-	// Get the blast results stored as XML from the analysisfeatureprop table
-   // the type for the property is named 'analysis_blast_output_iteration_hits'
-   // and is found in the 'tripal' controlled vocabulary.  This CV term was
-   // added by this module.
-   $select = array(
-      'analysisfeature_id' => array(
-         'feature_id' => $feature_id,
-      ), 
-      'type_id' => array(
-         'name' => 'analysis_blast_output_iteration_hits',
-         'cv_id' => array(
-            'name' => 'tripal'
-         ),
-      ),         
-   );
-   $blast_results = tripal_core_chado_select('analysisfeatureprop',array('*'),$select);
-   if (!$blast_results){
-      return;
-   }
-
-	// get the HTML content for viewing each of the XML file
-	$blast_obj_array = array ();
-	$blast_obj_counter = 0;
-	foreach ($blast_results as $index => $analysisfeatureprop) {
-      // get the blast XML for this feature
-      $blast_xml = $analysisfeatureprop->value;
-
-      // get the analysis record
-      $analysisfeature_arr = tripal_core_chado_select('analysisfeature',array('analysis_id'),
-         array('analysisfeature_id' => $analysisfeatureprop->analysisfeature_id));
-      $analysis_arr = tripal_core_chado_select('analysis',array('*'),
-         array('analysis_id' => $analysisfeature_arr[0]->analysis_id));
-      $analysis = $analysis_arr[0];
-      $analysis_id = $analysis->analysis_id;
-
-      // the old style was to store all parameters in a single CV term in the analysisprop 
-      // table. However now each property has it's own CV term in that table. But,
-      // we still need to support the old method for backwards compatibility.
-      // so, first get the old style variable and see if it has values. In
-      // particular we need the database setting
-      $blast_settings  = tripal_analysis_get_property($analysis_id,'analysis_blast_settings');	
-      if($blast_settings){
-		   $blastsettings = explode("|", $blast_settings->value);
-         // if we don't have the proper number of fields in the value column then
-         // skip this entry
-         if(count($blastsettings) != 3){
-           continue;
-         }
-		   $adb_id = $blastsettings[0];
-      }
-      // if we're not using the old style then try the new method to get the 
-      // database id
-      else {
-         $blastdb = tripal_analysis_get_property($analysis_id,'analysis_blast_blastdb');
-         $adb_id = $blastdb->value;
-      }
-      // if the callee specified a database to show then we want to check that
-      // with the database id of the analysis we're looking at.  If they
-      // don't match then skip this blast.  If a database id was not specified
-      // then continue
-      if($db_id and $adb_id != $db_id){
-         continue;
-      } 
-
-      // get the database
-      if($adb_id){
-        $db_arr = tripal_core_chado_select('db',array('*'),array('db_id' => $adb_id)); 
-        $db = $db_arr[0];
-      }
-
-      // parse the XML and add it to the array of blast results to be returned
-		$blast_obj = tripal_analysis_blast_get_result_object($blast_xml,$db,$max,$feature_id, $analysis);
-      $blast_obj->analysis = $analysis;
-		$blast_obj_array [$blast_obj_counter] = $blast_obj;
-		$blast_obj_counter ++;
-	}
-
-   return $blast_obj_array;
-}
-/*******************************************************************************
- * Scanning the file folder for blast results and prepare content for indexing
- */
-function tripal_get_blast_results_index_version ($feature_id){
-
-	// Get cvterm_id for 'analysis_blast_output_iteration_hits' which is required
-	// for inserting into the analysisfeatureprop table
-	$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_blast_output_iteration_hits' ".
-          "AND CV.name = 'tripal'";
-	$type_id = db_result(db_query($sql));
-
-	// Get xml string from analysisfeatureprop value column, get db_id from analysisprop value column
-	// , and get analysis_id from analysisfeature table
-	$sql = "SELECT AP.value AS apvalue, AFP.value AS afpvalue, AF.analysis_id AS aid
-           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);
-
-	// get the HTML content for viewing each of the XML file
-	while ($analysisfeatureprop = db_fetch_object($result)) {
-		// get analysis name and date
-		$previous_db = tripal_db_set_active('chado');
-		$sql = "SELECT analysis_id AS aid, name, to_char(timeexecuted, 'MM-DD-YYYY') AS time
-              FROM {analysis}               WHERE analysis_id = %d";
-		$analysis = db_fetch_object(db_query($sql, $analysisfeatureprop->aid));
-		tripal_db_set_active($previous_db);
-
-		$blastsettings = explode("|", $analysisfeatureprop->apvalue);
-		$att_db_id = $blastsettings [0];
-
-		// Get db object using the db_id
-		$previous_db = tripal_db_set_active('chado');
-		$sql = "SELECT * FROM {db} WHERE db_id=%d";
-		$db = db_fetch_object(db_query($sql, $att_db_id));
-		tripal_db_set_active($previous_db);
-		// Only index best 10 hits because the default page only shows 10 blast results
-		$max = 10;
-		$content .= parse_NCBI_Blast_XML_index_version($analysisfeatureprop->afpvalue,$db,$max,$feature_id,$ajax, $analysis);
-			
-	}
-	return $content;
-
-}
-
-
-/*******************************************************************************
- * Tripal Blast administrative setting form. This function is called by
- * tripal_analysis module which asks for an admin form to show on the page
- */
-function tripal_analysis_blast_get_settings() {
-	// Get an array of node types with internal names as keys
-	$options = node_get_types('names');
-	// Add 'chado_feature' to allowed content types for showing blast results
-	$allowedoptions ['chado_feature'] = "Show blast results on feature pages";
-
-	$form['description'] = array(
-       '#type' => 'item',
-       '#value' => t("Most chado features were analyzed by blast against major sequence databases. This option allows user to display the blast analysis results. Please read user manual for storage and display of blast files. Check the box to enable the analysis results. Uncheck to disable it."),
-		 '#weight' => 0,
-	);
-
-	$form['tripal_analysis_blast_setting'] = array(
-      '#type' => 'checkboxes',
-      '#options' => $allowedoptions,
-      '#default_value' => variable_get('tripal_analysis_blast_setting',
-	array('chado_feature')),
-	);
-	$form['blast_parser'] = array(
-      '#title' => t('Blast Parser Settings'),
-      '#type' => 'fieldset',
-      '#description' => t('Configure parsers for showing blast results. Each database is '.
-                          'allowed to have one xml parser.'),
-      '#weight' => 10
-	);
-
-	$previous_db = tripal_db_set_active('chado');  // use chado database
-	// get a list of db from chado for user to choose
-	$sql = 'SELECT db_id, name FROM {db} ORDER BY lower(name)';
-	$results = db_query ($sql);
-	$blastdbs = array();
-	while ($db = db_fetch_object($results)){
-		$blastdbs[$db->db_id] = $db->name;
-	}
-	$form['db_options'] = array(
-      '#type' => 'value',
-      '#value' => $blastdbs
-	);
-	$form['blast_parser']['blastdb'] = array(
-      '#title' => t('Database'),
-      '#type' => 'select',
-      '#description' => t('The database used for the blast analysis.'),
-      '#options' => $form['db_options']['#value'],
-      '#attributes' => array(
-         'onChange' => "return tripal_update_regex(this)",
-	    )
-	);
-	$form['blast_parser']['displayname'] = array(
-      '#title' => t('Title for the blast analysis'),
-      '#type' => 'textfield',
-	);
-	$form['blast_parser']['gb_style_parser'] = array(
-      '#title' => t('Use Genebank style parser. This will clear all regular expression settings for the selected database.'),
-	   '#type' => 'checkbox',
-	   '#attributes' => array(
-         'onClick' => "return tripal_set_genbank_style(this)",
-	    )
-	);
-	$form['blast_parser']['hit_id'] = array(
-      '#title' => t('Regular expression for Hit Name'),
-      '#type' => 'textfield',
-	);
-	$form['blast_parser']['hit_def'] = array(
-      '#title' => t('Regular expression for Hit Description'),
-      '#type' => 'textfield',
-	);
-	$form['blast_parser']['hit_accession'] = array(
-      '#title' => t('Regular expression for Hit Accession'),
-      '#type' => 'textfield',
-	);
-	$form['blast_parser']['button'] = array(
-      '#type' => 'submit',
-      '#value' => t('Save settings')
-	);
-	tripal_db_set_active($previous_db); // use drupal database
-
-	$settings->form = $form;
-	$settings->title = "Tripal Blast";
-	return $settings;
-}
-
-
-
-/*******************************************************************************
- * This function is only called by ajax to get regular expressions for blast
- * admin page
- */
-function tripal_get_blast_regex ($db_id) {
-	$sql = "SELECT * FROM {tripal_analysis_blast} WHERE db_id = %d";
-	$blast_regexs = db_fetch_object(db_query($sql, $db_id));
-	drupal_json(array(
-	     'name' => $blast_regexs->displayname,
-	     'genbank_style' => $blast_regexs->genbank_style,
-	     'reg1' => $blast_regexs->regex_hit_id,
-	     'reg2' => $blast_regexs->regex_hit_def,
-	     'reg3' => $blast_regexs->regex_hit_accession)
-	);
-}
-
-/*******************************************************************************
- *  Provide information to drupal about the node types that we're creating
- *  in this module
- */
-function tripal_analysis_blast_node_info() {
-	$nodes = array();
-	$nodes['chado_analysis_blast'] = array(
-      'name' => t('Analysis: Blast'),
-      'module' => 'chado_analysis_blast',
-      'description' => t('A blast analysis from the chado database'),
-      'has_title' => FALSE,
-      'title_label' => t('Analysis: Blast'),
-      'has_body' => FALSE,
-      'body_label' => t('Blast Analysis Description'),
-      'locked' => TRUE
-	);
-	return $nodes;
-}
-
-
-/*******************************************************************************
- *  Provide a Blast Analysis form
- */
-function chado_analysis_blast_form ($node){
-
-   // add in the default fields
-   $form = chado_analysis_form($node);
-
-   // set the default values
-   $blast = $node->analysis->tripal_analysis_blast;
-   $blastdb = $blast->blastdb;
-   $blastfile    = $blast->blastfile;
-   $blastfile_ext    = $blast->blastfile_ext;
-   $blastparameters = $blast->blastparameters;
-
-   $query_re = $blast->query_re;
-   $query_type = $blast->query_type;
-   $query_uniquename = $blast->query_uniquename;
-   $is_concat = $blast->is_concat;
-
-		
-	$form['blast'] = array(
-      '#title' => t('Blast Settings'),
-      '#type' => 'fieldset',
-      '#description' => t('Specific Settings for Blast Analysis.'),
-      '#collapsible' => TRUE,
-      '#attributes' => array('id' => 'blast-extra-settings'),
-      '#weight' => 11
-	);
-
-	$previous_db = tripal_db_set_active('chado');  // use chado database
-	// get a list of db from chado for user to choose
-	$sql = 'SELECT db_id, name FROM {db} ORDER BY lower(name)';
-	$results = db_query ($sql);
-	tripal_db_set_active($previous_db);
-	$blastdbs = array();
-	while ($db = db_fetch_object($results)){
-		$blastdbs[$db->db_id] = $db->name;
-	}
-	$form['db_options'] = array(
-      '#type' => 'value',
-      '#value' => $blastdbs
-	);
-	$form['blast']['blastdb'] = array(
-      '#title' => t('Database'),
-      '#type' => 'select',
-      '#description' => t('The database used for the blast analysis. If the database does not appear in this list, please add it.'),
-      '#options' => $form['db_options']['#value'],
-      '#default_value' => $blastdb,
-	);
-
-	$form['blast']['blastfile'] = array(
-      '#title' => t('Blast 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('The xml output file generated by blast in full path.'),
-      '#default_value' => $blastfile,
-	); 
-   $form['blast']['blastfile_ext'] = array(
-      '#title' => t('Blast XML file extension'),
-      '#type' => 'textfield',
-      '#description' => t('If a directory is provide for the blast file setting above, then a file extension can be provided here. Files with this extension in the directory will be parsed.  If no extension is provided then files with a .xml extension will be parsed within the directory. Please provide the extension without the preceeding period (e.g. "out" rather than ".out"'),
-      '#default_value' => $blastfile_ext,
-	);
-	$form['blast']['is_concat'] = array(
-      '#title' => t('Is the XML file concatenated?'),
-      '#type' => 'checkbox',
-      '#description' => t('Is the XML file a set of concatenated XML results?  Such is the case, for instance, if
-                          <a href="http://www.blast2go.org/">Blast2GO</a> was used to generate the blast results.'),
-      '#default_value' => $is_concat,
-	);
-	$form['blast']['no_parsed'] = array(
-	  '#title' => t('Number of hits to be parsed'),
-      '#type' => 'textfield',
-      '#description' => t("The number of hits to be parsed. Tripal will parse only top 10 hits if you input '10'' in this field."),
-      '#default_value' => 'all',
-	);
-
-	$form['blast']['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 blast results. This should be '.
-         'the same as the definition line in the query FASTA file.  This option is '.
-         'is only required when the query does not identically match a feature '.
-         'in the database.'),
-      '#default_value' => $query_re,
-	);
-
-	$form['blast']['query_type'] = array(
-      '#title' => t('Query Type'),
-      '#type' => 'textfield',
-      '#description' => t('Please enter the Sequence Ontology term that describes '.
-         'the query sequences used for blasting.  This is only necessary if two '.
-         'or more sequences have the same name.'),
-      '#default_value' => $query_type,
-	);
-
-	$form['blast']['query_uniquename'] = array(
-      '#title' => t('Use Unique Name'),
-      '#type' => 'checkbox',
-      '#description' => t('Select this checboxk if the query name in the blast file '.
-        'matches the uniquename of the feature.  By default, the blast results will '.
-        'mapped to the "name" of the feature.'),
-      '#default_value' => $query_uniquename,
-	);
-
-	$form['blast']['blastparameters'] = array(
-      '#title' => t('Parameters'),
-      '#type' => 'textfield',
-      '#description' => t('The parameters for running the blast analysis.'),
-      '#default_value' => $blastparameters,
-	);
-	
-	$form['blast']['blastjob'] = array(
-      '#type' => 'checkbox',
-      '#title' => t('Submit a job to parse the xml output into Chado'),
-      '#description' => t('Note: features associated with the blast results must '.
-                          'exist in chado before parsing the file. Otherwise, blast '.
-                          'results that cannot be linked to a feature will be '.
-                          'discarded. '),
-      '#default_value' => $blastjob
-	);
-	
-/*	$form['blast']['blastbesthit'] = array(
-      '#type' => 'checkbox',
-      '#title' => t('Submit a job to generate a "best hits" report.'),
-      '#description' => t('Note: the checkbox above must also be selected.'),
-      '#default_value' => $blastbesthit
-	);
-*/	
-	return $form;
-}
-/**
-*
-*/
-function chado_analysis_blast_validate($node, &$form){
-   // use the analysis parent to validate the node
-   tripal_analysis_validate($node, $form); 
-}
-
-/*******************************************************************************
- *  When a node is requested by the user this function is called to allow us
- *  to add auxiliary data to the node object.
- */
-function chado_analysis_blast_load($node){
-
-   // load the default set of analysis fields
-	$additions = chado_analysis_load($node);
-
-   // create some variables for easier lookup
-   $analysis = $additions->analysis;
-   $analysis_id = $analysis->analysis_id;
-
-   $blast_settings  = tripal_analysis_get_property($analysis->analysis_id,'analysis_blast_settings');	
-   $blastdb         = tripal_analysis_get_property($analysis->analysis_id,'analysis_blast_blastdb');
-   $blastfile       = tripal_analysis_get_property($analysis->analysis_id,'analysis_blast_blastfile');	
-   $blastparameters = tripal_analysis_get_property($analysis->analysis_id,'analysis_blast_blastparameters');
-   $no_parsed       = tripal_analysis_get_property($analysis->analysis_id,'analysis_blast_no_parsed');	
-   $query_re        = tripal_analysis_get_property($analysis->analysis_id,'analysis_blast_query_re');	
-   $query_type      = tripal_analysis_get_property($analysis->analysis_id,'analysis_blast_query_type');	
-   $query_uniquename= tripal_analysis_get_property($analysis->analysis_id,'analysis_blast_query_uniquename');	
-   $blastfile_ext   = tripal_analysis_get_property($analysis->analysis_id,'analysis_blast_blastfile_ext');	
-   $is_concat       = tripal_analysis_get_property($analysis->analysis_id,'analysis_blast_is_concat');	
-
-   $analysis->tripal_analysis_blast->blastdb         = $blastdb->value;
-   $analysis->tripal_analysis_blast->blastfile       = $blastfile->value;	
-   $analysis->tripal_analysis_blast->blastparameters = $blastparameters->value;
-   $analysis->tripal_analysis_blast->no_parsed       = $no_parsed->value;	
-   $analysis->tripal_analysis_blast->query_re        = $query_re->value;	
-   $analysis->tripal_analysis_blast->query_type      = $query_type->value;	
-   $analysis->tripal_analysis_blast->query_uniquename= $query_uniquename->value;	
-   $analysis->tripal_analysis_blast->blastfile_ext   = $blastfile_ext->value;	
-   $analysis->tripal_analysis_blast->is_concat       = $is_concat->value;	
-
-   // get the database information so that we don't have to require callers
-   // to do the lookup
-   $select = array('db_id' => $blastdb->value);
-   $analysis->tripal_analysis_blast->db = tripal_core_generate_chado_var('db',$select);
-
-   // if there is an old style 'blast_settings' array, then break these out for
-   // use in the new format
-   if(count($blast_settings)>0){
-	   $prop_values = explode ("|", $blast_settings->value);
-      $analysis->tripal_analysis_blast->blastdb = $prop_values[0];
-      $analysis->tripal_analysis_blast->blastfile = $prop_values[1];
-      $analysis->tripal_analysis_blast->blastparameters = $prop_values[2];
-   }
-
-   /* check if there exists a best hit report. if yes, reuturn the report url
-   $select = array(
-      'analysisfeature_id' => array(
-         'analysis_id' => $analysis_id,
-      ), 
-      'type_id' => array(
-         'name' => 'analysis_blast_besthit_query',
-         'cv_id' => array(
-            'name' => 'tripal'
-         ),
-      ),         
-   );
-   $blast_report = tripal_core_chado_select('analysisfeatureprop',array('analysisfeatureprop_id'),$select);
-   */
-   $sql = "SELECT AFP.analysisfeature_id
-	             FROM {analysisfeature} AF 
-	             INNER JOIN {analysisfeatureprop} AFP ON AF.analysisfeature_id = AFP.analysisfeature_id
-	             WHERE analysis_id = %d
-	             AND AFP.type_id = (
-	                SELECT cvterm_id 
-	                FROM {cvterm} 
-	                WHERE name = '%s' 
-	                AND cv_id = (
-	                   SELECT cv_id 
-	                   FROM {cv} 
-	                   WHERE name = 'tripal'
-	                )
-	             ) LIMIT 1 OFFSET 0";
-   $blast_report = db_result(chado_query($sql, $analysis_id, 'analysis_blast_besthit_query'));
-	if ($blast_report) {
-		$report_url = url("tripal_blast_report/".$analysis->analysis_id."/1/0/0/20");
-		$analysis->blast_report = $report_url;
-	}
-
-	return $additions;
-}
-/**
-*
-*/
-function chado_analysis_blast_insert($node){
-
-   // insert the analysistripal_core_generate_chado_var
-   chado_analysis_insert($node);
-
-   // set the type for this analysis
-   tripal_analysis_insert_property($node->analysis_id,'analysis_type','tripal_analysis_blast');
-
-   // now add in the remaining settings as a single property but separated by bars
-   tripal_analysis_insert_property($node->analysis_id,'analysis_blast_blastdb',$node->blastdb);
-   tripal_analysis_insert_property($node->analysis_id,'analysis_blast_blastfile',$node->blastfile);	
-   tripal_analysis_insert_property($node->analysis_id,'analysis_blast_blastparameters',$node->blastparameters);	
-   tripal_analysis_insert_property($node->analysis_id,'analysis_blast_no_parsed',$node->no_parsed);	
-   tripal_analysis_insert_property($node->analysis_id,'analysis_blast_query_re',$node->query_re);	
-   tripal_analysis_insert_property($node->analysis_id,'analysis_blast_query_type',$node->query_type);	
-   tripal_analysis_insert_property($node->analysis_id,'analysis_blast_query_uniquename',$node->query_uniquename);	
-   tripal_analysis_insert_property($node->analysis_id,'analysis_blast_blastfile_ext',$node->blastfile_ext);	
-   tripal_analysis_insert_property($node->analysis_id,'analysis_blast_is_concat',$node->is_concat);	
-  
-   // submit the parsing jobs
-   chado_analysis_blast_submit_jobs($node);
-}
-/**
- * 
- */
-function chado_analysis_blast_update($node){
-
-   // update the anlaysis
-   chado_analysis_update($node); 
-
-   // add the blast settings
-   tripal_analysis_update_property($node->analysis_id,'analysis_type','tripal_analysis_blast',1);	
-   tripal_analysis_update_property($node->analysis_id,'analysis_blast_blastdb',$node->blastdb,1);
-   tripal_analysis_update_property($node->analysis_id,'analysis_blast_blastfile',$node->blastfile,1);	
-   tripal_analysis_update_property($node->analysis_id,'analysis_blast_blastparameters',$node->blastparameters,1);	
-   tripal_analysis_update_property($node->analysis_id,'analysis_blast_no_parsed',$node->no_parsed,1);	
-   tripal_analysis_update_property($node->analysis_id,'analysis_blast_query_re',$node->query_re,1);	
-   tripal_analysis_update_property($node->analysis_id,'analysis_blast_query_type',$node->query_type,1);	
-   tripal_analysis_update_property($node->analysis_id,'analysis_blast_query_uniquename',$node->query_uniquename,1);	
-   tripal_analysis_update_property($node->analysis_id,'analysis_blast_blastfile_ext',$node->blastfile_ext,1);	
-   tripal_analysis_update_property($node->analysis_id,'analysis_blast_is_concat',$node->is_concat,1);	
-
-   // if this analysis uses the old style blast settings cvterm then remove that term
-   $old = tripal_analysis_get_property($node->analysis_id,'analysis_blast_settings');
-   if(count($old) > 0){
-      tripal_analysis_delete_property($node->analysis_id,'analysis_blast_settings');
-   }
-
-   // submit the parsing jobs
-   chado_analysis_blast_submit_jobs($node);
-}
-/**
-*
-*/
-function chado_analysis_blast_submit_jobs($node){
-   global $user;
-
-   // add a job if the user wants to parse the XML	    	
-	if($node->blastjob) {
-      $job_args = array(
-          $node->analysis_id,
-          $node->blastdb,
-          $node->blastfile,
-          $node->no_parsed,
-          $node->blastfile_ext,
-          $node->query_re,
-		    $node->query_type, 
-          $node->query_uniquename,
-          $node->is_concat
-      );
-
-		if (is_readable($node->blastfile)) {
-			tripal_add_job("Parse blast: $node->blastfile",'tripal_analysis_blast',
-                          'tripal_analysis_blast_parseXMLFile', $job_args, $user->uid);
-		} else {
-			drupal_set_message("Blast output file, $node->blastfile, is not readable 
-           by the server.  Check existence of file and file permissions. 
-           Job not scheduled.");
-		}
-	}
-   // add a job if the user wants to create a best hits report.
-	if($node->blastbesthit) {
-      $j_args[0] = $node->analysis_id;	
-		tripal_add_job("Parse best hit: $node->blastfile",'tripal_analysis_blast',
-                     'tripal_analysis_blast_parse_best_hit', $j_args, $user->uid);			
-   }
-		
-}
-/*******************************************************************************
- * Delete blast anlysis
- */
-function chado_analysis_blast_delete($node){
-	chado_analysis_delete($node);
-}
-
-/*******************************************************************************
- *  This function customizes the view of the chado_analysis node.  It allows
- *  us to generate the markup.
- */
-function chado_analysis_blast_view ($node, $teaser = FALSE, $page = FALSE) {
-	// use drupal's default node view:
-    //dprint_r($node);
-	if (!$teaser) {
-		$node = node_prepare($node, $teaser);
-		// When previewing a node submitting form, it shows 'Array' instead of
-		// correct date format. We need to format the date here
-		$time = $node->timeexecuted;
-		if(is_array($time)){
-			$month = $time['month'];
-			$day = $time['day'];
-			$year = $time['year'];
-			$timestamp = $year.'-'.$month.'-'.$day;
-			$node->timeexecuted = $timestamp;
-		}
-		// When viewing a node, we need to reformat the analysisprop since we
-		// separate each value with a bar |
-		if (preg_match("/.*\|.*\|.*/",$node->blastdb)) {
-			$prop_values = explode("|", $node->blastdb);
-			$node->blastdb = $prop_values[0];
-			$node->blastfile = $prop_values[1];
-			$node->blastparameters = $prop_values[2];
-		}
-	}
-	return $node;
-}
-
-/*******************************************************************************
- * Set the permission types that the chado module uses.  Essentially we
- * want permissionis that protect creation, editing and deleting of chado
- * data objects
- */
-function tripal_analysis_blast_perm(){
-	return array(
-      'access chado_analysis_blast content',
-      'create chado_analysis_blast content',
-      'delete chado_analysis_blast content',
-      'edit chado_analysis_blast content',
-	);
-}
-
-/*******************************************************************************
- *  The following function proves access control for users trying to
- *  perform actions on data managed by this module
- */
-function chado_analysis_blast_access($op, $node, $account){
-	if ($op == 'create') {
-		if(!user_access('create chado_analysis_blast content', $account)){
-			return FALSE;
-      }
-	}
-	if ($op == 'update') {
-		if (!user_access('edit chado_analysis_blast content', $account)) {
-			return FALSE;
-		}
-	}
-	if ($op == 'delete') {
-		if (!user_access('delete chado_analysis_blast content', $account)) {
-			return FALSE;
-		}
-	}
-	if ($op == 'view') {
-		if(!user_access('access chado_analysis_blast content', $account)){
-         return FALSE;
-      }
-	}
-   return NULL;
-}
-
-/**
- *
- *
- * @ingroup tripal_feature
- */
-function tripal_analysis_blast_job_describe_args($callback,$args){
-
-   $new_args = array();
-   if($callback == 'tripal_analysis_blast_parseXMLFile'){
-
-      // add in the analysis 
-      if($args[0]){
-         $analysis = tripal_core_chado_select('analysis',array('name'),array('analysis_id' => $args[0]));
-      }
-      $new_args['Analysis'] = $analysis[0]->name;
-
-      // add in the database 
-      if($args[1]){
-         $db = tripal_core_chado_select('db',array('name'),array('db_id' => $args[1]));
-      }
-      $new_args['Database'] = $db[0]->name;
-
-      $new_args['File or Directory Name'] = $args[2];
-      if($args[7] == 1){
-        $new_args['Is XML file concatenated'] = 'Yes';
-      } else {
-        $new_args['Is XML file concatenated'] = 'No';
-      }
-      $new_args['File Extension (if directory)'] = $args[4];
-      $new_args['Number matches parsed per query'] = $args[3];
-      $new_args['Query name regular expression'] = $args[5];
-      $new_args['Query type'] = $args[6];
-      if($args[7] == 1){
-        $new_args['Feature identifier'] = 'feature unique name';
-      } else {
-        $new_args['Feature identifier'] = 'feature name';
-      }
-      
-
-   }
-   return $new_args;
-}

+ 0 - 208
extensions/tripal_analysis_blast/tripal_analysis_blast_htmlreport.inc

@@ -1,208 +0,0 @@
-<?php
-
-function tripal_get_blast_report ($analysis_id, $currentpage, $sort, $descending, $per_page) {
-	if (!tripal_analysis_check_permission($analysis_id)) {
-		$html_out = "Access denied. You are not authorized to access this report.";
-		return $html_out;
-	}
-	$report_object = new stdClass;
-	
-	$symbol = "&and;";
-	$sort_key = "ASC";
-	if ($descending == 1) {
-		$symbol = "&or;";
-		$sort_key = "DESC";
-	}
-	$header = 'analysis_blast_besthit_query';
-	$convert = 0;
-	if ($sort == 1) {
-		$header = 'analysis_blast_besthit_match';
-	} else if ($sort == 2) {
-		$header = 'analysis_blast_besthit_description';
-	} else if ($sort == 3) {
-		$header = 'analysis_blast_besthit_evalue';
-		$convert = 1;
-	} else if ($sort == 4) {
-		$header = 'analysis_blast_besthit_identity';
-		$convert = 1;
-	} else if ($sort == 5) {
-		$header = 'analysis_blast_besthit_length';
-		$convert = 1;
-	}
-
-	$previous_db = tripal_db_set_active('chado');
-	// Get analysis information including 'Time', 'Name', and 'DB Settings'
-	$sql = "SELECT value, name, to_char(timeexecuted, 'MM-DD-YYYY') AS time
-                FROM {analysis}  A
-                INNER JOIN {analysisprop} AP ON  A.analysis_id = AP.analysis_id 
-                WHERE A.analysis_id = %d
-                AND type_id= (SELECT cvterm_id 
-                                           FROM {cvterm} 
-                                           WHERE name = 'analysis_blast_blastdb')";
-	$analysis = db_fetch_object(db_query($sql, $analysis_id));
-	$db_id = $analysis->value;
-	
-	// Get db 'urlprefix'
-	$sql = "SELECT urlprefix FROM {db} WHERE db_id=%d";
-	$urlprefix = db_result(db_query($sql, $db_id));
-	
-	// Get all analysisfeature_id's sorted by the selected header for this blast analysis
-	$sql = "SELECT AFP.analysisfeature_id
-	             FROM {analysisfeature} AF 
-	             INNER JOIN {analysisfeatureprop} AFP ON AF.analysisfeature_id = AFP.analysisfeature_id
-	             WHERE analysis_id = %d
-	             AND AFP.type_id = (SELECT cvterm_id FROM {cvterm} WHERE name = '%s' AND cv_id = (SELECT cv_id FROM {cv} WHERE name = 'tripal'))
-	             ORDER BY value ";
-	// Convert string to number for evalue, %identity, and length before SQL sorting
-	if ($convert == 1) {
-		$sql .= "::numeric  ";
-	} 
-	$sql .= "$sort_key";
-
-	$result = db_query($sql, $analysis_id, $header);
-	tripal_db_set_active($previous_db);
-	$analysisfeatureSet = array();
-	// Count how many analysisfeature_id we have and store them in order in $analysisfeatureSet
-	$counter = 0;	
-	while ($feature = db_fetch_object($result)) {
-		$analysisfeatureSet [$counter] = $feature->analysisfeature_id;
-		$counter ++;
-	}
-   
-	// Get analysis node id
-	$ana_nid = db_result(db_query("SELECT nid FROM {chado_analysis} WHERE analysis_id = %d", $analysis_id));
-	$ana_url = url("node/".$ana_nid);
-	
-	// Get pager info
-	$no_page = (int) ($counter / $per_page);
-	if ($counter % $per_page != 0) {
-		$no_page ++;
-	}
-	$first_item = ($currentpage - 1)* $per_page;
-
-	$report_object->time = $analysis->time;
-	$report_object->name = $analysis->name;
-	$report_object->url = $ana_url;
-	$report_object->counter = $counter;
-	$report_object->currentpage = $currentpage;
-	$report_object->no_page = $no_page;
-	$report_object->symbol = $symbol;
-	$report_object->sort = $sort;
-
-	// Construct URL path for different sorting column
-	$path =  "tripal_blast_report/$analysis_id/1/0/";
-	if ($descending == 0 && $sort == 0) {
-		$path .= "1";
-	} else {
-		$path .= "0";
-	}
-	$path .= "/$per_page";
-	$url_path = url ($path);
-	$report_object->byQuery = $url_path;
-
-	$path =  "tripal_blast_report/$analysis_id/1/1/";
-	if ($descending == 0 && $sort == 1) {
-		$path .= "1";
-	} else {
-		$path .= "0";
-	}
-	$path .= "/$per_page";
-	$url_path = url ($path);
-	$report_object->byMatchName =$url_path;
-
-	$path =  "tripal_blast_report/$analysis_id/1/2/";
-	if ($descending == 0 && $sort == 2) {
-		$path .= "1";
-	} else {
-		$path .= "0";
-	}
-	$path .= "/$per_page";
-	$url_path = url ($path);
-	$report_object->byDescription = $url_path;
-
-	$path =  "tripal_blast_report/$analysis_id/1/3/";
-	if ($descending == 0 && $sort == 3) {
-		$path .= "1";
-	} else {
-		$path .= "0";
-	}
-	$path .= "/$per_page";
-	$url_path = url ($path);
-	$report_object->byEvalue = $url_path;
-	
-	$path =  "tripal_blast_report/$analysis_id/1/4/";
-	if ($descending == 0 && $sort == 4) {
-		$path .= "1";
-	} else {
-		$path .= "0";
-	}
-	$path .= "/$per_page";
-	$url_path = url ($path);
-	$report_object->byIdentity = $url_path;
-
-	$path =  "tripal_blast_report/$analysis_id/1/5/";
-	if ($descending == 0 && $sort == 5) {
-		$path .= "1";
-	} else {
-		$path .= "0";
-	}
-	$path .= "/$per_page";
-	$url_path = url ($path);
-	$report_object->byLength = $url_path;
-
-	// Get table content
-	$sql = "SELECT value
-	             FROM {analysisfeatureprop} 
-	             WHERE analysisfeature_id = %d 
-	             AND type_id = (SELECT cvterm_id FROM {cvterm} WHERE name = '%s' AND cv_id = (SELECT cv_id FROM {cv} WHERE name = 'tripal'))";
-	$j = 0;
-	$hits = array ();
-	for ($i = $first_item; $i < $first_item +$per_page; $i ++) {
-		$previous_db = tripal_db_set_active('chado');
-		$query = db_result(db_query($sql, $analysisfeatureSet[$i], 'analysis_blast_besthit_query'));
-		$match = db_result(db_query($sql, $analysisfeatureSet[$i], 'analysis_blast_besthit_match'));
-		$desc = db_result(db_query($sql, $analysisfeatureSet[$i], 'analysis_blast_besthit_description'));
-		$evalue = db_result(db_query($sql, $analysisfeatureSet[$i], 'analysis_blast_besthit_evalue'));
-		$identity = db_result(db_query($sql, $analysisfeatureSet[$i], 'analysis_blast_besthit_identity'));
-		$length = db_result(db_query($sql, $analysisfeatureSet[$i], 'analysis_blast_besthit_length'));
-		
-		$sql_fid = "SELECT feature_id FROM analysisfeature WHERE analysisfeature_id = %d";
-		$fid = db_result(db_query($sql_fid, $analysisfeatureSet[$i]));
-		tripal_db_set_active($previous_db);
-		
-		$q_url = url("ID$fid");
-		$class = 'tripal_analysis_blast-table-odd-row tripal-table-odd-row';
-	 	if($j % 2 == 0 ){
-         $class = 'tripal_analysis_blast-table-even-row tripal-table-even-row';
-      }
-      $hit = new stdClass();
-		if ($query) {
-			$hit->class = $class;
-			$hit->q_url = $q_url;
-			$hit->query = $query;
-			$hit->urlprefix = $urlprefix;
-			$hit->match = $match;
-			$hit->desc = $desc;
-			$hit->evalue = $evalue;
-			$hit->identity = $identity;
-			$hit->length = $length;
-			$hits [$j] = $hit;
-		}
-		$j ++;
-	}
-	$report_object->hits = $hits;
-	
-	// The number of items to show on the page
-	$path =  "tripal_blast_report/$analysis_id/1/$sort/$descending/";
-	$report_object->path = $path;
-	$report_object->per_page = $per_page;
-
-	// Make AJAX call to update the  page which user selected 
-	$report_object->analysis_id = $analysis_id;
-	$report_object->sort = $sort;
-	$report_object->descending = $descending;
-	$report_object->per_page = $per_page;
-	$report_object->no_page = $no_page;
-
-    return theme('tripal_analysis_blast_report',$report_object);
-}

+ 0 - 23
extensions/tripal_analysis_go/go_path_counts

@@ -1,23 +0,0 @@
-SELECT  CVTP.subject_id, CVT.name, CVT2.name, CVTP.object_id, CVT3.name, CVTP.pathdistance, count(F.name)
-FROM {cvtermpath} CVTP
-   INNER JOIN CVTerm CVT ON CVTP.subject_id = CVT.cvterm_id
-   INNER JOIN CVTerm CVT2 on CVTP.type_id = CVT2.cvterm_id
-   INNER JOIN CVTerm CVT3 on CVTP.object_id = CVT3.cvterm_id
-   INNER JOIN Feature_cvterm FCVT on FCVT.cvterm_id = CVT.cvterm_id
-   INNER JOIN Feature F on FCVT.feature_id = F.feature_id
-WHERE object_id = 7438
-GROUP BY CVTP.subject_id, CVT.name, CVT2.name, CVTP.object_id, CVT3.name, CVTP.pathdistance
-ORDER BY pathdistance
-
-
-// THE MATERIALIZED VIEW!!!
-SELECT  CVT3.name, CVTP.object_id, count(F.name)
-FROM {cvtermpath} CVTP
-   INNER JOIN CVTerm CVT ON CVTP.subject_id = CVT.cvterm_id
-   INNER JOIN CVTerm CVT2 on CVTP.type_id = CVT2.cvterm_id
-   INNER JOIN CVTerm CVT3 on CVTP.object_id = CVT3.cvterm_id
-   INNER JOIN Feature_cvterm FCVT on FCVT.cvterm_id = CVT.cvterm_id
-   INNER JOIN Feature F on FCVT.feature_id = F.feature_id
-   INNER JOIN CV on CV.cv_id = CVT.cv_id
-WHERE CV.name = 'biological_process' or CV.name = 'molecular_function' or CV.name = 'cellular_component'
-GROUP BY CVT3.name, CVTP.object_id

+ 0 - 466
extensions/tripal_analysis_go/includes/gaf_loader.inc

@@ -1,466 +0,0 @@
-<?php
-
-function tripal_analysis_go_gaf_load_form (){
-
-   $form['notice']= array(
-      '#type' => 'item',
-      '#value' => t('Note: currently, the GAF loader only uses column 2 (Object ID) and 5 (GO ID) 
-          from the GAF file, and simply imports GO terms for the features. 
-          Further support for this file format will be provided later.'),
-   );
-
-   $form['gaf_file']= array(
-      '#type'          => 'textfield',
-      '#title'         => t('GAF File'),
-      '#description'   => t('Please enter the full system path for the GAF file, or a path within the Drupal
-                             installation (e.g. /sites/default/files/xyz.txt).  The path must be accessible to the
-                             server on which this Drupal instance is running.'),
-      '#required' => TRUE,
-   );
-   // get the list of organisms
-   $sql = "SELECT * FROM {organism} ORDER BY genus, species";
-   $previous_db = tripal_db_set_active('chado');  // use chado database
-   $org_rset = db_query($sql);
-   tripal_db_set_active($previous_db);  // now use drupal database
-   $organisms = array();
-   $organisms[''] = '';
-   while($organism = db_fetch_object($org_rset)){
-      $organisms[$organism->organism_id] = "$organism->genus $organism->species ($organism->common_name)";
-   }
-   $form['organism_id'] = array (
-     '#title'       => t('Organism'),
-     '#type'        => t('select'),
-     '#description' => t("Choose the organism to which these sequences are associated "),
-     '#required'    => TRUE,
-     '#options'     => $organisms,
-   );
-   $form['seq_type']= array(
-      '#type' => 'textfield',
-      '#title' => t('Sequence Type'),
-      '#required' => TRUE,
-      '#description' => t('Please enter the Sequence Ontology term that describes the sequences in the GAF file.'),
-   );
-	$form['query_uniquename'] = array(
-      '#title' => t('Use Unique Name'),
-      '#type' => 'checkbox',
-      '#description' => t('Select this checboxk if the feature name in the GAF file '.
-        'matches the uniquename in the database.  By default, the feature will '.
-        'be mapped to the "name" of the feature.'),
-      '#default_value' => $query_uniquename,
-	);
-   $form['import_options'] = array(
-      '#type' => 'fieldset',
-      '#title' => t('Import Options'),
-      '#collapsed' => TRUE
-   );
-   $form['import_options']['add_only']= array(
-      '#type' => 'checkbox',
-      '#title' => t('Add GO terms'),
-      '#required' => FALSE,
-      '#description' => t('GO terms in the GAF file will be added to each feature.'),
-   );
-//   $form['import_options']['replace']= array(
-//      '#type' => 'checkbox',
-//      '#title' => t('Replace GO terms'),
-//      '#required' => FALSE,
-//      '#description' => t('All GO terms for features in the GAF file will be replaced with terms in the GAF file.'),
-//   );
-   $form['import_options']['remove']= array(
-      '#type' => 'checkbox',
-      '#title' => t('Delete GO terms'),
-      '#required' => FALSE,
-      '#description' => t('GO terms for features in the GAF file will be removed. Other terms will remain.'),
-   );
-
-   $form['analysis'] = array(
-      '#type' => 'fieldset',
-      '#title' => t('Analysis Used to Derive GO terms'),
-      '#collapsed' => TRUE
-   ); 
-
-   // get the list of organisms
-   $sql = "SELECT * FROM {analysis} ORDER BY name";
-   $previous_db = tripal_db_set_active('chado');  // use chado database
-   $org_rset = db_query($sql);
-   tripal_db_set_active($previous_db);  // now use drupal database
-   $analyses = array();
-   $analyses[''] = '';
-   while($analysis = db_fetch_object($org_rset)){
-      $analyses[$analysis->analysis_id] = "$analysis->name ($analysis->program $analysis->programversion, $analysis->sourcename)";
-   }
-   $form['analysis']['analysis_id'] = array (
-     '#title'       => t('Analysis'),
-     '#type'        => t('select'),
-     '#description' => t("Choose the analysis that defines how the GO annotations in the GAF file were created. "),
-     '#required'    => TRUE,
-     '#options'     => $analyses,
-   );
-
-
-  // Advanced Options
-   $form['advanced'] = array(
-      '#type' => 'fieldset',
-      '#title' => t('Advanced Options'),
-      '#collapsed' => TRUE
-   );
-   $form['advanced']['re_help']= array(
-      '#type' => 'item',
-      '#value' => t('A regular expression is an advanced method for extracting information from a string of text.  
-                     By default, this loader will use the first word in the second column of the GAF file 
-                     as the uniquename for the sequences.  If this is not desired, you may use the following regular 
-                     expressions to define the location of the name or unique name within the text of column 2.'),
-   );
-
-   $form['advanced']['re_name']= array(
-      '#type' => 'textfield',
-      '#title' => t('Regular expression for the name'),
-      '#required' => FALSE,
-      '#description' => t('Enter the regular expression that will extract the '.
-         'feature name from the GAF file. This option is '.
-         'is only required when the feature identifier does not identically match a feature '.
-         'in the database.'),
-   );   
- 
-
-   $form['button'] = array(
-      '#type' => 'submit',
-      '#value' => t('Import GAF file'),
-   );
-   return $form;
-}
-/**
- *
- *
- * @ingroup gff3_loader
- */
-function tripal_analysis_go_gaf_load_form_validate ($form, &$form_state){
-
-   $gaf_file = $form_state['values']['gaf_file'];
-   $organism_id = $form_state['values']['organism_id'];
-   $add_only = $form_state['values']['add_only'];
-   $remove   = $form_state['values']['remove'];
-   $replace  = $form_state['values']['replace'];
-   $analysis_id = $form_state['values']['analysis_id'];
-   $type      = trim($form_state['values']['seq_type']);
-   $re_name      = trim($form_state['values']['re_name']);
-   $query_uniquename = $form_state['values']['query_uniquename'];
-
-
-   // check to see if the file is located local to Drupal
-   $dfile = $_SERVER['DOCUMENT_ROOT'] . base_path() . $gaf_file; 
-   if(!file_exists($dfile)){
-      // if not local to Drupal, the file must be someplace else, just use
-      // the full path provided
-      $dfile = $gaf_file;
-   }
-   if(!file_exists($dfile)){
-      form_set_error('gff_file',t("Cannot find the file on the system. Check that the file exists or that the web server has permissions to read the file."));
-   }
-
-   if (($add_only and ($remove or $replace)) or 
-       ($replace and ($add_only or $remove)) or
-       ($remove and ($replace or $add_only))){
-       form_set_error('add_only',t("Please select only one checkbox from the import options section"));
-   }
-
-   // check to make sure the types exists
-   $cvtermsql = "SELECT CVT.cvterm_id
-                 FROM {cvterm} CVT
-                    INNER JOIN {cv} CV on CVT.cv_id = CV.cv_id
-                    LEFT JOIN {cvtermsynonym} CVTS on CVTS.cvterm_id = CVT.cvterm_id
-                 WHERE cv.name = '%s' and (CVT.name = '%s' or CVTS.synonym = '%s')";
-   $cvterm = db_fetch_object(db_query($cvtermsql,'sequence',$type,$type));
-   if(!$cvterm){
-      form_set_error('type',t("The Sequence Ontology (SO) term selected for the sequence type is not available in the database. Please check spelling or select another."));
-   }
-   if($rel_type){
-      $cvterm = db_fetch_object(db_query($cvtermsql,'sequence',$parent_type,$parent_type));
-      if(!$cvterm){
-         form_set_error('parent_type',t("The Sequence Ontology (SO) term selected for the parent relationship is not available in the database. Please check spelling or select another."));
-      }
-   }
-}
-
-/**
- *
- * @ingroup gff3_loader
- */
-function tripal_analysis_go_gaf_load_form_submit ($form, &$form_state){
-   global $user;
-
-   $gaf_file = $form_state['values']['gaf_file'];
-   $organism_id = $form_state['values']['organism_id'];
-   $add_only = $form_state['values']['add_only'];
-   $remove   = $form_state['values']['remove'];
-   $replace  = $form_state['values']['replace'];
-   $analysis_id = $form_state['values']['analysis_id'];
-   $type      = trim($form_state['values']['seq_type']);
-   $re_name      = trim($form_state['values']['re_name']);
-   $query_uniquename = $form_state['values']['query_uniquename'];
-
-   $args = array($gaf_file,$organism_id,$analysis_id,$add_only,$replace,
-      $remove,$re_name,$type,$query_uniquename);
-   if($add_only){
-     $type = 'add GO terms';
-   }
-   if($replace){
-     $type = 'replace and add GO terms';
-   }
-   if($remove){
-     $type = 'remove GO terms';
-   }
-   tripal_add_job("Import GAF 2.0 file $gaf_file and $type",'tripal_analysis_go',
-      'tripal_analysis_go_load_gaf',$args,$user->uid);
-
-   return '';
-}
-
-/**
- *
- *
- * @ingroup gff3_loader
- */
-function tripal_analysis_go_load_gaf($gaf_file, $organism_id,$analysis_id,$add_only =0, 
-   $replace = 0, $remove = 0, $re_name, $type, $query_uniquename,
-   $job = NULL)
-{
-   print "Opening GAF file $gaf_file\n";
-
-    
-   $lines = file($gaf_file,FILE_SKIP_EMPTY_LINES);
-   $i = 0;
-
-   $name = '';
-   $residues = '';
-   $num_lines = sizeof($lines);
-   $interval = intval($num_lines * 0.01);
-   if($interval == 0){
-      $interval = 1;
-   }
-
-   foreach ($lines as $line_num => $line) {
-      $i++;  // update the line count     
-
-      // skip comments
-      if(preg_match('/^\!/',$line)){
-         continue; 
-      }
-
-      // update the job status every 1% features
-      if($job and $i % $interval == 0){
-         tripal_job_set_progress($job,intval(($i/$num_lines)*100));
-      }
-
-      // split the line into it's columns
-      $cols = explode("\t",$line);
-      if(sizeof($cols) < 15){
-         print "ERROR: improper number of columns on line $i\n";
-         print_r($cols);
-         return '';
-      }
-      $db        = $cols[0];
-      $object    = $cols[1];
-      $symbol    = $cols[2];
-      $qualifier = $cols[3];
-      $go_id     = $cols[4];
-      $dbxref    = $cols[5];
-      $ecode     = $cols[6];
-      $with      = $cols[7];
-      $aspect    = $cols[8];
-      $obj_name  = $cols[9];
-      $obj_syn   = $cols[10];
-      $obj_type  = $cols[11];
-      $taxon     = $cols[12];
-      $date      = $cols[13];
-      $assigned  = $cols[14];
-      $exten     = $cols[15];
-      $product   = $cols[16];
-
-      // get the name or uniquename for the feature
-      $name = $object;
-      if($re_name){
-         if(!preg_match("/$re_name/",$object,$matches)){
-            print "Regular expression for the feature name finds nothing\n";
-         } else {
-            $name = trim($matches[1]);
-         }
-      } else {
-         if(preg_match("/^\s*(.*?)[\s\|].*$/",$object,$matches)){
-            $name = trim($matches[1]);
-         }
-      }
-      
-
-      // get the feature
-      $values = array(
-         'type_id' => array(
-            'cv_id' => array(
-               'name' => 'sequence'
-            ),
-            'name' => $type,
-         ),
-         'organism_id' => $organism_id,
-      );
-      if(!$query_uniquename){
-        $values['name'] = $name;
-      } else {
-        $values['uniquename'] = $name;
-      } 
-      $feature = tripal_core_chado_select('feature',array('*'),$values);
-      if(count($feature) == 0){
-         print "WARNING: Cannot find the feature: '$name'\n";         
-      } else {
-         // add the GO term to the feature
-         tripal_analysis_go_load_gaff_go_term($feature[0],$go_id,$remove,$analysis_id);
-      }
-   }
-   return 1;
-}
-/**
-*
-*/
-function tripal_analysis_go_load_gaff_go_term($feature,$dbxref,$remove,$analysis_id){
-
-   // get the database name from the reference.  If it doesn't exist then create one.
-   $ref = explode(":",$dbxref);
-   $dbname = $ref[0];
-   $accession = $ref[1];
-
-   // first look for the database name 
-   $db = tripal_core_chado_select('db',array('db_id'),array('name' => "DB:$dbname"));  
-   if(sizeof($db) == 0){
-      $db = tripal_core_chado_select('db',array('db_id'),array('name' => "$dbname"));      
-   }        
-   if(sizeof($db) == 0){
-      print "ERROR: Database, $dbname is missing for reference: $dbname:$accession\n";
-      return 0;
-   } 
-   $db = $db[0];
-    
-   // now check to see if the accession exists
-   $dbxref = tripal_core_chado_select('dbxref',array('dbxref_id'),array(
-      'accession' => $accession,'db_id' => $db->db_id));
-   if(sizeof($dbxref) == 0){
-      print "ERROR: Accession, $accession is missing for reference: $dbname:$accession\n";
-      return 0;
-   }
-   $dbxref = $dbxref[0];
-
-   // now check to see if the cvterm exists
-   $cvterm = tripal_core_chado_select('cvterm',array('cvterm_id'),array(
-      'dbxref_id' => $dbxref->dbxref_id));
-   // if it doesn't exist in the cvterm table, look for an alternate id
-   if(sizeof($cvterm) == 0){
-      $cvterm = tripal_core_chado_select('cvterm_dbxref',array('cvterm_id'),array(
-         'dbxref_id' => $dbxref->dbxref_id));
-   }
-   if(sizeof($cvterm) == 0){
-      print "ERROR: CVTerm is missing for reference: $dbname:$accession\n";
-      return 0;
-   }
-   $cvterm = $cvterm[0];
-   
-
-   // check to see if this feature cvterm already exists
-   $fcvt = tripal_core_chado_select('feature_cvterm',array('feature_cvterm_id'),
-      array('cvterm_id' => $cvterm->cvterm_id,'feature_id' => $feature->feature_id));
-
-   // now associate this feature with the cvterm if it doesn't already exist
-   if(sizeof($fcvt)==0){
-      $values = array(
-         'feature_id' => $feature->feature_id,
-         'cvterm_id' => $cvterm->cvterm_id,
-         'pub_id' => array(
-            'uniquename' => 'null',
-         ),
-      );
-      $ret = tripal_core_chado_insert('feature_cvterm',$values);
-
-      if($ret){
-         print "   Added ontology term $dbname:$accession to feature $feature->uniquename\n";
-      } else {
-         print "ERROR: failed to insert ontology term '$dbname:$accession' for feature: $feature\n";
-         return 0;
-      }
-   } else {
-      if($remove){
-         $status = tripal_core_chado_delete('feature_cvterm',
-            array('cvterm_id' => $cvterm->cvterm_id,
-                 'feature_id' => $feature->feature_id));
-         if(!$status){
-            print "ERROR: Failed to delete ontology term $dbname:$accession from feature $feature->uniquename\n";
-         } else {
-            print "   Deleted ontology term $dbname:$accession from feature $feature->uniquename\n";
-         }
-      } else {
-         print "   Ontology term already associated to feature $feature->uniquename, skipping $dbname:$accession\n";
-      }
-   }
-
-   if(!$remove){
-      print "   Associating feature $feature->name to analysis\n";
-      // Insert into analysisfeature table only if it doesn't already exist
-      $values = array('feature_id' => $feature->feature_id, 'analysis_id' => $analysis_id);
-      $analysisfeature = tripal_core_chado_select('analysisfeature',array('*'),$values);
-      if(sizeof($analysisfeature) == 0){
-         $analysisfeature = tripal_core_chado_insert('analysisfeature',$values);
-         $analysisfeature_id = $analysisfeature['analysisfeature_id'];
-      } else {
-         $analysisfeature_id = $analysisfeature[0]->analysisfeature_id;
-      }
-
-      // Insert GO terms into analysisfeatureprop table
-      $values = array('analysisfeature_id' => $analysisfeature_id,
-                      'type_id' => $cvterm->cvterm_id,
-                      'rank' => 0);
-      $analysisfeatureprop = tripal_core_chado_select('analysisfeatureprop',array('*'),$values);
-      if(sizeof($analysisfeatureprop) == 0){
-         $values['value'] = $matches[1];
-         $analysisfeatureprop = tripal_core_chado_insert('analysisfeatureprop',$values);
-      }
-   }
-   return 1;
-}
-/**
-*
-*/
-function tripal_analysis_go_load_gaff_insert_analysisfeatureprop ($feature_id, $analysis_id,
-   $brite_id,$keggterm)
-{
-
-   // add the analysisfeature record if it doesn't already exist.
-   $values = array('feature_id' => $feature_id,'analysis_id' => $analysis_id);
-   $analysisfeature_arr = tripal_core_chado_select('analysisfeature',
-      array('analysisfeature_id'),$values);
-   if(count($analysisfeature_arr) == 0){
-      tripal_core_chado_insert('analysisfeature',$values);
-      $analysisfeature_arr = tripal_core_chado_select('analysisfeature',
-         array('analysisfeature_id'),$values);
-   }
-   $analysisfeature_id = $analysisfeature_arr[0]->analysisfeature_id;            
-   // Insert into analysisfeatureprop if the value doesn't already exist
-   // KEGG heir results sometimes have the same record more than once.
-   if($analysisfeature_id){
-      // Get the highest rank for this feature_id in analysisfeatureprop table
-      $sql = "SELECT rank FROM analysisfeatureprop WHERE analysisfeature_id = %d and type_id = %d ORDER BY rank DESC";
-      $previous_db = tripal_db_set_active('chado');
-      $result = db_fetch_object(db_query($sql,$analysisfeature_id,$brite_id));
-      tripal_db_set_active($previous);
-      $rank = 0;
-      if ($result and $result->rank > 0) {
-         $rank = $result->rank + 1;
-      }
-
-      $values = array(
-         'analysisfeature_id' => $analysisfeature_id, 
-         'type_id' => $brite_id,
-         'value' => $keggterm,
-         'rank' => $rank,
-      );
-
-      return tripal_core_chado_insert('analysisfeatureprop',$values);
-   }
-   else {
-      return 0;
-   }
-}

+ 0 - 17
extensions/tripal_analysis_go/theme/css/tripal_analysis_go.css

@@ -1,17 +0,0 @@
-
-.tripal_go-info-box, .tripal_go_summary-info-box {
-   margin-top: 10px;
-   margin-left: 0px;
-   margin-right: 0px;
-   margin-bottom: 0px;
-   padding-top: 0px;
-   padding-left: 0px;
-   padding-bottom: 0px;
-   padding-right: 0px;
-   border-collapse: collapse;
-   z-index: 10;
-}
-
-.tripal_go_summary-info-box .tripal_cv_tree {
-   border-collapse: separate;
-}

+ 0 - 52
extensions/tripal_analysis_go/theme/js/tripal_analysis_go.js

@@ -1,52 +0,0 @@
-
-
-if (Drupal.jsEnabled) {
-
-
-   $(document).ready(function() {
-       // Select default GO analysis when available
-       var selectbox = $('#edit-tripal-analysis-go-select');
-       if(selectbox.length > 0){ 
-    	   var option = document.getElementById("analysis_id_for_go_report");
-    	   if (option) {
-    		   var options = document.getElementsByTagName('option');
-    		   var index = 0;
-    		   for (index = 0; index < options.length; index ++) {
-    			   if (options[index].value == option.value) {
-    				   break;
-    			   }
-    		   }
-    		   selectbox[0].selectedIndex = index;
-    		   tripal_analysis_go_org_charts(option.value);
-    	// Otherwise, show the first option by default
-    	   } else {
-    		   selectbox[0].selectedIndex = 1;
-    		   tripal_analysis_go_org_charts(selectbox.val());
-    	   }
-       }
-   });
-
-
-   function tripal_analysis_go_org_charts(item){
-      if(!item){
-         $("#tripal_analysis_go_org_charts").html('');
-         return false;
-      }
-      // Form the link for the following ajax call 
-      baseurl = tripal_get_base_url();      
-      var link = baseurl + '?q=tripal_analysis_go_org_charts/' + item;
-      tripal_startAjax();
-      $.ajax({
-           url: link,
-           dataType: 'json',
-           type: 'POST',
-           success: function(data){
-             $("#tripal_analysis_go_org_charts").html(data[0]);
-             tripal_cv_init_chart();
-             tripal_cv_init_tree();
-             tripal_stopAjax();
-           }
-      });
-      return false;
-   }
-}

+ 0 - 35
extensions/tripal_analysis_go/theme/tripal_feature/tripal_feature_go_terms.tpl.php

@@ -1,35 +0,0 @@
-<?php
-$feature = $variables['node']->feature;
-$terms = $feature->tripal_analysis_go->terms;
-?>
-<div id="tripal_feature-go_terms-box" class="tripal_feature-info-box tripal-info-box">
-  <div class="tripal_feature-info-box-title tripal-info-box-title">GO Assignments</div>
-  <div class="tripal_feature-info-box-desc tripal-info-box-desc">This <?php print $feature->type_id->name ?> is annotated with the following GO terms.</div>
-  <?php if(count($terms) > 0){ ?>
-  <table id="tripal_feature-go_terms-table" class="tripal_feature-table tripal-table tripal-table-horz">
-    <tr>
-      <th>Category</th>
-      <th>Term Accession</th>
-      <th>Term Name</th>
-    </tr>
-    <?php
-    $i = 0; 
-    foreach ($terms as $term){
-      $class = 'tripal_feature-table-odd-row tripal-table-odd-row';
-      if($i % 2 == 0 ){
-         $class = 'tripal_feature-table-odd-row tripal-table-even-row';
-      }
-      ?>
-      <tr class="<?php print $class ?>">
-        <td><?php print $term->cvname ?></td>
-        <td>GO:<?php print $term->accession?></td>
-        <td><span title="<?php print $term->definition ?>"><?php print $term->goterm ?></span></td>
-      </tr>
-      <?php
-      $i++;  
-    } ?>
-  </table>
-  <?php } else { ?>
-    <div class="tripal-no-results">There are no GO terms for this feature</div> 
-  <?php }?>
-</div>

+ 0 - 35
extensions/tripal_analysis_go/theme/tripal_organism/tripal_organism_go_summary.tpl.php

@@ -1,35 +0,0 @@
-<?php
-  $organism = $node->organism;
-  $form = $organism->tripal_analysis_go->select_form['form'];
-  $has_results = $organism->tripal_analysis_go->select_form['has_results'];
-?>
-<div id="tripal_organism-go_summary-box" class="tripal_organism-info-box tripal-info-box">
-  <div  class="tripal_organism-info-box-title tripal-info-box-title">GO Analysis Reports</div>
-  <?php 
-     if($has_results){
-        print $form;
-     } else {
-       ?><div class="tripal-no-results">
-           There are no GO reports available
-           <?php if(user_access('access administration pages')){ ?>
-              <p><br>Administrators, to view a GO report you must:
-              <ul>
-                 <li>load GO assignments and associate them to features and a corresponding analysis</li>
-                 <li>Set the <a href="<?php print url('admin/tripal/tripal_cv/cvtermpath');?>">cvtermpath</a> for the 'biological process', 'molecular_function' and 'cellular_component' vocabularies.</li>
-                 <li>Populate the <a href="<?php print url('admin/tripal/tripal_mviews');?>">go_count_analysis</a> materialized view</li>
-              </ul> </p>
-           <?php }?>
-         </div><?php
-     }
-  ?>
-  <div id="tripal_analysis_go_org_charts"></div>    
-  <div id="tripal_cv_cvterm_info_box">
-      <a href="#" onclick="$('#tripal_cv_cvterm_info_box').hide()" style="float: right">Close [X]</a>
-      <div>Term Information</div>
-      <div id="tripal_cv_cvterm_info"></div>
-   </div>
-   <div id="tripal_ajaxLoading" style="display:none">
-     <div id="loadingText">Loading...</div>
-   </div>
-</div>
-

+ 0 - 10
extensions/tripal_analysis_go/tripal_analysis_go.info

@@ -1,10 +0,0 @@
-; $Id: tripal_analysis_go.info,v 1.2 2009/10/23 02:12:16 ccheng Exp $
-name = Tripal GO
-description = An analysis sub-module for displaying GO analysis and GO assignments to features.
-core = 6.x
-project = tripal_analysis_go
-package = Tripal Extensions
-dependencies[] = tripal_core
-dependencies[] = tripal_feature
-dependencies[] = tripal_analysis
-dependencies[] = tripal_organism

+ 0 - 133
extensions/tripal_analysis_go/tripal_analysis_go.install

@@ -1,133 +0,0 @@
-<?php
-
-/*******************************************************************************
-*  Implementation of hook_install();
-*/
-function tripal_analysis_go_install(){
-  
-   tripal_analysis_register_child('tripal_analysis_go');
-   
-   // The following view will create counts of features that are assigned
-   // either directly or by ancestry each GO term. The count is organized by
-   // organisms.
-   $previous_db = tripal_db_set_active('chado');
-   if (db_table_exists('go_count_organism')) {
-      $sql = "DROP TABLE go_count_organism";
-      db_query($sql);
-   }
-   if (db_table_exists('go_count_analysis')) {
-      $sql = "DROP TABLE go_count_analysis";
-      db_query($sql);
-   }
-   tripal_db_set_active($previous_db);
-   
-   tripal_add_mview(
-      // view name
-      'go_count_organism',
-      // tripal module name
-      'tripal_analysis_go',
-      // table name
-      'go_count_organism',
-      // table schema definition
-      'cvname character varying(255),
-       cvterm_id integer,
-       organism_id integer,
-       feature_count integer',
-      // columns for indexing
-      'cvterm_id,organism_id',
-      // SQL statement to populate the view
-      "SELECT T1.cvname, T1.object_id, T1.organism_id, count(T1.feature_id)
-       FROM
-         (SELECT DISTINCT CVT3.name as cvname, CVTP.object_id, 
-            O.organism_id, F.feature_id
-          FROM {cvtermpath} CVTP
-            INNER JOIN CVTerm CVT          ON CVTP.subject_id = CVT.cvterm_id
-            INNER JOIN CVTerm CVT2         ON CVTP.type_id = CVT2.cvterm_id
-            INNER JOIN CVTerm CVT3         ON CVTP.object_id = CVT3.cvterm_id
-            INNER JOIN Feature_cvterm FCVT ON FCVT.cvterm_id = CVT.cvterm_id
-            INNER JOIN Feature F           ON FCVT.feature_id = F.feature_id
-            INNER JOIN CV                  ON CV.cv_id = CVT.cv_id
-            INNER JOIN Organism O          ON O.organism_id = F.organism_id
-          WHERE (CV.name = 'biological_process' or 
-                 CV.name = 'molecular_function' or 
-                 CV.name = 'cellular_component')
-         ) as T1
-       GROUP BY T1.cvname,T1.object_id,T1.organism_id",
-      // special index
-      ''
-   );
-
-   // The following view will create counts of features that are assigned
-   // either directly or by ancestry each GO term. The count is organized by
-   // tripal_go_analysis analyses.
-   tripal_add_mview(
-      // view name
-      'go_count_analysis',
-      // tripal module name
-      'tripal_analysis_go',
-      // table name
-      'go_count_analysis',
-      // table schema definition
-      'cvname character varying(255),
-       cvterm_id integer,
-       analysis_id integer,
-       organism_id integer,
-       feature_count integer',
-      // columns for indexing
-      'cvterm_id,analysis_id,organism_id',
-      // SQL statement to populate the view
-      "SELECT T1.cvname,T1.cvterm_id,T1.analysis_id,T1.organism_id,count(*) as feature_count 
-       FROM
-        (SELECT DISTINCT AF.analysis_id, AF.feature_id,CVT.name as cvname,
-           CVT.cvterm_id,CVTP.object_id,CV.name, F.organism_id 
-         FROM {analysisfeatureprop} AFP
-           INNER JOIN analysisfeature AF ON AF.analysisfeature_id = AFP.analysisfeature_id
-           INNER JOIN feature F          ON AF.feature_id = F.feature_id
-           INNER JOIN cvtermpath CVTP    ON CVTP.subject_id = AFP.type_id
-           INNER JOIN cvterm CVT         ON CVTP.object_id = CVT.cvterm_id
-           INNER JOIN CV                 ON CV.cv_id = CVT.cv_id
-
-         WHERE  
-           (CV.name = 'biological_process' or 
-            CV.name = 'molecular_function' or 
-            CV.name = 'cellular_component')) as T1
-       GROUP BY T1.cvname,T1.cvterm_id,T1.analysis_id,T1.organism_id",
-      // special index
-      ''
-   );
-}
-
-/*******************************************************************************
-* Implementation of hook_uninstall()
-*/
-function tripal_analysis_go_uninstall(){
-
-   $mview = tripal_mviews_get_mview_id('go_count_organism');
-   if($mview){
-      tripal_mviews_action('delete',$mview);
-   }
-   $mview = tripal_mviews_get_mview_id('go_count_analysis');
-   if($mview){
-      tripal_mviews_action('delete',$mview);
-   }
-   tripal_analysis_unregister_child('tripal_analysis_go');
-
-}
-
-/*******************************************************************************
- * Implementation of hook_requirements(). Make sure 'Tripal Core' and 'Tripal
- * Analysis' are enabled before installation
- */
-function tripal_analysis_go_requirements($phase) {
-   $requirements = array();
-   if ($phase == 'install') {
-      if (!function_exists('tripal_create_moddir') || !function_exists('tripal_analysis_register_child')) {
-         $requirements ['tripal_analysis_go'] = array(
-            'title' => "tripal_analysis_go",
-            'value' => "error. Some required modules are just being installed. Please try again.",
-            'severity' => REQUIREMENT_ERROR,
-         );
-      }
-   }
-   return $requirements;
-}

+ 0 - 608
extensions/tripal_analysis_go/tripal_analysis_go.module

@@ -1,608 +0,0 @@
-<?php
-
-require_once "includes/gaf_loader.inc";
-
-function tripal_analysis_go_init(){
-   // Add style sheet
-   drupal_add_css(drupal_get_path('module', 'tripal_analysis_go').'/theme/css/tripal_analysis_go.css', 'theme');
-
-   drupal_add_js(drupal_get_path('module', 'tripal_analysis_go').'/theme/js/tripal_analysis_go.js');
-}
-
-/*******************************************************************************
- * Menu items are automatically added for the new node types created
- * by this module to the 'Create Content' Navigation menu item.  This function
- * adds more menu items needed for this module.
- */
-function tripal_analysis_go_menu() {
-   $items = array();
-
-   $items['download_goterm_features'] = array(
-      'path' => 'download_goterm_features',
-      'title' => t('Get GO Term Features'),
-      'page callback' => 'tripal_analysis_go_get_goterm_features',
-      'page arguments' => array(1,2),
-      'access arguments' => array('access chado_analysis_go content'),
-      'type' => MENU_CALLBACK
-   );
-   $items['tripal_analysis_go_org_charts'] = array(
-      'path' => 'tripal_analysis_go_org_charts',
-      'title' => t('Analysis GO Charts'),
-      'page callback' => 'tripal_analysis_go_org_charts',
-      'page arguments' => array(1),
-      'access arguments' => array('access chado_analysis_go content'),
-      'type' => MENU_CALLBACK
-   );
-   $items['admin/tripal/tripal_analysis_go'] = array(
-     'title' => 'Gene Ontology',
-     'description' => 'Administrative tools for managing Gene Ontology data.',
-     'page callback' => 'tripal_analysis_go_module_description_page',
-     'access arguments' => array('administer site configuration'),
-     'type' => MENU_NORMAL_ITEM,
-   );
-   $items['admin/tripal/tripal_analysis_go/gaf_load'] = array(
-     'title' => t('Import GO terms with GAF file'),
-     'description' => t("Import GO terms into Chado using the Gene Ontology's GAF 2.0 file format"),
-     'page callback' => 'drupal_get_form',
-     'page arguments' => array('tripal_analysis_go_gaf_load_form'),
-     'access arguments' => array('access administration pages'),
-     'type' => MENU_NORMAL_ITEM,
-   );
-
-   return $items;
-}
-/*************************************************************************
- * Purpose: Provide Guidance to new Tripal Admin
- *
- * @return HTML Formatted text
- */
-function tripal_analysis_go_module_description_page() {
-  $text = '';
-  
-  $text .= '<h3>Description:</h3>';
-  $text .= '<p>TODO: Basic Description of this module including mention/link to the chado module</p>';
-
-  $text .= '<h3>Post Installation Instructions:</h3>';
-  $text .= '<p>TODO: Describe any post installation intructions here. You shouldalways include setting user permissions.</p>';
-  
-  
-  $text .= '<h3>Features of this Module:</h3>';
-  $text .= '<p>TODO: Discuss the Features of this module including links. Some features to consider are creating content, details pages/node content, editing/deleteing, basic listings and vies integration. See admin/tripal/tripal_stock for an example.</p>';
-  
-  return $text;
-}
-/*******************************************************************************
- * Set the permission types that the chado module uses.  Essentially we
- * want permissionis that protect creation, editing and deleting of chado
- * data objects
- */
-function tripal_analysis_go_perm(){
-   return array(
-      'access chado_analysis_go content',
-      'create chado_analysis_go content',
-      'delete chado_analysis_go content',
-      'edit chado_analysis_go content',
-   );
-}
-/*******************************************************************************
- *  The following function proves access control for users trying to
- *  perform actions on data managed by this module
- */
-function chado_analysis_go_access($op, $node, $account){
-   if ($op == 'create') {
-      if(!user_access('create chado_analysis_go content', $account)){
-         return FALSE;
-      }
-   }
-   if ($op == 'update') {
-      if (!user_access('edit chado_analysis_go content', $account)) {
-         return FALSE;
-      }
-   }
-   if ($op == 'delete') {
-      if (!user_access('delete chado_analysis_go content', $account)) {
-         return FALSE;
-      }
-   }
-   if ($op == 'view') {
-      if (!user_access('access chado_analysis_go content', $account)) {
-         return FALSE;
-      }
-   }
-   return NULL;
-}
-/*******************************************************************************
- *
- */
-function tripal_analysis_go_block($op = 'list', $delta = 0, $edit=array()){
-   switch($op) {
-      case 'list':
-         $blocks['tago_org_sum']['info'] = t('Tripal Organism GO Analysis Report');
-         $blocks['tago_org_sum']['cache'] = BLOCK_NO_CACHE;
-
-         $blocks['featurego']['info'] = t('Tripal Feature GO Terms');
-         $blocks['featurego']['cache'] = BLOCK_NO_CACHE;
-
-         return $blocks;
-
-
-      case 'view':
-         if(user_access('access chado_analysis_go content') and arg(0) == 'node' and is_numeric(arg(1))) {
-            $nid = arg(1);
-            $node = node_load($nid);
- 
-            $block = array();
-            switch($delta){
-                 case 'tago_org_sum':
-                  $block['subject'] = t('GO Summary');
-                  $block['content'] = theme('tripal_organism_go_summary',$node);
-                  break;
-               case 'featurego':
-                  $block['subject'] = t('GO Terms');
-                  $block['content'] = theme('tripal_feature_go_terms',$node);
-                  break;
-               default :
-            }
-            return $block;
-         }
-
-   }
-}
-/*******************************************************************************
- * HOOK: Implementation of hook_nodeapi()
- * Display library information for associated features or organisms
- * This function also provides contents for indexing
- */
-function tripal_analysis_go_nodeapi(&$node, $op, $teaser, $page) {
-
-   switch ($op) {
-      case 'view':
-     
-         if ($teaser) {
-            return;
-         }
-         // add the library to the organism/feature search indexing
-         if($node->build_mode == NODE_BUILD_SEARCH_INDEX){
-            $node->content['tripal_analysis_go_search_index'] = array(
-					'#value' => theme('tripal_analysis_go_search_index',$node),
-					'#weight' => 5,
-            );
-         } else if ($node->build_mode == NODE_BUILD_SEARCH_RESULT) {
-            $node->content['tripal_analysis_go_search_result'] = array(
-					'#value' => theme('tripal_analysis_go_search_result',$node),
-					'#weight' => 5,
-            );
-         } else {
-            // Show go terms if the organism/feature is not at teaser view
-            switch($node->type){
-               case 'chado_organism':    
-                  $node->content['tripal_organism_go_summary'] = array(
-   				      '#value' => theme('tripal_organism_go_summary',$node),
-		      			'#weight' => 5,
-                  );
-                  break;
-               case 'chado_feature':
-                  $node->content['tripal_feature_go_terms'] = array(
-				         '#value' => theme('tripal_feature_go_terms',$node),
-      					'#weight' => 5,
-                  );
-                  break;
-            }
-         }
-         break;
-   }
-}
-
-/************************************************************************
- *  We need to let drupal know about our theme functions and their arguments.
- *  We create theme functions to allow users of the module to customize the
- *  look and feel of the output generated in this module
- */
-function tripal_analysis_go_theme () {
-	$path = drupal_get_path('module', 'tripal_analysis_go') . '/theme';
-   return array(
-      'tripal_analysis_go_search_index' => array (
-         'arguments' => array('node'),
-      ),
-      'tripal_analysis_go_search_result' => array (
-         'arguments' => array('node'),
-      ),
-      'tripal_organism_go_summary' => array (
-         'arguments' => array('node'=> null),
-         'template' => 'tripal_organism_go_summary',
-         'path' => $path . '/tripal_organism',
-      ),
-      'tripal_feature_go_terms' => array (
-         'arguments' => array('node'=> null),
-         'template' => 'tripal_feature_go_terms',
-         'path' => $path . '/tripal_feature',
-      )
-   );
-}
-/************************************************************************
-*/
-function theme_tripal_analysis_go_search_index($node){
-
-}
-
-/************************************************************************
-*/
-function theme_tripal_analysis_go_search_result($node){
-
-}
-/************************************************************************
-*/
-function tripal_analysis_go_preprocess_tripal_feature_go_terms(&$variables){
-   $feature = $variables['node']->feature;
-   $feature->tripal_analysis_go->terms = tripal_analysis_go_load_feature_terms($feature);
-}
-/************************************************************************
-*/
-function tripal_analysis_go_preprocess_tripal_organism_go_summary(&$variables){
-   $node = $variables['node'];
-   $organism = $node->organism;
-   $organism->tripal_analysis_go->select_form = tripal_analysis_go_load_organism_go_summary($node);
-}
-/************************************************************************
-*/
-function tripal_analysis_go_select_form(&$form_state = NULL,$node){
-
-   $form = array();
-   // find analyses that have GO terms
-   $sql = "
-     SELECT DISTINCT A.analysis_id, A.name, GCA.organism_id
-     FROM {go_count_analysis} GCA
-       INNER JOIN Analysis A on GCA.analysis_id = A.analysis_id
-     WHERE organism_id = %d
-     ORDER BY analysis_id DESC
-   ";
-   $previous_db = tripal_db_set_active('chado');
-   $results = db_query($sql,$node->organism->organism_id);
-   tripal_db_set_active($previous_db);
-
-   $analyses = array();
-   $analyses[''] = '';
-   while($analysis = db_fetch_object($results)){
-      # check to see if the user has permission to see this analysis
-      $anode = tripal_analysis_get_node($analysis->analysis_id);
-      if(node_access("view",$anode)){
-         $analyses[$analysis->analysis_id."-".$analysis->organism_id] = "$analysis->name";
-      }
-   }
-  
-   # create the select box
-   $form['tripal_analysis_go_select'] = array(
-      '#title' => t('Select a GO report to view'),
-      '#description' => t('Any analysis with GO results related to this organism are available for viewing. For further information, see the analysis information page.'),
-      '#type'  => 'select',
-      '#options' => $analyses,
-      '#attributes' => array (
-         'onchange' => 'tripal_analysis_go_org_charts(this.options[this.selectedIndex].value)'
-      ),
-   );
-   return $form;
-}
-/************************************************************************
-*/
-function tripal_analysis_go_org_charts ($element) {
-   $analysis_id = preg_replace("/^(\d+)-(\d+)$/","$1",$element);
-   $organism_id = preg_replace("/^(\d+)-(\d+)$/","$2",$element);
-   $content = '';
-
-   if($analysis_id and $organism_id){
-      $content = "
-
-        <b>Biological Process</b>
-        <br><i>Expand the tree to browse term counts. Click a term to view term details.</i>
-        <div class=\"tripal_cv_tree\"  id=\"tripal_analysis_go_cv_tree_".$organism_id."-".$analysis_id."_bp\"></div>
-	<br><br><img class=\"tripal_cv_chart\" id=\"tripal_analysis_go_cv_chart_".$organism_id."-".$analysis_id."_bp\" src=\"\" border=\"0\">	   
-	<br><br><br><br>
-
-        <b>Cellular Component</b>
-        <br><i>Expand the tree to browse term counts. Click a term to view term details.</i>
-        <div class=\"tripal_cv_tree\"  id=\"tripal_analysis_go_cv_tree_".$organism_id."-".$analysis_id."_cc\"></div>
-        <br><br><img class=\"tripal_cv_chart\" id=\"tripal_analysis_go_cv_chart_".$organism_id."-".$analysis_id."_cc\" src=\"\" border=\"0\">
-
-        <br><br><br><br>
-        <b>Molecular Function</b>       
-        <br><i>Expand the tree to browse term counts. Click a term to view term details.</i>
-        <div class=\"tripal_cv_tree\"  id=\"tripal_analysis_go_cv_tree_".$organism_id."-".$analysis_id."_mf\"></div>      
-        <br><br><img class=\"tripal_cv_chart\" id=\"tripal_analysis_go_cv_chart_".$organism_id."-".$analysis_id."_mf\" src=\"\" border=\"0\">
-      ";
-   }
-   $opt = array($content);
-   return drupal_json($opt);
-}
-/************************************************************************
-*/
-function tripal_analysis_go_load_organism_go_summary($node) {
-  $organism = $node->organism;
-	
-   // check to see if we have any analyses
-   $sql = "
-     SELECT A.analysis_id
-     FROM {go_count_analysis} GCA
-       INNER JOIN Analysis A on GCA.analysis_id = A.analysis_id
-     WHERE organism_id = %d
-   ";
-   $previous_db = tripal_db_set_active('chado');
-   $results = db_query($sql,$organism->organism_id);
-   tripal_db_set_active($previous_db);
-
-   # check to ensure we have access to at least one of the GO analyses
-   $has_results = 0;
-   while($analysis = db_fetch_object($results)){
-      $anode = tripal_analysis_get_node($analysis->analysis_id);
-      if(node_access("view",$anode)){
-         $has_results = 1;
-      }
-   }
-   return array (
-      'has_results' => $has_results,
-      'form' => drupal_get_form('tripal_analysis_go_select_form',$node),
-   );
-}
-/************************************************************************
- *
- */
-function tripal_analysis_go_cv_chart($chart_id){
-
-  // The CV module will create the JSON array necessary for buillding a
-  // pie chart using jgChart and Google Charts.  We have to pass to it
-  // a table that contains count information, tell it which column 
-  // contains the cvterm_id and provide a filter for getting the
-  // results we want from the table.
-  $organism_id = preg_replace("/^tripal_analysis_go_cv_chart_(\d+)-(\d+)_(bp|cc|mf)$/","$1",$chart_id);
-  $analysis_id = preg_replace("/^tripal_analysis_go_cv_chart_(\d+)-(\d+)_(bp|cc|mf)$/","$2",$chart_id);
-  $type        = preg_replace("/^tripal_analysis_go_cv_chart_(\d+)-(\d+)_(bp|cc|mf)$/","$3",$chart_id);
-
-  $sql = "SELECT * FROM {Analysis} WHERE analysis_id = %d";
-  $previous_db = tripal_db_set_active('chado');  // use chado database
-  $analysis = db_fetch_object(db_query($sql,$analysis_id));
-  tripal_db_set_active($previous_db);  // now use drupal database  
- 
-  if(strcmp($type,'mf')==0){
-     $class = 'molecular_function';
-     $title = "Number of Molecular Function Terms From $analysis->name Analysis";
-  }
-  if(strcmp($type,'cc')==0){
-     $class = 'cellular_component';
-     $title = "Number of Cellular Component Terms From $analysis->name Analysis";
-  }
-  if(strcmp($type,'bp')==0){
-     $class = 'biological_process';
-     $title = "Number of Biological Process Terms From $analysis->name Analysis";
-  }
-  $options = array(
-     count_mview      => 'go_count_analysis',
-     cvterm_id_column => 'cvterm_id',
-     count_column     => 'feature_count',
-     filter           => "
-        CNT.organism_id = $organism_id AND 
-        CNT.analysis_id = $analysis_id AND 
-        CNT.cvterm_id IN ( 
-          SELECT CVTR.subject_id 
-          FROM {CVTerm_relationship} CVTR 
-            INNER JOIN CVTerm CVT on CVTR.object_id = CVT.cvterm_id
-            INNER JOIN CV on CVT.cv_id = CV.cv_id
-          WHERE CVT.name = '$class' AND  
-                 CV.name = '$class'
-        )
-     ",
-     type             => 'p',
-     size             => '650x260',
-     title            => $title,
-  );
-  return $options;
-}
-/************************************************************************
- *
- */
-function tripal_analysis_go_cv_tree($tree_id){
-
-  $organism_id = preg_replace("/^tripal_analysis_go_cv_tree_(\d+)-(\d+)_(bp|cc|mf)$/","$1",$tree_id);
-  $analysis_id = preg_replace("/^tripal_analysis_go_cv_tree_(\d+)-(\d+)_(bp|cc|mf)$/","$2",$tree_id);
-  $type        = preg_replace("/^tripal_analysis_go_cv_tree_(\d+)-(\d+)_(bp|cc|mf)$/","$3",$tree_id);
-
-  if(strcmp($type,'mf')==0){
-     $class = 'molecular_function';
-  }
-  if(strcmp($type,'cc')==0){
-     $class = 'cellular_component';
-  }
-  if(strcmp($type,'bp')==0){
-     $class = 'biological_process';
-  }
-
-  $options = array(
-     cv_id            => tripal_cv_get_cv_id($class),
-     count_mview      => 'go_count_analysis',
-     cvterm_id_column => 'cvterm_id',
-     count_column     => 'feature_count',
-     filter           => "CNT.organism_id = $organism_id AND CNT.analysis_id = $analysis_id",
-     label            => 'Features',
-  );
-  return $options;
-}
-/************************************************************************
-*/
-function tripal_analysis_go_cvterm_add($cvterm_id,$tree_id){
-  $organism_id = preg_replace("/^tripal_analysis_go_cv_tree_(\d+)-(\d+)_(bp|cc|mf)$/","$1",$tree_id);
-  $analysis_id = preg_replace("/^tripal_analysis_go_cv_tree_(\d+)-(\d+)_(bp|cc|mf)$/","$2",$tree_id);
-
-  $sql = "
-     SELECT DBX.accession
-     FROM {cvterm} CVT
-       INNER JOIN dbxref DBX on DBX.dbxref_id = CVT.dbxref_id
-     WHERE cvterm_id = %d
-  ";
-  $previous_db = tripal_db_set_active('chado');
-  $xref = db_fetch_object(db_query($sql,$cvterm_id));
-  tripal_db_set_active($previous_db);
-
-  $link = url("download_goterm_features/$cvterm_id/$tree_id");
-  $options = array(
-     'Download sequences' => "<a href=\"$link\">GO_".$xref->accession.".fasta</a>",
-  );
-  return $options;
-}
-/************************************************************************
-*/
-function tripal_analysis_go_get_goterm_features($cvterm_id,$tree_id){
-
-   // get hte accession number for this cvterm and use it in naming the download
-   $sql = "
-      SELECT DBX.accession
-      FROM {cvterm} CVT
-        INNER JOIN dbxref DBX on DBX.dbxref_id = CVT.dbxref_id
-      WHERE cvterm_id = %d
-   ";
-   $previous_db = tripal_db_set_active('chado');
-   $xref = db_fetch_object(db_query($sql,$cvterm_id));
-   tripal_db_set_active($previous_db);
-
-   drupal_set_header('Content-Type: text');
-   drupal_set_header('Content-Disposition: attachment; filename="GO_'.$xref->accession.'.fasta"');
-
-   $organism_id = preg_replace("/^tripal_analysis_go_cv_tree_(\d+)-(\d+)_(bp|cc|mf)$/","$1",$tree_id);
-   $analysis_id = preg_replace("/^tripal_analysis_go_cv_tree_(\d+)-(\d+)_(bp|cc|mf)$/","$2",$tree_id);
-   $sql = "
-      SELECT DISTINCT F.name,F.residues,F.feature_id
-      FROM {cvtermpath} CVTP
-         INNER JOIN CVTerm CVT1 on CVTP.subject_id = CVT1.cvterm_id
-         INNER JOIN CVTerm CVT2 on CVTP.object_id = CVT2.cvterm_id
-         INNER JOIN AnalysisFeatureProp AFP on AFP.type_id = CVTP.subject_id 
-         INNER JOIN AnalysisFeature AF on AF.analysisfeature_id = AFP.analysisfeature_id
-         INNER JOIN Feature F on AF.feature_id = F.feature_id
-      WHERE CVTP.object_id = %d and F.organism_id = %d and AF.analysis_id = %d
-      ORDER BY F.name
-   ";
-   $previous_db = tripal_db_set_active('chado');
-   $results = db_query($sql,$cvterm_id,$organism_id,$analysis_id);
-   tripal_db_set_active($previous_db);
-   while($feature = db_fetch_object($results)){
-      // get the go term information for each sequence
-      $sql = "
-         SELECT CVT.name,DBX.accession 
-         FROM {Feature_CVTerm} FCVT 
-           INNER JOIN CVTerm CVT on FCVT.cvterm_id = CVT.cvterm_id
-           INNER JOIN DBXref DBX on CVT.dbxref_id = DBX.dbxref_id
-         WHERE FCVT.feature_id = %d
-      ";
-
-      $previous_db = tripal_db_set_active('chado');
-      $terms = db_query($sql,$feature->feature_id);
-      tripal_db_set_active($previous_db);
-      $desc = '[';
-      while($term = db_fetch_object($terms)){
-         $desc .= "GO:$term->accession $term->name; ";
-      }
-      $desc = chop($desc);
-      $desc = chop($desc,';');
-      $desc .= ']';
-      print tripal_feature_return_fasta($feature, $desc);   
-   }
-   return;
-}
-/************************************************************************
-*/
-function tripal_analysis_go_load_feature_terms($feature) {
-   $sql = "
-       SELECT DISTINCT FCVT.feature_id,DBX.accession,CVT.name as goterm, 
-          CVT.cvterm_id as go_id, CV.name as cvname, CVT.definition
-       FROM {Feature_Cvterm} FCVT  
-          INNER JOIN Cvterm CVT           ON CVT.cvterm_ID = FCVT.cvterm_ID
-          INNER JOIN CV                   ON CV.cv_id = CVT.cv_id  
-          INNER JOIN dbxref DBX           ON DBX.dbxref_id = CVT.dbxref_id
-        WHERE      
-          (CV.name = 'biological_process' OR 
-           CV.name = 'cellular_component' OR 
-           CV.name = 'molecular_function') AND 
-          FCVT.feature_id = %d
-        ORDER BY CV.name, CVT.name
-   ";
-
-   $previous_db = tripal_db_set_active('chado');
-   $results = db_query($sql,$feature->feature_id);
-   tripal_db_set_active($previous_db);
-   $i=0;
-   $terms = array();
-   while($term = db_fetch_object($results)){
-
-      $terms[$i++] = $term;
-   }
-   return $terms;
-}
-
-/*******************************************************************************
- * Tripal GO administrative setting form. This function is called by
- * tripal_analysis module which asks for an admin form to show on the page
- */
-function tripal_analysis_go_get_settings() {
-   // Get an array of node types with internal names as keys
-   $options = node_get_types('names');
-   // Add 'chado_feature' to allowed content types for showing unigene results
-   $allowedoptions ['chado_feature'] = "Show GO terms on feature pages";
-   $allowedoptions ['chado_organism'] = "Show GO analysis on organism pages";
-
-   $form['description'] = array(
-       '#type' => 'item',
-       '#value' => t("This option allows user to display the Gene Ontology (GO) ".
-          "information. For features, this would include all GO terms assigned to a feature ".
-          "and for organisms this would be statistical pie charts of GO terms for a organism. Check the box to ".
-          "enable the display of GO information. Uncheck to disable."),
-       '#weight' => 0,
-   );
-
-   $form['tripal_analysis_go_setting'] = array(
-      '#type' => 'checkboxes',
-      '#options' => $allowedoptions,
-      '#default_value'=>variable_get('tripal_analysis_go_setting',array('chado_feature', 'chado_organism')),
-   );
-   $settings->form = $form;
-   $settings->title = "Tripal GO";
-   return $settings;
-}
-/**
- *
- *
- * @ingroup tripal_feature
- */
-function tripal_analysis_go_job_describe_args($callback,$args){
-
-   $new_args = array();
-   if($callback == 'tripal_analysis_go_load_gaf'){
-      
-      $new_args['GAF 2.0 file'] = $args[0];
-
-      $organism = tripal_core_chado_select('organism',array('genus','species'),array('organism_id' => $args[1]));
-      $new_args['Organism'] = $organism[0]->genus." ". $organism[0]->species;
-      $new_args['Sequence Type'] = $args[7];
-      if(!$args[8]){
-        $new_args['Use Unique Name'] = 'No';
-      } else {
-        $new_args['Use Unique Name'] = 'Yes';
-      }
-
-      // add in the analysis 
-      if($args[2]){
-         $analysis = tripal_core_chado_select('analysis',array('name'),array('analysis_id' => $args[2]));
-      }
-      $new_args['Analysis'] = $analysis[0]->name;
-
-      if($args[3]){
-        $new_args['Function to perform'] = 'Add GO terms';
-      }
-      if($args[4]){
-        $new_args['Function to perform'] = 'Replace GO terms';
-      }
-      if($args[5]){
-        $new_args['Function to perform'] = 'Delete GO terms';
-      }
-
-      $new_args['Regular expression for the feature name'] = $args[6];
-
-
-   }
-   return $new_args;
-}

+ 0 - 584
extensions/tripal_analysis_interpro/includes/parseInterpro.inc

@@ -1,584 +0,0 @@
-<?php
-
-/*******************************************************************************
- * Parse Interpro HTML Output file into analysisfeatureprop table
- */
-function tripal_analysis_interpro_parseHTMLFile ($analysis_id, $interprofile, $parsego, $job_id) {
-
-	// Prepare log
-	$filename = preg_replace("/.*\/(.*)/", "$1", $interprofile);
-        $logfile = tempnam(sys_get_temp_dir(),"tripal_analysis_interpro_import");
-        $log = fopen($logfile, 'a'); // append parsing results to log file
-        if(!$log){
-           print "ERROR: cannot open log file: $logfile\n";
-           exit;
-        }
-
-	// Parsing started
-	print "Parsing File:".$interprofile." ...\n";
-	fwrite($log, date("D M j G:i:s Y").". Loading $interprofile\n");
-
-	// Get cvterm_id for 'analysis_interpro_output_iteration_hits' which is required
-	// for inserting into the analysisfeatureprop table
-	$previous_db = tripal_db_set_active('chado'); // use chado database
-	$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));
-	print "cvterm_id for analysis_interpro_output_iteration_hits is $type_id\n";
-
-	// Load the HTML file and convert it into XML for loading
-	$dom = new domDocument;
-	$dom->loadHTMLFile($interprofile);
-	$xml = $dom->saveXML();
-	$interproput = simplexml_load_string($xml);
-
-	// Get html tables for parsing
-	$tables = $interproput->children()->children();
-
-	// Count the number of tables to be processed
-	$no_iterations = 0;
-	foreach($tables as $tmp) {
-		if ($tmp->getName() == 'table') {
-			$no_iterations ++;
-		}
-	}
-	print "$no_iterations html tables to be processed.\n";
-	$interval = intval($no_iterations * 0.01);
-	$idx_iterations = 0;
-
-	// Processed the tables
-	foreach ($tables as $table) {
-        //if (preg_match('/No hits reported/', $table->asXML()) ) {
-            //print "skipping this table b/c no hits are reported\n";
-        //}
-        // make sure we are looking at a table and its not an empty table
-        if ($table->getName() == 'table' && !preg_match('/No hits reported/', $table->asXML()) ) {
-            $idx_iterations ++;
-            if ($idx_iterations % $interval == 0) {
-                    $percentage = (int) ($idx_iterations / $no_iterations * 100);
-                    tripal_db_set_active($previous_db);
-                    tripal_job_set_progress($job_id, $percentage);
-                    $previous_db = tripal_db_set_active('chado');
-                    print $percentage."% ";
-            }
-
-            // Set job status
-            // Get the first row and match its name with the feature name
-            $firsttd = $table->children()->children()->children();
-            $feature_id = 0;
-            foreach($firsttd as $b) {
-                foreach($b->children() as $a) {
-                    if ($a->getName() == 'a') {
-                        // Remove _ORF from the sequence name
-                        $seqname = preg_replace('/^(.+?)_\d_.+/', "$1", $a);
-                        print "seqname is $seqname\n";
-    
-                        // Find out how many features match this uniquename
-                        $sql = "SELECT count(feature_id) FROM {feature} ".
-                        "WHERE uniquename = '%s' ";
-                        $no_features = db_result(db_query($sql, $seqname));
-						    
-                        // If there is only one match, get the feature_id
-                        if ($no_features == 1) {
-                            $sql = "SELECT feature_id FROM {feature} ".
-                                    "WHERE uniquename = '%s' ";
-                            $feature_id = db_result(db_query($sql, $seqname));
-                            print "\tfeature id is $feature_id\n";
-    
-                            // If the uniquename matches more than one features then skip and print 'Ambiguous'
-                        } else if ($no_features > 1) {
-                            fwrite($log, "Ambiguous: ".$seqname." matches more than one feature and is not processed.\n");
-                            continue;
-    
-                        // If the uniquename did not match, skip and print 'Failed'
-                        } else {
-                            fwrite($log, "Failed: ".$seqname."\n");
-                        }
-    
-                    }
-                }
-            }
-
-            // Successfully matched. print 'Succeeded'. Add analysis_id and
-            // feature_id to analysisfeature. Add the table as XML to analysisfeatureprop
-            if ($feature_id) {
-
-                //------------------------------------
-                // Clease unwanted rows from the table
-                //------------------------------------
-
-                $parent_row =   "/<tr><td valign=\"top\"><b>Parent<\/b><\/td>\s*<td valign=\"top\">\s*no.*?parent<\/td>\s*<\/tr>/";
-                $children_row = "/<tr><td valign=\"top\"><b>Children<\/b><\/td>\s*<td valign=\"top\">\s*no.*?children<\/td>\s*<\/tr>/";
-                $found_row    = "/<tr><td valign=\"top\"><b>Found.*?in<\/b><\/td>\s*<td valign=\"top\">\s*no.*?entries<\/td>\s*<\/tr>/";
-                $contains_row = "/<tr><td valign=\"top\"><b>Contains<\/b><\/td>\s*<td valign=\"top\">\s*no.*?entries<\/td>\s*<\/tr>/";
-                $go_row       = "/<tr><td valign=\"top\"><b>GO.*?terms<\/b><\/td>\s*<td valign=\"top\">\s*none<\/td>\s*<\/tr>/";
-    
-                $table_txt = $table->asXML();
-                $table_txt = preg_replace($parent_row, "", $table_txt);
-                $table_txt = preg_replace($children_row, "", $table_txt);
-                $table_txt = preg_replace($found_row, "", $table_txt);
-                $table_txt = preg_replace($contains_row, "", $table_txt);
-                $table_txt = preg_replace($go_row, "", $table_txt);
-
-                //------------------------------------
-                // Clease unwanted ORF link from table 
-                //------------------------------------
-                $orf_link = "/<b><a href=\"\/iprscan\/wget.*?\">(.*?)<\/a><\/b>/";
-                $table_txt = preg_replace($orf_link, "$1", $table_txt);
-
-                //print "----------------------------\n";
-                //print "old: ".$table->asXML()."\n\n\n";
-                //print "----------------------------\n";
-                //print "Fixed: $table_txt\n";
-                //print "----------------------------\n";
-
-                //------------------------------------
-                // If this feature has already been associated with this analysis, do not reinsert
-                // Otherwise, Insert into analysisfeature table
-                //------------------------------------
-                $sql = "Select analysisfeature_id as id from {analysisfeature} where feature_id = %d and analysis_id = %d";
-                $analysisfeature =  db_fetch_object(db_query($sql, $feature_id, $analysis_id));
-                if($analysisfeature){ $analysisfeature_id = $analysisfeature->id; }
-                if(!$analysisfeature_id){
-                    print "inserting analysisfeature\n";
-                   $sql = "INSERT INTO {analysisfeature} (feature_id, analysis_id) ".
-                        "VALUES (%d, %d)";
-                   db_query ($sql, $feature_id, $analysis_id);
-                   $sql = "Select analysisfeature_id from {analysisfeature} where feature_id = %d and analysis_id = %d";
-                   $analysisfeature =  db_fetch_object(db_query($sql, $feature_id, $analysis_id));
-                   $analysisfeature_id = $analysisfeature->id;
-                }
-
-                print "analysisfeature_id is $analysisfeature_id (analysis_id = $analysis_id; feature_id = $feature_id)\n";
-
-
-                // Get the higest rank for this feature_id in analysisfeatureprop table.
-                // If the value of the inserting content is not duplicate, add it to  
-                // analysisfeaturepro with 'higest_rank + 1'
-                $sql = "SELECT MAX(rank) FROM {analysisfeatureprop} AFP ".
-                        "INNER JOIN analysisfeature AF ON AF.analysisfeature_id = AFP.analysisfeature_id ".       
-                        "WHERE feature_id=%d ".
-                        "AND analysis_id=%d ".
-                        "AND type_id=%d ";
-
-                $afp =  db_fetch_object(db_query($sql, $feature_id, $analysis_id, $type_id));
-                $hi_rank = 0;
-                if ($afp) {
-                    $hi_rank = $afp->max + 1;
-                }
-            
-				//------------------------------------------------------------
-				// Insert interpro html tags into analysisfeatureprop table
-				//------------------------------------------------------------
-				// Before inserting, make sure it's not a duplicate
-				$sql = "SELECT value FROM {analysisfeatureprop} WHERE analysisfeature_id = %d AND type_id = %d";
-				$result = db_query($sql, $analysisfeature_id, $type_id);
-				$duplicate = 0;
-				while ($afp_value = db_fetch_object($result)) {
-				    if ($table_txt == $afp_value->value) {
-                        $duplicate = 1;
-				    }
-				}
-				if (!$duplicate) {
-				    $sql = "INSERT INTO {analysisfeatureprop} (analysisfeature_id, type_id, value, rank)".
-                            "VALUES (%d, %d, '%s', %d)";
-				    db_query($sql, $analysisfeature_id, $type_id, $table_txt, $hi_rank);
-				    fwrite($log, " (Insert)\n"); // write to log
-                    print "\twriting table\n";
-				} else {
-				   fwrite($log, " (Skipped)\n");
-                    print "\tskipping table - dup\n";
-				}
-				
-                // Parse GO terms. Make sure GO database schema is installed in chado
-                $go_db_id = db_result(db_query("SELECT db_id FROM {db} WHERE name='GO'"));
-                if (!$go_db_id) {
-                    print 'GO schema not installed in chado. GO terms are not processed.';
-                }
-                if ($go_db_id && $parsego) {
-                    $trs = $table->children();
-                    foreach ($trs as $tr) {
-                        $tds = $tr->children();
-                        foreach($tds as $td) {
-                            $gotags = $td->children();
-                            foreach ($gotags as $gotag) {
-                                // Look for 'GO:accession#'
-                                if (preg_match("/^.*?GO:(\d+).*$/", $gotag, $matches)) {
-                        	
-                                    // Find cvterm_id for the matched GO term
-                                    $sql = "SELECT cvterm_id FROM {cvterm} CVT 
-                                            INNER JOIN dbxref DBX ON CVT.dbxref_id = DBX.dbxref_id
-                                            WHERE DBX.accession = '%s' AND DBX.db_id = %d";
-                                    $goterm_id = db_result(db_query($sql, $matches[1], $go_db_id));
-                           
-                                    //-------------------------------------------
-                                    // Insert GO terms into feature_cvterm table
-                                    //-------------------------------------------
-                                    // Default pub_id = 1 (NULL) was used
-                                    $sql = "INSERT INTO {feature_cvterm} (feature_id, cvterm_id, pub_id)
-                                            VALUES (%d, %d, 1)";
-                                    db_query($sql, $feature_id, $goterm_id);
-
-                                    //------------------------------------------------
-                                    // Insert GO terms into analysisfeatureprop table
-                                    //------------------------------------------------
-                                    $sql = "INSERT INTO {analysisfeatureprop} (analysisfeature_id, type_id, value, rank) ".
-                                            "VALUES (%d, %d, '%s', 0)";
-                                    db_query($sql, $analysisfeature_id, $goterm_id, $matches[1]);
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-        }
-    }
-    tripal_db_set_active ($previous_db); // Use drupal database
-    print "Done.\nSuccessful and failed entries have been saved in the log file:\n $logfile\n";
-	
-    fwrite($log, "\n");
-    fclose($log);
-    return;
-}
-/**
-*
-*/
-function tripal_analysis_interpro_parseXMLFile ($analysis_id, $interproxmlfile, 
-   $parsego, $query_re, $query_type, $query_uniquename, $job_id) 
-{
-   // clear out the anslysisfeature table for this analysis before getting started
-   tripal_core_chado_delete('analysisfeature',array('analysis_id' => $analysis_id));
-
-   // If user input a file (e.g. blast.xml)
-	if (is_file($interproxmlfile)) {
-      tripal_analysis_interpro_parseSingleXMLFile ($analysis_id, $interproxmlfile, 
-         $parsego, $query_re, $query_type, $query_uniquename, $job_id);
-   } 
-   else {
-		$dir_handle = @opendir($interproxmlfile) or die("Unable to open $interproxmlfile");
-		$pattern = sql_regcase($interproxmlfile . "/*.xml");
-		$total_files = count(glob($pattern));
-		print "$total_files file(s) to be parsed.\n";
-		
-		$interval = intval($total_files * 0.01);
-      if($interval == 0){
-         $interval = 1;
-      }
-		$no_file = 0;
-			
-		// Parsing all files in the directory
-		while ($file = readdir($dir_handle)) {
-			if(preg_match("/^.*\.xml/i",$file)){
-
-            tripal_analysis_interpro_parseSingleXMLFile ($analysis_id, "$interproxmlfile/$file", 
-               $parsego, $query_re, $query_type, $query_uniquename, $job_id,0);
-
-			   // Set job status
-			   if ($no_file % $interval == 0) {
-			      $percentage = (int) (($no_file / $total_files) * 100);
-				   tripal_job_set_progress($job_id, $percentage);
-				   print $percentage."% ";
-			   }				
-         }
-   	   $no_file ++;
-		}
-	}
-
-	print "Done.";
-}
-/**
-*
-*/
-function tripal_analysis_interpro_parseSingleXMLFile ($analysis_id, $interproxmlfile, 
-   $parsego, $query_re, $query_type, $query_uniquename, $job_id,$uptate_status = 1) 
-{
-
-   // Parsing started
-   print "Parsing File:".$interproxmlfile." ...\n";
-
-
-   // Get cvterm_id for 'analysis_interpro_xmloutput_hits' which is required
-   // for inserting into the analysisfeatureprop table
-   $previous_db = db_set_active('chado'); // use chado database
-   $sql = "SELECT CVT.cvterm_id FROM {cvterm} CVT ".
-          "   INNER JOIN cv ON cv.cv_id = CVT.cv_id ".
-          "WHERE CVT.name = 'analysis_interpro_xmloutput_hit' ".
-          "   AND CV.name = 'tripal'";
-   $type_id = db_result(db_query($sql));
-
-   // Load the XML file
-   $xml =  simplexml_load_file($interproxmlfile);
-
-   // If there is an EBI header then we need to skip that
-   // and set our proteins array to be the second element of the array. This
-   // occurs if results were generated with the online InterProScan tool.
-   // if the XML starts in with the results then this happens when InterProScan
-   // is used command-line and we can just use the object as is
-   if(preg_match('/^EBIInterProScanResults/',$xml->getname())){
-      $children = $xml->children();
-      $header = $children[0];
-      $proteins = $children[1];
-   } 
-   // if the XML starts with the <interpro_matches> tag
-   elseif(preg_match('/^interpro_matches/',$xml->getname())) {
-      $proteins = $xml;
-   }
-   else {
-      print "ERROR: cannot parse XML file format is not recognized\n";
-      return;
-   }
-
-   // Count the number of entires to be processed
-   $no_iterations = 0;
-   foreach($proteins as $protein) {
-      $no_iterations ++;
-   }
-   print "  Found results for $no_iterations sequences\n";
-   $interval = intval($no_iterations * 0.01);
-   if($interval == 0){
-      $interval = 1;
-   }
-   $idx_iterations = 0;
-
-   // get the DB id for the GO database
-   $parsego = tripal_analysis_get_property($analysis_id,'analysis_interpro_parsego');
-   $go_db_id = db_result(db_query("SELECT db_id FROM {db} WHERE name='GO'"));
-   if ($parsego and !$go_db_id) {
-     print 'GO schema not installed in chado. GO terms are not processed.';;
-   }
-
-   // Processed each protein
-   foreach ($proteins as $protein) {
-
-      // Set job status
-      $idx_iterations ++;
-      if ($idx_iterations % $interval == 0 and $update_status) {
-         $percentage = (int) ($idx_iterations / $no_iterations * 100);
-         db_set_active($previous_db);
-         tripal_job_set_progress($job_id, $percentage);
-         $previous_db = db_set_active('chado');
-         print $percentage."% ";
-      }
-
-      // match the protein id with the feature name
-      $feature_id = 0;
-      $attr = $protein->attributes();
-      $seqname =$attr ['id'];
-
-      // is the sequence name a generic name (i.e. 'Sequence_1') then the 
-      // blast results do not contain the original sequence names.  The only
-      // option we have is to use the filename.  This will work in the case of
-      // Blast2GO which stores the XML for each sequence in a file with the
-      // the filename the name of the sequence
-      if(preg_match('/Sequence_\d+/',$seqname)){
-         $filename = preg_replace('/^.*\/(.*).xml$/', '$1', $interproxmlfile);
-         print "  Sequence name is not specific, using filename: $filename\n";
-         $seqname = $filename;   
-      }
-
-      // Remove _ORF from the sequence name
-      $seqname = preg_replace('/^(.+)_\d+_ORF\d+.*/', '$1', $seqname);
-     
-      // if a regular expression is provided then pick out the portion requested
-		if ($query_re and preg_match("/$query_re/", $seqname, $matches)) {
-			$feature = $matches[1];
-		} 
-      // If no match by the regular expression then get everything up to the first space
-      else {
-			if (preg_match('/^(.*?)\s.*$/',  $seqname, $matches)) {
-				$feature = $matches[1];
-         } 
-         // if no match up to the first space then just use the entire string
-         else {
-            $feature =  $seqname;
-         }
-      }   
-
-      if(!$feature and $query_re){
-         print "Failed: Cannot find feature for '$seqname' using the regular expression: $query_re\n";
-         continue;
-      }
-
-      // now find the feature in chado
-      $select = array();
-      if($query_uniquename){
-         $select['uniquename'] = $feature;
-      } else {
-         $select['name'] = $feature;
-      }
-      if($query_type){
-         $select['type_id'] = array(
-           'cv_id' => array(
-              'name' => 'sequence'
-           ),
-           'name' => $query_type,
-         );
-      }
-
-      $feature_arr = tripal_core_chado_select('feature',array('feature_id'),$select);
-      if(count($feature_arr) > 1){
-		   print "Ambiguous: '$feature' matches more than one feature and is being skipped.\n";
-			continue;
-      }
-      if(count($feature_arr) == 0){
-			print "Failed: cannot find a matching feature for '$feature' in the database.\n";
-         continue;
-      }
-      $feature_id = $feature_arr[0]->feature_id;
-
-     
-      // Successfully matched. print 'Succeeded'. Add analysis_id and
-      // feature_id to analysisfeature. Add the table as XML to analysisfeatureprop
-      if ($feature_id) {
-
-         print "  Adding InterPro results for feature '$seqname' ($feature_id)\n";
-
-         // Insert into analysisfeature table only if it doesn't already exist
-         $values = array('feature_id' => $feature_id, 'analysis_id' => $analysis_id);
-         $analysisfeature = tripal_core_chado_select('analysisfeature',array('*'),$values);
-         if(sizeof($analysisfeature) == 0){
-            $analysisfeature = tripal_core_chado_insert('analysisfeature',$values);
-            $analysisfeature_id = $analysisfeature['analysisfeature_id'];
-         } else {
-            $analysisfeature_id = $analysisfeature[0]->analysisfeature_id;
-         }
-
-         // Insert interpro xml results into analysisfeatureprop table
-         // Check to see if we have an existing entry
-         $sql = "SELECT analysisfeatureprop_id,rank 
-                 FROM {analysisfeatureprop} 
-                 WHERE analysisfeature_id = %d AND type_id = %d 
-                 ORDER BY rank DESC";
-         $result = db_fetch_object(db_query($sql, $analysisfeature_id, $type_id));
-         $rank = 0;
-         if($result){
-            $afp_id = $result->analysisfeatureprop_id; 
-            $rank = $result->rank + 1; 
-         }
-         $sql = "INSERT INTO {analysisfeatureprop} (analysisfeature_id, type_id, value, rank)".
-                "VALUES (%d, %d, '%s', %d)";
-         db_query($sql, $analysisfeature_id, $type_id, $protein->asXML(), $rank);
-
-         // parse the XML for each protein if GO terms are requested
-         if($parsego and $go_db_id){		
-
-            $protein = tripal_analysis_interpro_get_result_object($protein->asXML(),$feature_id); 
-            $goterms = $protein['goterms'];                 
-
-            // cycle through the GO terms and add them to the database
-            foreach($goterms as $goterm){ 
-                   
-               // seperate the 'GO:' from the term
-               if (preg_match("/^.*?GO:(\d+).*$/", $goterm, $matches)) {
-
-                  // Find cvterm_id for the matched GO term
-                  $sql = "SELECT cvterm_id FROM {cvterm} CVT 
-                          INNER JOIN dbxref DBX ON CVT.dbxref_id = DBX.dbxref_id
-                          WHERE DBX.accession = '%s' AND DBX.db_id = %d";
-                  $goterm_id = db_result(db_query($sql, $matches[1], $go_db_id));
-
-                  // Insert GO terms into feature_cvterm table
-                  // Default pub_id = 1 (NULL) was used
-                  $values = array('feature_id' => $feature_id, 'cvterm_id' => $goterm_id, 'pub_id' => 1);
-                  $feature_cvterm = tripal_core_chado_select('feature_cvterm',array('*'),$values);
-                  if(sizeof($feature_cvterm) == 0){
-                     $feature_cvterm = tripal_core_chado_insert('feature_cvterm',$values);
-                  }
-
-                  // Insert GO terms into analysisfeatureprop table
-                  $values = array('analysisfeature_id' => $analysisfeature_id,
-                                  'type_id' => $goterm_id,
-                                  'rank' => 0);
-                  $analysisfeatureprop = tripal_core_chado_select('analysisfeatureprop',array('*'),$values);
-                  if(sizeof($analysisfeatureprop) == 0){
-                     $values['value'] = $matches[1];
-                     $analysisfeatureprop = tripal_core_chado_insert('analysisfeatureprop',$values);
-                  }
-               } // end if preg_match
-            } // end for each goterm
-         } // end if($parsego and $go_db_id)
-      } // end if($feature_id)            
-   } // end foreach ($proteins as $protein)
-   db_set_active ($previous_db); // Use drupal database
-
-   return;
-}
-/********************************************************************************
- * 
- */
-function tripal_analysis_interpro_get_result_object($interpro_xml,$feature_id){
-
-	// Load the XML into an object
-	$xmlObj = simplexml_load_string($interpro_xml);
-
-   // iterate through each interpro results for this protein
-   $results = array();
-   $terms = array();
-   $protein = array();
-   $iprterms = array();
-   $goterms = array();
-
-   $term_count = 0;
-   $match_count = 0;
-   
-   // get the properties of this result
-   $attr = $xmlObj->attributes();
-   $protein['orf_id'] = (string) $attr["id"];
-   $protein['orf_length'] = (string) $attr["length"];
-   $protein['orf_crc64'] = (string) $attr["crc64"];
-   
-	foreach($xmlObj->children() as $intepro){
-      // get the interpro term for this match
-      $attr = $intepro->attributes();
-	   $terms[$term_count]['ipr_id'] = (string) $attr["id"];
-	   $terms[$term_count]['ipr_name'] = (string) $attr["name"];
-	   $terms[$term_count]['ipr_type'] = (string) $attr["type"];
-      $iprterms[] = array($terms[$term_count]['ipr_id'],$terms[$term_count]['ipr_name']);
- 
-      // iterate through the elements of the interpro result
-      $matches[$term_count]['matches'] = array();
-      $match_count = 0;
-  	   foreach($intepro->children() as $level1){
-			$element_name = $level1->getName();
-			if($element_name == 'match'){
-            // get the match name for this match
-            $attr = $level1->attributes();
-	         $terms[$term_count]['matches'][$match_count]['match_id'] = (string) $attr["id"];
-	         $terms[$term_count]['matches'][$match_count]['match_name'] = (string) $attr["name"];
-	         $terms[$term_count]['matches'][$match_count]['match_dbname'] = (string) $attr["dbname"];
-            
-            // get the location information for this match     
-            $loc_count = 0;
-            foreach($level1->children() as $level2){
-			      $element_name = $level2->getName();
-			      if($element_name == 'location'){
-                  $attr = $level2->attributes();
-	               $terms[$term_count]['matches'][$match_count]['locations'][$loc_count]['match_start'] = (string) $attr["start"];
-	               $terms[$term_count]['matches'][$match_count]['locations'][$loc_count]['match_end'] = (string) $attr["end"];
-	               $terms[$term_count]['matches'][$match_count]['locations'][$loc_count]['match_score'] = (string) $attr["score"];
-	               $terms[$term_count]['matches'][$match_count]['locations'][$loc_count]['match_status'] = (string) $attr["status"];
-	               $terms[$term_count]['matches'][$match_count]['locations'][$loc_count]['match_evidence'] = (string) $attr["evidence"];
-                  $loc_count++;
-               }
-            }
-            $match_count++;
-         }
-
-			if($element_name == 'classification'){
-            $attr = $level1->attributes();
-            if($attr['class_type'] == 'GO'){
-               $terms[$term_count]['matches'][$match_count]['go_terms'][] = (string) $attr['id'];
-               $goterms[] = (string) $attr['id'];
-            }
-         }
-      }
-      $term_count++;
-	}
-   $results['terms'] = $terms;
-   $results['orf'] = $protein;
-   $results['iprterms'] = $iprterms;
-   $results['goterms'] = $goterms;
-	return $results;
-}

+ 0 - 100
extensions/tripal_analysis_interpro/node-chado_analysis_interpro.tpl.php

@@ -1,100 +0,0 @@
-<?php
-// Purpose: This template provides the layout of the organism node (page)
-//   using the same templates used for the various feature content blocks.
-//
-// To Customize the Featture Node Page:
-//   - This Template: customize basic layout and which elements are included
-//   - Using Panels: Override the node page using Panels3 and place the blocks
-//       of content as you please. This method requires no programming. See
-//       the Tripal User Guide for more details
-//   - Block Templates: customize the content/layout of each block of stock 
-//       content. These templates are found in the tripal_stock subdirectory
-//
-// Variables Available:
-//   - $node: a standard object which contains all the fields associated with
-//       nodes including nid, type, title, taxonomy. It also includes stock
-//       specific fields such as stock_name, uniquename, stock_type, synonyms,
-//       properties, db_references, object_relationships, subject_relationships,
-//       organism, etc.
-//   NOTE: For a full listing of fields available in the node object the
-//       print_r $node line below or install the Drupal Devel module which 
-//       provides an extra tab at the top of the node page labelled Devel
-?>
-
-<?php
- //uncomment this line to see a full listing of the fields avail. to $node
- //print '<pre>'.print_r($variables,TRUE).'</pre>';
-drupal_add_css('./tripal-node-templates.css');
-
-$node = $variables['node'];
-$organism = $variables['node']->organism;
-?>
-
-<?php if ($teaser) { 
-  include(drupal_get_path('module' , 'tripal_analysis_interpro') . '/theme/tripal_analysis_interpro/tripal_analysis_interpro_teaser.tpl.php'); 
-} else { ?>
-
-<script type="text/javascript">
-if (Drupal.jsEnabled) {
-   $(document).ready(function() {
-      // hide all tripal info boxes at the start
-      $(".tripal-info-box").hide();
- 
-      // iterate through all of the info boxes and add their titles
-      // to the table of contents
-      $(".tripal-info-box-title").each(function(){
-        var parent = $(this).parent();
-        var id = $(parent).attr('id');
-        var title = $(this).text();
-        $('#tripal_analysis_interpro_toc_list').append('<li><a href="#'+id+'" class="tripal_analysis_interpro_toc_item">'+title+'</a></li>');
-      });
-
-      // when a title in the table of contents is clicked, then
-      // show the corresponding item in the details box
-      $(".tripal_analysis_interpro_toc_item").click(function(){
-         $(".tripal-info-box").hide();
-         href = $(this).attr('href');
-         $(href).fadeIn('slow');
-         // we want to make sure our table of contents and the details
-         // box stay the same height
-         $("#tripal_analysis_interpro_toc").height($(href).parent().height());
-         return false;
-      }); 
-
-      // we want the base details to show up when the page is first shown 
-      // unless the user specified a specific block
-      var block = window.location.href.match(/[\?|\&]block=(.+?)\&/)
-      if(block == null){
-         block = window.location.href.match(/[\?|\&]block=(.+)/)
-      }
-      if(block != null){
-         $("#tripal_analysis_interpro-"+block[1]+"-box").show();
-      } else {
-         $("#tripal_analysis_interpro-base-box").show();
-      }
-
-      $("#tripal_analysis_interpro_toc").height($("#tripal_analysis_interpro-base-box").parent().height());
-      
-   });
-}
-</script>
-
-
-<div id="tripal_analysis_interpro_details" class="tripal_details">
-
-   <!-- Basic Details Theme -->
-   <?php include('theme/tripal_analysis_interpro/tripal_analysis_interpro_base.tpl.php'); ?>
-
-   <?php print $content ?>
-</div>
-
-<!-- Table of contents -->
-<div id="tripal_analysis_interpro_toc" class="tripal_toc">
-   <div id="tripal_analysis_interpro_toc_title" class="tripal_toc_title">Resources</i></div>
-   <span id="tripal_analysis_interpro_toc_desc" class="tripal_toc_desc"></span>
-   <ul id="tripal_analysis_interpro_toc_list" class="tripal_toc_list">
-
-   </ul>
-</div>
-
-<?php } ?>

+ 0 - 44
extensions/tripal_analysis_interpro/theme/css/tripal_analysis_interpro.css

@@ -1,44 +0,0 @@
-
-.tripal_interpro-info-box {
-   margin-top: 10px;
-   margin-left: 0px;
-   margin-right: 0px;
-   margin-bottom: 0px;
-   padding-top: 0px;
-   padding-left: 0px;
-   padding-bottom: 0px;
-   padding-right: 0px;
-   border-collapse: collapse;
-   z-index: 10;
-}
-
-.tripal_interpro_results_table {
-   margin-left: auto;
-   margin-right: auto;
-}
-
-.tripal_interpro_results_table tbody {
-    border-top: none;
-}
-
-.tripal_interpro_results_table tbody tr td table{
-   background: #FFFFFF;
-}
-
-.tripal_interpro_results_table tbody tr td table tr{
-   background: #FFFFFF;
-}
-
-.tripal_interpro_results_table tbody tr td table tr td{
-   background: #FFFFFF;
-}
-/* feature node sepcific template */
-.tripal_feature_interpro-results-table {
-   padding-top: 10px;
-   padding-bottom: 10px;
-}
-.tripal_feature-interpro_results_subtitle{
-   padding-top: 10px;
-   padding-bottom: 10px;
-   font-weight: bold;
-}

+ 0 - 29
extensions/tripal_analysis_interpro/theme/js/tripal_analysis_interpro.js

@@ -1,29 +0,0 @@
-if (Drupal.jsEnabled) {
-   
-   $(document).ready(function(){
-	   var fontcolor = $(".interpro_results_table tbody tr td table tbody tr td b a").parent().prev().css('color');
-	   // Disable the hyperlink for sequences in the interpro box
-	   $(".tripal_interpro_results_table tbody tr td table tbody tr td b a").removeAttr('href');
-	   $(".tripal_interpro_results_table tbody tr td table tbody tr td b a").css('font-weight','normal');
-	   $(".tripal_interpro_results_table tbody tr td table tbody tr td b a").css('text-decoration','none');
-	   $(".tripal_interpro_results_table tbody tr td table tbody tr td b a").css('color',fontcolor);
-	   
-	   // Allow selection of "Load GO term to the database" only when the submitting job to parse
-	   // html output is enabled
-	   isSubmittingJob ();
-   });
-   
-   // Disable parse GO checkbox if no interpro job is submitted
-   function isSubmittingJob () {
-	   if ($('#edit-interprojob').is(":checked")) {
-		   var fontcolor = $("#edit-parsego").parent().parent().prev().children().css('color');
-		   $("#edit-parsego").attr('disabled', false);
-		   $("#edit-parsego-wrapper").css("color", fontcolor);
-		   
-	   } else {
-		   $("#edit-parsego").attr('checked', false);
-		   $("#edit-parsego").attr('disabled', true);
-		   $("#edit-parsego-wrapper").css("color", "grey");
-	   }
-   }
-}

+ 0 - 56
extensions/tripal_analysis_interpro/theme/tripal_analysis_interpro/tripal_analysis_interpro_base.tpl.php

@@ -1,56 +0,0 @@
-<?php
-$node = $variables['node'];
-$analysis = $variables['node']->analysis;
-$interpro = $node->analysis->tripal_analysis_interpro;
-
-// the description is a text field so we want to expand that
-$analysis = tripal_core_expand_chado_vars($analysis,'field','analysis.description');
-?>
-<div id="tripal_analysis_interpro-base-box" class="tripal_analysis_interpro-info-box tripal-info-box">
-  <div class="tripal_analysis_interpro-info-box-title tripal-info-box-title">Details</div>
-   <table id="tripal_analysis_interpro-table-base" class="tripal_analysis_interpro-table tripal-table tripal-table-vert">
-      <tr class="tripal_analysis_interpro-table-even-row tripal-table-even-row">
-        <th>Analysis Name</th>
-        <td><?php print $analysis->name; ?></td>
-      </tr>
-      <tr class="tripal_analysis_interpro-table-odd-row tripal-table-odd-row">
-        <th nowrap>Software</th>
-        <td><?php 
-          print $analysis->program; 
-          if($analysis->programversion){
-             print " (" . $analysis->programversion . ")"; 
-          }
-          if($analysis->algorithm){
-             print ". " . $analysis->algorithm; 
-          }
-          ?>
-        </td>
-      </tr>
-      <tr class="tripal_analysis_interpro-table-even-row tripal-table-even-row">
-        <th nowrap>Source</th>
-        <td><?php 
-          if($analysis->sourceuri){
-             print "<a href=\"$analysis->sourceuri\">$analysis->sourcename</a>"; 
-          } else {
-             print $analysis->sourcename; 
-          }
-          if($analysis->sourceversion){
-             print " (" . $analysis->sourceversion . ")"; 
-          }
-          ?>
-          </td>
-      </tr>
-      <tr class="tripal_analysis_interpro-table-odd-row tripal-table-odd-row">
-        <th nowrap>Date performed</th>
-        <td><?php print preg_replace("/^(\d+-\d+-\d+) .*/","$1",$analysis->timeexecuted); ?></td>
-      </tr>
-      <tr class="tripal_analysis_interpro-table-even-row tripal-table-even-row">
-        <th nowrap>Description</th>
-        <td><?php print $analysis->description; ?></td>
-      </tr>      
-      <tr class="tripal_analysis_interpro-table-odd-row tripal-table-odd-row">
-        <th nowrap>InterProScan Arguments</th>
-        <td><?php print $interpro->interproparameters ?></td>
-      </tr>        	                                
-   </table>   
-</div>

+ 0 - 53
extensions/tripal_analysis_interpro/theme/tripal_analysis_interpro/tripal_analysis_interpro_teaser.tpl.php

@@ -1,53 +0,0 @@
-<?php
-$node = $variables['node'];
-$analysis = $variables['node']->analysis;
-
-// the description is a text field so we want to expand that
-$analysis = tripal_core_expand_chado_vars($analysis,'field','analysis.description');
-
-
-?>
-<div id="tripal_analysis-base-box" class="tripal_analysis-info-box tripal-info-box">
-  <div class="tripal_analysis-info-box-title tripal-info-box-title">Details</div>
-   <table id="tripal_analysis-table-base" class="tripal_analysis-table tripal-table tripal-table-vert">
-      <tr class="tripal_analysis-table-odd-row tripal-table-even-row">
-        <th>Analysis Name</th>
-        <td><?php print $analysis->name; ?></td>
-      </tr>
-      <tr class="tripal_analysis-table-odd-row tripal-table-odd-row">
-        <th nowrap>Software</th>
-        <td><?php 
-          print $analysis->program; 
-          if($analysis->programversion){
-             print " (" . $analysis->programversion . ")"; 
-          }
-          if($analysis->algorithm){
-             print ". " . $analysis->algorithm; 
-          }
-          ?>
-        </td>
-      </tr>
-      <tr class="tripal_analysis-table-odd-row tripal-table-even-row">
-        <th nowrap>Source</th>
-        <td><?php 
-          if($analysis->sourceuri){
-             print "<a href=\"$analysis->sourceuri\">$analysis->sourcename</a>"; 
-          } else {
-             print $analysis->sourcename; 
-          }
-          if($analysis->sourceversion){
-             print " (" . $analysis->sourceversion . ")"; 
-          }
-          ?>
-          </td>
-      </tr>
-      <tr class="tripal_analysis-table-odd-row tripal-table-odd-row">
-        <th nowrap>Date performed</th>
-        <td><?php print preg_replace("/^(\d+-\d+-\d+) .*/","$1",$analysis->timeexecuted); ?></td>
-      </tr>
-      <tr class="tripal_analysis-table-odd-row tripal-table-even-row">
-        <th nowrap>Description</th>
-        <td><?php print $analysis->description; ?></td>
-      </tr>             	                                
-   </table>   
-</div>

+ 0 - 121
extensions/tripal_analysis_interpro/theme/tripal_feature/tripal_feature_interpro_results.tpl.php

@@ -1,121 +0,0 @@
-<?php
-$feature  = $variables['node']->feature;
-$results = $feature->tripal_analysis_interpro->results->xml;
-$resultsHTML = $feature->tripal_analysis_interpro->results->html;
-
-if(count($results) > 0){ 
-   $i = 0;
-   foreach($results as $analysis_id => $analysisprops){ 
-     $analysis = $analysisprops['analysis'];
-     $protein_ORFs = $analysisprops['protein_ORFs']; 
-     $terms = $analysisprops['allterms']; 
-     ?>
-     <div id="tripal_feature-interpro_results_<?php print $i?>-box" class="tripal_analysis_interpro-box tripal-info-box">
-        <div class="tripal_feature-info-box-title tripal-info-box-title">InterPro Report <?php print preg_replace("/^(\d+-\d+-\d+) .*/","$1",$analysis->timeexecuted); ?></div>
-        <div class="tripal_feature-info-box-desc tripal-info-box-desc"><?php 
-            if($analysis->nid){ ?>
-               Analysis name: <a href="<?php print url('node/'.$analysis->nid) ?>"><?php print $analysis->name?></a><?php
-            } else { ?>
-               Analysis name: <?php print $analysis->name;
-            } ?><br>
-            Date Performed: <?php print preg_replace("/^(\d+-\d+-\d+) .*/","$1",$analysis->timeexecuted); ?>
-        </div>
-
-     <div class="tripal_feature-interpro_results_subtitle">Summary of Annotated IPR terms</div>
-     <table id="tripal_feature-interpro_summary-<?php $i ?>-table" class="tripal_analysis_interpro-summary-table tripal-table tripal-table-horz">
-      <tr>
-        <th>Term</td>
-        <th>Name</td>
-      </tr>
-     <?php 
-     $j=0;
-     foreach($terms as $term){ 
-       $ipr_id = $term[0];
-       $ipr_name = $term[1];
-       $class = 'tripal_feature-table-odd-row tripal-table-odd-row';
-       if($j % 2 == 0 ){
-         $class = 'tripal_feature-table-even-row tripal-table-even-row';
-       }?>
-       <tr class="<?php print $class ?>">
-         <td><?php print $ipr_id ?></td>
-         <td><?php print $ipr_name ?></td>         
-       </tr>
-       <?php
-       $j++;
-     } ?>
-     </table>
-     <br><br>
-     <div class="tripal_feature-interpro_results_subtitle">Analysis Details</div>
-     <table id="tripal_feature-interpro_results-<?php $i ?>-table" class="tripal-table tripal_feature_interpro-results-table tripal-table-horz" style="border-top: 0px; border-bottom: 0px">
-     <?php
-     foreach($protein_ORFs as $orf){  
-        $terms = $orf['terms'];
-        $orf = $orf['orf'];  
-        ?>
-        <?php foreach($terms as $term){ 
-          $matches = $term['matches'];
-          $ipr_id = $term['ipr_id'];
-          $ipr_name = $term['ipr_name'];
-          $ipr_type = $term['ipr_type']; ?>          
-            <tr>
-              <td colspan="4" style="padding-left: 0px">ORF: <?php print $orf['orf_id'] ?>, Length: <?php print $orf['orf_length'] ?> <br>
-                              IPR Term: <?php print "$ipr_id $ipr_name ($ipr_type)"; ?></th>
-            </tr>
-            <tr style="border-top: solid 1px;">
-              <th>Method</th>
-              <th>Identifier</th>
-              <th>Description</th>
-              <th>Matches<sup>*</sup></th>
-            </tr>
-            <?php $j = 0; 
-            foreach ($matches as $match){
-               $match_id = $match['match_id'];
-               $match_name = $match['match_name'];
-               $match_dbname = $match['match_dbname'];
-
-
-               $class = 'tripal_feature-table-odd-row tripal-table-odd-row';
-               if($j % 2 == 0 ){
-                  $class = 'tripal_feature-table-even-row tripal-table-even-row';
-               }?>
-               <tr class="<?php print $class ?>">
-                 <td><?php print $match_dbname ?></td>
-                 <td><?php print $match_id ?></td>
-                 <td><?php print $match_name ?></td>
-                 <td nowrap><?php
-                    $locations = $match['locations'];
-                    foreach($locations as $location){
-                      print $location['match_score']." [".$location['match_start']."-".$location['match_end']."] " . $location['match_status'] ."<br>";
-                      #$match_evidence =  $location['match_evidence'];
-                    } ?>
-                 </td>
-               </tr>
-               <?php
-               $j++;  
-            } // end foreach matches ?>
-            <tr><td colspan="4"><sup>* score [start-end] status</sup></td></tr> <?php
-        } // end foreach terms
-        $i++;
-     } // end foreach orfs ?>
-     </table>
-     </div> <?php
-   } // end for each analysis 
-} // end if
-if($resultsHTML){  ?>
-   <div id="tripal_feature-interpro_results_<?php print $i?>-box" class="tripal_analysis_interpro-box tripal-info-box">
-     <div class="tripal_feature-info-box-title tripal-info-box-title">InterPro Report <?php print preg_replace("/^(\d+-\d+-\d+) .*/","$1",$analysis->timeexecuted); ?></div>
-     <div class="tripal_feature-info-box-desc tripal-info-box-desc"><?php 
-         if($analysis->nid){ ?>
-            Analysis name: <a href="<?php print url('node/'.$analysis->nid) ?>"><?php print $analysis->name?></a><?php
-         } else { ?>
-            Analysis name: <?php print $analysis->name;
-         } ?><br>
-         Date Performed: <?php print preg_replace("/^(\d+-\d+-\d+) .*/","$1",$analysis->timeexecuted); ?>
-     </div>
-
-   <div class="tripal_feature-interpro_results_subtitle">Summary of Annotated IPR terms</div> <?php 
-   print $resultsHTML;?>
-   </div> <?php
-}
-?>
-

+ 0 - 10
extensions/tripal_analysis_interpro/tripal_analysis_interpro.info

@@ -1,10 +0,0 @@
-; $Id:
-name = Tripal Interpro
-description = An analysis sub-module for adding, editing, and displaying InterProScan analysis results.
-core = 6.x
-project = tripal_analysis_interpro
-package = Tripal Extensions
-dependencies[] = tripal_core
-dependencies[] = tripal_feature
-dependencies[] = tripal_analysis
-dependencies[] = tripal_analysis_go

+ 0 - 90
extensions/tripal_analysis_interpro/tripal_analysis_interpro.install

@@ -1,90 +0,0 @@
-<?php
-//$Id:
-
-/*******************************************************************************
- * Implementation of hook_install().
- */
-function tripal_analysis_interpro_install() {
-   // create the module's data directory
-   tripal_create_moddir('tripal_analysis_interpro');
-
-   // We need to register to tripal_analysis module so it can provide a control
-   // for our interpro result. Basically the registration is done by inserting
-   // modulename into the drupal {tripal_analysis} table AND inserting required
-   // information to the chado Analysis table. Also in tripal_analysis_interpro.module,
-   // we need to define HOOK_get_settings() for the module to work properly.
-   
-   // Inert into drupal's {tripal_analysis}
-   tripal_analysis_register_child('tripal_analysis_interpro');
-   
-   // add the CVterms needed for this module
-   tripal_analysis_interpro_add_cvterms();
-}
-
-/*******************************************************************************
- * Implementation of hook_uninstall().
- */
-function tripal_analysis_interpro_uninstall() {
-   
-   // Delete all information associate with the module
-   // Drupal complains when the user tries to uninstall tripal_analysis 
-   // and tripal_analysis_interpro at the same time. This is because Drupal drops
-   // the {tripal_analysis} table before we can delete anything from it. Thus,
-   // we perform a db_table_exists() check before the deletion
-   
-   //Delete the settings from {tripal_analysis} table
-   tripal_analysis_unregister_child('tripal_analysis_interpro');
-   
-   // Delete module's variables from variables table.
-   db_query("DELETE FROM {variable} WHERE name='%s'",
-            'tripal_analysis_interpro_setting');
-
-}
-/**
-*
-*/
-function tripal_analysis_interpro_add_cvterms(){
-   // Add cvterm 'analysis_interpro_output_iteration_hits' for inserting into featureprop table
-   tripal_add_cvterms('analysis_interpro_xmloutput_hit', 'Hit in the interpro XML output. Each hit belongs to a chado feature. This cvterm represents a hit in the output');
-   tripal_add_cvterms('analysis_interpro_output_hit', 'Hit in the interpro HTML output. Each hit belongs to a chado feature. This cvterm represents a hit in the output');
-   tripal_add_cvterms('analysis_interpro_settings', 'Settings of an interpro analysis, including output file and run parameters separated by a bar |');
-   tripal_add_cvterms('analysis_interpro_interproparameters','The parameters used when executing an InterProScan job');
-   tripal_add_cvterms('analysis_interpro_interprofile','Used to hold the name of the XML file containing the InterProScan results');
-   tripal_add_cvterms('analysis_interpro_parsego','Indicates whether or not the GO terms should be extracted when parsing the InterProScan XML file');
-   tripal_add_cvterms('analysis_interpro_parseHTML','Indicates that the input file is in HTML format. This functionality is deprecated and may not work, but is provided for backwards compatability.');
-   tripal_add_cvterms('analysis_interpro_query_re','The regular expression for finding the feature name in the query definition line of the InterPro results');
-   tripal_add_cvterms('analysis_interpro_query_type','The feature type (e.g. mRNA, polypeptide) of the query input file. This type is used to identify the query feature when multiple features have the same name');
-   tripal_add_cvterms('analysis_interpro_query_uniquename','Indicates if the matched name in the query definition line of the blast results is feature uniquename');
-   tripal_add_cvterms('analysis_interpro_output_keywords', 'Selected keywords for interpro html output which are indexed for search.');
-}
-/**
- * 
- */
-function tripal_analysis_interpro_update_6000(){
-
-   // we have some new cvterms to add
-   tripal_analysis_interpro_add_cvterms();
-
-   $ret = array(
-      '#finished' => 1,
-   );
-   
-   return $ret;
-}
-/*******************************************************************************
- * Implementation of hook_requirements(). Make sure 'Tripal Core' and 'Tripal
- * Analysis' are enabled before installation
- */
-function tripal_analysis_interpro_requirements($phase) {
-   $requirements = array();
-   if ($phase == 'install') {
-      if (!function_exists('tripal_create_moddir') || !function_exists('tripal_analysis_register_child')) {
-         $requirements ['tripal_analysis_interpro'] = array(
-            'title' => "tripal_analysis_interpro",
-            'value' => "error. Some required modules are just being installed. Please try again.",
-            'severity' => REQUIREMENT_ERROR,
-         );
-      }
-   }
-   return $requirements;
-}

+ 0 - 795
extensions/tripal_analysis_interpro/tripal_analysis_interpro.module

@@ -1,795 +0,0 @@
-<?php
-
-require_once "includes/parseInterpro.inc";
-
-/*******************************************************************************
- * Tripal Interpro lets users show/hide iprscan results associated with a tripal
- * feature
- ******************************************************************************/
-function tripal_analysis_interpro_init(){
-
-	// Add javascript and style sheet
-   drupal_add_css(drupal_get_path('module', 'tripal_analysis_interpro').'/theme/css/tripal_analysis_interpro.css', 'theme');
-   drupal_add_js( drupal_get_path('module', 'tripal_analysis_interpro').'/theme/js/tripal_analysis_interpro.js');
-}
-/*******************************************************************************
- *  Provide information to drupal about the node types that we're creating
- *  in this module
- */
-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;
-}
-/*******************************************************************************
- *  Provide a Interpro Analysis form
- */
-function chado_analysis_interpro_form ($node){
-
-   // add in the default fields for the analysis
-   $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']['interprokeywordjob'] = array(
-//      '#type' => 'checkbox',
-//      '#title' => t('Submit a job to extract keywords from the Interpro html output'),
-//      '#description' => t('Note: Interpro results are only searchable after keywords are extracted.'),/
-//	);
-	$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){
-   // use the analysis parent to validate the node
-   tripal_analysis_validate($node, $form); 
-}
-/**
- * 
- * 
- */
-function chado_analysis_interpro_load($node){
-
-   // load the default set of analysis fields
-	$additions = chado_analysis_load($node);
-
-   // create some variables for easier lookup
-   $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 there is an old style 'interpro_settings' array, then break these out for
-   // use in the new format
-   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){
-  // insert the analysistripal_core_generate_chado_var
-   chado_analysis_insert($node);
-
-   // set the type for this analysis
-   tripal_analysis_insert_property($node->analysis_id,'analysis_type','tripal_analysis_interpro');
-
-   // now add in the remaining settings as a single property but separated by bars
-   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);	
-  
-   // submit the parsing jobs
-   chado_analysis_interpro_submit_job($node);
-
-}
-/**
- * 
- */
-function chado_analysis_interpro_update($node){
-  // insert the analysistripal_core_generate_chado_var
-   chado_analysis_update($node);
-
-   // set the type for this analysis
-   tripal_analysis_update_property($node->analysis_id,'analysis_type','tripal_analysis_interpro',1);
-
-   // now add in the remaining settings as a single property but separated by bars
-   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);	
-
-   // if this analysis uses the old style settings cvterm then remove that term
-   $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');
-   }
-  
-   // submit the parsing jobs
-   chado_analysis_interpro_submit_job($node);
-}
-/*******************************************************************************
- * Delete interpro anlysis
- */
-function chado_analysis_interpro_delete($node){
-	chado_analysis_delete($node);
-}
-
-/**
-*
-*/
-function chado_analysis_interpro_submit_job($node){
-   global $user;
-
-	// Add a job if the user wants to parse the html output
-	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.");
-		}
-	}
-	
-	// Add a job if the user wants to the keywords from the HTML output
-	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);
-	}
-}
-
-
-/*******************************************************************************
- *  This function customizes the view of the chado_analysis node.  It allows
- *  us to generate the markup.
- */
-function chado_analysis_interpro_view ($node, $teaser = FALSE, $page = FALSE) {
-	// use drupal's default node view:
-	if (!$teaser) {
-		$node = node_prepare($node, $teaser);
-		// When previewing a node submitting form, it shows 'Array' instead of
-		// correct date format. We need to format the date here
-		$time = $node->timeexecuted;
-		if(is_array($time)){
-			$month = $time['month'];
-			$day = $time['day'];
-			$year = $time['year'];
-			$timestamp = $year.'-'.$month.'-'.$day;
-			$node->timeexecuted = $timestamp;
-		}
-		// When viewing a node, we need to reformat the analysisprop since we
-		// separate each value with a bar |
-		if (preg_match("/.*\|.*/",$node->interprofile)) {
-			$prop_values = explode("|", $node->interprofile);
-			$node->interprofile = $prop_values[0];
-			$node->interproparameters = $prop_values[1];
-		}
-	}
-	return $node;
-}
-/**
- *
- *
- * @ingroup tripal_analysis_interpro
- */
-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;
-         }
-   }
-}
-
-/*******************************************************************************
- * tripal_analysis_interpro_nodeapi()
- * HOOK: Implementation of hook_nodeapi()
- * Display interpro results for allowed node types
- */
-function tripal_analysis_interpro_nodeapi(&$node, $op, $teaser, $page) {
-
-	switch ($op) {
-		case 'view':
-			// Find out which node types for showing the interpro
-			$types_to_show = variable_get('tripal_analysis_interpro_setting',
-			array('chado_feature'));
-
-			// Abort if this node is not one of the types we should show.
-			if (!in_array($node->type, $types_to_show, TRUE)) {
-				break;
-			}
-			// Add interpro to the content item if it's not a teaser
-			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 {
-					// Show interpro result if not at teaser view
-					$node->content['tripal_feature_interpro_results'] = array(
-                  '#value' => theme('tripal_feature_interpro_results', $node),
-                  '#weight' => 7
-					);
-				}
-			}
-	}
-}
-
-/**
- * Implements hook_theme_registry_alter().
- */
-function tripal_analysis_interpro_theme_registry_alter(&$info) {
-  // Inject our module into the node theme registry as being an available theme
-  // path so that we can override the node template for our content type.
-  array_splice($info['node']['theme paths'], 1, 0, array(drupal_get_path('module', 'tripal_analysis_interpro')));
-}
-
-/************************************************************************
- *  We need to let drupal know about our theme functions and their arguments.
- *  We create theme functions to allow users of the module to customize the
- *  look and feel of the output generated in this module
- */
-function tripal_analysis_interpro_theme () {
-	$path = drupal_get_path('module' , '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',
-         'path' => $path . '/tripal_feature',
-	   ),
-      'tripal_analysis_interpro_base' => array (
-         'arguments' => array('node'=> null),
-         'template' => 'tripal_analysis_interpro_base',
-         'path' => $path . '/tripal_analysis_interpro',
-	   )
-	);
-}
-/*******************************************************************************
- * Prepare interpro result for the feature shown on the page
- */
-//function theme_tripal_analysis_interpro_results ($node) {
-//	$feature = $node->feature;
-//	$content = tripal_get_interpro_results($feature->feature_id);
-//	return $content;
-//}
-
-function tripal_analysis_interpro_preprocess_tripal_feature_interpro_results(&$variables){
-   $feature = $variables['node']->feature;
-
-   // we don't know how many analysis are the old style HTML version and how many are the newer
-   // XML format.  So, to be backwards compatible we should get both.
-  // $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);
-}
-
-/*******************************************************************************
- * Prepare interpro result for the feature shown on the page
- */
-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){
-
-	// Get the blast results stored as XML from the analysisfeatureprop table
-   // the type for the property is named 'analysis_blast_output_iteration_hits'
-   // and is found in the 'tripal' controlled vocabulary.  This CV term was
-   // added by this module.
-   $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);
-
-   // iterate through all of the interpro XML properties for this feature
-	$results = array ();
-   if($afeatureprops){
-	   foreach ($afeatureprops as $index => $afeatureprop) {
-
-         // get the analysis feature record
-         $analysisfeature_arr = tripal_core_chado_select('analysisfeature',array('analysis_id'),
-            array('analysisfeature_id' => $afeatureprop->analysisfeature_id));
-         $analysisfeature = $analysisfeature_arr[0];
-
-         // get the analysis record and the analysis_id
-         $analysis = tripal_core_generate_chado_var('analysis',
-            array('analysis_id' => $analysisfeature->analysis_id));
-         $analysis_id = $analysis->analysis_id;
-
-         // parse the XML and add it to the array of blast results to be returned
-         $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;
-
-         // iterate through all of the protein ORFs and combine the terms into one large list
-         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;
-}
-/*******************************************************************************
- * tripal_get_interpro_results()
- * Get interpro result from featureprop table for the feature
- */
-function tripal_get_interpro_HTML_results($feature_id){
-	// Get cvterm_id for 'analysis_interpro_output_hit' which is required
-	// for inserting into the analysisfeatureprop table
-	$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));
-   
-   // Get analysis times for the feature
-	$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);
-
-   // Show interpro result ORDER BY time
-   if ($hasResult) { // If there is any result, show expandable box
-      $content .= "<table class=\"tripal_interpro_results_table\">
-                         <tr><td>";
-
-      while ($ana = db_fetch_object($result)) {
-         // Show analysis date
-         $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));
-         // Find node id for the analysis
-         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');
-       
-         // Show content
-         $content .= "<strong>Analysis Date:</strong> $ana_details->time
-                        (<a href=$ana_url>$ana_details->name</a>)";
-         
-         // Show interpro results
-         $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;
-}
-
-/*******************************************************************************
- * tripal_get_interpro_results()
- * Get interpro result from featureprop table for the feature
- */
-function tripal_get_interpro_results_index_version($feature_id){
-   // Get cvterm_id for 'analysis_interpro_output_hit' which is required
-   // for inserting into the analysisfeatureprop table
-   $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));
-
-   // Get xml string from analysisfeatureprop value column
-   $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)) {
-      // get the HTML content for viewing each of the XML file
-      while ($analysisfeatureprop = db_fetch_object($result)) {
-         $content .= $analysisfeatureprop->afpvalue;
-      }
-   }
-   return $content;
-}
-
-/*******************************************************************************
- * Tripal Interpro administrative setting form. This function is called by
- * tripal_analysis module which asks for an admin form to show on the page
- */
-function tripal_analysis_interpro_get_settings() {
-	// Get an array of node types with internal names as keys
-	$options = node_get_types('names');
-	// Add 'chado_feature' to allowed content types for showing interpro results
-	$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;
-}
-
-/*******************************************************************************
- * Set the permission types that the chado module uses.  Essentially we
- * want permissionis that protect creation, editing and deleting of chado
- * data objects
- */
-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',
-   );
-}
-
-/*******************************************************************************
- *  The following function proves access control for users trying to
- *  perform actions on data managed by this module
- */
-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;
-}
-
-/**
- *
- *
- * @ingroup tripal_analysis_interpro
- */
-function tripal_analysis_interpro_job_describe_args($callback,$args){
-
-
-   $new_args = array();
-   if($callback == 'tripal_analysis_interpro_parseXMLFile'){
-
-      // add in the analysis 
-      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;
-}
-
-
-/*******************************************************************************
- * Parsing Interpro HTML results that are stored in analysisfeatureprop for 
- * searching 
- * */
-function tripal_analysis_interpro_extract_keywords ($analysis_id) {	
-	
-	// Remove previously stored interpro keywords for this analysis
-	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);
-	// Define what to be extracted in the array
-	$search = array (
-							"'SEQUENCE:.*'",
-							"'CRC64:.*'",
-							"'LENGTH:.*'",
-							"'unintegrated'",
-							"'noIPR'",
-							"'<td>seg</td>'",
-							"'<b>InterPro<br/>'",
-							"'<br/>Domain|Family\n'",
-							"'<td>no description</td>'",
-                 		"'<[/!]*?[^<>]*?>'si",          // replace HTML tags with a space
-							"'\n'", // replace newlines with a space
-	);
-	$replace = array (
-								"",
-								"",
-								"",
-								"",
-								"",
-								"",
-								"",
-								"", 
-								"",
-					  			" ",
-                 			" ",
-	);
-	while ($record = db_fetch_object($results)) {
-		$af_id = $record->analysisfeature_id;
-		$value = $record->value;
-
-		// Retrive keywords for this analysisfeature_id if there is any
-		$sql = "SELECT value FROM {analysisfeatureprop} WHERE analysisfeature_id =$af_id AND type_id = $keyword_type_id";
-		$keywords = db_result(chado_query($sql));
-		
-		// Extract new keywords from the interpro html output
-		$text = preg_replace($search, $replace, $value); 
-		$new_keywords = trim(ereg_replace(' +', ' ', $text)); // remove extra spaces
-		
-		// Append the new keywords 
-		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 {
-			// Insert the keyword into the analysisfeatureprop table
-			$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";
-	
-}

+ 0 - 101
extensions/tripal_analysis_kegg/node-chado_analysis_kegg.tpl.php

@@ -1,101 +0,0 @@
-<?php
-// Purpose: This template provides the layout of the organism node (page)
-//   using the same templates used for the various feature content blocks.
-//
-// To Customize the Featture Node Page:
-//   - This Template: customize basic layout and which elements are included
-//   - Using Panels: Override the node page using Panels3 and place the blocks
-//       of content as you please. This method requires no programming. See
-//       the Tripal User Guide for more details
-//   - Block Templates: customize the content/layout of each block of stock 
-//       content. These templates are found in the tripal_stock subdirectory
-//
-// Variables Available:
-//   - $node: a standard object which contains all the fields associated with
-//       nodes including nid, type, title, taxonomy. It also includes stock
-//       specific fields such as stock_name, uniquename, stock_type, synonyms,
-//       properties, db_references, object_relationships, subject_relationships,
-//       organism, etc.
-//   NOTE: For a full listing of fields available in the node object the
-//       print_r $node line below or install the Drupal Devel module which 
-//       provides an extra tab at the top of the node page labelled Devel
-?>
-
-<?php
- //uncomment this line to see a full listing of the fields avail. to $node
- //print '<pre>'.print_r($variables,TRUE).'</pre>';
-drupal_add_css('./tripal-node-templates.css');
-$node = $variables['node'];
-$organism = $variables['node']->organism;
-?>
-
-<?php if ($teaser) { 
-  include(drupal_get_path('module', 'tripal_analysis_kegg') . '/theme/tripal_analysis_kegg/tripal_analysis_kegg_teaser.tpl.php'); 
-} else { ?>
-
-<script type="text/javascript">
-if (Drupal.jsEnabled) {
-   $(document).ready(function() {
-      // hide all tripal info boxes at the start
-      $(".tripal-info-box").hide();
- 
-      // iterate through all of the info boxes and add their titles
-      // to the table of contents
-      $(".tripal-info-box-title").each(function(){
-        var parent = $(this).parent();
-        var id = $(parent).attr('id');
-        var title = $(this).text();
-        $('#tripal_analysis_kegg_toc_list').append('<li><a href="#'+id+'" class="tripal_analysis_kegg_toc_item">'+title+'</a></li>');
-      });
-
-      // when a title in the table of contents is clicked, then
-      // show the corresponding item in the details box
-      $(".tripal_analysis_kegg_toc_item").click(function(){
-         $(".tripal-info-box").hide();
-         href = $(this).attr('href');
-         $(href).fadeIn('slow');
-         // we want to make sure our table of contents and the details
-         // box stay the same height
-         $("#tripal_analysis_kegg_toc").height($(href).parent().height());
-         return false;
-      }); 
-
-      // we want the base details to show up when the page is first shown 
-      // unless the user specified a specific block
-      var block = window.location.href.match(/[\?|\&]block=(.+?)\&/)
-      if(block == null){
-         block = window.location.href.match(/[\?|\&]block=(.+)/)
-      }
-      if(block != null){
-         $("#tripal_analysis_kegg-"+block[1]+"-box").show();
-      } else {
-         $("#tripal_analysis_kegg-base-box").show();
-      }
-      
-      // make the height of the table of contents match the height of the details box
-      $("#tripal_analysis_kegg_toc").height($("#tripal_analysis_kegg-base-box").parent().height());
-      
-   });
-}
-</script>
-
-
-<div id="tripal_analysis_kegg_details" class="tripal_details">
-
-   <!-- Basic Details Theme -->
-   <?php include(drupal_get_path('module', 'tripal_analysis_kegg') . '/theme/tripal_analysis_kegg/tripal_analysis_kegg_base.tpl.php'); ?>
-   <?php include(drupal_get_path('module', 'tripal_analysis_kegg') . '/theme/tripal_analysis_kegg/tripal_analysis_kegg_report.tpl.php'); ?>
-
-   <?php print $content ?>
-</div>
-
-<!-- Table of contents -->
-<div id="tripal_analysis_kegg_toc" class="tripal_toc">
-   <div id="tripal_analysis_kegg_toc_title" class="tripal_toc_title">Resources</i></div>
-   <span id="tripal_analysis_kegg_toc_desc" class="tripal_toc_desc"></span>
-   <ul id="tripal_analysis_kegg_toc_list" class="tripal_toc_list">
-
-   </ul>
-</div>
-
-<?php } ?>

+ 0 - 46
extensions/tripal_analysis_kegg/theme/css/tripal_analysis_kegg.css

@@ -1,46 +0,0 @@
-/*
- Copyright 2009 Clemson University
-*/
-
-.tripal_kegg-info-box, .tripal_kegg_summary-info-box {
-   margin-top: 10px;
-   margin-left: 0px;
-   margin-right: 0px;
-   margin-bottom: 0px;
-   padding-top: 0px;
-   padding-left: 0px;
-   padding-bottom: 0px;
-   padding-right: 0px;
-   border-collapse: collapse;
-   z-index: 10;
-}
-
-.tripal_kegg_brite_terms {
-   line-height: 170%;
-   text-align: left;
-}
-
-#tripal_kegg_brite_hierarchy {
-   border-collapse: separate;
-}
-
-#tripal_kegg_brite_links {
-   background-image:url("../images/kegg.gif");/*TODO: figure out what to do about images in tripal extensions*/
-   background-repeat: no-repeat;
-   padding-left:20px;
-}
-
-#tripal_kegg_feature_links {
-   background-image:none;
-   background-repeat: no-repeat;
-   padding:0px 0px 0px 0px;
-}
-
-.tripal_kegg_results_table #tripal_kegg_brite_links {
-   padding: 0px 0px 0px 22px;
-}
-
-#tripal_kegg_brite_results {
-   height: 600px;
-   overflow: auto;   
-}

binární
extensions/tripal_analysis_kegg/theme/images/kegg.gif


+ 0 - 162
extensions/tripal_analysis_kegg/theme/js/tripal_analysis_kegg.js

@@ -1,162 +0,0 @@
-
-
-if (Drupal.jsEnabled) {
-   $(document).ready(function() {
-
-       // Select default KEGG analysis when available
-       var selectbox = $('#edit-tripal-analysis-kegg-select');
-       if(selectbox.length > 0){ 
-    	   var option = document.getElementById("analysis_id_for_kegg_report");
-    	   if (option) {
-    		   var options = document.getElementsByTagName('option');
-    		   var index = 0;
-    		   for (index = 0; index < options.length; index ++) {
-    			   if (options[index].value == option.value) {
-    				   break;
-    			   }
-    		   }
-    		   selectbox[0].selectedIndex = index;
-    		   var baseurl = tripal_get_base_url();
-    		   tripal_analysis_kegg_org_report(option.value, baseurl);
-    		// Otherwise, show the first option by default
-    	   } else {
-    		   selectbox[0].selectedIndex = 1;
-    		   selectbox.change();
-    	   }
-       }
-
-   });
-
-   //------------------------------------------------------------
-   function tripal_analysis_kegg_org_report(item,baseurl,themedir){
-      if(!item){
-         $("#tripal_analysis_kegg_org_report").html('');
-         return false;
-      }
-      // Form the link for the following ajax call  
-      var link = baseurl + "/";
-      if(!isClean){
-         link += "?q=";
-      }
-      link += 'tripal_analysis_kegg_org_report/' + item;
-
-      tripal_startAjax();
-      $.ajax({
-           url: link,
-           dataType: 'json',
-           type: 'POST',
-           success: function(data){
-             $("#tripal_analysis_kegg_org_report").html(data[0]);
-             $(".tripal_kegg_brite_tree").attr("id", function(){
-                init_kegg_tree($(this).attr("id"));    
-             });
-             tripal_stopAjax();
-           }
-      });
-      return false;
-   }
-   
-   //------------------------------------------------------------
-   // Update the BRITE hierarchy based on the user selection
-   function tripal_update_brite(link,type_id){
-      tripal_startAjax();
-      $.ajax({
-         url: link.href,
-         dataType: 'json',
-         type: 'POST',
-         success: function(data){
-            $("#tripal_kegg_brite_hierarchy").html(data.update);
-            $("#tripal_kegg_brite_header").html(data.brite_term);
-            tripal_stopAjax();
-            init_kegg_tree(data.id);
-         }
-      });
-      return false;
-   }
-
-   //------------------------------------------------------------
-   // This function initializes a KEGG term tree
-   function init_kegg_tree(id){
-
-      // Form the link for the following ajax call
-      var theme_path = baseurl + '/' + themedir + "/js/jsTree/source/themes/";
-	   
-      $("#" + id).tree ({
-	    data    : {
-	        type    : "predefined", // ENUM [json, xml_flat, xml_nested, predefined]
-	        method  : "GET",        // HOW TO REQUEST FILES
-	        async   : false,        // BOOL - async loading onopen
-	        async_data : function (NODE) { return { id : $(NODE).attr("id") || 0 } }, // PARAMETERS PASSED TO SERVER
-	        url     : false,        // FALSE or STRING - url to document to be used (async or not)
-	        json    : false,        // FALSE or OBJECT if type is JSON and async is false - the tree dump as json
-	        xml     : false         // FALSE or STRING
-	    },
-        ui      : {
-           dots        : true,     // BOOL - dots or no dots
-           rtl         : false,    // BOOL - is the tree right-to-left
-           animation   : 0,        // INT - duration of open/close animations in miliseconds
-           hover_mode  : true,     // SHOULD get_* functions chage focus or change hovered item
-           scroll_spd  : 4,
-           theme_path  : theme_path,    // Path to themes
-           theme_name  : "classic",// Name of theme
-        },
-
-        rules   : {
-           multiple    : false,    // FALSE | CTRL | ON - multiple selection off/ with or without holding Ctrl
-           metadata    : false,    // FALSE or STRING - attribute name (use metadata plugin)
-           type_attr   : "rel",    // STRING attribute name (where is the type stored if no metadata)
-           multitree   : false,    // BOOL - is drag n drop between trees allowed
-           createat    : "bottom", // STRING (top or bottom) new nodes get inserted at top or bottom
-           use_inline  : false,    // CHECK FOR INLINE RULES - REQUIRES METADATA
-           clickable   : "all",    // which node types can the user select | default - all
-           renameable  : false,    // which node types can the user select | default - all
-           deletable   : false,    // which node types can the user delete | default - all
-           creatable   : false,    // which node types can the user create in | default - all
-           draggable   : "none",   // which node types can the user move | default - none | "all"
-           dragrules   : "all",    // what move operations between nodes are allowed | default - none | "all"
-           drag_copy   : false,    // FALSE | CTRL | ON - drag to copy off/ with or without holding Ctrl
-           droppable   : [],
-           drag_button : "left"
-        },
-
-        callback    : {             // various callbacks to attach custom logic to
-           // before focus  - should return true | false
-           beforechange: function(NODE,TREE_OBJ) { return true },
-           beforeopen  : function(NODE,TREE_OBJ) { return true },
-           beforeclose : function(NODE,TREE_OBJ) { return true },
-           // before move   - should return true | false
-           beforemove  : function(NODE,REF_NODE,TYPE,TREE_OBJ) { return true }, 
-           // before create - should return true | false
-           beforecreate: function(NODE,REF_NODE,TYPE,TREE_OBJ) { return true }, 
-           // before rename - should return true | false
-           beforerename: function(NODE,LANG,TREE_OBJ) { return true }, 
-           // before delete - should return true | false
-           beforedelete: function(NODE,TREE_OBJ) { return true }, 
-
-           onJSONdata  : function(DATA,TREE_OBJ) { return DATA; },
-           onselect    : function(NODE,TREE_OBJ) {        	   
-               window.onerror = function(){return true;};
-        	   throw 'exit';
-        	},                  // node selected
-           ondeselect  : function(NODE,TREE_OBJ) { },                  // node deselected
-           onchange    : function(NODE,TREE_OBJ) { },                  // focus changed
-           onrename    : function(NODE,LANG,TREE_OBJ,RB) { },              // node renamed ISNEW - TRUE|FALSE, current language
-           onmove      : function(NODE,REF_NODE,TYPE,TREE_OBJ,RB) { }, // move completed (TYPE is BELOW|ABOVE|INSIDE)
-           oncopy      : function(NODE,REF_NODE,TYPE,TREE_OBJ,RB) { }, // copy completed (TYPE is BELOW|ABOVE|INSIDE)
-           oncreate    : function(NODE,REF_NODE,TYPE,TREE_OBJ,RB) { }, // node created, parent node (TYPE is createat)
-           ondelete    : function(NODE, TREE_OBJ,RB) { },                  // node deleted
-           onopen      : function(NODE, TREE_OBJ) { },                 // node opened
-           onopen_all  : function(TREE_OBJ) { },                       // all nodes opened
-           onclose     : function(NODE, TREE_OBJ) { },                 // node closed
-           error       : function(TEXT, TREE_OBJ) { },                 // error occured
-           // double click on node - defaults to open/close & select
-           ondblclk    : function(NODE, TREE_OBJ) { TREE_OBJ.toggle_branch.call(TREE_OBJ, NODE); TREE_OBJ.select_branch.call(TREE_OBJ, NODE); },
-           // right click - to prevent use: EV.preventDefault(); EV.stopPropagation(); return false
-           onrgtclk    : function(NODE, TREE_OBJ, EV) { },
-           onload      : function(TREE_OBJ) { },
-           onfocus     : function(TREE_OBJ) { },
-           ondrop      : function(NODE,REF_NODE,TYPE,TREE_OBJ) {}
-        }
-      });
-   }
-}

+ 0 - 53
extensions/tripal_analysis_kegg/theme/tripal_analysis_kegg/tripal_analysis_kegg_base.tpl.php

@@ -1,53 +0,0 @@
-<?php
-$node = $variables['node'];
-$analysis = $variables['node']->analysis;
-
-// the description is a text field so we want to expand that
-$analysis = tripal_core_expand_chado_vars($analysis,'field','analysis.description');
-
-
-?>
-<div id="tripal_analysis_kegg-base-box" class="tripal_analysis_kegg-info-box tripal-info-box">
-  <div class="tripal_analysis_kegg-info-box-title tripal-info-box-title">KEGG Analysis Details</div>
-   <table id="tripal_analysis_kegg-table-base" class="tripal_analysis_kegg-table tripal-table tripal-table-vert">
-      <tr class="tripal_analysis_kegg-table-odd-row tripal-table-even-row">
-        <th>Analysis Name</th>
-        <td><?php print $analysis->name; ?></td>
-      </tr>
-      <tr class="tripal_analysis_kegg-table-odd-row tripal-table-odd-row">
-        <th nowrap>Software</th>
-        <td><?php 
-          print $analysis->program; 
-          if($analysis->programversion){
-             print " (" . $analysis->programversion . ")"; 
-          }
-          if($analysis->algorithm){
-             print ". " . $analysis->algorithm; 
-          }
-          ?>
-        </td>
-      </tr>
-      <tr class="tripal_analysis_kegg-table-odd-row tripal-table-even-row">
-        <th nowrap>Source</th>
-        <td><?php 
-          if($analysis->sourceuri){
-             print "<a href=\"$analysis->sourceuri\">$analysis->sourcename</a>"; 
-          } else {
-             print $analysis->sourcename; 
-          }
-          if($analysis->sourceversion){
-             print " (" . $analysis->sourceversion . ")"; 
-          }
-          ?>
-          </td>
-      </tr>
-      <tr class="tripal_analysis_kegg-table-odd-row tripal-table-odd-row">
-        <th nowrap>Date performed</th>
-        <td><?php print preg_replace("/^(\d+-\d+-\d+) .*/","$1",$analysis->timeexecuted); ?></td>
-      </tr>
-      <tr class="tripal_analysis_kegg-table-odd-row tripal-table-even-row">
-        <th nowrap>Description</th>
-        <td><?php print $analysis->description; ?></td>
-      </tr>             	                                
-   </table>   
-</div>

+ 0 - 11
extensions/tripal_analysis_kegg/theme/tripal_analysis_kegg/tripal_analysis_kegg_report.tpl.php

@@ -1,11 +0,0 @@
-<?php
-$analysis = $node->analysis;
-$report = $analysis->tripal_analysis_kegg->kegg_report;
-//dpm($analysis);
-?>
-
-<div id="tripal_analysis_kegg-report-box" class="tripal_analysis_kegg-box tripal-info-box">
-  <div class="tripal_analysis_kegg-info-box-title tripal-info-box-title">KEGG Report</div>
-  <div class="tripal_analysis_kegg-info-box-desc tripal-info-box-desc"><?php print $analysis->name ?></div>
-  <?php print $report ?>
-</div>

+ 0 - 53
extensions/tripal_analysis_kegg/theme/tripal_analysis_kegg/tripal_analysis_kegg_teaser.tpl.php

@@ -1,53 +0,0 @@
-<?php
-$node = $variables['node'];
-$analysis = $variables['node']->analysis;
-
-// the description is a text field so we want to expand that
-$analysis = tripal_core_expand_chado_vars($analysis,'field','analysis.description');
-
-
-?>
-<div id="tripal_analysis-base-box" class="tripal_analysis-info-box tripal-info-box">
-  <div class="tripal_analysis-info-box-title tripal-info-box-title">Details</div>
-   <table id="tripal_analysis-table-base" class="tripal_analysis-table tripal-table tripal-table-vert">
-      <tr class="tripal_analysis-table-odd-row tripal-table-even-row">
-        <th>Analysis Name</th>
-        <td><?php print $analysis->name; ?></td>
-      </tr>
-      <tr class="tripal_analysis-table-odd-row tripal-table-odd-row">
-        <th nowrap>Software</th>
-        <td><?php 
-          print $analysis->program; 
-          if($analysis->programversion){
-             print " (" . $analysis->programversion . ")"; 
-          }
-          if($analysis->algorithm){
-             print ". " . $analysis->algorithm; 
-          }
-          ?>
-        </td>
-      </tr>
-      <tr class="tripal_analysis-table-odd-row tripal-table-even-row">
-        <th nowrap>Source</th>
-        <td><?php 
-          if($analysis->sourceuri){
-             print "<a href=\"$analysis->sourceuri\">$analysis->sourcename</a>"; 
-          } else {
-             print $analysis->sourcename; 
-          }
-          if($analysis->sourceversion){
-             print " (" . $analysis->sourceversion . ")"; 
-          }
-          ?>
-          </td>
-      </tr>
-      <tr class="tripal_analysis-table-odd-row tripal-table-odd-row">
-        <th nowrap>Date performed</th>
-        <td><?php print preg_replace("/^(\d+-\d+-\d+) .*/","$1",$analysis->timeexecuted); ?></td>
-      </tr>
-      <tr class="tripal_analysis-table-odd-row tripal-table-even-row">
-        <th nowrap>Description</th>
-        <td><?php print $analysis->description; ?></td>
-      </tr>             	                                
-   </table>   
-</div>

+ 0 - 46
extensions/tripal_analysis_kegg/theme/tripal_feature/tripal_feature_kegg_terms.tpl.php

@@ -1,46 +0,0 @@
-<?php
-
-$feature  = $variables['node']->feature;
-$results = $feature->tripal_analysis_kegg->results;
-
-if($feature->cvname != 'gene' and count($results) > 0){ 
-   $i = 0;
-   foreach($results as $analysis_id => $analysisprops){ 
-     $analysis = $analysisprops['analysis'];
-     $terms = $analysisprops['terms']; 
-     ?>
-     <div id="tripal_feature-kegg_results_<?php print $i?>-box" class="tripal_analysis_kegg-box tripal-info-box">
-        <div class="tripal_feature-info-box-title tripal-info-box-title">KEGG Report <?php print preg_replace("/^(\d+-\d+-\d+) .*/","$1",$analysis->timeexecuted); ?></div>
-        <div class="tripal_feature-info-box-desc tripal-info-box-desc"><?php 
-            if($analysis->nid){ ?>
-               Analysis name: <a href="<?php print url('node/'.$analysis->nid) ?>"><?php print $analysis->name?></a><?php
-            } else { ?>
-               Analysis name: <?php print $analysis->name;
-            } ?><br>
-            Date Performed: <?php print preg_replace("/^(\d+-\d+-\d+) .*/","$1",$analysis->timeexecuted); ?>
-        </div>
-
-     <div class="tripal_feature-kegg_results_subtitle">Annotated Terms</div>
-     <table id="tripal_feature-kegg_summary-<?php $i ?>-table" class="tripal_analysis_kegg-summary-table tripal-table tripal-table-horz">
-     <?php 
-     $j=0;
-     foreach($terms as $term){ 
-       $ipr_id = $term[0];
-       $ipr_name = $term[1];
-       $class = 'tripal_feature-table-odd-row tripal-table-odd-row';
-       if($j % 2 == 0 ){
-         $class = 'tripal_feature-table-even-row tripal-table-even-row';
-       }?>
-       <tr class="<?php print $class ?>">
-         <td><?php print $term ?></td>
-       </tr>
-       <?php
-       $j++;
-     } ?>
-     </table>     
-     </div> <?php
-     $i++;
-   } // end for each analysis 
-} // end if
-?>
-

+ 0 - 22
extensions/tripal_analysis_kegg/theme/tripal_organism/tripal_organism_kegg_summary.tpl.php

@@ -1,22 +0,0 @@
-<?php
-  $organism = $node->organism;
-  $form = $organism->tripal_analysis_kegg->select_form['form'];
-  $has_results = $organism->tripal_analysis_kegg->select_form['has_results'];
-?>
-<div id="tripal_organism-kegg_summary-box" class="tripal_organism-info-box tripal-info-box">
-  <div  class="tripal_organism-info-box-title tripal-info-box-title">KEGG Analysis Reports</div>
-  <?php 
-     if($has_results){
-        print $form;
-     } else {
-       ?><div class="tripal-no-results">There are no KEGG reports available</div><?php
-     }
-  ?>
-   <div id="tripal_analysis_kegg_org_report"></div>
-   <div id="tripal_ajaxLoading" style="display:none">
-     <div id="loadingText">Loading...</div>
-   </div>   
-</div>
-
-
-

+ 0 - 10
extensions/tripal_analysis_kegg/tripal_analysis_kegg.info

@@ -1,10 +0,0 @@
-; $Id: tripal_analysis_kegg.info,v 1.2 2009/10/23 02:12:27 ccheng Exp $
-name = Tripal Kegg
-description = An analysis sub-module for adding, editing, and displaying KEGG/KAAS analysis results.
-core = 6.x
-project = tripal_analysis_kegg
-package = Tripal Extensions
-dependencies[] = tripal_core
-dependencies[] = tripal_feature
-dependencies[] = tripal_analysis
-

+ 0 - 106
extensions/tripal_analysis_kegg/tripal_analysis_kegg.install

@@ -1,106 +0,0 @@
-<?php
-
-/*******************************************************************************
-*  Implementation of hook_install();
-*/
-function tripal_analysis_kegg_install(){
-   // create the module's data directory
-   tripal_create_moddir('tripal_analysis_kegg');
-   
-   // We need to register to tripal_analysis module so it can provide a control
-   // for our kegg result. Basically the registration is done by inserting
-   // modulename into the drupal {tripal_analysis} table AND inserting required
-   // information to the chado Analysis table. Also in tripal_analysis_interpro.module,
-   // we need to define HOOK_get_settings() for the module to work properly.
-   
-   // Inert into drupal's {tripal_analysis}
-   tripal_analysis_register_child('tripal_analysis_kegg');
-   
-   // add the cvterms needed for this module
-   tripal_analysis_kegg_add_cvterms ();
-
-   // add the db and the cv for the KEGG terms
-   tripal_add_db('KEGG','KEGG: Kyoto Encyclopedia of Genes and Genomes.',
-      'http://www.genome.jp',
-      'http://www.genome.jp/kegg/');
-
-  tripal_add_mview(
-      // view name
-      'kegg_by_organism',
-      // tripal module name
-      'kegg_by_organism',
-      // table name
-      'kegg_by_organism',
-      // table schema definition
-      'analysis_name character varying(255),
-       analysis_id integer,
-       organism_id integer',
-      // columns for indexing
-      'analysis_id,organism_id',
-      // SQL statement to populate the view
-      "SELECT DISTINCT A.name,A.analysis_id,F.organism_id
-       FROM {analysisprop} AP
-          INNER JOIN analysis A on A.analysis_id = AP.analysis_id
-          INNER JOIN cvterm CVT on CVT.cvterm_id = AP.type_id
-          INNER JOIN analysisfeature AF on AF.analysis_id = A.analysis_id
-          INNER JOIN feature F on F.feature_id = AF.feature_id
-       WHERE CVT.name = 'analysis_kegg_settings'",
-      // special index
-      ''
-   );
-}
-/*******************************************************************************
- * Provide update script for adding new cvterms
- */
-function tripal_analysis_kegg_update_6000(){
-
-   // we have some new cvterms to add
-   tripal_analysis_kegg_add_cvterms();
-
-   $ret = array(
-      '#finished' => 1,
-   );
-   
-   return $ret;
-}
-/**
-*
-*/
-function tripal_analysis_kegg_add_cvterms () {
-   tripal_add_cvterms('analysis_kegg_settings', 'Settings of a KEGG analysis, Currently include only the heir.tar.gz file name & path.');
-   tripal_add_cvterms('kegg_brite_data', 'This term is intended for use in the analysisfeatureprop table to store the KAAS results data.');
-   tripal_add_cvterms('analysis_kegg_query_re','The regular expression for finding the feature name in the query definition line of the blast results');
-   tripal_add_cvterms('analysis_kegg_query_type','The feature type (e.g. mRNA, polypeptide) of the query input file. This type is used to identify the query feature when multiple features have the same name');
-   tripal_add_cvterms('analysis_kegg_query_uniquename','Indicates if the matched name in the query definition line of the blast results is feature uniquename');
-   tripal_add_cvterms('analysis_kegg_output_keywords', 'Selected keywords for kegg html output which are indexed for search.');
-}
-/*******************************************************************************
-* Implementation of hook_uninstall()
-*/
-function tripal_analysis_kegg_uninstall(){
-//   tripal_delete_db('KEGG');
-   tripal_analysis_unregister_child('tripal_analysis_kegg');
-
-   $mview = tripal_mviews_get_mview_id('kegg_by_organism');
-   if($mview){
-	   tripal_mviews_action('delete',$mview);
-	}
-}
-
-/*******************************************************************************
- * Implementation of hook_requirements(). Make sure 'Tripal Core' and 'Tripal
- * Analysis' are enabled before installation
- */
-function tripal_analysis_kegg_requirements($phase) {
-   $requirements = array();
-   if ($phase == 'install') {
-      if (!function_exists('tripal_create_moddir') || !function_exists('tripal_analysis_register_child')) {
-         $requirements ['tripal_analysis_kegg'] = array(
-            'title' => "tripal_analysis_kegg",
-            'value' => "error. Some required modules are just being installed. Please try again.",
-            'severity' => REQUIREMENT_ERROR,
-         );
-      }
-   }
-   return $requirements;
-}

+ 0 - 1302
extensions/tripal_analysis_kegg/tripal_analysis_kegg.module

@@ -1,1302 +0,0 @@
-<?php
-
-
-/*******************************************************************************
- *
- ******************************************************************************/
-
-function tripal_analysis_kegg_init(){
-   // add the tripal_analysis_kegg JS and CSS
-   drupal_add_js(drupal_get_path('module', 'tripal_analysis_kegg').'/theme/js/tripal_analysis_kegg.js');
-   drupal_add_css(drupal_get_path('module', 'tripal_analysis_kegg').'/theme/css/tripal_analysis_kegg.css', 'theme');
-   // add the jsTree JS and CSS
-   drupal_add_css(drupal_get_path('theme', 'tripal').'/js/jsTree/source/tree_component.css', 'theme');
-   drupal_add_js (drupal_get_path('theme', 'tripal').'/js/jsTree/source/_lib.js');
-   drupal_add_js (drupal_get_path('theme', 'tripal').'/js/jsTree/source/tree_component.js');
-}
-/*******************************************************************************
- *  Provide information to drupal about the node types that we're creating
- *  in this module
- */
-function tripal_analysis_kegg_node_info() {
-   $nodes = array();
-   $nodes['chado_analysis_kegg'] = array(
-      'name' => t('Analysis: KEGG'),
-      'module' => 'chado_analysis_kegg',
-      'description' => t('Results from a KEGG/KAAS analysis'),
-      'has_title' => FALSE,
-      'title_label' => t('Analysis: KEGG'),
-      'has_body' => FALSE,
-      'body_label' => t('KEGG Analysis Description'),
-      'locked' => TRUE
-   );
-   return $nodes;
-}
-
-/*******************************************************************************
- * Menu items are automatically added for the new node types created
- * by this module to the 'Create Content' Navigation menu item.  This function
- * adds more menu items needed for this module.
- */
-function tripal_analysis_kegg_menu() {
-   $items['brite/%'] = array(
-     'title' => t('KEGG BRITE'),
-     'page callback' => 'tripal_analysis_kegg_brite',
-     'page arguments' => array(1, 2),
-     'access arguments' => array('access content'),
-     'type' => MENU_CALLBACK
-   );
-   $items['tripal_analysis_kegg_org_report/%'] = array(
-      'path' => 'tripal_analysis_kegg_org_report',
-      'title' => t('Analysis KEGG report'),
-      'page callback' => 'tripal_analysis_kegg_org_report',
-      'page arguments' => array(1),
-      'access arguments' => array('access chado_analysis_kegg content'),
-      'type' => MENU_CALLBACK
-   );
-   return $items;
-}
-/*******************************************************************************
- * Set the permission types that the chado module uses.  Essentially we
- * want permissionis that protect creation, editing and deleting of chado
- * data objects
- */
-function tripal_analysis_kegg_perm(){
-   return array(
-      'access chado_analysis_kegg content',
-      'create chado_analysis_kegg content',
-      'delete chado_analysis_kegg content',
-      'edit chado_analysis_kegg content',
-   );
-}
-
-/*******************************************************************************
- *  The following function proves access control for users trying to
- *  perform actions on data managed by this module
- */
-function chado_analysis_kegg_access($op, $node, $account){
-	if ($op == 'create') {
-		if(!user_access('create chado_analysis_kegg content', $account)){
-			return FALSE;
-      }
-	}
-	if ($op == 'update') {
-		if (!user_access('edit chado_analysis_kegg content', $account)) {
-			return FALSE;
-		}
-	}
-	if ($op == 'delete') {
-		if (!user_access('delete chado_analysis_kegg content', $account)) {
-			return FALSE;
-		}
-	}
-	if ($op == 'view') {
-		if(!user_access('access chado_analysis_kegg content', $account)){
-         return FALSE;
-      }
-	}
-   return NULL;
-}
-
-/*******************************************************************************
- */
-function tripal_analysis_kegg_brite($analysis_id, $type_id, $ajax){
-   global $base_url;
-   $theme_dir = drupal_get_path('theme','tripal');
-   // If not called by ajax
-   if (!$ajax) {
-      $content .=  
-        "<div id=\"tripal_kegg_brite_results\" class=\"tripal_kegg_brite-info-box\">
-          <table>
-            <tr>
-              <th>KEGG BRITE</th>
-              <th id=\"tripal_kegg_brite_header\">Hierarchy:</th>
-            </tr>
-            <tr>
-              <td nowrap valign=\"top\">
-      ";
-      // List all BRITE terms on the left
-      $sql = "SELECT DISTINCT CVT.name, CVT.cvterm_id
-              FROM {cvterm} CVT 
-                INNER JOIN analysisprop AP ON CVT.cvterm_id = AP.type_id
-              WHERE AP.analysis_id = %d AND CVT.definition LIKE 'KEGG BRITE term: %'
-              ORDER BY CVT.cvterm_id";
-      $previous_db = tripal_db_set_active('chado');
-      $result = db_query($sql, $analysis_id);
-      tripal_db_set_active($previous_db);
-      while ($brite_term = db_fetch_object($result)) {
-         $url = url("brite/$analysis_id/$brite_term->cvterm_id/1");
-         $content .= "<li class=\"tripal_kegg_brite_terms\"><a onclick=\"return tripal_update_brite(".
-                   "this,$brite_term->cvterm_id,'$base_url','$theme_dir')\" href=\"$url\">
-                   $brite_term->name
-                   </a></li>";
-      }
-      // Show the hierarchy tree
-      $content .="</td>
-                  <td nowrap id=\"tripal_kegg_brite_hierarchy\" valign=\"top\">";
-      $content .= "<i>Note:</i> Click a BRITE term for its functional hierarchy";
-      
-   // If called by ajax, generate tree structure
-   } else {
-      // Get BRITE term from cvterm table
-      $previous_db = tripal_db_set_active('chado');
-      $sql = 'SELECT name FROM {cvterm} WHERE cvterm_id=%d';
-      $brite_term = db_result(db_query($sql, $type_id));
-
-      // Get BRITE hierarchy tree
-      $sql = "SELECT value
-           FROM {analysisprop} AP
-             INNER JOIN CVterm CVT on AP.type_id = CVT.cvterm_id
-             INNER JOIN CV on CVT.cv_id = CV.cv_id
-           WHERE CV.name = 'tripal' and CVT.name = '%s' 
-           AND AP.analysis_id = %d";
-
-      $result = db_fetch_object(db_query($sql, $brite_term, $analysis_id));
-      tripal_db_set_active($previous_db);
-      $content .= "<div class=\"tripal_kegg_brite_tree\" id=\"tripal_kegg_brite_tree_$type_id\">$result->value</div>";
-   }
-    
-   if (!$ajax) {
-            $content .= "     </td>
-                            </tr>
-                          </table>
-                      </div>";
-   }
-   // since this function provides output for addition into
-   // an analysis page, as well as an AJAX refresh of content
-   // within the BRITE hierarchy we need to setup the return
-   // different depending on the request type
-   if($ajax){
-      drupal_json(array('update' => $content,
-      					   'id' => "tripal_kegg_brite_tree_$type_id",
-                        'brite_term' => "Hierarchy: $brite_term"));
-   } else {
-      return $content;
-   }
-}
-
-/*******************************************************************************
- *  Provide a KEGG Analysis form
- */
-function chado_analysis_kegg_form ($node){
-   // add in the default fields
-   $form = chado_analysis_form($node);
-
-   // set the defaults
-   $kegg = $node->analysis->tripal_analysis_kegg;
-   $query_re = $kegg->query_re;
-   $query_type = $kegg->query_type;
-   $query_uniquename = $kegg->query_uniquename;
-
-   $hierfile = $kegg->hierfile;
-
-   $moreSettings ['kegg'] = 'KEGG Analysis Settings';
-   $form['kegg'] = array(
-      '#title' => t('KEGG Settings'),
-      '#type' => 'fieldset',
-      '#description' => t('Specific Settings for KEGG Analysis.'),
-      '#collapsible' => TRUE,
-      '#attributes' => array('id' => 'kegg-extra-settings'),
-      '#weight' => 11
-   );
-   $form['kegg']['hierfile'] = array(
-      '#title' => t('KAAS hier.tar.gz Output File'),
-      '#type' => 'textfield',
-      '#description' => t('The full path to the hier.tar.gz file generated by KAAS. 
-                           Alternatively, you can input the full path to the directory
-                           that contains decompressed kegg files.'),
-      '#default_value' => $hierfile,
-   );
-	$form['kegg']['query_re'] = array(
-      '#title' => t('Query Name RE'),
-      '#type' => 'textfield',
-      '#description' => t('Enter the regular expression that will extract the '.
-         'feature name from the results line in the KEGG heir results. This will be '.
-         'the same as the definition line in the query FASTA file used for the analysis.  This option is '.
-         'is only required when the query does not identically match a feature '.
-         'in the database.'),
-      '#default_value' => $query_re,
-	);
-
-	$form['kegg']['query_type'] = array(
-      '#title' => t('Query Type'),
-      '#type' => 'textfield',
-      '#description' => t('Please enter the Sequence Ontology term that describes '.
-         'the query sequences used for KEGG.  This is only necessary if two '.
-         'or more sequences have the same name.'),
-      '#default_value' => $query_type,
-	);
-
-	$form['kegg']['query_uniquename'] = array(
-      '#title' => t('Use Unique Name'),
-      '#type' => 'checkbox',
-      '#description' => t('Select this checboxk if the feature name in the KEGG heir file '.
-        'matches the uniquename in the database.  By default, the feature will '.
-        'be mapped to the "name" of the feature.'),
-      '#default_value' => $query_uniquename,
-	);
-   $form['kegg']['keggjob'] = array(
-      '#type' => 'checkbox',
-      '#title' => t('Submit a job to parse the kegg output into Chado'),
-      '#description' => t('Note: features used in the KAAS analysis must '.
-                          'exist in chado before parsing the file. Otherwise, KEGG '.
-                          'results that cannot be linked to a feature will be '.
-                          'discarded.'),
-   );
-/*   $form['kegg']['keggkeywordjob'] = array(
-      '#type' => 'checkbox',
-      '#title' => t('Submit a job to extract keywords from the KEGG html output'),
-      '#description' => t('Note: KEGG results are only searchable after keywords are extracted.'),
-	);
-*/
-   return $form;
-}
-/**
-*
-*/
-function chado_analysis_kegg_validate($node, &$form){
-   // use the analysis parent to validate the node
-   tripal_analysis_validate($node, $form); 
-}
-/*******************************************************************************
- *
- */
-function chado_analysis_kegg_insert($node){
-   // insert the analysis
-   chado_analysis_insert($node);
-
-   // set the type for this analysis
-   tripal_analysis_insert_property($node->analysis_id,'analysis_type','tripal_analysis_kegg');
-
-   // now add in the remaining settings as a single property but separated by bars
-   tripal_analysis_insert_property($node->analysis_id,'analysis_kegg_settings',$node->hierfile);
-   tripal_analysis_insert_property($node->analysis_id,'analysis_kegg_query_re',$node->query_re);	
-   tripal_analysis_insert_property($node->analysis_id,'analysis_kegg_query_type',$node->query_type);	
-   tripal_analysis_insert_property($node->analysis_id,'analysis_kegg_query_uniquename',$node->query_uniquename);	
-     
-   // Add a job if the user wants to parse the html output
-   chado_analysis_kegg_submit_job($node);
-}
-/**
-*
-*/
-function chado_analysis_kegg_submit_job($node){
-   global $user;
-   global $base_url;
-
-   if($node->keggjob) {
-      $job_args[0] = $node->analysis_id;
-      $job_args[1] = $node->hierfile;
-      $job_args[2] = $base_url;
-      $job_args[3] = $node->query_re;
-      $job_args[4] = $node->query_type;
-      $job_args[5] = $node->query_uniquename;
-
-      if (is_readable($node->hierfile)) {
-      	$fname = preg_replace("/.*\/(.*)/", "$1", $node->hierfile);
-         tripal_add_job("Parse KAAS output: $fname",'tripal_analysis_kegg',
-                        'tripal_analysis_kegg_parseHierFile', $job_args, $user->uid);
-      } else {
-         drupal_set_message("Can not open KAAS hier.tar.gz output file. Job not scheduled.");
-      }
-   }
-	// Add a job if the user wants to the keywords from the HTML output
-	if ($node->keggkeywordjob) {
-		$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_kegg',
-                           'tripal_analysis_kegg_extract_keywords', $job_args, $user->uid);
-	}
-}
-/*******************************************************************************
- * Delete KEGG anlysis
- */
-function chado_analysis_kegg_delete($node){
-   chado_analysis_delete($node);
-}
-
-/*******************************************************************************
- * Update KEGG analysis
- */
-function chado_analysis_kegg_update($node){
-   // insert the analysis
-   chado_analysis_update($node);
-
-   // set the type for this analysis
-   tripal_analysis_update_property($node->analysis_id,'analysis_type','tripal_analysis_kegg',1);
-
-   // now add in the remaining settings as a single property but separated by bars
-   tripal_analysis_update_property($node->analysis_id,'analysis_kegg_settings',$node->hierfile,1);
-   tripal_analysis_update_property($node->analysis_id,'analysis_kegg_query_re',$node->query_re,1);	
-   tripal_analysis_update_property($node->analysis_id,'analysis_kegg_query_type',$node->query_type,1);	
-   tripal_analysis_update_property($node->analysis_id,'analysis_kegg_query_uniquename',$node->query_uniquename,1);	
-
-     
-   // Add a job if the user wants to parse the output
-   chado_analysis_kegg_submit_job($node);
-}
-/*******************************************************************************
- *  When a node is requested by the user this function is called to allow us
- *  to add auxiliary data to the node object.
- */
-function chado_analysis_kegg_load($node){
-
-   // load the default set of analysis fields
-	$additions = chado_analysis_load($node);
-
-   // create some variables for easier lookup
-   $analysis = $additions->analysis;
-   $analysis_id = $analysis->analysis_id;
-
-   // get the heirfile name
-   $hierfile        = tripal_analysis_get_property($analysis_id,'analysis_kegg_settings');	
-   $query_re        = tripal_analysis_get_property($analysis->analysis_id,'analysis_kegg_query_re');	
-   $query_type      = tripal_analysis_get_property($analysis->analysis_id,'analysis_kegg_query_type');	
-   $query_uniquename= tripal_analysis_get_property($analysis->analysis_id,'analysis_kegg_query_uniquename');	
-
-   $analysis->tripal_analysis_kegg->hierfile = $hierfile->value;
-   $analysis->tripal_analysis_kegg->query_re        = $query_re->value;	
-   $analysis->tripal_analysis_kegg->query_type      = $query_type->value;	
-   $analysis->tripal_analysis_kegg->query_uniquename= $query_uniquename->value;	
-
-   return $additions;
-}
-
-/**
-*
-*/
-function chado_analysis_kegg_view ($node, $teaser = FALSE, $page = FALSE) {
-   // use drupal's default node view:
-   if (!$teaser) {
-      $node = node_prepare($node, $teaser);
-      // When previewing a node submitting form, it shows 'Array' instead of
-      // correct date format. We need to format the date here
-      $time = $node->timeexecuted;
-      if(is_array($time)){
-         $month = $time['month'];
-         $day = $time['day'];
-         $year = $time['year'];
-         $timestamp = $year.'-'.$month.'-'.$day;
-         $node->timeexecuted = $timestamp;
-      }
-   }
-   return $node;
-}
-/********************************************************************************
- */
-function tripal_analysis_kegg_parseHierFile ($analysis_id, $hierfile, $base_path, 
-   $query_re,$query_type,$query_uniquename,$job_id) {
- 
-   // If user input a file (e.g. hier.tar.gz), decompress it first
-   if (is_file($hierfile)) {
-      // generate a unique directory name for extracting and parsing the file
-      $data_dir = sys_get_temp_dir() . "/" . uniqid();
-      mkdir($data_dir);
-      $stderr = shell_exec("cd $data_dir; tar -zxf $hierfile;");
-      print "$stderr\n";
-      $hierdir = $data_dir . "/hier";
-   } 
-   // Otherwise, treat it as a directory
-   else {
-      $hierdir = $hierfile;
-   }
-   $dir_handle = @opendir($hierdir) or die("Unable to open $hierdir");
-   $total_files = count(glob($hierdir . '/*.*'));
-   print "There are $total_files keg file(s).\n";
-   $interval = intval($total_files * 0.01);
-   if($interval > 1){
-      $interval = 1;
-   }
-   $no_file = 0;
-
-   // Remove the analysis features for this analysis
-   // we will rebuild them from just this parsing
-   $select =  array('analysis_id' => $analysis_id);
-   if(!tripal_core_chado_delete('analysisfeature',$select)){
-      print "ERROR: Unable to clear previous results.\n";
-      exit;
-   }
-
-   while ($file = readdir($dir_handle)) {
-
-      if(preg_match("/^.*\.keg/",$file)){
-         // Update the progress
-         if ($no_file % $interval == 0) {
-            $percentage = (int) ($no_file / $total_files * 100);
-            tripal_job_set_progress($job_id, $percentage);
-            print $percentage."%\r";
-         }
-         $no_file ++;
-         
-         # $heirarchy variable will be set in tripal_analysis_kegg_parse_kegg_file()
-         $results = tripal_analysis_kegg_parse_kegg_file("$hierdir/$file",$heirarchy,
-            $analysis_id, $base_path, $query_re,$query_type,$query_uniquename);
-
-         # add the item to the database
-         if(count($results) > 0){
-            print "Loading results for '$heirarchy'\n";
-            // We want to insert the KEGG heirarchy results into the
-            // analysisprop table. We insert a separate record for each 
-            // heirarchy.  But we need to clear out any prevous results first.
-            $sql = "DELETE
-                    FROM {analysisprop}
-                    WHERE analysis_id = %d
-                    AND type_id = (SELECT cvterm_id 
-                                   FROM {cvterm} CVT 
-                                   INNER JOIN CV ON CVT.cv_id = CV.cv_id
-                                   WHERE CV.name = 'tripal' AND CVT.name = '%s'
-                                   )
-                   ";
-
-            $previous_db = tripal_db_set_active('chado');
-            db_result(db_query($sql, $analysis_id, $heirarchy));
-            tripal_db_set_active($previous_db);
-            
-            	
-         	$previous_db = tripal_db_set_active('chado'); // Use chado database
-         	// Get type_id for the BRITE term
-         	$sql = "SELECT cvterm_id 
-                    FROM {cvterm} CVT 
-                    INNER JOIN CV ON CVT.cv_id = CV.cv_id
-                    WHERE CV.name = 'tripal' AND CVT.name = '%s'";
-         	$brite_cvterm_id = db_result(db_query($sql, $heirarchy)); 
-            if(!$brite_cvterm_id){
-               print "ERROR: Cannot find cvterm for '$heirarchy'.\n";
-               exit; 
-            }
-
-            // convert the array to text for saving in the database
-         	// Replace all single quote as HTML code before insert
-            $i = 0;
-            $content = '<ul>';
-            tripal_analysis_kegg_array2list($results,$content,$i);
-            $content .= '</ul>';
-         	$content = preg_replace("/\'/", "&#39;", $content);
-         	
-         	// Insert the value
-            $sql = "INSERT INTO {analysisprop} (analysis_id, type_id, value) 
-                    VALUES (%d, %d,'$content')";   
-            
-            if(!db_query($sql, $analysis_id, $brite_cvterm_id)){
-               print "ERROR: Cannot add '$heirarchy' results to the database.\n";
-               exit;
-            }
-            tripal_db_set_active($previous_db); // Use drupal database
-
-            
-         }
-      }
-   }
-   print "Done.\n";
-   tripal_job_set_progress($job_id,100);
-   closedir($dir_handle);
-
-   // If user input a file, remove decompressed files after parsing
-   if (is_file($hierfile)) {
-      $stderr = shell_exec("rm -r $data_dir;");
-      print "$stderr\n";
-   }
-   return;
-}
-/**
-*
-*/
-function tripal_analysis_kegg_array2list($array,&$content,&$i){
-   foreach($array as $index => $item){
-      if(is_array($item)){
-         if(is_numeric($index)){
-            tripal_analysis_kegg_array2list($item,$content,$i);
-         } else {
-            $content .= "<li id=\"term_$i\"><a></a>$index\n<ul>";
-            $i++;
-            tripal_analysis_kegg_array2list($item,$content,$i);
-            $content .= "</ul>\n</li>\n";
-         }
-      } else {
-         $content .= "<li id=\"term_$i\"><a></a>$item</li>\n";
-         $i++;
-      }
-   }   
-}
-/*******************************************************************************
- * Parse *.keg files. 
- * Each file has a definition line. BRITE term is extracted * from this line 
- * and added to chado as a cvterm. Tree structure for this cvterm is then 
- * generated and saved to analysisfeature and analysisfeatureprop tables.
- */
-function tripal_analysis_kegg_parse_kegg_file ($file, &$heirarchy, $analysis_id, 
-   $base_path, $query_re, $query_type, $query_uniquename)
-{
-
-   print "Parsing $file\n";
-
-   // get the 'kegg_brite_data' cvterm
-   $select = array('name' => 'kegg_brite_data', 
-                   'cv_id' => array('name' => 'tripal'));
-   $bdt_arr = tripal_core_chado_select('cvterm',array('cvterm_id'),$select);
-   $brite_id = $bdt_arr[0]->cvterm_id;
-
-   $filepos = 0;
-
-   // iterate through the lines of the file and recurse through the various levels
-   $handle = fopen($file,'r');
-   while($line = fgets($handle)){
-      $filepos += strlen($line);
-      $line = trim($line);
-
-      // the first line of the file provides the BRITE heirarchy name
-      if(preg_match("/#.*nbsp;\s(.*)<\/h2>$/",$line,$matches)){
-         $heirarchy = $matches[1];
-         // get the CVterm for the heirarchy.  If it doesn't exist then add it
-         $select = array('name' => $heirarchy,'cv_id' => array('name' => 'tripal'));
-         $cvt_arr = tripal_core_chado_select('cvterm',array('cvterm_id'),$select);
-         if (count($cvt_arr) == 0) {
-            tripal_add_cvterms($heirarchy, "KEGG BRITE term: $heirarchy");
-            $cvt_arr = tripal_core_chado_select('cvterm',array('cvterm_id'),$select);
-         }
-         $heirarchy_id = $cvt_arr[0]->cvterm_id;
-
-         // now that we have the file type we can recurse
-         $next = tripal_analysis_kegg_get_next_line($handle,$filepos);
-         $results = tripal_analysis_kegg_recurse_heir($handle,$next,$query_re,
-            $query_type,$query_uniquename,$base_path,$analysis_id,
-            $brite_id,$heirarchy,$filepos);
-      }
-   }
-   fclose($handle);
-   return $results;
-}
-
-/**
-*
-*/
-function tripal_analysis_kegg_recurse_heir($handle, $line,$query_re,
-   $query_type, $query_uniquename, $base_path, $analysis_id, $brite_id, 
-   $heirarchy,&$filepos)
-{
-   $results = array(); 
-
-   // get the current level and the value
-   $level = $line[0];
-   $value = $line[1];
-
-   // now get the next line to see what is coming next.  If the 
-   // next level is greater then recurse immediately. 
-   $prevpos = $filepos;
-   while($next = tripal_analysis_kegg_get_next_line($handle,$filepos)){
-      $next_level = $next[0];
-      $next_value = $next[1];
-
-      // check this line to see if it has a feature we need to keep
-      $ret = tripal_analysis_kegg_check_line_handle_feature($query_re,
-         $query_type, $query_uniquename, $base_path, $analysis_id, $brite_id, 
-         $heirarchy,$value);
-      if($ret){
-         $results[] = $ret;
-      }
-
-      // if we're going up a level then recurse immediately and add results to our array
-      if(ord($next_level) > ord($level)){
-         // now recurse
-         $ret = tripal_analysis_kegg_recurse_heir($handle,$next, 
-            $query_re,$query_type, $query_uniquename, $base_path, $analysis_id,
-            $brite_id,$heirarchy,$filepos);
-         if(count($ret) > 0){
-            $results[][$value] = $ret; 
-         }
-      }
-
-      // if we go down a level on the next line then reset the 
-      // filepointer and return
-      elseif(ord($next_level) < ord($level)){
-          fseek($handle,$prevpos);
-          $filepos = $prevpos;
-          return $results;
-      }
-      else {
-         $line = $next;
-         $level = $next[0];
-         $value = $next[1];
-      }
-      $prevpos = $filepos; 
-   }
-
-   return $results;
-}
-/**
-*
-*/
-
-function tripal_analysis_kegg_get_next_line($handle,&$filepos){
-   $good = 0;
-
-   // get the next line in the file
-   $line = fgets($handle);
-   $filepos += strlen($line);
-
-   // we hit the end of the file, so exit with a null
-   if(!$line){
-      return null;
-   }  
-   while(!$good){
-      $line = trim($line);
-      preg_match("/^([ABCDEFGHIJKLMNOP])\s*(.*)/",$line,$matches);
-      $level = $matches[1];
-      $value = $matches[2];
-
-      // skip lines that aren't data or are empty
-      if($level and $value) {
-
-         // change all relative paths to absolute paths pointing to KEGG (www.genome.jp)
-         // add id to <a> tags so we can link kegg.gif to it in tripal_analysis_kegg.css
-         $value = preg_replace("/<a href=\"\//i","<a href=\"http://www.genome.jp/",$value);     
-         $value = preg_replace("/<a href=\"/i","<a id=\"tripal_kegg_brite_links\" target=\"_blank\" href=\"",$value);
-
-         // this line is good so let's exit out
-         $good = 1;
-      } else {
-         $line = fgets($handle);
-         $filepos += strlen($line);
-         // we hit the end of the file, so exit with a null
-         if(!$line){
-            return null;
-         }         
-      }
-   }
-   return array($level,$value);
-}
-/**
-*
-*/
-function tripal_analysis_kegg_check_line_handle_feature($query_re,
-   $query_type, $query_uniquename, $base_path, $analysis_id, $brite_id, 
-   $heirarchy,$value)
-{
-
-   // extract the features that have been mapped to the KEGG IDs
-   if(preg_match("/^(.*?);\s*(\<a.+)/",$value,$matches)){
-      $has_feature = 1;
-      $fname = $matches[1];
-      $keggterm = $matches[2];
-
-		// get the feature name using the user's regular expression
-		if ($query_re and preg_match("/$query_re/", $fname, $matches)) {
-			$feature = $matches[1];
-		} 
-      // If not in above format then pull up to the first space
-      else {
-			if (preg_match('/^(.*?)\s.*$/', $fname, $matches)) {
-				$feature = $matches[1];
-         } 
-         // if no match up to the first space then just use the entire string
-         else {
-            $feature = $fname;
-         }
-      } 
-
-      // now find the feature in chado
-      $select = array();
-      if($query_uniquename){
-         $select['uniquename'] = $feature;
-      } else {
-         $select['name'] = $feature;
-      }
-      if($query_type){
-         $select['type_id'] = array(
-           'cv_id' => array(
-              'name' => 'sequence'
-           ),
-           'name' => $query_type,
-         );
-      }
-
-      $feature_arr = tripal_core_chado_select('feature',array('feature_id'),$select);
-
-      if(count($feature_arr) > 1){
-		   print "Ambiguous: '$feature' matches more than one feature and is being skipped.\n";
-			return;
-      }
-      if(count($feature_arr) == 0){
-			print "Failed: '$feature' cannot find a matching feature in the databasef.  RE: $query_re; LINE: $fname\n";
-         return;
-      }
-      $feature_id = $feature_arr[0]->feature_id;
-
-      if($feature_id){
-         print "Adding KEGG term for $feature ($feature_id,$analysis_id). $heirarchy\n";
-
-         // add this term to the analysis feature properties
-         tripal_analysis_kegg_insert_featureprop($feature_id,$analysis_id,
-            $brite_id,$keggterm);
-
-         // get the node ID of the feature if one exists
-         $sql = "SELECT nid FROM {chado_feature} WHERE feature_id = %d";
-         $nid = db_result(db_query($sql, $feature_id)); 
-
-         // Add link to each matched feature
-         if($nid){
-            $value = preg_replace("/^(.*?)(;\s*\<a)/","<a id=\"tripal_kegg_feature_links\" target=\"_blank\" href=\"$base_path/node/$nid\">"."$1"."</a>"."$2",$value);
-         }
-         // if we have a feature match then add this to our results array
-         return $value;  
-      }       
-   }
-   return null;
-}
-/**
-*
-*/
-function tripal_analysis_kegg_insert_featureprop ($feature_id, $analysis_id,
-   $brite_id,$keggterm)
-{
-
-   // add the analysisfeature record if it doesn't already exist.
-   $values = array('feature_id' => $feature_id,'analysis_id' => $analysis_id);
-   $analysisfeature_arr = tripal_core_chado_select('analysisfeature',
-      array('analysisfeature_id'),$values);
-   if(count($analysisfeature_arr) == 0){
-      tripal_core_chado_insert('analysisfeature',$values);
-      $analysisfeature_arr = tripal_core_chado_select('analysisfeature',
-         array('analysisfeature_id'),$values);
-   }
-   $analysisfeature_id = $analysisfeature_arr[0]->analysisfeature_id;            
-   // Insert into analysisfeatureprop if the value doesn't already exist
-   // KEGG heir results sometimes have the same record more than once.
-   if($analysisfeature_id){
-      // Get the highest rank for this feature_id in analysisfeatureprop table
-      $sql = "SELECT rank FROM analysisfeatureprop WHERE analysisfeature_id = %d and type_id = %d ORDER BY rank DESC";
-      $previous_db = tripal_db_set_active('chado');
-      $result = db_fetch_object(db_query($sql,$analysisfeature_id,$brite_id));
-      tripal_db_set_active($previous);
-      $rank = 0;
-      if ($result and $result->rank > 0) {
-         $rank = $result->rank + 1;
-      }
-
-      $values = array(
-         'analysisfeature_id' => $analysisfeature_id, 
-         'type_id' => $brite_id,
-         'value' => $keggterm,
-         'rank' => $rank,
-      );
-
-      return tripal_core_chado_insert('analysisfeatureprop',$values);
-   }
-   else {
-      return 0;
-   }
-}
-/**
- *
- *
- * @ingroup tripal_analysis_kegg
- */
-function tripal_analysis_kegg_block($op = 'list', $delta = 0, $edit=array()){
-   switch($op) {
-      case 'list':
-         $blocks['featurekegg']['info'] = t('Tripal Feature KEGG Terms');
-         $blocks['featurekegg']['cache'] = BLOCK_NO_CACHE;
-
-         $blocks['orgkegg']['info'] = t('Organism KEGG Summary');
-         $blocks['orgkegg']['cache'] = BLOCK_NO_CACHE;
-
-         $blocks['kegg_base']['info'] = t('Analsyis: KEGG Details');
-         $blocks['kegg_base']['cache'] = BLOCK_NO_CACHE;
-
-         
-         return $blocks;
-
-
-      case 'view':
-         if(user_access('access chado_analysis_kegg content') and arg(0) == 'node' and is_numeric(arg(1))) {
-            $nid = arg(1);
-            $node = node_load($nid);
- 
-            $block = array();
-            switch($delta){
-               case 'featurekegg':
-                  $block['subject'] = t('KEGG Terms');
-                  $block['content'] = theme('tripal_feature_kegg_terms',$node);
-                  break;
-
-               case 'orgkegg':
-                  $block['subject'] = t('KEGG Terms');
-                  $block['content'] = theme('tripal_organism_kegg_summary',$node);
-                  break;
-
-               case 'kegg_base':
-                  $block['subject'] = t('KEGG Terms');
-                  $block['content'] = theme('tripal_analysis_kegg_report',$node);
-                  break;
-              
-               default :
-            }
-            return $block;
-         }
-   }
-}
-/*******************************************************************************
- * HOOK: Implementation of hook_nodeapi()
- * Display library information for associated features or organisms
- * This function also provides contents for indexing
- */
-function tripal_analysis_kegg_nodeapi(&$node, $op, $teaser, $page) {
-   switch ($op) {
-      case 'view':
-              
-         // add the library to the organism/feature search indexing
-         if($node->build_mode == NODE_BUILD_SEARCH_INDEX){
-            $node->content['tripal_analysis_kegg_search_index'] = array(
-               '#value' => theme('tripal_analysis_kegg_search_index',$node),
-               '#weight' => 6,
-            );
-         } else if ($node->build_mode == NODE_BUILD_SEARCH_RESULT) {
-            $node->content['tripal_analysis_kegg_search_result'] = array(
-               '#value' => theme('tripal_analysis_kegg_search_result',$node),
-               '#weight' => 6,
-            );
-         } else {
-            switch($node->type){
-               case 'chado_organism':
-                  // Show KEGG report on the analysis page
-                  $node->content['tripal_organism_kegg_summary'] = array(
-                     '#value' => theme('tripal_organism_kegg_summary', $node),
-                  );
-                  break;
-               case 'chado_feature':
-                  // Show KEGG terms on a feature page
-                  $node->content['tripal_feature_kegg_terms'] = array(
-                     '#value' => theme('tripal_feature_kegg_terms', $node),
-                  );
-            }
-
-         }
-         break;
-   }
-}
-
-/**
- * Implements hook_theme_registry_alter().
- */
-function tripal_analysis_kegg_theme_registry_alter(&$info) {
-  // Inject our module into the node theme registry as being an available theme
-  // path so that we can override the node template for our content type.
-  array_splice($info['node']['theme paths'], 1, 0, array(drupal_get_path('module', 'tripal_analysis_kegg')));
-}
-
-/************************************************************************
- *  We need to let drupal know about our theme functions and their arguments.
- *  We create theme functions to allow users of the module to customize the
- *  look and feel of the output generated in this module
- */
-function tripal_analysis_kegg_theme () {
-	$path = drupal_get_path('module', 'tripal_analysis_kegg') . '/theme';
-   return array(
-      'tripal_analysis_kegg_search_index' => array (
-         'arguments' => array('node'),
-      ),
-      'tripal_analysis_kegg_search_result' => array (
-         'arguments' => array('node'),
-      ),
-      'tripal_organism_kegg_summary' => array (
-         'arguments' => array('node'=> null),
-         'template' => 'tripal_organism_kegg_summary',
-         'path' => $path . '/tripal_organism',
-      ),
-      'tripal_feature_kegg_terms' => array (
-         'arguments' => array('node'=> null),
-         'template' => 'tripal_feature_kegg_terms',
-         'path' => $path . '/tripal_feature',
-      ),
-      'tripal_analysis_kegg_report' => array (
-         'arguments' => array('node'=> null),
-         'template' => 'tripal_analysis_kegg_report',
-         'path' => $path . '/tripal_analysis_kegg',
-      ),
-   );
-}
-/**
- *  
- *
- * @ingroup tripal_analysis_kegg
- */
-function tripal_analysis_kegg_preprocess(&$variables){
-
-   // if the template file is the default node template file then we want
-   // to add all of our variables.
-   if($variables['template_files'][0] == 'node-chado_analysis_kegg'){
-      $analysis = $variables['node']->analysis;
-      $report = tripal_analysis_kegg_full_report($analysis->analysis_id);
-      $analysis->tripal_analysis_kegg->kegg_report = $report;
-   }
-}
-/*******************************************************************************
- *  
- */
-function tripal_analysis_kegg_preprocess_tripal_organism_kegg_summary(&$variables){
-   $node = $variables['node'];
-   $organism = $node->organism;
-   $organism->tripal_analysis_kegg->select_form = tripal_analysis_kegg_load_organism_kegg_summary($node);
-}
-/**
-*
-*/
-function tripal_analysis_kegg_preprocess_tripal_feature_kegg_terms(&$variables){
-   $node = $variables['node'];
-   $feature = $node->feature;
-   $feature->tripal_analysis_kegg->results = tripal_analysis_kegg_load_feature_terms($feature);
-}
-/************************************************************************
- */
-function theme_tripal_analysis_kegg_search_index($node){
- if ($node->type == 'chado_feature') {
-      // Find cvterm_id for 'kegg_brite_data'
-      $sql = "SELECT cvterm_id 
-              FROM {cvterm} CVT
-              INNER JOIN cv ON cv.cv_id = CVT.cv_id
-              WHERE cv.name = 'tripal'
-              AND CVT.name = '%s'";
-      $previous_db = tripal_db_set_active('chado');
-      $brite_id = db_result(db_query($sql, 'kegg_brite_data'));
-      
-      // Get analysis id
-      $sql = "SELECT analysis_id AS aid 
-              FROM {analysisfeature} AF 
-              INNER JOIN analysisfeatureprop AFP ON AF.analysisfeature_id = AFP.analysisfeature_id
-              WHERE feature_id = %d
-              AND AFP.type_id = %d
-              GROUP BY analysis_id";
-      $feature = $node->feature;
-      $feature_id = $feature->feature_id;
-      $hasResult = db_result(db_query($sql, $feature_id, $brite_id));
-      $result = db_query($sql, $feature->feature_id, $brite_id);
-
-      // Show kegg result ORDER BY time
-      if ($hasResult) { // If there is any result, show expandable box
-         $content = "";
-
-         while ($ana = db_fetch_object($result)) {
-            // Show analysis date
-            $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));
-            // Find node id for the analysis
-            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');
-       
-            // Show content
-            $content .= "$ana_details->name";
-         
-            // Show Kegg results
-            $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
-                   ";
-            $kegg_results = db_query($sql, $ana->aid, $feature_id);
-            while ($afp = db_fetch_object($kegg_results)) {
-               $content .= " $afp->afpvalue";
-            }
-         }
-      }
-      tripal_db_set_active($previous_db);
-      return $content;
-   }
-}
-
-/************************************************************************
- */
-function theme_tripal_analysis_kegg_search_result($node){
- //  $content = theme_tripal_analysis_kegg_node_add($node);
- //  return $content;
-}
-
-
-/************************************************************************
- */
-function tripal_analysis_kegg_load_organism_kegg_summary($node) {
-   $organism = $node->organism;
-
-   // find analyses that have KEGG terms
-   $sql = "
-     SELECT analysis_id
-     FROM {kegg_by_organism} KBO
-     WHERE organism_id = %d
-     ORDER BY analysis_id DESC
-   ";
-   $previous_db = tripal_db_set_active('chado');
-   $results = db_query($sql,$organism->organism_id);
-   tripal_db_set_active($previous_db);
-
-   # check to ensure we have access to at least one of the GO analyses
-   $has_results = 0;
-   while($analysis = db_fetch_object($results)){
-      $anode = tripal_analysis_get_node($analysis->analysis_id);
-      if(node_access("view",$anode)){
-         $has_results = 1;
-      }
-   }
-   return array (
-      'has_results' => $has_results,
-      'form' => drupal_get_form('tripal_analysis_kegg_select_form',$node),
-   );
-}
-/************************************************************************
- 
-
-   // Show Kegg additional information on a KEGG Analysis page
-   if ($node->type == 'chado_analysis_kegg') {
-      return tripal_analysis_kegg_full_report($node->analysis_id);
-   }   
-   
-   // Show Kegg-info-box on a Feature page
-   else if ($node->type == 'chado_feature') {
-       return tripal_analysis_kegg_feature_add($node);
-   } 
-   
-   return $content;
-}
- */
-
-function tripal_analysis_kegg_org_report($analysis_id){
-   $content = tripal_analysis_kegg_full_report($analysis_id);
-   $opt = array($content);
-   return drupal_json($opt);
-}
-/************************************************************************
- */
-function tripal_analysis_kegg_full_report($analysis_id){
-   // Test if brite data have been parsed into the database
-   $sql = "SELECT CVT.name, CVT.cvterm_id
-           FROM {cvterm} CVT 
-             INNER JOIN analysisprop AP ON CVT.cvterm_id = AP.type_id
-           WHERE AP.analysis_id = %d
-              AND CVT.definition LIKE 'KEGG BRITE term: %'
-           ORDER BY CVT.cvterm_id";
-   $previous_db = tripal_db_set_active('chado');
-   $result = db_query($sql, $analysis_id);
-   tripal_db_set_active($previous_db);
-
-   if (db_result($result)) {
-      $content = tripal_analysis_kegg_brite($analysis_id, $type_id, 0);
-   } else {
-      $content = "<i>Note:</i> Analysis result is not available. Please schedule and run the job to parse the kegg output.";
-   }
-   return $content;
-}
-/*******************************************************************************
- * Tripal Kegg administrative setting form. This function is called by
- * tripal_analysis module which asks for an admin form to show on the page
- */
-function tripal_analysis_kegg_get_settings() {
-   // Get an array of node types with internal names as keys
-   $options = node_get_types('names');
-   // Add 'chado_feature' to allowed content types for showing kegg results
-   $allowedoptions ['chado_feature'] = "Show KEGG results on feature pages";
-   $allowedoptions ['chado_analysis_kegg'] = "Show KEGG BRITE results on the analysis page.";
-   $allowedoptions ['chado_organism'] = "Show KEGG BRITE results on the organism pages.";
-
-   $form['description'] = array(
-       '#type' => 'item',
-       '#value' => t("Some chado features were analyzed by KEGG automatic annotation server (KAAS). This option allows user to display the kegg analysis results. Please read user manual for storage and display of kegg files. Check the box to enable the analysis results. Uncheck to disable it."),
-       '#weight' => 0,
-   );
-
-   $form['tripal_analysis_kegg_setting'] = array(
-      '#type' => 'checkboxes',
-      '#options' => $allowedoptions,
-      '#default_value' => variable_get('tripal_analysis_kegg_setting',
-      array('chado_feature', 'chado_analysis_kegg')),
-   );
-
-   $settings->form = $form;
-   $settings->title = "Tripal Kegg";
-   return $settings;
-}
-/************************************************************************
-*/
-function tripal_analysis_kegg_organism_results($node) {
-   $node = node_load($node);
-   return tripal_analysis_kegg_organism_add($node);
-}
-/************************************************************************
-*/
-function tripal_analysis_kegg_load_feature_terms($feature) {
-  
-   $feature_id = $feature->feature_id;
-
-	// Get the KEGG results stored using the term 'kegg_brite_data'
-   $select = array(
-      'analysisfeature_id' => array(
-         'feature_id' => $feature_id,
-      ), 
-      'type_id' => array(
-         'name' => 'kegg_brite_data',
-         'cv_id' => array(
-            'name' => 'tripal'
-         ),
-      ),         
-   );
-   $afeatureprops = tripal_core_chado_select('analysisfeatureprop',array('*'),$select);
-   if(!$afeatureprops){
-      return;
-   }
-
-   // iterate through all of the KEGG properties for this feature
-   $results = array();
-	foreach ($afeatureprops as $index => $afeatureprop) {
-
-      // get the analysis feature record
-      $analysisfeature_arr = tripal_core_chado_select('analysisfeature',array('analysis_id'),
-         array('analysisfeature_id' => $afeatureprop->analysisfeature_id));
-      $analysisfeature = $analysisfeature_arr[0];
-
-      // get the analysis record and the analysis_id
-      $analysis = tripal_core_generate_chado_var('analysis',
-         array('analysis_id' => $analysisfeature->analysis_id));
-      $analysis_id = $analysis->analysis_id;
-    
-      $results[$analysis_id]['analysis'] = $analysis;
-   }
-
-   // now get all the terms for each analysis
-   foreach($results as $analysis_id => $arr){
-      $select = array(
-         'analysisfeature_id' => array(
-            'analysis_id' => $analysis_id,
-            'feature_id' => $feature_id,
-         ),
-         'type_id' => array(
-            'name' => 'kegg_brite_data',
-            'cv_id' => array(
-               'name' => 'tripal',
-            ),
-         ),
-      );
-      $terms = tripal_core_chado_select('analysisfeatureprop',array('*'),$select);
-      foreach ($terms as $term){
-         $results[$analysis_id]['terms'][] = $term->value;
-      }
-   }
-
-   return $results;
-}
-/************************************************************************
-*/
-function tripal_analysis_kegg_select_form(&$form_state = NULL,$node){
-
-   $form = array();
-   // find analyses that have KEGG terms
-   $sql = "
-     SELECT *
-     FROM {kegg_by_organism} KBO
-     WHERE organism_id = %d
-     ORDER BY analysis_id DESC
-   ";
-   $previous_db = tripal_db_set_active('chado');
-   $results = db_query($sql,$node->organism->organism_id);
-   tripal_db_set_active($previous_db);
-
-   $analyses = array();
-   $analyses[''] = '';
-   while($analysis = db_fetch_object($results)){
-      # check to see if the user has permission to see this analysis
-      $anode = tripal_analysis_get_node($analysis->analysis_id);
-      if(node_access("view",$anode)){
-   		$analyses[$analysis->analysis_id] = "$analysis->analysis_name";
-      }
-   }
-  
-   global $base_url;
-   // we need to set some hidden values for the javascript to use
-   $form['theme_dir'] = array(
-      '#type' => 'hidden',
-      '#value' => drupal_get_path('theme', 'tripal'),
-   );
-   $form['base_url'] = array(
-      '#type' => 'hidden',
-      '#value' => $base_url,
-   );
-   // now generate the select box
-   global $base_url;
-   $theme_dir = drupal_get_path('theme', 'tripal');
-   $form['tripal_analysis_kegg_select'] = array(
-      '#title' => t('Select a KEGG report to view'),
-      '#description' => t('Any analysis with KEGG results related to this organism are available for viewing. For further information, see the analysis information page.'),
-      '#type'  => 'select',
-      '#options' => $analyses,
-      '#attributes' => array (
-         'onchange' => "tripal_analysis_kegg_org_report(this.options[this.selectedIndex].value,'".$base_url. "','".$theme_dir."')"
-      ),
-   );
-   return $form;
-}
-
-/*******************************************************************************
- * Parsing KEGG HTML results that are stored in analysisfeatureprop for 
- * searching 
- * */
-function tripal_analysis_kegg_extract_keywords ($analysis_id) {
-	
-	// Remove kegg keywords previously stored
-	print "Remove keywords previously stored...\n";
-	$output_type_id = tripal_get_cvterm_id('kegg_brite_data');
-	$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_kegg_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";
-	$results = chado_query($sql);
-	// Define what to be extracted in the array
-	$search = array (
-                 		"'<[/!]*?[^<>]*?>'si",          // replace HTML tags with a space
-							"'\n'", // replace newlines with a space
-	);
-	$replace = array (
-					  			" ",
-                 			" ",
-	);
-	while ($record = db_fetch_object($results)) {
-		$af_id = $record->analysisfeature_id;
-		$value = $record->value;
-
-		// Retrive keywords for this analysisfeature_id if there is any
-		$sql = "SELECT value FROM {analysisfeatureprop} WHERE analysisfeature_id =$af_id AND type_id = $keyword_type_id";
-		$keywords = db_result(chado_query($sql));
-		
-		// Extract new keywords from the kegg html output
-		$text = preg_replace($search, $replace, $value); 
-		$new_keywords = trim(ereg_replace(' +', ' ', $text)); // remove extra spaces
-		
-		// Append the new keywords 
-		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 {
-			// Insert the keyword into the analysisfeatureprop table
-			$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";
-	
-}
-

+ 0 - 103
extensions/tripal_analysis_unigene/node-chado_analysis_unigene.tpl.php

@@ -1,103 +0,0 @@
-<?php
-// Purpose: This template provides the layout of the organism node (page)
-//   using the same templates used for the various feature content blocks.
-//
-// To Customize the Featture Node Page:
-//   - This Template: customize basic layout and which elements are included
-//   - Using Panels: Override the node page using Panels3 and place the blocks
-//       of content as you please. This method requires no programming. See
-//       the Tripal User Guide for more details
-//   - Block Templates: customize the content/layout of each block of stock 
-//       content. These templates are found in the tripal_stock subdirectory
-//
-// Variables Available:
-//   - $node: a standard object which contains all the fields associated with
-//       nodes including nid, type, title, taxonomy. It also includes stock
-//       specific fields such as stock_name, uniquename, stock_type, synonyms,
-//       properties, db_references, object_relationships, subject_relationships,
-//       organism, etc.
-//   NOTE: For a full listing of fields available in the node object the
-//       print_r $node line below or install the Drupal Devel module which 
-//       provides an extra tab at the top of the node page labelled Devel
-?>
-
-<?php
- //uncomment this line to see a full listing of the fields avail. to $node
-// print '<pre>'.print_r($node,TRUE).'</pre>';
-drupal_add_css('./tripal-node-templates.css');
-$node = $variables['node'];
-$analysis = $variables['node']->analysis;
-$unigene_name = $analysis->tripal_analysis_unigene->unigene_name;
-
-//dpm($analysis);
-
-// get the unigene name from the properties list
-
-
-?>
-
-<?php if ($teaser) { 
-  include('tripal_analysis_unigene/tripal_analysis_unigene_teaser.tpl.php'); 
-} else { ?>
-
-<script type="text/javascript">
-if (Drupal.jsEnabled) {
-   $(document).ready(function() {
-      // hide all tripal info boxes at the start
-      $(".tripal-info-box").hide();
- 
-      // iterate through all of the info boxes and add their titles
-      // to the table of contents
-      $(".tripal-info-box-title").each(function(){
-        var parent = $(this).parent();
-        var id = $(parent).attr('id');
-        var title = $(this).text();
-        $('#tripal_analysis_unigene_toc_list').append('<li><a href="#'+id+'" class="tripal_analysis_unigene_toc_item">'+title+'</a></li>');
-      });
-
-      // when a title in the table of contents is clicked, then
-      // show the corresponding item in the details box
-      $(".tripal_analysis_unigene_toc_item").click(function(){
-         $(".tripal-info-box").hide();
-         href = $(this).attr('href');
-         $(href).fadeIn('slow');
-         // we want to make sure our table of contents and the details
-         // box stay the same height
-         $("#tripal_analysis_unigene_toc").height($(href).parent().height());
-         return false;
-      }); 
-
-      // we want the base details to show up when the page is first shown 
-      // unless the user specified a specific block
-      var block = window.location.href.match(/[\?|\&]block=(.+?)\&/)
-      if(block == null){
-         block = window.location.href.match(/[\?|\&]block=(.+)/)
-      }
-      if(block != null){
-         $("#tripal_analysis_unigene-"+block[1]+"-box").show();
-      } else {
-         $("#tripal_analysis_unigene-base-box").show();
-      }
-      $("#tripal_analysis_unigene_toc").height($("#tripal_analysis_unigene-base-box").parent().height());
-   });
-}
-</script>
-
-<div id="tripal_analysis_unigene_details" class="tripal_details">
-
-   <!-- Basic Details Theme -->
-   <?php include('theme/tripal_analysis_unigene/tripal_analysis_unigene_base.tpl.php'); ?>
-
-   <?php print $content ?>
-</div>
-
-<!-- Table of contents -->
-<div id="tripal_analysis_unigene_toc" class="tripal_toc">
-   <div id="tripal_analysis_unigene_toc_title" class="tripal_toc_title">Resources</div>
-   <span id="tripal_analysis_unigene_toc_desc" class="tripal_toc_desc"></span>
-   <ul id="tripal_analysis_unigene_toc_list" class="tripal_toc_list">
-
-   </ul>
-</div>
-
-<?php } ?>

+ 0 - 16
extensions/tripal_analysis_unigene/theme/css/tripal_analysis_unigene.css

@@ -1,16 +0,0 @@
-/*
- Copyright 2009 Clemson University
-*/
-
-.tripal_unigene-info-box {
-   margin-top: 10px;
-   margin-left: 0px;
-   margin-right: 0px;
-   margin-bottom: 0px;
-   padding-top: 0px;
-   padding-left: 0px;
-   padding-bottom: 0px;
-   padding-right: 0px;
-   border-collapse: collapse;
-   z-index: 10;
-}

+ 0 - 86
extensions/tripal_analysis_unigene/theme/tripal_analysis_unigene/tripal_analysis_unigene_base.tpl.php

@@ -1,86 +0,0 @@
-<?php
-$node = $variables['node'];
-$analysis = $variables['node']->analysis;
-
-// the description is a text field so we want to expand that
-$analysis = tripal_core_expand_chado_vars($analysis,'field','analysis.description');
-
-$unigene = $node->analysis->tripal_analysis_unigene;
-//dpm($node);
-
-?>
-<div id="tripal_analysis_unigene-base-box" class="tripal_analysis_unigene-info-box tripal-info-box">
-  <div class="tripal_analysis_unigene-info-box-title tripal-info-box-title">Unigene Details</div>
-  <div class="tripal_analysis_unigene-info-box-desc tripal-info-box-desc"></div>
-   <table id="tripal_analysis_unigene-table-base" class="tripal_analysis_unigene-table tripal-table tripal-table-vert">
-      <tr class="tripal_analysis_unigene-table-even-row tripal-table-even-row">
-        <th>Analysis Name</th>
-        <td><?php print $analysis->name; ?></td>
-      </tr>
-      <tr class="tripal_analysis_unigene-table-odd-row tripal-table-odd-row">
-        <th>Unigene Name</th>
-        <td><?php print $unigene->unigene_name; ?></td>
-      </tr>
-      <tr class="tripal_analysis_unigene-table-even-row tripal-table-even-row">
-        <th nowrap>Software</th>
-        <td><?php 
-          print $analysis->program; 
-          if($analysis->programversion){
-             print " (" . $analysis->programversion . ")"; 
-          }
-          if($analysis->algorithm){
-             print ". " . $analysis->algorithm; 
-          }
-          ?>
-        </td>
-      </tr>
-      <tr class="tripal_analysis_unigene-table-odd-row tripal-table-odd-row">
-        <th nowrap>Source</th>
-        <td><?php 
-          if($analysis->sourceuri){
-             print "<a href=\"$analysis->sourceuri\">$analysis->sourcename</a>"; 
-          } else {
-             print $analysis->sourcename; 
-          }
-          if($analysis->sourceversion){
-             print " (" . $analysis->sourceversion . ")"; 
-          }
-          ?>
-          </td>
-      </tr>
-      <tr class="tripal_analysis_unigene-table-even-row tripal-table-even-row">
-        <th nowrap>Date constructed</th>
-        <td><?php print preg_replace("/^(\d+-\d+-\d+) .*/","$1",$analysis->timeexecuted); ?></td>
-      </tr>
-      <tr class="tripal_analysis_unigene-table-odd-row tripal-table-odd-row">
-        <th nowrap>Description</th>
-        <td><?php print $analysis->description; ?></td>
-      </tr> 
-      <tr class="tripal_analysis_unigene-table-even-row tripal-table-even-row">
-        <th nowrap>Stats</th>
-        <td>
-             <?php if($unigene->num_reads){print "Number of reads: $unigene->num_reads<br>";} ?>
-             <?php if($unigene->num_clusters){print "Number of clusters: $unigene->num_clusters<br>";} ?>
-             <?php if($unigene->num_contigs){print "Number of contigs: $unigene->num_contigs<br>";} ?>
-             <?php if($unigene->num_singlets){print "Number of singlets: $unigene->num_singlets<br>";} ?>
-        </td>
-      </tr>  
-      <tr class="tripal_analysis_unigene-table-odd-row tripal-table-odd-row">
-        <th>Organisms</th>
-        <td><?php 
-            if($unigene->organisms and is_array($unigene->organisms)){
-               foreach($unigene->organisms as $organism){
-                  if($organism->nid){
-                     print "<i><a href=\"".url("node/$organism->nid")."\">$organism->genus $organism->species</i></a><br>";
-                  } else {
-                     print "<i>$organism->genus $organism->species</i><br>";
-                  }
-               }
-            } else {
-                // add message here with instructions for administrators to make this work.
-            }
-            ?>
-        </td>
-      </tr>       	                                
-   </table>   
-</div>

+ 0 - 53
extensions/tripal_analysis_unigene/theme/tripal_analysis_unigene/tripal_analysis_unigene_teaser.tpl.php

@@ -1,53 +0,0 @@
-<?php
-$node = $variables['node'];
-$analysis = $variables['node']->analysis;
-
-// the description is a text field so we want to expand that
-$analysis = tripal_core_expand_chado_vars($analysis,'field','analysis.description');
-
-
-?>
-<div id="tripal_analysis-base-box" class="tripal_analysis-info-box tripal-info-box">
-  <div class="tripal_analysis-info-box-title tripal-info-box-title">Details</div>
-   <table id="tripal_analysis-table-base" class="tripal_analysis-table tripal-table tripal-table-vert">
-      <tr class="tripal_analysis-table-odd-row tripal-table-even-row">
-        <th>Analysis Name</th>
-        <td><?php print $analysis->name; ?></td>
-      </tr>
-      <tr class="tripal_analysis-table-odd-row tripal-table-odd-row">
-        <th nowrap>Software</th>
-        <td><?php 
-          print $analysis->program; 
-          if($analysis->programversion){
-             print " (" . $analysis->programversion . ")"; 
-          }
-          if($analysis->algorithm){
-             print ". " . $analysis->algorithm; 
-          }
-          ?>
-        </td>
-      </tr>
-      <tr class="tripal_analysis-table-odd-row tripal-table-even-row">
-        <th nowrap>Source</th>
-        <td><?php 
-          if($analysis->sourceuri){
-             print "<a href=\"$analysis->sourceuri\">$analysis->sourcename</a>"; 
-          } else {
-             print $analysis->sourcename; 
-          }
-          if($analysis->sourceversion){
-             print " (" . $analysis->sourceversion . ")"; 
-          }
-          ?>
-          </td>
-      </tr>
-      <tr class="tripal_analysis-table-odd-row tripal-table-odd-row">
-        <th nowrap>Date performed</th>
-        <td><?php print preg_replace("/^(\d+-\d+-\d+) .*/","$1",$analysis->timeexecuted); ?></td>
-      </tr>
-      <tr class="tripal_analysis-table-odd-row tripal-table-even-row">
-        <th nowrap>Description</th>
-        <td><?php print $analysis->description; ?></td>
-      </tr>             	                                
-   </table>   
-</div>

+ 0 - 61
extensions/tripal_analysis_unigene/theme/tripal_feature/tripal_feature_unigenes.tpl.php

@@ -1,61 +0,0 @@
-<?php
-$node = $variables['node'];
-$feature = $node->feature;
-$unigenes = $feature->tripal_analysis_unigene->unigenes;
-
-// if this feature has a unigene then we want to show the box
-if($unigenes){
-  //dpm($unigenes);
-?>
-<div id="tripal_feature-unigenes-box" class="tripal_feature-info-box tripal-info-box">
-  <div class="tripal_feature-info-box-title tripal-info-box-title">Unigenes</div>
-  <div class="tripal_feature-info-box-desc tripal-info-box-desc">This <?php print $feature->type_id->name ?> is part of the following unigenes:</div>
-  <?php if(count($unigenes) > 0){ ?>
-  <table id="tripal_feature-unigenes-table" class="tripal_feature-table tripal-table tripal-table-horz">
-    <tr>
-      <th>Unigene Name</th>
-      <th>Analysis Name</th>
-      <th>Sequence type in Unigene</th>
-    </tr>
-    <?php
-    $i = 0; 
-    foreach ($unigenes as $unigene){
-      $class = 'tripal-table-odd-row';
-      if($i % 2 == 0 ){
-         $class = 'tripal-table-even-row';
-      }
-      ?>
-      <tr class="<?php print $class ?>">
-        <td><?php 
-           if($unigene->nid){
-              print "<a href=\"".url("node/$unigene->nid")."\">$unigene->unigene_name</a>";
-           } else {
-              print $unigene->unigene_name;
-           }?>
-        </td>
-        <td><?php 
-           if($analysis->nid){
-              print "<a href=\"".url("node/$analysis->nid")."\">$analysis->name</a>";
-           } else {
-              print $analysis->name;
-           }?>
-        </td>
-        <td nowrap><?php 
-           if($unigene->singlet){
-              print "Singlet";
-           } else {
-              print $feature->type_id->name;
-           }?>
-        </td>
-      </tr>
-      <?php
-      $i++;  
-    } ?>
-  </table>
-  <?php } else { ?>
-    <div class="tripal-no-results">There are no unigenes for this feature</div> 
-  <?php }?>
-</div>
-<?php 
-}
-?>

+ 0 - 52
extensions/tripal_analysis_unigene/theme/tripal_organism/tripal_organism_unigenes.tpl.php

@@ -1,52 +0,0 @@
-<?php
-$node = $variables['node'];
-$organism = $node->organism;
-$unigenes = $organism->tripal_analysis_unigene->unigenes;
-
-//dpm($unigenes);
-?>
-<div id="tripal_organism-unigenes-box" class="tripal_feature-info-box tripal-info-box">
-  <div class="tripal_feature-info-box-title tripal-info-box-title">Unigenes</div>
-  <div class="tripal_feature-info-box-desc tripal-info-box-desc">Below is a list of unigenes available for <i><?php print $organism->genus ?> <?php print $organism->species ?></i>. Click the unigene name for further details.</div>
-  <?php if(count($unigenes) > 0){ ?>
-  <table id="tripal_organism-unigenes-table" class="tripal_feature-table tripal-table tripal-table-horz">
-    <tr>
-      <th>Unigene Name</th>
-      <th>Analysis Name</th>
-      <th>Date Constructed</th>
-      <th>Stats</th>
-    </tr>
-    <?php
-    $i = 0; 
-    foreach ($unigenes as $unigene){
-      $class = 'tripal-table-odd-row';
-      if($i % 2 == 0 ){
-         $class = 'tripal-table-even-row';
-      }
-      ?>
-      <tr class="<?php print $class ?>">
-        <td>
-           <?php 
-           if($unigene->nid){
-              print "<a href=\"".url("node/$unigene->nid")."\">$unigene->unigene_name</a>";
-           } else {
-              print $unigene->unigene_name;
-           }?>
-        </td>
-        <td><?php print $unigene->name; ?></td>
-        <td><?php print preg_replace("/^(\d+-\d+-\d+) .*/","$1",$unigene->timeexecuted); ?></td>
-        <td nowrap>
-             <?php if($unigene->num_reads){print "Reads: $unigene->num_reads<br>";} ?>
-             <?php if($unigene->num_clusters){print "Clusters: $unigene->num_clusters<br>";} ?>
-             <?php if($unigene->num_contigs){print "Contigs: $unigene->num_contigs<br>";} ?>
-             <?php if($unigene->num_singlets){print "Singlets: $unigene->num_singlets<br>";} ?>
-        </td>
-      </tr>
-      <?php
-      $i++;  
-    } ?>
-  </table>
-  <?php } else { ?>
-    <div class="tripal-no-results">There are no unigenes for this organism</div> 
-  <?php }?>
-</div>

+ 0 - 9
extensions/tripal_analysis_unigene/tripal_analysis_unigene.info

@@ -1,9 +0,0 @@
-; $Id:
-name = Tripal Unigene
-description = An analysis sub-module for displaying unigene analysis results.
-core = 6.x
-project = tripal_analysis_unigene
-package = Tripal Extensions
-dependencies[] = tripal_core
-dependencies[] = tripal_feature
-dependencies[] = tripal_analysis

+ 0 - 290
extensions/tripal_analysis_unigene/tripal_analysis_unigene.install

@@ -1,290 +0,0 @@
-<?php
-//$Id:
-
-/*******************************************************************************
- * Implementation of hook_install().
- */
-function tripal_analysis_unigene_install() {
-   // create the module's data directory
-   tripal_create_moddir('tripal_analysis_unigene');
-
-   // We need to register to tripal_analysis module so it can provide a control
-   // for our unigene result. Basically the registration is done by inserting
-   // required information into the {tripal_analysis} table.
-   tripal_analysis_register_child('tripal_analysis_unigene');
-
-   $previous_db = tripal_db_set_active('chado');
-   if (db_table_exists('unigene_libraries_mview')) {
-      $sql = "DROP TABLE unigene_libraries_mview";
-      db_query($sql);
-   }
-   if (db_table_exists('unigene_mview')) {
-      $sql = "DROP TABLE unigene_mview";
-      db_query($sql);
-   }
-   tripal_db_set_active($previous_db);
-   
-
-   tripal_analysis_unigene_add_cvterms();
-   tripal_analysis_unigene_add_organism_unigene_mview();
-   
-   tripal_analysis_unigene_add_stat_mview(); // Add statistics mview
-
-}
-
-/**
-*
-*/
-function tripal_analysis_unigene_update_6001(){
-
-   // we have some new cvterms to add
-   tripal_analysis_unigene_add_cvterms();
-
-   // remove the old unigene materialized view and add the new one.
-   $mview = tripal_mviews_get_mview_id('unigene_mview');
-   if($mview){
-      tripal_mviews_action('delete',$mview);
-   }
-   tripal_analysis_unigene_add_organism_unigene_mview();
-   tripal_analysis_unigene_add_stat_mview(); // Add statistics mview
-
-   // next, add the cvterm 'analysis_unigene_name' to all existing 
-   // unigenes that are already in the database. This will allow the 
-   // materialized view to work.
-   $sql = "SELECT N.nid,N.title,CN.analysis_id
-           FROM {node} N
-             INNER JOIN {chado_analysis} CN on CN.nid = N.nid
-           WHERE type = 'chado_analysis_unigene'";
-   $analyses = db_query($sql);
-   while($analysis = db_fetch_object($analyses)){
-      tripal_analysis_insert_property($analysis->analysis_id,'analysis_unigene_name',$analysis->title);	
-   }
-
-   $ret = array(
-      '#finished' => 1,
-   );
-   
-   return $ret;
-}
-/**
-*
-*/
-function tripal_analysis_unigene_add_cvterms(){
-   tripal_add_cvterms('unigene_version','The version number for the unigene ".
-     "(e.g. v1, v2, etc...) ');
-   tripal_add_cvterms('analysis_unigene_name', 'The name for a unigene.');
-   tripal_add_cvterms('analysis_unigene_num_contigs','The number of contigs in the unigene assembly');
-   tripal_add_cvterms('analysis_unigene_num_singlets','The number of singlets remaining in the unigene assembly');
-   tripal_add_cvterms('analysis_unigene_num_clusters','The number of clusters in the unigene assembly');
-   tripal_add_cvterms('analysis_unigene_num_reads','The number of reads, after filtering, used as input for the assembly');
-   tripal_add_cvterms('analysis_unigene_avg_length','The average contig length');
-   tripal_add_cvterms('singlet',"Indicates the feature is a singlet in a ".
-     "specific unigene version (e.g. v1, v2, etc...). The value specified ".
-     "should match that of the unigene_version");
-
-   // Add cveterm 'analysis_unigene_settings' for inserting into analysisprop table   
-   tripal_add_cvterms('analysis_unigene_settings', 'Settings of a unigene analysis');
-   tripal_add_cvterms('singlet_in_analysis', 'Label the feature as a singlet of specified analysis. The value is the name of a unigene analysis. More importantly, the analysis_id of said analysis is inserted to the featureprop table as rank');
-}
-/**
-*
-*/
-function tripal_analysis_unigene_add_organism_unigene_mview(){
-
-   $view_name = 'organism_unigene_mview';
-
-   // Drop the MView table if it exists
-   $mview_id = tripal_mviews_get_mview_id($view_name);
-   if($mview_id){
-      tripal_mviews_action("delete",$mview_id);
-   }
-
-   tripal_add_mview(
-      // view name
-      $view_name,
-      // tripal module name
-      'tripal_analysis_unigene',
-      // table name
-      $view_name,
-      // table schema definition
-      'analysis_id integer, organism_id integer',
-      // columns for indexing
-      'analysis_id, organism_id',
-      // SQL statement to populate the view
-	   "SELECT DISTINCT A.analysis_id, O.organism_id ".
-      "FROM {Analysis} A ".
-      "  INNER JOIN analysisprop AP    ON AP.analysis_id = A.analysis_id ".
-      "  INNER JOIN cvterm CVT         ON AP.type_id = CVT.cvterm_id ".
-      "  INNER JOIN cv CV              ON CV.cv_id = CVT.cv_id ".
-      "  INNER JOIN analysisfeature AF ON A.analysis_id = AF.analysis_id ".
-      "  INNER JOIN feature F          ON AF.feature_id = F.feature_id ".
-      "  INNER JOIN organism O         ON F.organism_id = O.organism_id ".
-      "WHERE CV.name = 'tripal' AND CVT.name='analysis_unigene_name'",
-      // special index 
-	   ''
-   );
-
-   // add a job to the job queue so this view gets updated automatically next
-   // time the job facility is run
-   $mview_id = tripal_mviews_get_mview_id($view_name);
-   if($mview_id){
-      tripal_mviews_action('update',$mview_id);
-   }
-}
-/*******************************************************************************
- * Implementation of hook_uninstall().
- */
-function tripal_analysis_unigene_uninstall() {
-   $mview = tripal_mviews_get_mview_id('unigene_mview');
-   if($mview){
-      tripal_mviews_action('delete',$mview);
-   }
-   $mview = tripal_mviews_get_mview_id('unigene_libraries_mview');
-   if($mview){
-      tripal_mviews_action('delete',$mview);
-   }
-   // Delete the settings from {tripal_analysis} table
-   // Drupal complains when the user tries to uninstall tripal_analysis 
-   // and tripal_analysis_unigene at the same time. This is because Drupal drops
-   // the {tripal_analysis} table before we can delete anything from it. Thus,
-   // we perform a db_table_exists() check before the deletion
-   tripal_analysis_unregister_child('tripal_analysis_unigene');
-
-   // Delete module's variables from variables table.
-   db_query("DELETE FROM {variable} WHERE name='%s'",
-            'tripal_analysis_unigene_setting');
-   
-}
-
-/*******************************************************************************
- * Implementation of hook_requirements(). Make sure 'Tripal Core' and 'Tripal
- * Analysis' are enabled before installation
- */
-function tripal_analysis_unigene_requirements($phase) {
-   $requirements = array();
-   if ($phase == 'install') {
-      if (!function_exists('tripal_create_moddir') || !function_exists('tripal_analysis_register_child')) {
-         $requirements ['tripal_analysis_unigene'] = array(
-            'title' => "tripal_analysis_unigene",
-            'value' => "error. Some required modules are just being installed. Please try again.",
-            'severity' => REQUIREMENT_ERROR,
-         );
-      }
-   }
-   return $requirements;
-}
-
-/********************************************************************************
-* Add a materialized view for unigene basic stat
-*/
-function tripal_analysis_unigene_add_stat_mview() {
-	$view_name = 'unigene_basic_stats';
-	// Drop the MView table if it exists
-	$mview_id = tripal_mviews_get_mview_id($view_name);
-	if($mview_id){
-		tripal_mviews_action("delete",$mview_id);
-	}
-
-	$schema = " analysis_id integer,
-   							  name character varying(255),
-   							  unigene_no integer,
-   							  unigene_min_length integer,
-   							  unigene_max_length integer,
-   							  unigene_avg_length integer,
-   							  contig_no integer,
-   							  contig_min_length integer,
-   							  contig_max_length integer,
-   							  contig_avg_length integer,
-   							  singlet_no integer,
-   							  singlet_min_length integer,
-   							  singlet_max_length integer,
-   							  singlet_avg_length integer
-   							  ";
-	 
-	$index = "analysis_id";
-	 
-	$ana_type = tripal_get_cvterm_id('analysis_type');
-	$singlet_type_id = tripal_get_cvterm_id('singlet_in_analysis');
-	$contig_type = db_result(chado_query("SELECT cvterm_id FROM {cvterm} WHERE name = 'contig' AND cv_id = (SELECT cv_id FROM {cv} WHERE name = 'sequence')")); //P.S. 'contig' is not a tripal term
-	$EST_type = db_result(chado_query("SELECT cvterm_id FROM {cvterm} WHERE name = 'EST' AND cv_id = (SELECT cv_id FROM {cv} WHERE name = 'sequence')")); //P.S. 'EST' is not a tripal term
-	$sql = "SELECT
-						A.analysis_id, name, 
-						coalesce(unigene_no, 0), 
-						coalesce(unigene_min, 0), 
-						coalesce(unigene_max, 0), 
-						coalesce(unigene_avg, 0), 
-						coalesce(contig_no, 0), 
-						coalesce(contig_min, 0), 
-						coalesce(contig_max, 0), 
-						coalesce(contig_avg, 0), 
-						coalesce(singlet_no, 0), 
-						coalesce(singlet_min, 0), 
-						coalesce(singlet_max, 0), 
-						coalesce(singlet_avg, 0)
-
-					FROM analysis A 
-					INNER JOIN analysisprop AP ON A.analysis_id = AP.analysis_id
-
-					LEFT JOIN (SELECT count (F.feature_id) AS unigene_no, 
-												min(F.seqlen) AS unigene_min, 
-												max(F.seqlen) AS unigene_max, 
-												round(avg(F.seqlen),0) AS unigene_avg, 
-												analysis_id 
-												FROM feature F
-						         			INNER JOIN analysisfeature AF ON F.feature_id = AF.feature_id
-												LEFT JOIN featureprop FP on F.feature_id = FP.feature_id
-            								WHERE F.type_id = $contig_type
-            								AND ((FP.type_id = $singlet_type_id AND FP.rank != AF.analysis_id) OR FP.type_id IS NULL)
-												OR (FP.type_id = $singlet_type_id AND FP.rank = AF.analysis_id)
-												GROUP BY analysis_id) Unigene ON Unigene.analysis_id = A.analysis_id
-			
-					LEFT JOIN (SELECT count (F.feature_id) AS contig_no, 
-												min(F.seqlen) AS contig_min, 
-												max(F.seqlen) AS contig_max, 
-												round(avg(F.seqlen),0) AS contig_avg, 
-												analysis_id 
-											FROM feature F
-         								INNER JOIN analysisfeature AF ON F.feature_id = AF.feature_id
-											LEFT JOIN featureprop FP on F.feature_id = FP.feature_id
-            							WHERE F.type_id = $contig_type
-            							AND ((FP.type_id = $singlet_type_id AND FP.rank != AF.analysis_id) OR FP.type_id IS NULL)
-											GROUP BY analysis_id) Contig ON Contig.analysis_id = A.analysis_id
-
-					LEFT JOIN (SELECT count (F.feature_id) AS singlet_no, 
-												min(F.seqlen) AS singlet_min, 
-												max(F.seqlen) AS singlet_max, 
-												round(avg(F.seqlen),0) AS singlet_avg, 
-												analysis_id 
-											FROM featureprop FP
-											INNER JOIN feature F ON F.feature_id = FP.feature_id
-         								INNER JOIN analysisfeature AF ON FP.feature_id = AF.feature_id
-											WHERE FP.type_id = $singlet_type_id AND FP.rank = AF.analysis_id
-											GROUP BY analysis_id) Singlet ON Singlet.analysis_id = A.analysis_id			
-			
-					WHERE type_id = $ana_type AND value = 'tripal_analysis_unigene'";
-	 
-	// Create the MView
-	tripal_add_mview(
-	// view name
-	$view_name,
-	// tripal module name
-      ' tripal_analysis_unigene',
-	// table name
-	$view_name,
-	// table schema definition
-	$schema,
-	// columns for indexing
-	$index,
-	// SQL statement to populate the view
-	$sql,
-	// special index
-      ''
-	);
-	 
-	// add a job to the job queue so this view gets updated automatically next
-	// time the job facility is run
-	$mview_id = tripal_mviews_get_mview_id($view_name);
-	if($mview_id){
-		tripal_mviews_action('update',$mview_id);
-	}
-}

+ 0 - 922
extensions/tripal_analysis_unigene/tripal_analysis_unigene.module

@@ -1,922 +0,0 @@
-<?php
-
-function tripal_analysis_unigene_init(){
-   // Add style sheet
-   drupal_add_css(drupal_get_path('module', 'tripal_analysis_unigene').'/theme/css/tripal_analysis_unigene.css', 'theme');
-}
-/**
-*
-*/
-function tripal_analysis_unigene_node_info() {
-	$nodes = array();
-	$nodes['chado_analysis_unigene'] = array(
-      'name' => t('Analysis: Unigene'),
-      'module' => 'chado_analysis_unigene',
-      'description' => t('A unigene assembly constructed from transcriptomic reads.'),
-      'has_title' => FALSE,
-      'title_label' => t('Analysis: Unigene'),
-      'has_body' => FALSE,
-      'body_label' => t('Unigene Analysis Description'),
-      'locked' => TRUE
-	);
-	return $nodes;
-}
-/*******************************************************************************
- * Set the permission types that the chado module uses.  Essentially we
- * want permissionis that protect creation, editing and deleting of chado
- * data objects
- */
-function tripal_analysis_unigene_perm(){
-   return array(
-      'access chado_analysis_unigene content',
-      'create chado_analysis_unigene content',
-      'delete chado_analysis_unigene content',
-      'edit chado_analysis_unigene content',
-   );
-}
-
-/*******************************************************************************
- *  The following function proves access control for users trying to
- *  perform actions on data managed by this module
- */
-function chado_analysis_unigene_access($op, $node, $account){
-	if ($op == 'create') {
-		if(!user_access('create chado_analysis_unigene content', $account)){
-			return FALSE;
-      }
-	}
-	if ($op == 'update') {
-		if (!user_access('edit chado_analysis_unigene content', $account)) {
-			return FALSE;
-		}
-	}
-	if ($op == 'delete') {
-		if (!user_access('delete chado_analysis_unigene content', $account)) {
-			return FALSE;
-		}
-	}
-	if ($op == 'view') {
-		if(!user_access('access chado_analysis_unigene content', $account)){
-         return FALSE;
-      }
-	}
-   return NULL;
-}
-/**
-*
-*/
-function chado_analysis_unigene_form ($node){
-
-   $unigene = $node->analysis->tripal_analysis_unigene;
-
-   // set the form defaults
-   $unigene_name = $node->unigene_name;
-   if(!$unigene_name){
-      $unigene_name = $unigene->unigene_name;
-   }
-   $num_reads = $node->num_reads;
-   if(!$num_reads){
-      $num_reads = $unigene->num_reads;
-   }
-   $avg_length = $node->avg_length;
-   if(!$avg_length){
-      $avg_length = $unigene->avg_length;
-   }
-   $num_clusters = $node->num_clusters;
-   if(!$num_clusters){
-      $num_clusters = $unigene->num_clusters;
-   }
-   $num_contigs = $node->num_contigs;
-   if(!$num_contigs){
-      $num_contigs = $unigene->num_contigs;
-   }
-   $num_singlets = $node->num_singlets;
-   if(!$num_singlets){
-      $num_singlets = $unigene->num_singlets;
-   }
-   $contig_min_len= $node->contig_min_len;
-   if(!$contig_min_len){
-      $contig_min_len = $unigene->contig_min_len;
-   }
-   $contig_max_len= $node->contig_max_len;
-   if(!$contig_max_len){
-      $contig_max_len = $unigene->contig_max_len;
-   }
-   $contig_avg_len= $node->contig_avg_len;
-   if(!$contig_avg_len){
-      $contig_avg_len = $unigene->contig_avg_len;
-   }
-   $singlet_min_len= $node->singlet_min_len;
-   if(!$singlet_min_len){
-      $singlet_min_len = $unigene->singlet_min_len;
-   }
-   $singlet_max_len= $node->singlet_max_len;
-   if(!$singlet_max_len){
-      $singlet_max_len = $unigene->singlet_max_len;
-   }
-   $singlet_avg_len= $node->singlet_avg_len;
-   if(!$singlet_avg_len){
-      $singlet_avg_len = $unigene->singlet_avg_len;
-   }
-
-
-   // add in the default fields for an analysis
-   $form = chado_analysis_form($node);
-
-	$form['unigene_name'] = array(
-      '#title' => t('Unigene Name'),
-      '#type' => 'textfield',
-      '#required' => TRUE,
-      '#description' => t('A distinct name used to identify this unigene'),
-      '#default_value' => $unigene_name,
-	);
-
-
-	$form['unigene_stats'] = array(
-      '#title' => t('Unigene Stats'),
-      '#type' => 'fieldset',
-      '#description' => t('Unigene, contig and singlet statistics'),
-      '#collapsible' => TRUE,
-	);
-
-   
-	$form['unigene_stats']['num_reads'] = array(
-      '#title' => t('Number of Reads'),
-      '#type' => 'textfield',
-      '#required' => FALSE,
-      '#description' => t('Provide the number of reads, after filtering that were used for input into the assembly'),
-      '#default_value' => $num_reads,
-	);
-
-	$form['unigene_stats']['avg_length'] = array(
-      '#title' => t('Average Contig Length'),
-      '#type' => 'textfield',
-      '#required' => FALSE,
-      '#description' => t('Provide the average sequence length in the ungiene (average of contigs and signlets).'),
-      '#default_value' => $avg_length,
-	);
-
-	$form['unigene_stats']['num_clusters'] = array(
-      '#title' => t('Number of Clusters'),
-      '#type' => 'textfield',
-      '#required' => FALSE,
-      '#description' => t('Provide the number of clusters generated by the asssembly if a clustering mechanism was used for unigene constructions'),
-      '#default_value' => $num_clusters,
-	);
-
-	$form['unigene_stats']['num_contigs'] = array(
-      '#title' => t('Number of Contigs'),
-      '#type' => 'textfield',
-      '#required' => FALSE,
-      '#description' => t('Provide the number of contigs generated by the assembly'),
-      '#default_value' => $num_contigs,
-	);
-
-	$form['unigene_stats']['num_singlets'] = array(
-      '#title' => t('Number of Singlets'),
-      '#type' => 'textfield',
-      '#required' => FALSE,
-      '#description' => t('Provide the number of singlets remaining in the assembly'),
-      '#default_value' => $num_singlets,
-	);
-
-
-	$form['contig_stats'] = array(
-      '#title' => t('Contig Stats'),
-      '#type' => 'fieldset',
-      '#description' => t('Unigene Contig statistics'),
-      '#collapsible' => TRUE,
-	);
-	$form['contig_stats']['contig_min_len'] = array(
-      '#title' => t('Minimum Contig Length'),
-      '#type' => 'textfield',
-      '#required' => FALSE,
-      '#description' => t('Provide the length of the smallest contig'),
-      '#default_value' => $contig_min_len,
-	);
-	$form['contig_stats']['contig_max_len'] = array(
-      '#title' => t('Maximum Contig Length'),
-      '#type' => 'textfield',
-      '#required' => FALSE,
-      '#description' => t('Provide the length of the largest contig'),
-      '#default_value' => $contig_max_len,
-	);
-	$form['contig_stats']['contig_avg_len'] = array(
-      '#title' => t('Average Contig Length'),
-      '#type' => 'textfield',
-      '#required' => FALSE,
-      '#description' => t('Provide the average contig length'),
-      '#default_value' => $contig_avg_len,
-	);
-
-
-	$form['singlet_stats'] = array(
-      '#title' => t('Singlet Stats'),
-      '#type' => 'fieldset',
-      '#description' => t('Unigene Singlet statistics'),
-      '#collapsible' => TRUE,
-	);
-	$form['singlet_stats']['singlet_min_len'] = array(
-      '#title' => t('Minimum Singlet Length'),
-      '#type' => 'textfield',
-      '#required' => FALSE,
-      '#description' => t('Provide the length of the smallest singlet'),
-      '#default_value' => $singlet_min_len,
-	);
-	$form['singlet_stats']['singlet_max_len'] = array(
-      '#title' => t('Maximum Singlet Length'),
-      '#type' => 'textfield',
-      '#required' => FALSE,
-      '#description' => t('Provide the length of the largest singlet'),
-      '#default_value' => $singlet_max_len,
-	);
-	$form['singlet_stats']['singlet_avg_len'] = array(
-      '#title' => t('Average Singlet Length'),
-      '#type' => 'textfield',
-      '#required' => FALSE,
-      '#description' => t('Provide the average singlet length'),
-      '#default_value' => $singlet_avg_len,
-	);
-   return $form;
-}
-/**
-*
-*/
-function chado_analysis_unigene_validate($node, &$form){
-   // use the analysis parent to validate the node
-   tripal_analysis_validate($node, $form); 
-}
-/**
-*
-*/
-function chado_analysis_unigene_insert($node){
-   // insert the analysis
-   chado_analysis_insert($node);
-
-   // add the unigene name as a property of the anslysis
-   tripal_analysis_insert_property($node->analysis_id,'analysis_type','tripal_analysis_unigene');	
-   tripal_analysis_insert_property($node->analysis_id,'analysis_unigene_name',$node->unigene_name);	
-   tripal_analysis_insert_property($node->analysis_id,'analysis_unigene_num_contigs',$node->num_contigs);	
-   tripal_analysis_insert_property($node->analysis_id,'analysis_unigene_num_reads',$node->num_reads);	
-   tripal_analysis_insert_property($node->analysis_id,'analysis_unigene_avg_length',$node->avg_length);
-   tripal_analysis_insert_property($node->analysis_id,'analysis_unigene_num_clusters',$node->num_clusters);	
-   tripal_analysis_insert_property($node->analysis_id,'analysis_unigene_num_singlets',$node->num_clusters);	
-}
-/**
-*
-*/
-function chado_analysis_unigene_update($node){
-   chado_analysis_update($node); 
-
-   tripal_analysis_update_property($node->analysis_id,'analysis_unigene_name',$node->unigene_name,1);
-   tripal_analysis_update_property($node->analysis_id,'analysis_unigene_num_contigs',$node->num_contigs,1);
-   tripal_analysis_update_property($node->analysis_id,'analysis_unigene_num_reads',$node->num_reads,1);
-   tripal_analysis_update_property($node->analysis_id,'analysis_unigene_avg_length',$node->avg_length,1);
-   tripal_analysis_update_property($node->analysis_id,'analysis_unigene_num_clusters',$node->num_clusters,1);
-   tripal_analysis_update_property($node->analysis_id,'analysis_unigene_num_singlets',$node->num_singlets,1);   
-}
-/**
-*
-*/
-function chado_analysis_unigene_delete($node){
-  chado_analysis_delete($node);
-}
-/**
-*
-*/
-function chado_analysis_unigene_view ($node, $teaser = FALSE, $page = FALSE) {
-   // use drupal's default node view:
-   $node = node_prepare($node, $teaser);
-   return $node;
-}
-/**
-*
-*/
-function chado_analysis_unigene_load($node){
-
-   // load the default set of analysis fields
-	$additions = chado_analysis_load($node);
-
-   // create some variables for easier lookup
-   $analysis = $additions->analysis;
-   $analysis_id = $analysis->analysis_id;
-
-   // add in the properties
-   $unigene_name = tripal_analysis_get_property($analysis_id,'analysis_unigene_name');
-   $num_contigs  = tripal_analysis_get_property($analysis_id,'analysis_unigene_num_contigs');
-   $num_reads    = tripal_analysis_get_property($analysis_id,'analysis_unigene_num_reads');
-   $avg_length   = tripal_analysis_get_property($analysis_id,'analysis_unigene_avg_length');
-   $num_clusters = tripal_analysis_get_property($analysis_id,'analysis_unigene_num_clusters');
-   $num_singlets = tripal_analysis_get_property($analysis_id,'analysis_unigene_num_singlets');
-
-   $analysis->tripal_analysis_unigene->unigene_name = $unigene_name->value;
-   $analysis->tripal_analysis_unigene->num_contigs = $num_contigs->value;
-   $analysis->tripal_analysis_unigene->num_reads = $num_reads->value;
-   $analysis->tripal_analysis_unigene->avg_length = $avg_length->value;
-   $analysis->tripal_analysis_unigene->num_clusters = $num_clusters->value;
-   $analysis->tripal_analysis_unigene->num_singlets = $num_singlets->value;
-
-   // add in organism information using the materialized view
-   $sql = "SELECT * FROM {organism_unigene_mview} OUM ".
-          "  INNER JOIN {organism} O on OUM.organism_id = O.organism_id ".
-          "WHERE OUM.analysis_id = %d ".
-          "ORDER BY O.genus, O.species";
-   $previous_db = tripal_db_set_active('chado');  // use chado database
-   $organisms = db_query($sql,$analysis_id);
-   tripal_db_set_active($previous_db);  // now use drupal database
-
-   while($organism = db_fetch_object($organisms)){
-      $sql = "SELECT nid FROM {chado_organism} WHERE organism_id = %d";
-      $c_org = db_fetch_object(db_query($sql,$organism->organism_id));
-      $organism->nid = $c_org->nid;
-      $analysis->tripal_analysis_unigene->organisms[] = $organism;
-   }
-
-
-   return $additions;
-}
-/**
- *
- *
- * @ingroup tripal_analysis_unigene
- */
-function tripal_analysis_unigene_block($op = 'list', $delta = 0, $edit=array()){
-   switch($op) {
-      case 'list':
-         $blocks['base_ugene']['info'] = t('Analysis: Unigene Details');
-         $blocks['base_ugene']['cache'] = BLOCK_NO_CACHE;
-
-         $blocks['feature_ugene']['info'] = t('Tripal Feature Unigene');
-         $blocks['feature_ugene']['cache'] = BLOCK_NO_CACHE;
-
-         $blocks['org_ugene']['info'] = t('Tripal Organism Unigene');
-         $blocks['org_ugene']['cache'] = BLOCK_NO_CACHE;
-         
-         return $blocks;
-
-
-      case 'view':
-         if(user_access('access chado_analysis_unigene content') and arg(0) == 'node' and is_numeric(arg(1))) {
-            $nid = arg(1);
-            $node = node_load($nid);
- 
-            $block = array();
-            switch($delta){
-               case 'base_ugene':
-                  $block['subject'] = t('Unigene Details');
-                  $block['content'] = theme('tripal_analysis_unigene_base',$node);
-                  break;
-               case 'feature_ugene':
-                  $block['subject'] = t('Unigene');
-                  $block['content'] = theme('tripal_feature_unigenes',$node);
-                  break;
-               case 'org_ugene':
-                  $block['subject'] = t('Unigene');
-                  $block['content'] = theme('tripal_organism_unigenes',$node);
-                  break;
-               default :
-            }
-            return $block;
-         }
-   }
-}
-/*******************************************************************************
- * tripal_analysis_unigene_nodeapi()
- * HOOK: Implementation of hook_nodeapi()
- * Display unigene results for allowed node types
- */
-function tripal_analysis_unigene_nodeapi(&$node, $op, $teaser, $page) {
-
-   switch ($op) {
-      case 'view':
-         // Find out which node types for showing the unigene
-         $types_to_show = variable_get('tripal_analysis_unigene_setting',
-            array('chado_feature','chado_organism'));
-
-         // Abort if this node is not one of the types we should show.
-         if (in_array($node->type, $types_to_show, TRUE)) {
-            // Add unigene to the content item if it's not a teaser
-            if ($teaser) {
-               return '';
-            }
-         	
-            // add the alignment to the feature search indexing
-            if($node->build_mode == NODE_BUILD_SEARCH_INDEX){
-               $node->content['tripal_analysis_unigene_index_version'] = array(
-						'#value' => theme('tripal_analysis_unigene_search_index',$node),
-						'#weight' => 4,
-               );
-            } else if ($node->build_mode == NODE_BUILD_SEARCH_RESULT) {
-               $node->content['tripal_analysis_unigene_index_version'] = array(
-						'#value' => theme('tripal_analysis_unigene_search_result',$node),
-						'#weight' => 4,
-               );
-            } else {
-
-               if(strcmp($node->type,'chado_organism')==0){
-                  $node->content['tripal_organism_unigenes'] = array(
-					   	'#value' => theme('tripal_organism_unigenes', $node),
-						'#weight' => 4
-                  );
-               }
-               if(strcmp($node->type,'chado_feature')==0){
-                  $node->content['tripal_feature_unigenes'] = array(
-					   	'#value' => theme('tripal_feature_unigenes', $node),
-						'#weight' => 4
-                  );
-               }
-            }
-         }
-      break;   
-   }
-}
-
-/**
- * Implements hook_theme_registry_alter().
- */
-function tripal_analysis_unigene_theme_registry_alter(&$info) {
-  // Inject our module into the node theme registry as being an available theme
-  // path so that we can override the node template for our content type.
-  array_splice($info['node']['theme paths'], 1, 0, array(drupal_get_path('module', 'tripal_analysis_unigene')));
-}
-
-/************************************************************************
- *  We need to let drupal know about our theme functions and their arguments.
- *  We create theme functions to allow users of the module to customize the
- *  look and feel of the output generated in this module
- */
-function tripal_analysis_unigene_theme () {
-	$path = drupal_get_path('module', 'tripal_analysis_unigene') . '/theme';
-   return array(
-      'tripal_analysis_unigene_search_index' => array (
-         'arguments' => array('node'),
-      ),
-      'tripal_analysis_unigene_search_result' => array (
-         'arguments' => array('node'),
-      ),
-      'tripal_organism_unigenes' => array (
-         'arguments' => array('node'=> null),
-         'template' => 'tripal_organism_unigenes',
-         'path' => $path . '/tripal_organism',
-      ),
-      'tripal_analysis_unigene_base' => array (
-         'arguments' => array('node'=> null),
-         'template' => 'tripal_analysis_unigene_base',
-         'path' => $path . '/tripal_analysis_unigene',
-      ),
-   );
-}
-
-/*******************************************************************************
- *  
- */
-function tripal_analysis_unigene_preprocess_tripal_organism_unigenes(&$variables){
-   $node = $variables['node'];
-   $organism = $node->organism;
-   $unigenes = tripal_analysis_unigene_load_organism_unigenes($organism);
-   $node->organism->tripal_analysis_unigene->unigenes =  $unigenes;
-}
-/*******************************************************************************
- *  
- */
-function tripal_analysis_unigene_preprocess_tripal_feature_unigenes(&$variables){
-   $node = $variables['node'];
-   $feature = $node->feature;
-   $unigenes = tripal_analysis_unigene_load_feature_unigenes($feature);
-   $node->feature->tripal_analysis_unigene->unigenes =  $unigenes;
-}
-/************************************************************************
- *  This function is an extension of the chado_feature_view by providing
- *  the markup for the feature object THAT WILL BE INDEXED.
- */
-function theme_tripal_analysis_unigene_search_index ($node) {
-
-   $feature = $node->feature;
-   $obj_feature = tripal_analysis_unigene_get_alignments($feature);
-   $alignments = $obj_feature->alignments;
-   $content = "<strong>";
-   if(count($alignments) > 0){
-      // iterate through each alignment
-      foreach ($alignments as $result){
-         // EST alignments in chado use an EST_match type to map ESTs to
-         // contigs and a rank to indicate the major srcfeature.
-         // We don't want to show EST_matches on the alignment view
-         // since that doesn't make much sense to the end user.  If this
-         // is an EST_match and the feature is an EST then we want to show
-         // the contig in the alignments.  The contig name is part of the
-         // uniquename in the EST_match
-         if($node->feature->cvname == 'EST' && $result->cvname == 'EST_match'){
-            $sql = "SELECT srcfeature_id ".
-                   "FROM {featureloc} ".
-                   "WHERE feature_id = $result->feature_id ".
-                   "ORDER BY rank";
-            $previous_db = tripal_db_set_active ('chado');
-            $contig_fid = db_result(db_query($sql));
-            $sql = "SELECT name FROM {feature} WHERE feature_id = $contig_fid";
-            $contig_name = db_result(db_query($sql));
-            tripal_db_set_active($previous_db);
-            $sql = "SELECT nid ".
-                   "FROM {chado_feature} ".
-                   "WHERE feature_id = $contig_fid";
-            $contig_nid = db_result(db_query($sql));
-            // Check if the EST exists as a drupal node. If yes, add a link to
-            // it. If no, just show the name
-            if ($contig_nid != 0) {
-               $sql = "SELECT nid FROM {node} WHERE nid=$contig_nid";
-               $node_exists = db_result(db_query($sql));
-            }
-            $content .= "$contig_name " ;
-         }
-         elseif($node->feature->cvname == 'contig' && $result->cvname == 'EST_match'){
-            $sql = "SELECT vid ".
-                   "FROM {node} ".
-                   "WHERE title = '$result->feature_name'".
-                   "ORDER BY vid DESC";
-            // since the feature name is also the node title we can look it up
-            $est_node = db_fetch_object(db_query($sql));
-            $content .= "$result->feature_name ";
-         }
-         else {
-            $content .= "$result->cvname $result->feature_name ";
-         }
-      }
-   }
-   $content .= "</strong>";
-   return $content;
-}
-
-/************************************************************************
- *  This function is an extension of the chado_feature_view by providing
- *  the markup for the feature object to show on a search result page.
- */
-function theme_tripal_analysis_unigene_search_result ($node) {
-
-   $feature = $node->feature;
-   $obj_feature = tripal_analysis_unigene_get_alignments($feature);
-   $alignments = $obj_feature->alignments;
-   $content = "<strong>";
-   if(count($alignments) > 0){
-      // iterate through each alignment
-      foreach ($alignments as $result){
-         // EST alignments in chado use an EST_match type to map ESTs to
-         // contigs and a rank to indicate the major srcfeature.
-         // We don't want to show EST_matches on the alignment view
-         // since that doesn't make much sense to the end user.  If this
-         // is an EST_match and the feature is an EST then we want to show
-         // the contig in the alignments.  The contig name is part of the
-         // uniquename in the EST_match
-         if($node->feature->cvname == 'EST' && $result->cvname == 'EST_match'){
-            $sql = "SELECT srcfeature_id ".
-                   "FROM {featureloc} ".
-                   "WHERE feature_id = $result->feature_id ".
-                   "ORDER BY rank";
-            $previous_db = tripal_db_set_active ('chado');
-            $contig_fid = db_result(db_query($sql));
-            $sql = "SELECT name FROM {feature} WHERE feature_id = $contig_fid";
-            $contig_name = db_result(db_query($sql));
-            tripal_db_set_active($previous_db);
-            $sql = "SELECT nid ".
-                   "FROM {chado_feature} ".
-                   "WHERE feature_id = $contig_fid";
-            $contig_nid = db_result(db_query($sql));
-            // Check if the EST exists as a drupal node. If yes, add a link to
-            // it. If no, just show the name
-            if ($contig_nid != 0) {
-               $sql = "SELECT nid FROM {node} WHERE nid=$contig_nid";
-               $node_exists = db_result(db_query($sql));
-            }
-            $content .= "Alignment to contig $contig_name. " ;
-         }
-         elseif($node->feature->cvname == 'contig' && $result->cvname == 'EST_match'){
-            $sql = "SELECT vid ".
-                   "FROM {node} ".
-                   "WHERE title = '$result->feature_name'".
-                   "ORDER BY vid DESC";
-            // since the feature name is also the node title we can look it up
-            $est_node = db_fetch_object(db_query($sql));
-            $content .= "Aligned EST: $result->feature_name ";
-         }
-         else {
-            $content .= "Aligned $result->cvname: $result->feature_name ";
-         }
-      }
-   }
-   $content .= "</strong>";
-   return $content;
-}
-
-/*******************************************************************************
- * tripal_analysis_unigene_results ()
- * Prepare unigene result for the feature shown on the page
- */
-function theme_tripal_analysis_unigene_feature_alignments($node) {
-   $feature = $node->feature;
-   $obj_feature = tripal_analysis_unigene_get_alignments($feature);
-   $alignments = $obj_feature->alignments;
-   if(count($alignments) > 0){
-      $content = "<div id=\"tripal_analysis_unigene_box\" class=\"tripal_unigene-info-box\">";
-      // we're showing contig alignments in GBrowse so create a link here for
-      // that if this feature is a contig
-      if($node->feature->cvname == 'contig'){
-         $content .= "<div class=\"tripal_expandableBox\">".
-                     "  <h3>ESTs in this contig</h3>".
-                     "</div>";
-         $content .= "<div class=\"tripal_expandableBoxContent\">";
-      } else {
-         $content .= "<div class=\"tripal_expandableBox\">".
-                     "  <h3>Alignments</h3>".
-                     "</div>";
-         $content .= "<div class=\"tripal_expandableBoxContent\">";
-      }
-      $content .= "".
-         "<table class=\"tripal_table_horz\">".
-         "  <tr>".
-         "    <th>Type</th>".
-         "    <th>Feature</th>".
-         "    <th align=\"right\">Position</th>".
-         "  </tr>";
-      // iterate through each alignment
-      foreach ($alignments as $result){
-         // EST alignments in chado use an EST_match type to map ESTs to
-         // contigs and a rank to indicate the major srcfeature.
-         // We don't want to show EST_matches on the alignment view
-         // since that doesn't make much sense to the end user.  If this
-         // is an EST_match and the feature is an EST then we want to show
-         // the contig in the alignments.  The contig name is part of the
-         // uniquename in the EST_match
-         if($node->feature->cvname == 'EST' && $result->cvname == 'EST_match'){
-            $sql = "SELECT srcfeature_id ".
-                   "FROM {featureloc} ".
-                   "WHERE feature_id = $result->feature_id ".
-                   "ORDER BY rank";
-            $previous_db = tripal_db_set_active ('chado');
-            $contig_fid = db_result(db_query($sql));
-            $sql = "SELECT name FROM {feature} WHERE feature_id = $contig_fid";
-            $contig_name = db_result(db_query($sql));
-            tripal_db_set_active($previous_db);
-            $sql = "SELECT nid ".
-                   "FROM {chado_feature} ".
-                   "WHERE feature_id = $contig_fid";
-            $contig_nid = db_result(db_query($sql));
-            // Check if the EST exists as a drupal node. If yes, add a link to
-            // it. If no, just show the name
-            if ($contig_nid != 0) {
-               $sql = "SELECT nid FROM {node} WHERE nid=$contig_nid";
-               $node_exists = db_result(db_query($sql));
-            }
-            $content .=
-              "<tr>".
-              "  <td>Contig</td>".
-              "  <td>";
-            if ($node_exists != 0) {
-               $content .= "<a href=\"".url("node/$contig_nid")."\">".
-              	     	   "$contig_name</a>";
-            } else {
-               $content .= $contig_name;
-            }
-            $content .=
-              "  </td>".
-              "  <td align=\"right\">".
-            number_format($result->fmin).
-                   "-".
-            number_format($result->fmax).
-              "  </td>".
-              "</tr>";
-         }
-
-         elseif($node->feature->cvname == 'contig' &&
-         $result->cvname == 'EST_match'){
-            $sql = "SELECT vid ".
-                   "FROM {node} ".
-                   "WHERE title = '$result->feature_name'".
-                   "ORDER BY vid DESC";
-            // since the feature name is also the node title we can look it up
-            $est_node = db_fetch_object(db_query($sql));
-            $content .=
-              "<tr>".
-              "  <td>EST</td>".
-              "  <td>";
-            //Check if the EST exists as a drupal node before adding a hyperlink
-            if ($est_node->vid != 0) {
-               $content .=
-               	 "<a href=\"".url("node/$est_node->vid")."\">".
-               $result->feature_name.
-              	 "</a>";
-            } else {
-               $content .= $result->feature_name;
-            }
-            $content .=
-              "  </td>".
-              "  <td align=\"right\">".
-            number_format($result->fmin).
-                   "-".
-            number_format($result->fmax).
-              "  </td>".
-              "</tr>";
-         }
-         else {
-            $content .= "".
-              "<tr>".
-              "  <td>$result->cvname</td>".
-              "  <td>$result->feature_name</td>".
-              "  <td align=\"right\">$result->fmin</td>".
-              "  <td align=\"right\">$result->fmax</td>".
-              "  <td align=\"right\">$result->strand</td>".
-              "</tr>";
-         }
-      }
-      $content .= "</table>";
-
-      /* if this is a contig then get the alignment
-       if($node->feature->cvname == 'contig'){
-       // get the directory prefix
-       $prefix = preg_replace("/^(\d*)\d{3}$/","$1",$node->feature_id);
-       if(!$prefix){
-       $prefix = '0';
-       }
-       $data_url = variable_get('chado_feature_data_url','sites/default/files/data');
-       $fh = fopen("$data_url/misc/$prefix/$node->feature->feature_id/alignment.txt", 'r');
-       if($fh){
-       $content .= "<b>Alignment:</b><div class=\"tripal_feature_assembly_alignment\"><pre>";
-       while(!feof($fh)){
-       $content .= fgets($fh);
-       }
-       $content .="</pre></div>";
-       }
-       fclose($fh);
-       }
-       */
-      $content .= "</div></div>";
-   }
-   return $content;
-}
-/*******************************************************************************
-*
-*/
-function tripal_analysis_unigene_get_alignments($map) {
-
-   // get the alignments for this feature
-   $sql = "SELECT F.name as feature_name, FL.fmin, FL.fmax, FL.strand, ".
-          "  FL.phase, CVT.name as cvname, F.feature_id, F.uniquename, ".
-          "  FL.featureloc_id ".
-          "FROM {featureloc} FL ".
-          "  INNER JOIN Feature F ON F.feature_id = FL.feature_id ".
-          "  INNER JOIN Cvterm CVT ON CVT.cvterm_id = F.type_id ".
-          "WHERE srcfeature_id = %d AND ".
-          "  NOT(CVT.name = 'match' or CVT.name = 'match_part') ".
-          "ORDER BY FL.fmin, FL.fmax";
-   $previous_db = tripal_db_set_active('chado');
-   $results = db_query($sql,$map->feature_id);
-   $alignments = array();
-   $i=0;
-   while($subfeature = db_fetch_object($results)){
-      $alignments[$i++] = $subfeature;
-   }
-   $additions->alignments = $alignments;
-
-   /* get the GO Terms
-    $sql = "SELECT DISTINCT * FROM {go_results_mview} ".
-    "WHERE feature_id = %d";
-    $results = db_query($sql,$map->feature_id);
-    $go_terms = array();
-    $i=0;
-    while($term = db_fetch_object($results)){
-    $go_terms[$i++] = $term;
-    }
-    $additions->go_terms = $go_terms;
-
-    // get the feature properties
-    $sql = "SELECT FP.value,FP.rank,CVT.name,CVT.definition ".
-    "FROM {featureprop} FP".
-    "  INNER JOIN Cvterm CVT ".
-    "    ON FP.type_id = CVT.cvterm_id ".
-    "WHERE feature_id = %d";
-    $results = db_query($sql,$map->feature_id);
-    $properties = array();
-    $i=0;
-    while($property = db_fetch_object($results)){
-    $properties[$i++] = $property;
-    }
-    $additions->properties = $properties;
-    */
-   tripal_db_set_active($previous_db);
-   return $additions;
-}
-/************************************************************************
-*
-*/   
-function tripal_analysis_unigene_load_organism_unigenes($organism){
-
-   // get information about this assemblies and add it to the items in this node
-   $sql = "SELECT * FROM {organism_unigene_mview} OUM ".
-          "  INNER JOIN {analysis} A  ON A.analysis_id = OUM.analysis_id ".
-          "WHERE OUM.organism_id = %d ".
-          "ORDER BY A.timeexecuted DESC";
-   $previous_db = tripal_db_set_active('chado');  // use chado database
-   $results = db_query($sql,$organism->organism_id);
-   tripal_db_set_active($previous_db);  // now use drupal database
-
-   $unigenes = array();
-   $i=0;
-   $sql = "SELECT nid FROM {chado_analysis} WHERE analysis_id = %d";
-   while($unigene = db_fetch_object($results)){
-      $analysis_id = $unigene->analysis_id;
-      $c_node = db_fetch_object(db_query($sql,$analysis_id));
-      if($c_node){  
-         $unigene->nid = $c_node->nid;
-      }
-      // add in the properties
-      $unigene_name = tripal_analysis_get_property($analysis_id,'analysis_unigene_name');
-      $num_contigs  = tripal_analysis_get_property($analysis_id,'analysis_unigene_num_contigs');
-      $num_reads    = tripal_analysis_get_property($analysis_id,'analysis_unigene_num_reads');
-      $num_clusters = tripal_analysis_get_property($analysis_id,'analysis_unigene_num_clusters');
-      $num_singlets = tripal_analysis_get_property($analysis_id,'analysis_unigene_num_singlets');
-      
-      $unigene->unigene_name = $unigene_name->value;
-      $unigene->num_reads = $num_reads->value;
-      $unigene->num_clusters = $num_clusters->value;
-      $unigene->num_contigs = $num_contigs->value;     
-      $unigene->num_singlets = $num_singlets->value;
-
-      $unigenes[$i++] = $unigene;
-   }
-   return $unigenes;
-}
-/************************************************************************
-*
-*/   
-function tripal_analysis_unigene_load_feature_unigenes($feature){
-
-   // first get all the unigene analyses for this organism
-   $sql = "SELECT * FROM {organism_unigene_mview} OUM ".
-          "  INNER JOIN {analysis} A  ON A.analysis_id = OUM.analysis_id ".
-          "WHERE OUM.organism_id = %d ".
-          "ORDER BY A.timeexecuted DESC";
-   $previous_db = tripal_db_set_active('chado');  // use chado database
-   $results = db_query($sql,$feature->organism_id->organism_id);
-   tripal_db_set_active($previous_db);  // now use drupal database
-
-   // iterate through the unigenes and find those that use this feature
-   $unigenes = array();
-   $i=0;
-   $sql = "SELECT nid FROM {chado_analysis} WHERE analysis_id = %d";
-   while($unigene = db_fetch_object($results)){
-      $analysis_id = $unigene->analysis_id;
-
-      // check if this feature is present in the unigene
-      $values = array(
-         'feature_id' => $feature->feature_id,
-         'analysis_id' => $analysis_id,
-      );
-      $hasFeature = tripal_core_chado_select('analysisfeature',array('*'),$values);
-      
-      // if the feature is present then get information about it
-      if(sizeof($hasFeature) > 0){
-         // see if there is a drupal node for this unigene
-         $c_node = db_fetch_object(db_query($sql,$analysis_id));
-         if($c_node){  
-            $unigene->nid = $c_node->nid;
-         }
-         // add in the properties
-         $unigene_name = tripal_analysis_get_property($analysis_id,'analysis_unigene_name');
-         $singlet = tripal_core_get_property('analysisfeature',$analysis_id,'singlet','tripal');       
-         
-         $unigene->unigene_name = $unigene_name->value;    
-         $unigene->singlet = $num_singlets->value;
-
-         $unigenes[$i++] = $unigene;
-      }
-   }
-   return $unigenes;
-}
-/*******************************************************************************
- * Tripal Unigene administrative setting form. This function is called by
- * tripal_analysis module which asks for an admin form to show on the page
- */
-function tripal_analysis_unigene_get_settings() {
-   // Get an array of node types with internal names as keys
-   $options = node_get_types('names');
-   // Add 'chado_feature' to allowed content types for showing unigene results
-   $allowedoptions ['chado_feature'] = "Show 'ESTs in this contig' on feature pages";
-   $allowedoptions ['chado_organism'] = "Show assemblies on organism pages";
-
-   $form['description'] = array(
-       '#type' => 'item',
-       '#value' => t("This option allows user to display the unigene assembly ".
-          "information. For contigs, this would include an alignment and for ".
-          "organisms this would be a list of assemblies. Check the box to ".
-          "enable the display of unigene information. Uncheck to disable."),
-		 '#weight' => 0,
-   );
-
-   $form['tripal_analysis_unigene_setting'] = array(
-      '#type' => 'checkboxes',
-      '#options' => $allowedoptions,
-      '#default_value'=>variable_get('tripal_analysis_unigene_setting',array()),
-   );
-   $settings->form = $form;
-   $settings->title = "Tripal Unigene";
-   return $settings;
-}
-
-

+ 1 - 1
extensions/tripal_search_unigene/tripal_search_unigene.install

@@ -35,7 +35,7 @@ function tripal_search_unigene_install(){
    							  ";
    
    $index = "feature_id, go_term, unigene, blast_value, kegg_value, interpro_value";
-   $singlet_type_id = tripal_get_cvterm_id('singlet_in_analysis');
+   $singlet_type_id = tripal_cv_get_cvterm_by_name('singlet_in_analysis');
    if ($singlet_type_id) {
    	$singlet_condition = " AND F.feature_id NOT IN (SELECT feature_id from feature
    						   WHERE type_id = (select cvterm_id from cvterm where name = 'EST')

+ 7 - 4
extensions/tripal_search_unigene/views_handler_filter_analysis_name.inc

@@ -1,10 +1,13 @@
 <?php
 class views_handler_filter_analysis_name extends views_handler_filter_string {
 	function value_form(&$form, &$form_state) {
-		$type_id = tripal_get_cvterm_id("analysis_type");
-		$sql = "SELECT name, A.analysis_id FROM {analysis} A INNER JOIN {analysisprop} AP ON A.analysis_id = AP.analysis_id WHERE type_id = $type_id AND value = 'tripal_analysis_unigene'";
+		$type_id = tripal_cv_get_cvterm_by_name("analysis_type");
+		$sql = "SELECT name, A.analysis_id 
+		        FROM {analysis} A 
+		           INNER JOIN {analysisprop} AP ON A.analysis_id = AP.analysis_id 
+		        WHERE type_id = %d AND value = 'tripal_analysis_unigene'";
 
-		$results = chado_query($sql);
+		$results = chado_query($sql,$typ_id->cvterm_id);
 		$analyses = array();
 		$block_ana = array();
 		$counter = 0;
@@ -47,4 +50,4 @@ class views_handler_filter_analysis_name extends views_handler_filter_string {
 			'=' => t('Is equal to')
 		);
 	}
-}
+}

+ 0 - 34
base/tripal_analysis/tripal_analysis.admin.inc → tripal_analysis/tripal_analysis.admin.inc

@@ -481,39 +481,5 @@ function tripal_analysis_admin_validate($form, &$form_state) {
 		tripal_add_job('Cleanup orphaned analyses','tripal_analysis',
          'tripal_analyses_cleanup',$job_args,$user->uid);
 	}
-
-	// -------------------------------------
-	// Save blast regular expression settings
-	if ($form_state['values']['op'] == t('Save settings')) {
-		$db_id = $form_state['values']['blastdb'];
-		$name = $form_state['values']['displayname'];
-		$gbstyle = $form_state['values']['gb_style_parser'];
-		$reg1 = $form_state['values']['hit_id'];
-		$reg2 = $form_state['values']['hit_def'];
-		$reg3 = $form_state['values']['hit_accession'];
-		
-		// Check if the blast settings exists
-		
-		$sql = "SELECT db_id FROM {tripal_analysis_blast} WHERE db_id=%d";
-		$check = db_result(db_query($sql, $db_id));
-
-		// If setting exists, update it
-		if ($check) {
-			$sql = "UPDATE {tripal_analysis_blast} ".
-   	          "SET displayname = '%s', ".
-   	          "    regex_hit_id = '%s', ".
-   	          "    regex_hit_def = '%s', ".
-   	          "    regex_hit_accession = '%s', ".
-			       "    genbank_style = %d ".
-   	          "WHERE db_id=%d";
-			db_query($sql, $name, $reg1, $reg2, $reg3, $gbstyle, $db_id);
-			// Otherwise, insert a new setting for the db
-		} else {
-			$sql = "INSERT INTO {tripal_analysis_blast} (db_id, displayname, ".
-   		       "           regex_hit_id, regex_hit_def, regex_hit_accession, genbank_style) ".
-   		       "VALUES (%d, '%s', '%s', '%s', '%s', %d) ";
-			db_query($sql, $db_id, $name, $reg1, $reg2, $reg3, $gbstyle);
-		}
-	}
 }
 

+ 0 - 0
base/tripal_analysis/tripal_analysis.api.inc → tripal_analysis/tripal_analysis.api.inc


+ 0 - 0
base/tripal_analysis/tripal_analysis.info → tripal_analysis/tripal_analysis.info


+ 7 - 7
base/tripal_analysis/tripal_analysis.install → tripal_analysis/tripal_analysis.install

@@ -29,10 +29,10 @@ function tripal_analysis_install() {
 	}
 	tripal_db_set_active($previous_db);
 
-   tripal_add_cvterms('analysis_type','The type of analysis was performed. This value is automatically set by each Tripal Analysis module and should be equal to the module name (e.g. tripal_analysis_blast, tripal_analysis_go).');
-	tripal_add_cvterms('analysis_date','The date that an analysis was performed.');
-	tripal_add_cvterms('analysis_short_name','A computer legible (no spaces '.
-      'or special characters) abbreviation for the analysis.');
+   tripal_cv_add_cvterm(array('name' => 'analysis_type','def' => 'The type of analysis was performed. This value is automatically set by each Tripal Analysis module and should be equal to the module name (e.g. tripal_analysis_blast, tripal_analysis_go).'),'tripal',0,1,'tripal');
+	tripal_cv_add_cvterm(array('name' => 'analysis_date','def' => 'The date that an analysis was performed.'),'tripal',0,1,'tripal');
+	tripal_cv_add_cvterm(array('name' => 'analysis_short_name','def' => 'A computer legible (no spaces '.
+      'or special characters) abbreviation for the analysis.'),'tripal',0,1,'tripal');
 }
 
 /*******************************************************************************
@@ -131,10 +131,10 @@ function tripal_analysis_requirements($phase) {
  */
 function tripal_analysis_update_6001(){
    // we have some new cvterms to add
-   tripal_add_cvterms('based_on_analysis','The analysis that this analysis was based on. For example, blast/kegg/interpro analyses are based on a unigene analysis. The unigene analysis_id should be stored in analysisprop as the rank using this cvterm. The name of said unigene analysis can be inserted as the value in analysisprop.');
-   tripal_add_cvterms('additional_files', 'Additional files for this analysis. Each file should be separated by a semi-colon and have this format: <file description>, <file path>;');
+   tripal_cv_add_cvterm(array('name' => 'based_on_analysis','def' => 'The analysis that this analysis was based on. For example, blast/kegg/interpro analyses are based on a unigene analysis. The unigene analysis_id should be stored in analysisprop as the rank using this cvterm. The name of said unigene analysis can be inserted as the value in analysisprop.'),'tripal',0,1,'tripal');
+   tripal_cv_add_cvterm(array('name' => 'additional_files', 'def' => 'Additional files for this analysis. Each file should be separated by a semi-colon and have this format: <file description>, <file path>;'),'tripal',0,1,'tripal');
    $ret = array(
       '#finished' => 1,
    );   
    return $ret;
-}
+}

+ 4 - 2
base/tripal_analysis/tripal_analysis.module → tripal_analysis/tripal_analysis.module

@@ -140,6 +140,7 @@ function tripal_analysis_node_info() {
  */
 function chado_analysis_insert($node){
 	global $user;
+
 	// Create a timestamp so we can insert it into the chado database
 	$time = $node->timeexecuted;
 	$month = $time['month'];
@@ -151,8 +152,8 @@ function chado_analysis_insert($node){
 	$analysis_id = $node->analysis_id;
 	if ($analysis_id) {
 		$sql = "SELECT analysis_id ".
-               "FROM {Analysis} ".
-               "WHERE analysis_id = %d ";
+             "FROM {Analysis} ".
+             "WHERE analysis_id = %d ";
 		$previous_db = tripal_db_set_active('chado');
 		$analysis = db_fetch_object(db_query($sql, $node->analysis_id));
 		tripal_db_set_active($previous_db);
@@ -492,6 +493,7 @@ function chado_analysis_load($node){
    $values = array('analysis_id' => $analysis_id);
    $analysis = tripal_core_generate_chado_var('analysis',$values);
 
+   $additions = new stdClass();
    $additions->analysis = $analysis;
    return $additions;
 }

+ 0 - 0
base/tripal_analysis/tripal_analysis.views.inc → tripal_analysis/tripal_analysis.views.inc


+ 0 - 0
base/tripal_analysis/tripal_analysis_privacy.inc → tripal_analysis/tripal_analysis_privacy.inc


+ 0 - 0
base/tripal_analysis/views/README → tripal_analysis/views/README


+ 0 - 0
base/tripal_analysis/views/analysis.views.inc → tripal_analysis/views/analysis.views.inc


+ 16 - 0
base/tripal_analysis/views/chado_analysis.views.inc → tripal_analysis/views/chado_analysis.views.inc

@@ -25,6 +25,22 @@ function retrieve_chado_analysis_views_data () {
   // Basic table definition
   $data['chado_analysis']['table'] = array(
     'field' => 'nid',
+    'group' => 'Chado Analysis'
+  );
+
+  $data['chado_analysis']['nid'] = array(
+    'title' => t('Analysis Node ID'),
+    'help' => t('The node ID for this analysis'),
+    'field' => array(
+     	'handler' => 'views_handler_field_numeric',
+ 		  'click sortable' => TRUE,
+    ),
+    'filter' => array(
+     	'handler' => 'views_handler_filter_numeric',
+    ),
+    'sort' => array(
+     	'handler' => 'views_handler_sort',
+    ),
   );
   
   // Note: No joins need to be made from $data['analysis']['table']

+ 0 - 0
base/tripal_analysis/views/handlers/views_handler_field_computed_analysis_nid.inc → tripal_analysis/views/handlers/views_handler_field_computed_analysis_nid.inc


+ 0 - 0
base/tripal_analysis/views/misc_tables.views.inc → tripal_analysis/views/misc_tables.views.inc


+ 0 - 0
base/tripal_analysis/views/template.node_join.views.inc → tripal_analysis/views/template.node_join.views.inc


+ 0 - 0
base/tripal_analysis/views/template.table_defn.views.inc → tripal_analysis/views/template.table_defn.views.inc


+ 0 - 0
base/tripal_bulk_loader/tripal_bulk_loader.admin.inc → tripal_bulk_loader/tripal_bulk_loader.admin.inc


+ 0 - 0
base/tripal_bulk_loader/tripal_bulk_loader.constants.inc → tripal_bulk_loader/tripal_bulk_loader.constants.inc


+ 0 - 0
base/tripal_bulk_loader/tripal_bulk_loader.info → tripal_bulk_loader/tripal_bulk_loader.info


+ 0 - 0
base/tripal_bulk_loader/tripal_bulk_loader.install → tripal_bulk_loader/tripal_bulk_loader.install


+ 8 - 1
base/tripal_bulk_loader/tripal_bulk_loader.loader.inc → tripal_bulk_loader/tripal_bulk_loader.loader.inc

@@ -243,8 +243,15 @@ function tripal_bulk_loader_load_data($nid) {
       if($node->job_id and $num_lines % $interval == 0){
         // percentage of lines processed for the current group
         $group_progress = round(($num_lines/$total_lines)*100);
+        
         // percentage of lines processed for all groups
-        $job_progress = round(($group_index / $total_num_groups) * $group_progress);
+        // <previous group index> * 100 + <current group progress>
+        // --------------------------------------------------------
+        //               <total number of groups>
+        // For example, if you were in the third group of 3 constant sets 
+        // and had a group percentage of 50% then the job progress would be
+        // (2*100 + 50%) / 3 = 250%/3 = 83%
+        $job_progress = round(((($group_index-1)*100)+$group_progress)/$total_num_groups);
         
           print "\nProgress Update:\n"
             ."\t- ".$num_lines." lines have been processed for the current constant set.\n"

+ 0 - 0
base/tripal_bulk_loader/tripal_bulk_loader.module → tripal_bulk_loader/tripal_bulk_loader.module


+ 0 - 0
base/tripal_contact/tripal_contact.api.inc → tripal_contact/tripal_contact.api.inc


+ 0 - 0
base/tripal_contact/tripal_contact.info → tripal_contact/tripal_contact.info


+ 0 - 0
base/tripal_contact/tripal_contact.module → tripal_contact/tripal_contact.module


+ 0 - 0
base/tripal_contact/tripal_contact.views.inc → tripal_contact/tripal_contact.views.inc


+ 0 - 0
base/tripal_contact/views/README → tripal_contact/views/README


+ 0 - 0
base/tripal_contact/views/template.node_join.views.inc → tripal_contact/views/template.node_join.views.inc


+ 0 - 0
base/tripal_contact/views/template.table_defn.views.inc → tripal_contact/views/template.table_defn.views.inc


+ 0 - 0
base/tripal_core/chado_install.php → tripal_core/chado_install.php


+ 0 - 0
base/tripal_core/default_schema.sql → tripal_core/default_schema.sql


+ 0 - 0
base/tripal_core/initialize.sql → tripal_core/initialize.sql


+ 2 - 1
base/tripal_core/jobs.php → tripal_core/jobs.php

@@ -310,7 +310,8 @@ function tripal_jobs_check_running () {
            "WHERE TJ.end_time IS NULL and NOT TJ.start_time IS NULL ";
    $jobs = db_query($sql);
    while($job = db_fetch_object($jobs)){
-      if($job->pid and posix_kill($job->pid, 0)) {
+      $status = `ps --pid=$job->pid --no-header`;
+      if($job->pid && $status) {
          // the job is still running so let it go
 		   // we return 1 to indicate that a job is running
 		   print "Job is still running (pid $job->pid)\n";

+ 703 - 0
tripal_core/mviews.php

@@ -0,0 +1,703 @@
+<?php
+
+/** 
+ * @defgroup tripal_mviews_api Core Module Materalized Views API
+ * @{
+ * Provides an application programming interface (API) to manage materialized views in Chado.
+ * The Perl-based chado comes with an interface for managing materialzed views.  This
+ * API provides an alternative Drupal-based method.  
+ * @}
+ * @ingroup tripal_api
+ */
+
+/**
+ * Add a materialized view to the chado database to help speed data access. This
+ * function supports the older style where postgres column specifications 
+ * are provided using the $mv_table, $mv_specs and $indexed variables. It also
+ * supports the newer preferred method where the materialized view is described
+ * using the Drupal Schema API array.  
+ *
+ * @param $name 
+ *   The name of the materialized view.
+ * @param $modulename 
+ *   The name of the module submitting the materialized view (e.g. 'tripal_library')
+ * @param $mv_table 
+ *   The name of the table to add to chado. This is the table that can be queried.
+ * @param $mv_specs 
+ *   The table definition 
+ * @param $indexed 
+ *   The columns that are to be indexed
+ * @param $query 
+ *   The SQL query that loads the materialized view with data
+ * @param $special_index  
+ *   currently not used
+ * @param $comment
+ *   A string containing a description of the materialized view
+ * @param $mv_schema
+ *   If using the newer Schema API array to define the materialized view then
+ *   this variable should contain the array.
+ *
+ * @ingroup tripal_mviews_api
+ */
+function tripal_add_mview ($name, $modulename, $mv_table, $mv_specs, $indexed,
+   $query, $special_index, $comment=NULL, $mv_schema=NULL)
+{
+   // get the table name from the schema array
+   $schema_arr = array();
+   if($mv_schema){
+      // get the schema from the mv_specs and use it to add the custom table
+      eval("\$schema_arr = $mv_schema;");
+      $mv_table = $schema_arr['table'];
+   }
+
+   $record = new stdClass();
+   $record->name = $name;
+   $record->modulename = $modulename;
+   $record->mv_table = $mv_table;
+   $record->mv_specs = $mv_specs;
+   $record->indexed = $indexed;
+   $record->query = $query;
+   $record->special_index = $special_index;
+   $record->comment = $comment;
+   $record->mv_schema = $mv_schema;
+
+   // add the record to the tripal_mviews table and if successful
+   // create the new materialized view in the chado schema
+   if(drupal_write_record('tripal_mviews',$record)){
+
+      // drop the table from chado if it exists
+      $previous_db = tripal_db_set_active('chado');  // use chado database
+      if (db_table_exists($mv_table)) {
+         $sql = "DROP TABLE $mv_table";
+         db_query($sql);
+      }
+      tripal_db_set_active($previous_db);  // now use drupal database
+      
+      // now construct the indexes
+      $index = '';
+      if($indexed){
+        // add to the array of values
+        $vals = preg_split("/[\n,]+/",$indexed);
+        $index = '';
+        foreach ($vals as $field){
+           $field = trim($field);
+           $index .= "CREATE INDEX idx_${mv_table}_${field} ON $mv_table ($field);";
+        }
+      }
+
+      // create the table differently depending on if it the traditional method
+      // or the Drupal Schema API method
+      if($mv_schema){
+         if(!tripal_create_chado_table ($ret,$mv_table,$schema_arr)){
+            drupal_set_message("Could not create the materialized view. Check Drupal error report logs.");
+         } else {
+            drupal_set_message(t("View '$name' created"));
+         }
+      } else {
+         // add the table to the database
+         $sql = "CREATE TABLE {$mv_table} ($mv_specs); $index"; 
+         $previous_db = tripal_db_set_active('chado');  // use chado database
+         $results = db_query($sql);
+         tripal_db_set_active($previous_db);  // now use drupal database
+         if($results){
+            drupal_set_message(t("View '$name' created"));
+         } else {
+            drupal_set_message(t("Failed to create the materialized view table: '$mv_table'"));
+         }
+      }
+   }
+}
+/**
+ * Edits a materialized view to the chado database to help speed data access.This
+ * function supports the older style where postgres column specifications 
+ * are provided using the $mv_table, $mv_specs and $indexed variables. It also
+ * supports the newer preferred method where the materialized view is described
+ * using the Drupal Schema API array.  
+ *
+ * @param $mview_id 
+ *   The mview_id of the materialized view to edit
+ * @param $name 
+ *   The name of the materialized view.
+ * @param $modulename 
+ *   The name of the module submitting the materialized view (e.g. 'tripal_library')
+ * @param $mv_table 
+ *   The name of the table to add to chado. This is the table that can be queried.
+ * @param $mv_specs 
+ *   The table definition 
+ * @param $indexed 
+ *   The columns that are to be indexed
+ * @param $query 
+ *   The SQL query that loads the materialized view with data
+ * @param $special_index  
+ *   currently not used
+ * @param $comment
+ *   A string containing a description of the materialized view
+ * @param $mv_schema
+ *   If using the newer Schema API array to define the materialized view then
+ *   this variable should contain the array.
+ *
+ * @ingroup tripal_mviews_api
+ */
+function tripal_edit_mview ($mview_id,$name,$modulename,$mv_table,$mv_specs,
+   $indexed,$query,$special_index,$comment=NULL,$mv_schema=NULL)
+{
+
+   // get the table name from the schema array
+   $schema_arr = array();
+   if($mv_schema){
+      // get the schema from the mv_specs and use it to add the custom table
+      eval("\$schema_arr = $mv_schema;");
+      $mv_table = $schema_arr['table'];
+   }
+
+   $record = new stdClass();
+   $record->mview_id = $mview_id;
+   $record->name = $name;
+   $record->modulename = $modulename;
+   $record->mv_schema = $mv_schema;
+   $record->mv_table = $mv_table;
+   $record->mv_specs = $mv_specs;
+   $record->indexed = $indexed;
+   $record->query = $query;
+   $record->special_index = $special_index;
+   $record->last_update = 0;
+   $record->status = '';
+   $record->comment = $comment;
+
+   // drop the table from chado if it exists
+   $sql = "SELECT * FROM {tripal_mviews} WHERE mview_id = $mview_id ";
+   $mview = db_fetch_object(db_query($sql));
+   $previous_db = tripal_db_set_active('chado');  // use chado database
+   if (db_table_exists($mview->mv_table)) {
+      $sql = "DROP TABLE $mview->mv_table";
+      db_query($sql);
+   }
+   tripal_db_set_active($previous_db);  // now use drupal database
+
+   // update the record to the tripal_mviews table and if successful
+   // create the new materialized view in the chado schema
+   if(drupal_write_record('tripal_mviews',$record,'mview_id')){
+
+      // drop the table from chado if it exists
+      $previous_db = tripal_db_set_active('chado');  // use chado database
+      if (db_table_exists($mv_table)) {
+         $sql = "DROP TABLE $mv_table";
+         db_query($sql);
+      }
+      tripal_db_set_active($previous_db);  // now use drupal database
+      
+      // now construct the indexes
+      $index = '';
+      if($indexed){
+        // add to the array of values
+        $vals = preg_split("/[\n,]+/",$indexed);
+        $index = '';
+        foreach ($vals as $field){
+           $field = trim($field);
+           $index .= "CREATE INDEX idx_${mv_table}_${field} ON $mv_table ($field);";
+        }
+      }
+      // re-create the table differently depending on if it the traditional method
+      // or the Drupal Schema API method
+      if($mv_schema){         
+         if(!tripal_create_chado_table ($ret,$mv_table,$schema_arr)){
+            drupal_set_message("Could not create the materialized view. Check Drupal error report logs.");
+         } else {
+            drupal_set_message(t("View '$name' created"));
+         }
+      } else {
+         $sql = "CREATE TABLE {$mv_table} ($mv_specs); $index"; 
+         $previous_db = tripal_db_set_active('chado');  // use chado database
+         $results = db_query($sql);
+         tripal_db_set_active($previous_db);  // now use drupal database
+         if($results){
+            drupal_set_message(t("View '$name' edited and saved.  All results cleared. Please re-populate the view."));
+         } else {
+            drupal_set_message(t("Failed to create the materialized view table: '$mv_table'"));
+         }
+      }
+   }
+}
+/**
+ * Retrieve the materialized view_id given the name
+ *
+ * @param $view_name
+ *   The name of the materialized view
+ *
+ * @return
+ *   The unique identifier for the given view
+ *
+ * @ingroup tripal_mviews_api
+ */
+function tripal_mviews_get_mview_id ($view_name){
+
+   $sql = "SELECT * FROM {tripal_mviews} ".
+          "WHERE name = '%s'";
+   if(db_table_exists('tripal_mviews')){
+      $mview = db_fetch_object(db_query($sql,$view_name));
+	   if($mview){
+	      return $mview->mview_id;
+	   }
+   }
+   return 0;
+}
+/**
+*
+*
+* @ingroup tripal_core
+*/
+function tripal_mviews_action ($op,$mview_id,$redirect=0){
+   global $user;
+   $args = array("$mview_id");
+   
+   if(!$mview_id){
+      return '';
+   }
+
+   // get this mview details
+   $sql = "SELECT * FROM {tripal_mviews} WHERE mview_id = $mview_id ";
+   $mview = db_fetch_object(db_query($sql));
+   
+   // add a job or perform the action based on the given operation
+   if($op == 'update'){
+      tripal_add_job("Populate materialized view '$mview->name'",'tripal_core',
+         'tripal_update_mview',$args,$user->uid);
+	}
+   if($op == 'delete'){
+	   // remove the mview from the tripal_mviews table
+	   $sql = "DELETE FROM {tripal_mviews} ".
+             "WHERE mview_id = $mview_id";
+      db_query($sql);
+		
+	   // drop the table from chado if it exists
+      $previous_db = tripal_db_set_active('chado');  // use chado database
+      if (db_table_exists($mview->mv_table)) {
+         $sql = "DROP TABLE $mview->mv_table";
+         db_query($sql);
+      }
+      tripal_db_set_active($previous_db);  // now use drupal database
+   }
+   if($redirect){
+      drupal_goto("admin/tripal/mviews");
+   }
+}
+/**
+* Update a Materialized View
+*
+* @param $mview_id
+*   The unique identifier for the materialized view to be updated
+*
+* @return
+*   True if successful, false otherwise
+*
+* @ingroup tripal_mviews_api
+*/
+function tripal_update_mview ($mview_id){
+   $sql = "SELECT * FROM {tripal_mviews} WHERE mview_id = %d ";
+   $mview = db_fetch_object(db_query($sql,$mview_id));
+   if($mview){
+      $previous_db = tripal_db_set_active('chado');  // use chado database
+	   $results = db_query("DELETE FROM {$mview->mv_table}");
+      $results = db_query("INSERT INTO {$mview->mv_table} ($mview->query)");
+      tripal_db_set_active($previous_db);  // now use drupal database
+      if($results){
+         $sql = "SELECT count(*) as cnt FROM {$mview->mv_table}";
+         $count = db_fetch_object(db_query($sql));
+	      $record = new stdClass();
+         $record->mview_id = $mview_id;
+         $record->last_update = time();
+         $record->status = "Populated with " . number_format($count->cnt) . " rows";
+		   drupal_write_record('tripal_mviews',$record,'mview_id');
+		   return 1;
+      } else {
+         # print and save the error message
+	      $record = new stdClass();
+         $record->mview_id = $mview_id;
+         $record->status = "ERROR populating. See Drupal's recent log entries for details.";
+         print $record->status . "\n";
+		   drupal_write_record('tripal_mviews',$record,'mview_id');
+	      return 0;
+	  }
+   }
+}
+/**
+*
+*
+* @ingroup tripal_mviews_api
+*/
+function tripal_mview_report ($mview_id) {
+   // get this mview details
+   $sql = "SELECT * FROM {tripal_mviews} WHERE mview_id = $mview_id ";
+   $mview = db_fetch_object(db_query($sql));
+
+   // create a table with each row containig stats for
+   // an individual job in the results set.
+
+   $return_url = url("admin/tripal/mviews/");
+
+   $output .= "<p><a href=\"$return_url\">Return to table of materialized views.</a></p>";
+   $output .= "<br />";
+   $output .= "<p>Details for <b>$mview->name</b>:</p>";
+   $output .= "<br />";
+   $output .= "<table class=\"border-table\">";
+   if($mview->name){
+      $output .= "  <tr>".
+      "    <th>View Name</th>".
+      "    <td>$mview->name</td>".
+      "  </tr>";
+   }   
+   if($mview->modulename){
+      $output .= "  <tr>".
+      "    <th>Module Name</th>".
+      "    <td>$mview->modulename</td>".
+      "  </tr>";
+   }
+   if($mview->mv_table){
+      $output .= "  <tr>".
+      "    <th>Table Name</th>".
+      "    <td>$mview->mv_table</td>".
+      "  </tr>";
+   }   
+   if($mview->mv_specs){
+      $output .= "  <tr>".
+      "    <th>Table Field Definitions</th>".
+      "    <td>$mview->mv_specs</td>".
+      "  </tr>";
+   }   
+   if($mview->query){
+      $output .= "  <tr>".
+      "    <th>Query</th>".
+      "    <td><pre>$mview->query</pre></td>".
+      "  </tr>";
+   }   
+   if($mview->indexed){
+      $output .= "  <tr>".
+      "    <th>Indexed Fields</th>".
+      "    <td>$mview->indexed</td>".
+      "  </tr>";
+   }   
+   if($mview->special_index){
+      $output .= "  <tr>".
+      "    <th>Special Indexed Fields</th>".
+      "    <td>$mview->speical_index</td>".
+      "  </tr>";
+   }   
+   if($mview->last_update > 0){
+      $update = format_date($mview->last_update);
+   } else {
+      $update = 'Not yet populated';
+   }
+   $output .= "  <tr>".
+      "    <th>Last Update</th>".
+      "    <td>$update</td>".
+      "  </tr>";
+
+   // build the URLs using the url function so we can handle installations where
+   // clean URLs are or are not used
+   $update_url = url("admin/tripal/mviews/action/update/$mview->mview_id");
+   $delete_url = url("admin/tripal/mviews/action/delete/$mview->mview_id");
+   $edit_url = url("admin/tripal/mviews/edit/$mview->mview_id");
+
+   $output .= "<tr><th>Actions</th>".
+              "<td> <a href='$update_url'>Populate</a>, ".
+              "     <a href='$edit_url'>Edit</a>, ".
+              "     <a href='$delete_url'>Delete</a></td></tr>";
+
+   $output .= "</table>";
+
+   return $output;
+}
+/**
+*
+*
+* @ingroup tripal_mviews_api
+*/
+function tripal_mviews_report () {
+
+   $header = array('','MView Name','Last Update','Status','Description','');
+   $rows = array();
+
+   $mviews = db_query("SELECT * FROM {tripal_mviews} ORDER BY name");  
+   while($mview = db_fetch_object($mviews)){
+      if($mview->last_update > 0){
+         $update = format_date($mview->last_update);
+      } else {
+         $update = 'Not yet populated';
+      }
+      $rows[] = array(
+         l('View',"admin/tripal/mviews/report/$mview->mview_id") ." | ".
+         l('Edit',"admin/tripal/mviews/edit/$mview->mview_id") ." | ".
+         l('Populate',"admin/tripal/mviews/action/update/$mview->mview_id"),
+         $mview->name,
+         $update,
+         $mview->status,
+         $mview->comment,
+         l('Delete',"admin/tripal/mviews/action/delete/$mview->mview_id"),
+      );
+   }
+   $rows[] = array(
+      'data' => array( 
+         array('data' => l('Create a new materialized view.',"admin/tripal/mviews/new"), 
+               'colspan' => 6),
+         )
+   );
+   $page = theme('table', $header, $rows);
+
+   return $page;
+}
+/**
+*
+*
+* @ingroup tripal_core
+*/
+function tripal_mviews_form(&$form_state = NULL,$mview_id = NULL){
+
+   if(!$mview_id){
+      $action = 'Add';
+   } else {
+      $action = 'Edit';
+   }
+
+   // get this requested view
+   if(strcmp($action,'Edit')==0){
+      $sql = "SELECT * FROM {tripal_mviews} WHERE mview_id = %d ";
+      $mview = db_fetch_object(db_query($sql,$mview_id));
+      
+      # set the default values.  If there is a value set in the 
+      # form_state then let's use that, otherwise, we'll pull 
+      # the values from the database 
+      $default_name = $form_state['values']['name'];
+      $default_mv_table = $form_state['values']['mv_table'];
+      $default_mv_specs = $form_state['values']['mv_specs'];
+      $default_indexed = $form_state['values']['indexed'];
+      $default_mvquery = $form_state['values']['mvquery'];
+      $default_special_index = $form_state['values']['special_index'];
+      $default_comment = $form_state['values']['cpmment'];
+      if(!$default_name){
+         $default_name = $mview->name;
+      }
+      if(!$default_mv_table){
+         $default_mv_table = $mview->mv_table;
+      }
+      if(!$default_mv_specs){
+         $default_mv_specs = $mview->mv_specs;
+      }
+      if(!$default_indexed){
+         $default_indexed = $mview->indexed;
+      }
+      if(!$default_mvquery){
+         $default_mvquery = $mview->query;
+      }
+      if(!$default_special_index){
+         $default_special_index = $mview->special_index;
+      }
+      if(!$default_comment){
+         $default_comment = $mview->comment;
+      }      
+      if(!$default_schema){
+         $default_schema = $mview->mv_schema;
+      }
+      // the mv_table column of the tripal_mviews table always has the table 
+      // name even if it is a custom table. However, for the sake of the form,
+      // we do not want this to show up as the mv_table is needed for the 
+      // traditional style input.  We'll blank it out if we have a custom 
+      // table and it will get reset in the submit function using the 
+      // 'table' value from the schema array
+      if($default_schema){
+         $default_mv_table = '';
+      }
+      
+      // set which fieldset is collapsed 
+      $schema_collapsed = 0;      
+      $traditional_collapsed = 1;
+      if(!$default_schema){
+         $schema_collapsed = 1;      
+         $traditional_collapsed = 0;
+      }
+   }
+   // Build the form
+   $form['action'] = array(
+      '#type' => 'value',
+      '#value' => $action
+   );
+   $form['mview_id'] = array(
+      '#type' => 'value',
+      '#value' => $mview_id
+   );
+   $form['name']= array(
+      '#type'          => 'textfield',
+      '#title'         => t('View Name'),
+      '#description'   => t('Please enter the name for this materialized view.'),
+      '#required'      => TRUE,
+      '#default_value' => $default_name,
+   );
+   $form['comment']= array(
+      '#type'          => 'textarea',
+      '#title'         => t('MView Description'),
+      '#description'   => t('Optional.  Please provide a description of the purpose for this materialized vieww.'),
+      '#required'      => FALSE,
+      '#default_value' => $default_comment,
+   );
+
+   // add a fieldset for the Drupal Schema API
+   $form['schema'] = array(
+     '#type' => 'fieldset',
+     '#title' => 'Drupal Schema API Setup',
+     '#description' => t('Use the Drupal Schema API array to describe a table. The benefit is that it '.
+                         'can be fully integrated with Tripal Views.  Tripal supports an extended '.
+                         'array format to allow for descriptoin of foreign key relationships.'),
+     '#collapsible' => 1,
+     '#collapsed' => $schema_collapsed ,
+   );
+   $form['schema']['schema']= array(
+      '#type'          => 'textarea',
+      '#title'         => t('Schema Array'),
+      '#description'   => t('Please enter the Drupal Schema API compatible array that defines the table.'),
+      '#required'      => FALSE,
+      '#default_value' => $default_schema,
+      '#rows'          => 25,
+   ); 
+   // add a fieldset for the Original Table Description fields
+   $form['traditional'] = array(
+     '#type' => 'fieldset',
+     '#title' => 'Traditional MViews Setup',
+     '#description' => t('Traidtionally with Tripal MViews were created by specifying PostgreSQL style '.
+                         'column types.  This method can be used but is deprecated in favor of the '.
+                         'newer Drupal schema API method provided above.'),
+     '#collapsible' => 1,
+     '#collapsed' => $traditional_collapsed,
+   ); 
+   $form['traditional']['mv_table']= array(
+      '#type'          => 'textfield',
+      '#title'         => t('Table Name'),
+      '#description'   => t('Please enter the table name that this view will generate in the database.  You can use the schema and table name for querying the view'),
+      '#required'      => FALSE,
+      '#default_value' => $default_mv_table,
+   );
+   $form['traditional']['mv_specs']= array(
+      '#type'          => 'textarea',
+      '#title'         => t('Table Definition'),
+      '#description'   => t('Please enter the field definitions for this view. Each field should be separated by a comma or enter each field definition on each line.'),
+      '#required'      => FALSE,
+      '#default_value' => $default_mv_specs,
+   );
+   $form['traditional']['indexed']= array(
+      '#type'          => 'textarea',
+      '#title'         => t('Indexed Fields'),
+      '#description'   => t('Please enter the field names (as provided in the table definition above) that will be indexed for this view.  Separate by a comma or enter each field on a new line.'),
+      '#required'      => FALSE,
+      '#default_value' => $default_indexed,
+   );
+/**
+   $form['traditional']['special_index']= array(
+      '#type'          => 'textarea',
+      '#title'         => t('View Name'),
+      '#description'   => t('Please enter the name for this materialized view.'),
+      '#required'      => TRUE,
+      '#default_value' => $default_special_index,
+   );
+*/
+   $form['mvquery']= array(
+      '#type'          => 'textarea',
+      '#title'         => t('Query'),
+      '#description'   => t('Please enter the SQL statement used to populate the table.'),
+      '#required'      => TRUE,
+      '#default_value' => $default_mvquery,
+      '#rows'          => 25,
+   );
+   if($action == 'Edit'){
+      $value = 'Save';
+   }
+   if($action == 'Add'){
+      $value = 'Add';
+   }
+   $form['submit'] = array (
+     '#type'         => 'submit',
+     '#value'        => t($value),
+     '#weight'       => 9,
+     '#executes_submit_callback' => TRUE,
+   );
+
+   $form['#redirect'] = 'admin/tripal/mviews';
+   return $form;
+}
+/**
+*
+*
+* @ingroup tripal_core
+*/
+function tripal_mviews_form_validate($form, &$form_state){
+   $action = $form_state['values']['action'];
+   $mview_id = $form_state['values']['mview_id'];
+   $name = $form_state['values']['name'];
+   $mv_table = $form_state['values']['mv_table'];
+   $mv_specs = $form_state['values']['mv_specs'];
+   $indexed = $form_state['values']['indexed'];
+   $query = $form_state['values']['mvquery'];
+   $special_index = $form_state['values']['special_index'];
+   $comment = $form_state['values']['comment'];
+   $schema = $form_state['values']['schema'];
+   
+   if($schema and ($mv_table or $mv_specs or $indexed or $special_index)){
+       form_set_error($form_state['values']['schema'], 
+          t('You can create an MView using the Drupal Schema API method or the '.
+            'traditional method but not both.'));
+   }
+   if(!$schema){
+      if(!$mv_specs){
+         form_set_error($form_state['values']['mv_specs'], 
+            t('The Table Definition field is required.'));
+      }
+      if(!$mv_table){
+         form_set_error($form_state['values']['mv_table'], 
+            t('The Table Name field is required.'));
+      }
+   }
+   
+   // make sure the array is valid
+   if($schema){
+      $success = eval("\$schema_array = $schema;");
+      if ($success === FALSE){
+         $error = error_get_last();
+         form_set_error($form_state['values']['schema'], 
+            t("The schema array is improperly formatted. Parse Error : " . $error["message"]));
+      }
+      if(!array_key_exists('table',$schema_array)){
+         form_set_error($form_state['values']['schema'], 
+            t("The schema array must have key named 'table'"));
+      } 
+      // TODO: add in more validation checks of the array to help the user
+   }
+}
+/**
+*
+*
+* @ingroup tripal_core
+*/
+function tripal_mviews_form_submit($form, &$form_state){
+   $ret = array();
+   
+   $action = $form_state['values']['action'];
+   $mview_id = $form_state['values']['mview_id'];
+   $name = $form_state['values']['name'];
+   $mv_table = $form_state['values']['mv_table'];
+   $mv_specs = $form_state['values']['mv_specs'];
+   $indexed = $form_state['values']['indexed'];
+   $query = $form_state['values']['mvquery'];
+   $special_index = $form_state['values']['special_index'];
+   $comment = $form_state['values']['comment'];
+   $schema = $form_state['values']['schema'];
+
+   if(strcmp($action,'Edit')==0){
+      tripal_edit_mview($mview_id,$name, 'tripal_core',$mv_table, $mv_specs,
+         $indexed,$query,$special_index,$comment,$schema);
+   }
+   else if(strcmp($action,'Add')==0){
+      tripal_add_mview ($name, 'tripal_core',$mv_table, $mv_specs,
+         $indexed,$query,$special_index,$comment,$schema);
+   }
+   else {
+        drupal_set_message("No action performed.");
+   }
+   return '';
+}

+ 236 - 27
base/tripal_core/tripal_core.api.inc → tripal_core/tripal_core.api.inc

@@ -595,7 +595,7 @@ function tripal_core_chado_select($table,$columns,$values,$options = null){
               'case_insensitive_columns' => $options['case_insensitive_columns']
             );
             $results = tripal_core_chado_get_foreign_key($table_desc,$field,$value, $foreign_options);
-            if (sizeof($results) < 1) {
+            if (count($results) ==0) {
               // foreign key records are required
               // thus if none matched then return false and alert the admin through watchdog
               //watchdog('tripal_core', 
@@ -759,10 +759,12 @@ function tripal_core_chado_get_foreign_key($table_desc,$field,$values, $options
                $select_cols = array($right);
                $result = tripal_core_chado_select($table,$select_cols,$values, $options);
                $fields = array();
-               foreach ($result as $obj) {
-                 $fields[] = $obj->$right;
+               if(count($result) > 0){
+                  foreach ($result as $obj) {
+                    $fields[] = $obj->$right;
+                  }
+                  return $fields;
                }
-               return $fields;
             }
          }
       } 
@@ -840,6 +842,8 @@ function tripal_core_chado_get_foreign_key($table_desc,$field,$values, $options
  * @ingroup tripal_chado_api
  */
  function tripal_core_generate_chado_var($table, $values, $base_options=array()) {
+
+  $all = new stdClass();
   
   // get description for the current table----------------------------------------------------------
   $table_desc = module_invoke_all('chado_'.$table.'_schema');
@@ -1357,24 +1361,27 @@ function chado_get_node_id ($table, $id) {
  *   The base table for which the property should be retrieved. Thus to retrieve a property
  *   for a feature the basetable=feature and property is retrieved from featureprop
  * @param $record_id
- *   The primary key of the basetable to retrieve properties for. This should be in integer.
+ *   The foriegn key field of the base table. This should be in integer.
  * @param $property
  *   The cvterm name describing the type of properties to be retrieved
  * @param $cv_name
  *   The name of the cv that the above cvterm is part of
  *
  * @return
- *   A chado variable with the specified properties expanded
+ *   An array in the same format as that generated by the function
+ *   tripal_core_generate_chado_var().  If only one record is returned it
+ *   is a single object.  If more than one record is returned then it is an array
+ *   of objects
  *
  * @ingroup tripal_chado_api
  */
 function tripal_core_get_property($basetable, $record_id, $property, $cv_name){
-
+  
    // get the foreign key for this property table
    $table_desc = module_invoke_all('chado_'.$basetable.'prop_schema');
    $fkcol = key($table_desc['foreign keys'][$basetable]['columns']);
 
-   // construct the array of values to be inserted  
+   // construct the array of values to be selected  
    $values = array (
       $fkcol => $record_id,
       'type_id' => array ( 
@@ -1385,18 +1392,22 @@ function tripal_core_get_property($basetable, $record_id, $property, $cv_name){
          'is_obsolete' => 0
       ),
    );
+
    $results = tripal_core_generate_chado_var($basetable.'prop',$values);
    $results = tripal_core_expand_chado_vars($results,'field',$basetable.'prop.value');
    return $results;
 }
 /**
- * Insert a property for a given basetable record
+ * Insert a property for a given base table.  By default if the property already
+ * exists a new property is added with the next available rank.  If 
+ * $update_if_present argument is specified then the record will be updated if it
+ * exists rather than adding a new property.
  *
  * @param $basetable
  *   The base table for which the property should be inserted. Thus to insert a property
  *   for a feature the basetable=feature and property is inserted into featureprop
  * @param $record_id
- *   The primary key of the basetable to insert a property for. This should be in integer.
+ *   The foriegn key field of the base table. This should be in integer. 
  * @param $property
  *   The cvterm name describing the type of properties to be inserted
  * @param $cv_name
@@ -1404,7 +1415,9 @@ function tripal_core_get_property($basetable, $record_id, $property, $cv_name){
  * @param $value
  *   The value of the property to be inserted (can be empty)
  * @param $update_if_present
- *   A boolean indicating whether an existing record should be updated or an error thrown
+ *   A boolean indicating whether an existing record should be updated. If the
+ *   property already exists and this value is not specified or is zero then
+ *   a new property will be added with the next largest rank.
  *
  * @return
  *   Return True on Insert/Update and False otherwise
@@ -1414,13 +1427,31 @@ function tripal_core_get_property($basetable, $record_id, $property, $cv_name){
 function tripal_core_insert_property($basetable, $record_id, $property, 
    $cv_name, $value, $update_if_present = 0)
 {
-   // first see if the property already exists, if so we can't insert
-   $prop = tripal_core_get_property($basetable,$record_id,$property,$cv_name);
-   if(count($prop)>0){ 
+   // first see if the property already exists, if the user want's to update
+   // then we can do that, but otherwise we want to increment the rank and
+   // insert
+   $props = tripal_core_get_property($basetable,$record_id,$property,$cv_name);
+   if(!is_array($props)) { 
+    $props = array($props); 
+   }   
+   $rank = 0;
+   if(count($props)>0){       
       if($update_if_present){
-        return tripal_core_update_property($basetable,$record_id,$property,$cv_name,$value) ;
+         return tripal_core_update_property($basetable, $record_id, $property, $cv_name, $value) ;
       } else {
-        return FALSE;
+         // iterate through the properties returned and check to see if the
+         // property with this value already exists if not, get the largest rank
+         // and insert the same property but with this new value
+         foreach($props as $p){
+            if($p->rank > $rank){
+               $rank = $p->rank;
+            }
+            if(strcmp($p->value,$value)==0){
+               return TRUE;
+            }
+         }
+         // now add 1 to the rank
+         $rank++;
       }
    }
 
@@ -1439,21 +1470,27 @@ function tripal_core_insert_property($basetable, $record_id, $property,
          'is_obsolete' => 0
       ),
       'value' => $value, 
-      'rank' => 0,
+      'rank' => $rank,
    );
+
    return tripal_core_chado_insert($basetable.'prop',$values);
 }
 
 /**
- * Update a property for a given basetable record
+ * Update a property for a given base table record and property name.  This 
+ * function should be used only if one record of the property will be present.
+ * If the property name can have multiple entries (with increasing rank) then
+ * use the function named tripal_core_update_property_by_id
  *
  * @param $basetable
- *   The base table for which the property should be updated. Thus to update a property
- *   for a feature the basetable=feature and property is updated in featureprop
+ *   The base table for which the property should be updated. The property table 
+ *   is constructed using  a combination of the base table name and the suffix 
+ *   'prop' (e.g. basetable = feature then property tabie is featureprop).
  * @param $record_id
- *   The primary key of the basetable to update a property for. This should be in integer.
+ *   The foreign key of the basetable to update a property for. This should be in integer.
+ *   For example, if the basetable is 'feature' then the $record_id should be the feature_id
  * @param $property
- *   The cvterm name describing the type of property to be updated
+ *   The cvterm name of property to be updated
  * @param $cv_name
  *   The name of the cv that the above cvterm is part of
  * @param $value
@@ -1461,7 +1498,7 @@ function tripal_core_insert_property($basetable, $record_id, $property,
  * @param $insert_if_missing
  *   A boolean indicating whether a record should be inserted if one doesn't exist to update
  *
- * Note: The property to be updated is select via theu nique combination of $record_id and
+ * Note: The property to be updated is select via the unique combination of $record_id and
  * $property and then it is updated with the supplied value
  *
  * @return
@@ -1469,8 +1506,8 @@ function tripal_core_insert_property($basetable, $record_id, $property,
  *
  * @ingroup tripal_chado_api
  */
-function tripal_core_update_property($basetable, $record_id,$property,$cv_name,
-   $value,$insert_if_missing = 0)
+function tripal_core_update_property($basetable, $record_id, $property, 
+   $cv_name, $value, $insert_if_missing = 0)
 {
 
    // first see if the property is missing (we can't update a missing property
@@ -1505,7 +1542,55 @@ function tripal_core_update_property($basetable, $record_id,$property,$cv_name,
 }
 
 /**
- * Deletes a property for a given basetable record
+ * Update a property for a given base table record.  This function should be 
+ * used if multiple records of the same property will be present. Also, use this
+ * function to change the property name of an existing property.
+ *
+ * @param $basetable
+ *   The base table for which the property should be updated. The property table 
+ *   is constructed using  a combination of the base table name and the suffix 
+ *   'prop' (e.g. basetable = feature then property tabie is featureprop).
+ * @param $record_id
+ *   The primary key of the base table. This should be in integer.
+ *   For example, if the basetable is 'feature' then the $record_id should be the featureprop_id
+ * @param $property
+ *   The cvterm name of property to be updated
+ * @param $cv_name
+ *   The name of the cv that the above cvterm is part of
+ * @param $value
+ *   The value of the property to be inserted (can be empty)
+ *
+ * @return
+ *   Return True on Update/Insert and False otherwise
+ *
+ * @ingroup tripal_chado_api
+ */
+function tripal_core_update_property_by_id($basetable, $record_id, $property, 
+   $cv_name, $value)
+{
+
+   // get the primary key for this property table
+   $table_desc = module_invoke_all('chado_'.$basetable.'prop_schema');
+   $pkcol = $table_desc['primary key'][0];
+
+   // construct the array that will match the exact record to update
+   $match = array (
+      $pkcol => $record_id,
+   );
+   // construct the array of values to be updated
+   $values = array (      
+      'type_id' => array ( 
+         'cv_id' => array (
+            'name' => $cv_name,
+         ),
+         'name' => $property,
+      ),
+      'value' => $value, 
+   );
+   return tripal_core_chado_update($basetable.'prop',$match,$values);
+}
+/**
+ * Deletes a property for a given base table record using the property name
  *
  * @param $basetable
  *   The base table for which the property should be deleted. Thus to deleted a property
@@ -1517,7 +1602,7 @@ function tripal_core_update_property($basetable, $record_id,$property,$cv_name,
  * @param $cv_name
  *   The name of the cv that the above cvterm is part of
  *
- * Note: The property to be deleted is select via theu nique combination of $record_id and $property 
+ * Note: The property to be deleted is select via the unique combination of $record_id and $property 
  *
  * @return
  *   Return True on Delete and False otherwise
@@ -1542,6 +1627,32 @@ function tripal_core_delete_property($basetable, $record_id,$property,$cv_name){
    return tripal_core_chado_delete($basetable.'prop',$match);
 }
 
+/**
+ * Deletes a property using the property ID
+ *
+ * @param $basetable
+ *   The base table for which the property should be deleted. Thus to deleted a property
+ *   for a feature the basetable=feature and property is deleted from featureprop
+ * @param $record_id
+ *   The primary key of the basetable to delete a property for. This should be in integer.
+ *
+ * @return
+ *   Return True on Delete and False otherwise
+ *
+ * @ingroup tripal_chado_api
+ */
+function tripal_core_delete_property_by_id($basetable, $record_id){
+   // get the foreign key for this property table
+   $table_desc = module_invoke_all('chado_'.$basetable.'prop_schema');
+   $pkcol = $table_desc['primary key'][0];
+
+   // construct the array that will match the exact record to update
+   $match = array (
+      $pkcol => $record_id,
+   );
+   return tripal_core_chado_delete($basetable.'prop',$match);
+}
+
 /**
  * This function is typically used in the '.install' file for a Tripal module
  * Each module should call this function during installation to create
@@ -1686,3 +1797,101 @@ function tripal_get_max_chado_rank ($tablename, $where_options) {
 		return -1;
 	}
 }
+/**
+ * Add a new table to the Chado schema. This function is simply a wrapper for
+ * the db_create_table() function of Drupal, but ensures the table is created
+ * inside the Chado schema rather than the Drupal schema.  If the table already
+ * exists then it will be dropped and recreated using the schema provided.
+ * Howver, it will only drop a table if it exsits in the tripal_custom_tables
+ * table. This way the function cannot be used to accidentally alter existing
+ * non custom tables.
+ * 
+ * @param $ret
+ *   Array to which query results will be added.
+ * @param $table
+ *   The name of the table to create.
+ * @param $schema 
+ *   A Drupal-style Schema API definition of the table
+ *
+ * @return 
+ *   A database query result resource for the new table, or FALSE if table was not constructed.
+ *
+ * @ingroup tripal_core_api
+ */
+function tripal_create_chado_table (&$ret,$table,$schema) {
+   $ret = array();
+
+   // If the table exits in Chado but not in the tripal_custom_tables field
+   // then call an error.  if the table exits in the tripal_custom_tables but
+   // not in Chado then create the table and replace the entry.
+   $sql = "SELECT * FROM {tripal_custom_tables} WHERE table_name = '%s'";
+   $centry = db_fetch_object(db_query($sql,$table));
+   $previous_db = tripal_db_set_active('chado');  // use chado database   
+   $exists = db_table_exists($table);
+   tripal_db_set_active($previous_db);  // now use drupal database
+   if(!$exists){
+      $previous_db = tripal_db_set_active('chado');  // use chado database   
+      db_create_table($ret,$table,$schema);
+      tripal_db_set_active($previous_db);  // now use drupal database  
+      if(count($ret)==0){
+   	   watchdog('tripal_core', "Error adding custom table '!table_name'.", 
+   	      array('!table_name' => $table), WATCHDOG_ERROR); 
+         return FALSE;
+      }       
+   }
+   if($exists and !$centry){
+   	watchdog('tripal_core', "Could not add custom table '!table_name'. It ".
+   	         "already exists but is not known to Tripal as being a custom table.", 
+   	   array('!table_name' => $table), WATCHDOG_WARNING);       
+   	   return FALSE;
+   }
+   if($exists and $centry){
+      // drop the table we'll recreate it with the new schema
+      $previous_db = tripal_db_set_active('chado');  // use chado database   
+      db_drop_table($ret,$table);
+      db_create_table($ret,$table,$schema);
+      tripal_db_set_active($previous_db);  // now use drupal database        
+   }
+   
+   // if the table creation was succesful then add an entry
+   // in the tripal_custom_table
+   $record = new stdClass();
+   $record->table_name = $table;
+   $record->schema = serialize($schema);
+   // if an entry already exists then remove it
+   if($centry){
+      $sql = "DELETE FROM {tripal_custom_tables} WHERE table_name = '%s'";
+      db_query($sql,$table);
+   } 
+   $success = drupal_write_record('tripal_custom_tables',$record);
+   if(!$success){
+	   watchdog('tripal_core', "Error adding custom table.", 
+	      array('!table_name' => $table), WATCHDOG_ERROR); 
+      return FALSE;
+   }
+   return $ret;
+}
+/**
+ * Retrieves the schema in an array for the specified custom table.
+ * 
+ * @param $table
+ *   The name of the table to create.
+ *
+ * @return 
+ *   A Drupal-style Schema API array definition of the table. Returns
+ *   FALSE on failure.
+ *
+ * @ingroup tripal_core_api
+ */
+function tripal_get_chado_custom_schema ($table) {
+   $sql = "SELECT schema FROM {tripal_custom_tables} WHERE table_name = '%s'";
+   $custom = db_fetch_object(db_query($sql,$table));
+   if(!$custom){
+      return FALSE;
+   } 
+   else {
+      return unserialize($custom->schema);
+   }
+}
+
+

+ 159 - 0
tripal_core/tripal_core.drush.inc

@@ -0,0 +1,159 @@
+<?php
+
+/**
+ * Describes each drush command implemented by the module
+ *
+ * @return
+ *   The first line of description when executing the help for a given command
+ */
+function tripal_core_drush_help($command) {
+  switch ($command) {
+    case 'drush:tripal-current-job':
+      return dt('Returns details about the currently running tripal job including percent complete.');
+    case 'drush:tripal-update-mview':
+      return dt('Updates the specified materialized view.');
+  }
+}
+
+/**
+ * Registers a drush command and constructs the full help for that command
+ *
+ * @return
+ *   And array of command descriptions
+ */
+function tripal_core_drush_command() {
+  $items = array();
+  $items['tripal-current-job'] = array(
+    'description' => dt('Returns details about the currently running tripal job including percent complete.'),
+    'arguments'   => array(
+    ),
+    'examples' => array(
+      'Standard example' => 'drush tripal-current-job',
+    ),
+    'aliases' => array('trpjob-cur'),
+  );
+  $items['tripal-update-mview'] = array(
+    // used by drush help
+    'description' => dt('Updates the specified materialized view.'),
+    'arguments' => array(
+      'mview_id' => dt('The ID of the materialized view to update'),
+      'table_name' => dt('The name of the materialized view table to update.'),
+    ),
+    'examples' => array(
+      'By Materialized View ID' => 'drush tripal-update-mview --mview_id=5',
+      'By Table Name' => 'drush tripal-update-mview --table_name=organism_feature_count'
+    ),
+    // supply options
+    'options' => array(
+      'mview_id',
+      'table_name'
+    ),
+    'aliases' => array('trpmv-up')
+  );
+  $items['tripal-launch-jobs'] = array(
+    // used by drush help
+    'description' => dt('Lauches any jobs waiting in the queue.'),
+    'arguments' => array(
+      'parallel' => dt('Normally jobs are executed one at a time. But if you are certain no conflicts will occur with other currently running jobs you may set this argument to a value of 1 to make the job run in parallel with other running jobs.'),
+    ),
+    'examples' => array(
+      'Normal Job' => 'drush tripal-launch-jobs',
+      'Parallel Job' => 'drush tripal-launch-jobs --parallel=1'
+    ),
+    // supply options
+    'options' => array(
+      'parallel',
+    ),
+    'aliases' => array('trpjob-run')
+  );
+  return $items;
+}
+
+/**
+ * Executes jobs in the Tripal Jobs Queue
+ * 
+ * NOTE: The following code is executed when drush 'trpjob-run' or 'drush tripal-launch-jobs' is called
+ */
+function drush_tripal_core_tripal_launch_jobs () {
+  $parallel = drush_get_option('parallel');   
+  
+  if($parallel){
+    print "Tripal Job Launcher (in parallel)\n";
+    print "-------------------\n";
+    tripal_jobs_launch($parallel);
+  } else {
+    print "Tripal Job Launcher\n";
+    print "-------------------\n";
+    tripal_jobs_launch();  
+  }
+}
+
+/**
+ * Prints details about the current running job
+ * 
+ * NOTE: The following code is executed when 'drush trpjob-curr' or 'drush tripal-current-job' is called
+ */
+function drush_tripal_core_tripal_current_job () {
+  
+  $sql =  "SELECT * FROM {tripal_jobs} TJ ".
+            "WHERE TJ.end_time IS NULL and NOT TJ.start_time IS NULL ";
+  $jobs = db_query($sql);
+  while ($job = db_fetch_object($jobs)) {
+    $job_pid = $job->pid;
+
+    $output = "Name: ".$job->job_name."\n"
+             ."Submitted: ".date(DATE_RFC822,$job->submit_date)."\n"
+             ."Started: ".date(DATE_RFC822,$job->start_time)."\n"
+             ."Module: ".$job->modulename."\n"
+             ."Callback: ".$job->callback."\n"
+             ."Process ID: ".$job->pid."\n"
+             ."Progress: ".$job->progress."%\n";
+    drush_print($output);
+  }
+  
+  if (!$job_pid) {
+    drush_print('There are currently no running jobs.');
+  }
+    
+  //log to the command line with an OK status
+  drush_log('Running tripal-current-job', 'ok');
+}
+
+/**
+ * Updates the specified materialized view
+ *
+ * @param $mview_id
+ *   The ID of the materialized view (tripal_mview.mview_id)
+ * @param $table_name
+ *   The name of the table storing the materialized view (tripal_mview.mv_table)
+ *
+ * Note: Either $mview_id OR $table_name is required
+ */ 
+function drush_tripal_core_tripal_update_mview () {
+  $mview_id = drush_get_option('mview_id');
+  $table_name = drush_get_option('table_name');
+  
+  // Either table_name or mview is required
+  if (!$mview_id) {
+    if ($table_name) {
+      // if table_name supplied use that to get mview_id
+      $sql = "SELECT mview_id FROM {tripal_mviews} WHERE mv_table='%s'";
+      $r = db_fetch_object(db_query($sql, $table_name));
+      if (!$r->mview_id) {
+        drush_set_error('No Materialized View associated with that table_name.');
+      }
+      $mview_id=$r->mview_id;
+    } else {
+      drush_set_error('Either mview_id OR table_name are required.');
+    }
+  }
+  
+  drush_print('Updating the Materialized View with ID='.$mview_id);  
+  $status = tripal_update_mview($mview_id);
+  if ($status) {
+    drush_log('Materialized View Updated', 'ok');
+  } else {
+    drush_set_error('Update failed.');
+  }
+  
+}

+ 0 - 0
base/tripal_core/tripal_core.info → tripal_core/tripal_core.info


+ 69 - 4
base/tripal_core/tripal_core.install → tripal_core/tripal_core.install

@@ -21,6 +21,33 @@ function tripal_core_install(){
   drupal_install_schema('tripal_core');
 
 }
+/**
+*  Update for Drupal 6.x, Tripal 0.4
+*  This update adjusts the materialized view by adding a 'cvterm_id' column
+*
+* @ingroup tripal_feature
+*/
+function tripal_core_update_6000(){
+   // add additional columsn to the tripal_mviews table
+   db_add_field($ret, 'tripal_mviews', 'status', array('type' => 'text', 'size' => 'normal', 'not null' => FALSE));
+   db_add_field($ret, 'tripal_mviews', 'comment', array('type' => 'text', 'size' => 'normal', 'not null' => FALSE));
+   db_add_field($ret, 'tripal_mviews', 'mv_schema', array('type' => 'text', 'size' => 'normal', 'not null' => FALSE));
+   db_change_field($ret, 'tripal_mviews', 'mv_table','mv_table',array('type' => 'varchar','length' => 128, 'not null' => FALSE));
+   db_change_field($ret, 'tripal_mviews', 'mv_specs','mv_specs',array('type' => 'text', 'size' => 'normal', 'not null' => FALSE));
+   db_change_field($ret, 'tripal_mviews', 'indexed','indexed',array('type' => 'text', 'size' => 'normal', 'not null' => FALSE));
+
+   
+   // create the custom tables table
+   $ret = array();
+   $schema = tripal_core_custom_tables_schema();
+   db_create_table($ret,'tripal_custom_tables',$schema['tripal_custom_tables']);
+   
+   $ret = array(
+      '#finished' => 1,
+   );
+
+   return $ret;
+}
 
 /************************************************************************
 * Implementation of hook_schema().
@@ -29,6 +56,18 @@ function tripal_core_install(){
 */
 function tripal_core_schema() {
    $schema = tripal_core_get_schemas();
+   
+   // if this module is already installed and enabled, then we want to provide
+   // the schemas for all of the custom tables.  This will allow Views to 
+   // see the schemas.  We check if the module is installed because during 
+   // installation we don't want to make these custom tables available as we don't
+   // want them created in the Drupal database.  The custom tables go in the 
+   // Chado database.
+   $sql = 'SELECT * FROM {tripal_custom_tables}';
+   $q = db_query($sql);
+   while($custom = db_fetch_object($q)){
+      $schema[$custom->table_name] = unserialize($custom->schema);
+   }
    return $schema;
 }
 /************************************************************************
@@ -60,7 +99,10 @@ function tripal_core_get_schemas (){
    foreach ($temp as $table => $arr){ 
       $schema[$table] = $arr; 
    }
-
+   $temp = tripal_core_custom_tables_schema();
+   foreach ($temp as $table => $arr){ 
+      $schema[$table] = $arr; 
+   }
 	return $schema;
 }
 /************************************************************************
@@ -75,12 +117,15 @@ function tripal_core_mviews_schema(){
          'mview_id'      => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
          'name'          => array('type' => 'varchar','length' => 255, 'not null' => TRUE),
          'modulename'    => array('type' => 'varchar','length' => 50, 'not null' => TRUE, 'description' => 'The module name that provides the callback for this job'),
-         'mv_table'      => array('type' => 'varchar','length' => 128, 'not null' => TRUE),
-         'mv_specs'      => array('type' => 'text', 'size' => 'normal', 'not null' => TRUE),
-         'indexed'       => array('type' => 'text', 'size' => 'normal', 'not null' => TRUE),
+         'mv_table'      => array('type' => 'varchar','length' => 128, 'not null' => FALSE),
+         'mv_specs'      => array('type' => 'text', 'size' => 'normal', 'not null' => FALSE),
+         'mv_schema'     => array('type' => 'text', 'size' => 'normal', 'not null' => FALSE),
+         'indexed'       => array('type' => 'text', 'size' => 'normal', 'not null' => FALSE),
          'query'         => array('type' => 'text', 'size' => 'normal', 'not null' => TRUE),
          'special_index' => array('type' => 'text', 'size' => 'normal', 'not null' => FALSE),
          'last_update'   => array('type' => 'int', 'not null' => FALSE, 'description' => 'UNIX integer time'),
+         'status'        => array('type' => 'text', 'size' => 'normal', 'not null' => FALSE),
+         'comment'       => array('type' => 'text', 'size' => 'normal', 'not null' => FALSE),
       ),
       'indexes' => array(
          'mview_id' => array('mview_id')
@@ -127,4 +172,24 @@ function tripal_core_jobs_schema(){
    );
    return $schema;
 }
+/************************************************************************
+* 
+*
+* @ingroup tripal_core
+*/
+function tripal_core_custom_tables_schema(){
+   $schema = array();
+   $schema['tripal_custom_tables'] = array(
+      'fields' => array(
+         'table_id' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
+         'table_name' => array ('type' => 'varchar', 'length' => 255, 'not null' => TRUE),
+         'schema' => array('type' => 'text','not null' => TRUE),
+      ),
+      'indexes' => array(
+         'table_id' => array('table_id'),
+      ),
+      'primary key' => array('table_id'),
+   );
+   return $schema;
+}
 ?>

+ 1 - 3
base/tripal_core/tripal_core.module → tripal_core/tripal_core.module

@@ -2,7 +2,6 @@
 
 require_once "jobs.php";
 require_once "mviews.php";
-require_once "cvterms.php";
 require_once "chado_install.php";
 require_once "tripal_core.api.inc";
 
@@ -134,9 +133,8 @@ function tripal_core_menu() {
      'type' => MENU_CALLBACK,
    );
  
-
+   
    // Materialized Views 
-
    $items['admin/tripal/mviews'] = array(
      'title' => 'MViews',
      'description' => 'Materialized views are used to improve speed of large or complex queries.',

+ 23 - 2
base/tripal_core/tripal_core.schema.api.inc → tripal_core/tripal_core.schema.api.inc

@@ -37,10 +37,20 @@
  */
 
 /**
+ * Retrieves the list tables in the Chado schema.  By default it only retursn
+ * the default Chado tables, but may also return custom tables added to the 
+ * Chado schema as well.
  *
+ * @param $include_custom
+ *   Optional.  Set as TRUE to include any custom tables created in the
+ *   Chado schema. Custom tables are added to Chado using the
+ *   tripal_core_chado_create_table() function.
+ *
+ * @returns
+ *   An associative array where the key and value pairs are the Chado table names.
  * @ingroup tripal_schema_api
  */
-function tripal_core_get_chado_tables() {
+function tripal_core_get_chado_tables($include_custom = NULL) {
   if(is_array($db_url) and array_key_exists('chado',$db_url)){
     $previous_db = tripal_db_set_active('chado');
     $sql = 'SELECT tablename FROM pg_tables';
@@ -50,11 +60,22 @@ function tripal_core_get_chado_tables() {
     $sql = "SELECT tablename FROM pg_tables WHERE schemaname='chado'";
     $resource = db_query($sql);
   }
-  
   $tables = array();
   while ($r = db_fetch_object($resource)) {
     $tables[$r->tablename] = $r->tablename;
+  }  
+  
+  
+  // now add in the custom tables too
+  if($include_custom){
+    $sql = "SELECT table_name FROM tripal_custom_tables";
+    $resource = db_query($sql);
   }
+  while ($r = db_fetch_object($resource)) {
+    $tables[$r->table_name] = $r->table_name;
+  } 
+  
+
   asort($tables);
   return $tables;
 }

Některé soubory nejsou zobrazeny, neboť je v těchto rozdílových datech změněno mnoho souborů